From 688b9f7af0259c40d80a09f66225e6cab7ceb8a8 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 9 Jun 2010 16:08:48 +0200 Subject: [PATCH] Fix mouse::leave signal emit on widgets (FS#774) Signed-off-by: Julien Danjou --- event.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/event.c b/event.c index 6063d9f2d..a3d545590 100644 --- a/event.c +++ b/event.c @@ -344,18 +344,19 @@ event_handle_destroynotify(void *data __attribute__ ((unused)), */ static void event_handle_widget_motionnotify(wibox_t *wibox, - widget_t **mouse_over, widget_t *widget) { - if(widget != *mouse_over) + if(widget != wibox->mouse_over) { - if(*mouse_over) + if(wibox->mouse_over) { /* Emit mouse leave signal on old widget: * - Push wibox.*/ luaA_object_push(globalconf.L, wibox); /* - Push the widget the mouse was on */ - luaA_object_push_item(globalconf.L, -1, *mouse_over); + luaA_object_push_item(globalconf.L, -1, wibox->mouse_over); + /* - Invert wibox/widget */ + lua_insert(globalconf.L, -2); /* - Emit the signal mouse::leave with the wibox as argument */ luaA_object_emit_signal(globalconf.L, -2, "mouse::leave", 1); /* - Remove the widget */ @@ -363,8 +364,7 @@ event_handle_widget_motionnotify(wibox_t *wibox, /* Re-push wibox */ luaA_object_push(globalconf.L, wibox); - luaA_object_unref_item(globalconf.L, -1, *mouse_over); - *mouse_over = NULL; + luaA_object_unref_item(globalconf.L, -1, wibox->mouse_over); /* Remove the wibox */ lua_pop(globalconf.L, 1); } @@ -379,9 +379,6 @@ event_handle_widget_motionnotify(wibox_t *wibox, /* - Reference the widget into the wibox */ luaA_object_ref_item(globalconf.L, -2, -1); - /* Store that this widget was the one with the mouse over */ - *mouse_over = widget; - /* Emit mouse::enter signal on new widget: * - Push the widget */ luaA_object_push_item(globalconf.L, -1, widget); @@ -393,6 +390,10 @@ event_handle_widget_motionnotify(wibox_t *wibox, /* - Remove the widget from the stack */ lua_pop(globalconf.L, 1); } + + /* Store that this widget was the one with the mouse over */ + wibox->mouse_over = widget; + } } @@ -417,8 +418,8 @@ event_handle_motionnotify(void *data __attribute__ ((unused)), wibox->geometry.width, wibox->geometry.height, &ev->event_x, &ev->event_y); - if(w) - event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w); + + event_handle_widget_motionnotify(wibox, w); } return 0; @@ -455,6 +456,8 @@ event_handle_leavenotify(void *data __attribute__ ((unused)), luaA_object_push(globalconf.L, wibox); /* Push the widget the mouse is over in this wibox */ luaA_object_push_item(globalconf.L, -1, wibox->mouse_over); + /* Move the widget before the wibox */ + lua_insert(globalconf.L, -2); /* Emit mouse::leave signal on widget the mouse was over with * its wibox as argument */ luaA_object_emit_signal(globalconf.L, -2, "mouse::leave", 1); @@ -493,8 +496,8 @@ event_handle_enternotify(void *data __attribute__ ((unused)), wibox->geometry.width, wibox->geometry.height, &ev->event_x, &ev->event_y); - if(w) - event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w); + + event_handle_widget_motionnotify(wibox, w); luaA_object_push(globalconf.L, wibox); luaA_object_emit_signal(globalconf.L, -1, "mouse::enter", 0);