diff options
Diffstat (limited to 'src/wrapped/wrappedgdk3.c')
| -rw-r--r-- | src/wrapped/wrappedgdk3.c | 67 |
1 files changed, 59 insertions, 8 deletions
diff --git a/src/wrapped/wrappedgdk3.c b/src/wrapped/wrappedgdk3.c index 671301b9..aea28c68 100644 --- a/src/wrapped/wrappedgdk3.c +++ b/src/wrapped/wrappedgdk3.c @@ -37,10 +37,10 @@ GO(3) // GdkFilterFunc #define GO(A) \ -static uintptr_t my_filter_fct_##A = 0; \ -static int my_filter_##A(void* xevent, void* event, void* data) \ -{ \ - return (int)RunFunction(my_context, my_filter_fct_##A, 3, xevent, event, data);\ +static uintptr_t my_filter_fct_##A = 0; \ +static int my_filter_##A(void* xevent, void* event, void* data) \ +{ \ + return (int)RunFunctionFmt(my_filter_fct_##A, "ppp", xevent, event, data); \ } SUPER() #undef GO @@ -54,14 +54,60 @@ static void* findFilterFct(void* fct) #define GO(A) if(my_filter_fct_##A == 0) {my_filter_fct_##A = (uintptr_t)fct; return my_filter_##A; } SUPER() #undef GO - printf_log(LOG_NONE, "Warning, no more slot for gtk-2 GdkFilterFunc callback\n"); + printf_log(LOG_NONE, "Warning, no more slot for gdk-3 GdkFilterFunc callback\n"); + return NULL; +} +// GSourceFunc +#define GO(A) \ +static uintptr_t my_GSourceFunc_fct_##A = 0; \ +static int my_GSourceFunc_##A(void* a) \ +{ \ + return (int)RunFunctionFmt(my_GSourceFunc_fct_##A, "p", a); \ +} +SUPER() +#undef GO +static void* findGSourceFunc(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_GSourceFunc_fct_##A == (uintptr_t)fct) return my_GSourceFunc_##A; + SUPER() + #undef GO + #define GO(A) if(my_GSourceFunc_fct_##A == 0) {my_GSourceFunc_fct_##A = (uintptr_t)fct; return my_GSourceFunc_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for gdk-3 GSourceFunc callback\n"); + return NULL; +} +// GDestroyNotify +#define GO(A) \ +static uintptr_t my_GDestroyNotify_fct_##A = 0; \ +static void my_GDestroyNotify_##A(void* data) \ +{ \ + RunFunctionFmt(my_GDestroyNotify_fct_##A, "p", data); \ +} +SUPER() +#undef GO +static void* findGDestroyNotifyFct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_GDestroyNotify_fct_##A == (uintptr_t)fct) return my_GDestroyNotify_##A; + SUPER() + #undef GO + #define GO(A) if(my_GDestroyNotify_fct_##A == 0) {my_GDestroyNotify_fct_##A = (uintptr_t)fct; return my_GDestroyNotify_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for gdk-3 GDestroyNotify callback\n"); return NULL; } +#undef SUPER + static void my3_event_handler(void* event, my_signal_t* sig) { - RunFunction(my_context, sig->c_handler, 2, event, sig->data); + RunFunctionFmt(sig->c_handler, "pp", event, sig->data) ; } EXPORT void my3_gdk_event_handler_set(x64emu_t* emu, void* func, void* data, void* notify) @@ -76,7 +122,7 @@ EXPORT void my3_gdk_event_handler_set(x64emu_t* emu, void* func, void* data, voi static void my3_input_function(my_signal_t* sig, int source, int condition) { - RunFunction(my_context, sig->c_handler, 3, sig->data, source, condition); + RunFunctionFmt(sig->c_handler, "pii", sig->data, source, condition) ; } EXPORT int my3_gdk_input_add(x64emu_t* emu, int source, int condition, void* f, void* data) @@ -92,7 +138,7 @@ EXPORT int my3_gdk_input_add_full(x64emu_t* emu, int source, int condition, void { if(!f) return my->gdk_input_add_full(source, condition, f, data, notify); - + my_signal_t* sig = new_mysignal(f, data, notify); return my->gdk_input_add_full(source, condition, my3_input_function, sig, my_signal_delete); } @@ -120,6 +166,11 @@ EXPORT void my3_gdk_window_remove_filter(x64emu_t* emu, void* window, void* f, v my->gdk_window_remove_filter(window, findFilterFct(f), data); } +EXPORT uint32_t my3_gdk_threads_add_idle_full(x64emu_t* emu, int priority, void* f, void* data, void* d) +{ + return my->gdk_threads_add_idle_full(priority, findGSourceFunc(f), data, findGDestroyNotifyFct(d)); +} + #define PRE_INIT \ if(box64_nogtk) \ return -1; |