[mutter] frames: Fix pressed state of window menu buttons



commit e2105dc72174c32f65994aa248a8bad69713accb
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat May 31 02:22:21 2014 +0200

    frames: Fix pressed state of window menu buttons
    
    Since window menus have been moved to the compositor, the pressed
    state of the corresponding window buttons is messed up, as it is
    reset immediately when getting a LeaveNotify event due to the
    compositor taking a grab. Fix this by ignoring that particular
    event.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731058

 src/ui/frames.c |   21 +++++++++++++++++++++
 src/ui/frames.h |    1 +
 2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 976c71c..e2e160e 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -1238,6 +1238,11 @@ meta_frames_button_press_event (GtkWidget      *widget,
           menu = control == META_FRAME_CONTROL_MENU ? META_WINDOW_MENU_WM
                                                     : META_WINDOW_MENU_APP;
 
+          /* if the compositor takes a grab for showing the menu, we will
+           * get a LeaveNotify event we want to ignore, to keep the pressed
+           * button state while the menu is open
+           */
+          frame->maybe_ignore_leave_notify = TRUE;
           meta_core_show_window_menu_for_rect (display,
                                                frame->xwindow,
                                                menu,
@@ -1933,6 +1938,8 @@ meta_frames_enter_notify_event      (GtkWidget           *widget,
   if (frame == NULL)
     return FALSE;
 
+  frame->maybe_ignore_leave_notify = FALSE;
+
   control = get_control (frames, frame, event->x, event->y);
   meta_frames_update_prelit_control (frames, frame, control);
 
@@ -1945,6 +1952,8 @@ meta_frames_leave_notify_event      (GtkWidget           *widget,
 {
   MetaUIFrame *frame;
   MetaFrames *frames;
+  Display *display;
+  MetaGrabOp grab_op;
 
   frames = META_FRAMES (widget);
 
@@ -1952,6 +1961,18 @@ meta_frames_leave_notify_event      (GtkWidget           *widget,
   if (frame == NULL)
     return FALSE;
 
+  display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+  grab_op = meta_core_get_grab_op (display);
+
+  /* ignore the first LeaveNotify event after opening a window menu
+   * if it is the result of a compositor grab
+   */
+  frame->maybe_ignore_leave_notify = frame->maybe_ignore_leave_notify &&
+                                     grab_op == META_GRAB_OP_COMPOSITOR;
+
+  if (frame->maybe_ignore_leave_notify)
+    return FALSE;
+
   meta_frames_update_prelit_control (frames, frame, META_FRAME_CONTROL_NONE);
 
   return TRUE;
diff --git a/src/ui/frames.h b/src/ui/frames.h
index 5a0e58d..d0af95d 100644
--- a/src/ui/frames.h
+++ b/src/ui/frames.h
@@ -80,6 +80,7 @@ struct _MetaUIFrame
   int text_height;
   char *title; /* NULL once we have a layout */
   guint shape_applied : 1;
+  guint maybe_ignore_leave_notify : 1;
 
   /* FIXME get rid of this, it can just be in the MetaFrames struct */
   MetaFrameControl prelit_control;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]