[mutter/wip/focus: 13/16] keybindings: fix per window keybindings



commit ed6821a819bd632a8dfe9ae30b1cac94341b71cd
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Wed Feb 26 18:56:17 2014 +0100

    keybindings: fix per window keybindings
    
    We must spoof events to clutter even if they are associated
    with a MetaWindow, because keyboard events are always associated
    with one (the focus window), and we must process keybindings
    for window togheter with the global ones if they include Super,
    because we're not going to see them again.

 src/compositor/compositor.c |   55 +++++++++++--------------------------------
 src/core/keybindings.c      |   16 +++++-------
 2 files changed, 21 insertions(+), 50 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 0fd6d67..8982bbd 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -971,24 +971,22 @@ maybe_spoof_event_as_stage_event (MetaCompScreen *info,
       event->xcookie.extension == display->xinput_opcode)
     {
       XIEvent *input_event = (XIEvent *) event->xcookie.data;
+      XIDeviceEvent *device_event = ((XIDeviceEvent *) input_event);
 
       switch (input_event->evtype)
         {
         case XI_Motion:
         case XI_ButtonPress:
         case XI_ButtonRelease:
-        case XI_KeyPress:
-        case XI_KeyRelease:
-          {
-            XIDeviceEvent *device_event = ((XIDeviceEvent *) input_event);
-
             /* If this is a GTK+ widget, like a window menu, let GTK+ handle
              * it as-is without mangling. */
             if (meta_ui_window_is_widget (info->screen->ui, device_event->event))
               break;
 
+            /* fall through */
+        case XI_KeyPress:
+        case XI_KeyRelease:
             device_event->event = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage));
-          }
           break;
         default:
           break;
@@ -1008,6 +1006,12 @@ meta_compositor_process_event (MetaCompositor *compositor,
                                XEvent         *event,
                                MetaWindow     *window)
 {
+  MetaDisplay *display = compositor->display;
+  MetaScreen *screen = display->screens->data;
+  MetaCompScreen *info;
+
+  info = meta_screen_get_compositor_data (screen);
+
   if (compositor->modal_plugin && is_grabbed_event (compositor->display, event))
     {
       _meta_plugin_xevent_filter (compositor->modal_plugin, event);
@@ -1017,43 +1021,12 @@ meta_compositor_process_event (MetaCompositor *compositor,
       return TRUE;
     }
 
-  if (window)
-    {
-      MetaCompScreen *info;
-      MetaScreen     *screen;
-
-      screen = meta_window_get_screen (window);
-      info = meta_screen_get_compositor_data (screen);
+  maybe_spoof_event_as_stage_event (info, event);
 
-      if (meta_plugin_manager_xevent_filter (info->plugin_mgr, event))
-       {
-         DEBUG_TRACE ("meta_compositor_process_event (filtered,window==NULL)\n");
-         return TRUE;
-       }
-    }
-  else
+  if (meta_plugin_manager_xevent_filter (info->plugin_mgr, event))
     {
-      GSList *l;
-
-      l = meta_display_get_screens (compositor->display);
-
-      while (l)
-       {
-         MetaScreen     *screen = l->data;
-         MetaCompScreen *info;
-
-         info = meta_screen_get_compositor_data (screen);
-
-          maybe_spoof_event_as_stage_event (info, event);
-
-         if (meta_plugin_manager_xevent_filter (info->plugin_mgr, event))
-           {
-             DEBUG_TRACE ("meta_compositor_process_event (filtered,window==NULL)\n");
-             return TRUE;
-           }
-
-         l = l->next;
-       }
+      DEBUG_TRACE ("meta_compositor_process_event (filtered,window==NULL)\n");
+      return TRUE;
     }
 
   if (!meta_is_wayland_compositor () &&
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index db2db76..bf33587 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -1842,8 +1842,7 @@ process_event (MetaKeyBinding       *bindings,
                MetaDisplay          *display,
                MetaScreen           *screen,
                MetaWindow           *window,
-               ClutterKeyEvent      *event,
-               gboolean              on_window)
+               ClutterKeyEvent      *event)
 {
   int i;
 
@@ -1859,7 +1858,7 @@ process_event (MetaKeyBinding       *bindings,
     {
       MetaKeyHandler *handler = bindings[i].handler;
 
-      if ((!on_window && handler->flags & META_KEY_BINDING_PER_WINDOW) ||
+      if ((!window && handler->flags & META_KEY_BINDING_PER_WINDOW) ||
           (event->keyval != bindings[i].keysym) ||
           (event->modifier_state != bindings[i].mask) ||
           meta_compositor_filter_keybinding (display->compositor, screen, &bindings[i]))
@@ -1891,7 +1890,8 @@ process_event (MetaKeyBinding       *bindings,
 static gboolean
 process_overlay_key (MetaDisplay *display,
                      MetaScreen *screen,
-                     ClutterKeyEvent *event)
+                     ClutterKeyEvent *event,
+                     MetaWindow *window)
 {
   if (display->overlay_key_only_pressed)
     {
@@ -1913,8 +1913,7 @@ process_overlay_key (MetaDisplay *display,
            */
           if (process_event (display->key_bindings,
                              display->n_key_bindings,
-                             display, screen, NULL, event,
-                             FALSE))
+                             display, screen, window, event))
             {
               /* As normally, after we've handled a global key
                * binding, we unfreeze the keyboard but keep the grab
@@ -2056,7 +2055,7 @@ meta_display_process_key_event (MetaDisplay     *display,
   all_keys_grabbed = window ? window->all_keys_grabbed : screen->all_keys_grabbed;
   if (!all_keys_grabbed)
     {
-      handled = process_overlay_key (display, screen, event);
+      handled = process_overlay_key (display, screen, event, window);
       if (handled)
         return TRUE;
 
@@ -2150,8 +2149,7 @@ meta_display_process_key_event (MetaDisplay     *display,
   /* Do the normal keybindings */
   return process_event (display->key_bindings,
                         display->n_key_bindings,
-                        display, screen, window, event,
-                        !all_keys_grabbed && window);
+                        display, screen, window, event);
 }
 
 static gboolean


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