diff options
-rw-r--r-- | deadbeef.h | 3 | ||||
-rw-r--r-- | plugins.c | 12 | ||||
-rw-r--r-- | plugins.h | 6 | ||||
-rw-r--r-- | plugins/hotkeys/hotkeys.c | 5 |
4 files changed, 25 insertions, 1 deletions
@@ -244,6 +244,9 @@ typedef struct { int (*conf_get_int) (const char *key, int def); void (*conf_set_str) (const char *key, const char *val); DB_conf_item_t * (*conf_find) (const char *group, DB_conf_item_t *prev); + // gui locking + void (*gui_lock) (void); + void (*gui_unlock) (void); // exporting plugin conf options for gui // all exported options are grouped by plugin, and will be available to user // from gui @@ -119,6 +119,8 @@ static DB_functions_t deadbeef_api = { .conf_get_int = conf_get_int, .conf_set_str = conf_set_str, .conf_find = conf_find, + .gui_lock = plug_gui_lock, + .gui_unlock = plug_gui_unlock, }; DB_functions_t *deadbeef = &deadbeef_api; @@ -153,6 +155,16 @@ DB_decoder_t *g_decoder_plugins[MAX_DECODER_PLUGINS+1]; DB_vfs_t *g_vfs_plugins[MAX_VFS_PLUGINS+1]; void +plug_gui_lock (void) { + gdk_threads_enter (); +} + +void +plug_gui_unlock (void) { + gdk_threads_leave (); +} + +void plug_md5 (uint8_t sig[16], const char *in, int len) { md5_buffer (in, len, sig); } @@ -88,4 +88,10 @@ plug_volume_set_amp (float amp); const char * plug_get_config_dir (void); +void +plug_gui_lock (void); + +void +plug_gui_unlock (void); + #endif // __PLUGINS_H diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c index e890d1ac..d00d01b7 100644 --- a/plugins/hotkeys/hotkeys.c +++ b/plugins/hotkeys/hotkeys.c @@ -275,12 +275,15 @@ x_err_handler (Display *d, XErrorEvent *evt) { static void hotkeys_event_loop( uintptr_t unused ) { int i; - XSetErrorHandler( x_err_handler ); + deadbeef->gui_lock (); for ( i = 0; i < command_count; i++ ) { + XSetErrorHandler( x_err_handler ); XGrabKey( disp, commands[ i ].keycode, commands[ i ].modifier, DefaultRootWindow( disp ), False, GrabModeAsync, GrabModeAsync ); } + XSetErrorHandler( x_err_handler ); XSync (disp, 0); + deadbeef->gui_unlock (); while (!finished) { XEvent event; |