metacity r3649 - in trunk: . src/core



Author: tthurman
Date: Tue Mar 11 03:37:54 2008
New Revision: 3649
URL: http://svn.gnome.org/viewvc/metacity?rev=3649&view=rev

Log:
2008-03-11  Matthew Wilson  <msw gimp org>

        * src/core/keybindings.c (meta_display_process_key_event, process_event,
        find_handler, process_mouse_move_resize_grab): allow moving workspace
	while moving window with modifier
        * src/core/workspace.c (meta_workspace_activate_with_focus): remove the
	correct window on jumping workspace while moving



Modified:
   trunk/ChangeLog
   trunk/src/core/keybindings.c
   trunk/src/core/workspace.c

Modified: trunk/src/core/keybindings.c
==============================================================================
--- trunk/src/core/keybindings.c	(original)
+++ trunk/src/core/keybindings.c	Tue Mar 11 03:37:54 2008
@@ -1583,7 +1583,7 @@
   return NULL;
 }               
 
-static void
+static gboolean
 process_event (MetaKeyBinding       *bindings,
                int                   n_bindings,
                const MetaKeyHandler *handlers,
@@ -1597,13 +1597,13 @@
 
   /* we used to have release-based bindings but no longer. */
   if (event->type == KeyRelease)
-    return;
+    return FALSE;
   
   i = 0;
   while (i < n_bindings)
     {
       if (bindings[i].keycode == event->xkey.keycode && 
-          ((event->xkey.state & ~(display->ignored_modifier_mask)) ==
+          ((event->xkey.state & 0xff & ~(display->ignored_modifier_mask)) ==
            bindings[i].mask) &&
           event->type == KeyPress)
         {
@@ -1637,7 +1637,7 @@
 
           (* handler->func) (display, screen, window, event,
                              &bindings[i]);
-          return;
+          return TRUE;
         }
       
       ++i;
@@ -1645,6 +1645,7 @@
 
   meta_topic (META_DEBUG_KEYBINDINGS,
               "No handler found for this event in this binding table\n");
+  return FALSE;
 }
 
 /* Handle a key event. May be called recursively: some key events cause
@@ -1665,16 +1666,17 @@
 {
   KeySym keysym;
   gboolean handled;
+  gboolean keep_grab;
   gboolean all_keys_grabbed;
   const char *str;
   MetaScreen *screen;
-
+  
   XAllowEvents (display->xdisplay,
                 all_bindings_disabled ? ReplayKeyboard : AsyncKeyboard,
                 event->xkey.time);
   if (all_bindings_disabled)
     return;
-
+  
   /* if key event was on root window, we have a shortcut */
   screen = meta_display_screen_for_root (display, event->xkey.window);
   
@@ -1703,115 +1705,102 @@
               str ? str : "none", event->xkey.state,
               window ? window->desc : "(no window)");
 
+  keep_grab = TRUE;
   all_keys_grabbed = window ? window->all_keys_grabbed : screen->all_keys_grabbed;
-  if (!all_keys_grabbed)
-    {
-      /* Do the normal keybindings */
-      process_event (display->screen_bindings,
-                     display->n_screen_bindings,
-                     screen_handlers,
-                     display, screen, NULL, event, keysym);
-
-      if (window)
-        process_event (display->window_bindings,
-                       display->n_window_bindings,
-                       window_handlers,
-                       display, screen, window, event, keysym);
-
-      return;
-    }
-
-  if (display->grab_op == META_GRAB_OP_NONE)
-    return;    
-
-  /* If we get here we have a global grab, because
-   * we're in some special keyboard mode such as window move
-   * mode.
-   */
-  
-  handled = FALSE;
-
-  if (window ? (window == display->grab_window) :
-               (screen == display->grab_screen))
+  if (all_keys_grabbed)
     {
-      switch (display->grab_op)
+      if (display->grab_op == META_GRAB_OP_NONE)
+        return;
+      /* If we get here we have a global grab, because
+        * we're in some special keyboard mode such as window move
+        * mode.
+        */
+      if (window ? (window == display->grab_window) :
+          (screen == display->grab_screen))
+        {
+          switch (display->grab_op)
+            {
+            case META_GRAB_OP_MOVING:
+            case META_GRAB_OP_RESIZING_SE:
+            case META_GRAB_OP_RESIZING_S:      
+            case META_GRAB_OP_RESIZING_SW:      
+            case META_GRAB_OP_RESIZING_N:
+            case META_GRAB_OP_RESIZING_NE:
+            case META_GRAB_OP_RESIZING_NW:
+            case META_GRAB_OP_RESIZING_W:
+            case META_GRAB_OP_RESIZING_E:
+              meta_topic (META_DEBUG_KEYBINDINGS,
+                          "Processing event for mouse-only move/resize\n");
+              g_assert (window != NULL);
+              keep_grab = process_mouse_move_resize_grab (display, screen,
+                                                          window, event, keysym);
+              break;
+ 
+            case META_GRAB_OP_KEYBOARD_MOVING:
+              meta_topic (META_DEBUG_KEYBINDINGS,
+                          "Processing event for keyboard move\n");
+              g_assert (window != NULL);
+              keep_grab = process_keyboard_move_grab (display, screen,
+                                                      window, event, keysym);
+              break;
+              
+            case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN:
+            case META_GRAB_OP_KEYBOARD_RESIZING_S:
+            case META_GRAB_OP_KEYBOARD_RESIZING_N:
+            case META_GRAB_OP_KEYBOARD_RESIZING_W:
+            case META_GRAB_OP_KEYBOARD_RESIZING_E:
+            case META_GRAB_OP_KEYBOARD_RESIZING_SE:
+            case META_GRAB_OP_KEYBOARD_RESIZING_NE:
+            case META_GRAB_OP_KEYBOARD_RESIZING_SW:
+            case META_GRAB_OP_KEYBOARD_RESIZING_NW:          
+              meta_topic (META_DEBUG_KEYBINDINGS,
+                          "Processing event for keyboard resize\n");
+              g_assert (window != NULL);
+              keep_grab = process_keyboard_resize_grab (display, screen,
+                                                        window, event, keysym);
+              break;
+ 
+            case META_GRAB_OP_KEYBOARD_TABBING_NORMAL:
+            case META_GRAB_OP_KEYBOARD_TABBING_DOCK:
+            case META_GRAB_OP_KEYBOARD_TABBING_GROUP:
+            case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL:
+            case META_GRAB_OP_KEYBOARD_ESCAPING_DOCK:
+            case META_GRAB_OP_KEYBOARD_ESCAPING_GROUP:
+              meta_topic (META_DEBUG_KEYBINDINGS,
+                          "Processing event for keyboard tabbing/cycling\n");
+              keep_grab = process_tab_grab (display, screen, event, keysym);
+              break;
+              
+            case META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING:
+              meta_topic (META_DEBUG_KEYBINDINGS,
+                          "Processing event for keyboard workspace switching\n");
+              keep_grab = process_workspace_switch_grab (display, screen, event, keysym);
+              break;
+ 
+            default:
+              break;
+            }
+        }
+      if (!keep_grab)
         {
-        case META_GRAB_OP_MOVING:
-        case META_GRAB_OP_RESIZING_SE:
-        case META_GRAB_OP_RESIZING_S:      
-        case META_GRAB_OP_RESIZING_SW:      
-        case META_GRAB_OP_RESIZING_N:
-        case META_GRAB_OP_RESIZING_NE:
-        case META_GRAB_OP_RESIZING_NW:
-        case META_GRAB_OP_RESIZING_W:
-        case META_GRAB_OP_RESIZING_E:
-          meta_topic (META_DEBUG_KEYBINDINGS,
-                      "Processing event for mouse-only move/resize\n");
-          g_assert (window != NULL);
-          handled = process_mouse_move_resize_grab (display, screen,
-                                                    window, event, keysym);
-          break;
-
-        case META_GRAB_OP_KEYBOARD_MOVING:
-          meta_topic (META_DEBUG_KEYBINDINGS,
-                      "Processing event for keyboard move\n");
-          g_assert (window != NULL);
-          handled = process_keyboard_move_grab (display, screen,
-                                                window, event, keysym);
-          break;
-
-        case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN:
-        case META_GRAB_OP_KEYBOARD_RESIZING_S:
-        case META_GRAB_OP_KEYBOARD_RESIZING_N:
-        case META_GRAB_OP_KEYBOARD_RESIZING_W:
-        case META_GRAB_OP_KEYBOARD_RESIZING_E:
-        case META_GRAB_OP_KEYBOARD_RESIZING_SE:
-        case META_GRAB_OP_KEYBOARD_RESIZING_NE:
-        case META_GRAB_OP_KEYBOARD_RESIZING_SW:
-        case META_GRAB_OP_KEYBOARD_RESIZING_NW:          
-          meta_topic (META_DEBUG_KEYBINDINGS,
-                      "Processing event for keyboard resize\n");
-          g_assert (window != NULL);
-          handled = process_keyboard_resize_grab (display, screen,
-                                                  window, event, keysym);
-          break;
-
-        case META_GRAB_OP_KEYBOARD_TABBING_NORMAL:
-        case META_GRAB_OP_KEYBOARD_TABBING_DOCK:
-        case META_GRAB_OP_KEYBOARD_TABBING_GROUP:
-        case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL:
-        case META_GRAB_OP_KEYBOARD_ESCAPING_DOCK:
-        case META_GRAB_OP_KEYBOARD_ESCAPING_GROUP:
-          meta_topic (META_DEBUG_KEYBINDINGS,
-                      "Processing event for keyboard tabbing/cycling\n");
-          handled = process_tab_grab (display, screen, event, keysym);
-          break;
-          
-        case META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING:
           meta_topic (META_DEBUG_KEYBINDINGS,
-                      "Processing event for keyboard workspace switching\n");
-          handled = process_workspace_switch_grab (display, screen, event, keysym);
-          break;
-
-        default:
-          break;
+                      "Ending grab op %u on key event sym %s\n",
+                      display->grab_op, XKeysymToString (keysym));
+          meta_display_end_grab_op (display, event->xkey.time);
+          return;
         }
-    }
-  
-  /* end grab if a key that isn't used gets pressed */
-  if (!handled)
-    {
-      meta_topic (META_DEBUG_KEYBINDINGS,
-                  "Ending grab op %u on key event sym %s\n",
-                  display->grab_op, XKeysymToString (keysym));
-      meta_display_end_grab_op (display, event->xkey.time);
-
-      g_assert (display->grab_op == META_GRAB_OP_NONE);
-
-      /* and go round again: #112560 */
-      meta_display_process_key_event (display, window, event);
-
-    }
+      }
+  /* Do the normal keybindings */
+  handled = process_event (display->screen_bindings,
+                           display->n_screen_bindings,
+                           screen_handlers,
+                           display, screen, NULL, event, keysym);
+ 
+  if (!all_keys_grabbed && !handled && window)
+    handled = process_event (display->window_bindings,
+                             display->n_window_bindings,
+                             window_handlers,
+                             display, screen, window, event, keysym);
 }
 
 static gboolean
@@ -1848,13 +1837,10 @@
       else
         display->grab_was_cancelled = TRUE;
 
-      /* End grab, since this was an "unhandled" keypress */
+      /* End grab */
       return FALSE;
     }
 
-  /* The keypress really isn't handled but we just want to ignore it, so
-   * treat it as handled.
-   */
   return TRUE;
 }
 

Modified: trunk/src/core/workspace.c
==============================================================================
--- trunk/src/core/workspace.c	(original)
+++ trunk/src/core/workspace.c	Tue Mar 11 03:37:54 2008
@@ -315,10 +315,12 @@
        * then remove from old workspace, so the window
        * never gets unmapped and we maintain the button grab
        * on it.
+       *
+       * \bug  This comment appears to be the reverse of what happens
        */
       if (move_window && (move_window->workspace != workspace))
         {
-          meta_workspace_remove_window (workspace, move_window);
+          meta_workspace_remove_window (old, move_window);
           meta_workspace_add_window (workspace, move_window);
         }
     }



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