[mutter] Remove MetaAltTabHandler



commit d04b15ee25b17eeb5e3512e2ab15df2433c15d5a
Author: Dan Winship <danw gnome org>
Date:   Wed Sep 23 21:27:42 2009 -0400

    Remove MetaAltTabHandler
    
    gnome-shell is no longer using MetaAltTabHandler, so there's no need
    to keep that abstraction around.
    
    This reverts commit 1d5117a6 (and a comment from 7b0ba87b), with a bit
    of rebasing and whitespace cleanup.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=596210

 src/Makefile.am                    |    5 -
 src/core/alttabhandler.c           |  138 ----------------------
 src/core/alttabhandlerdefault.c    |  223 ------------------------------------
 src/core/keybindings.c             |   12 +--
 src/core/screen-private.h          |    6 +-
 src/core/screen.c                  |  140 ++++++++++++++++++----
 src/include/alttabhandler.h        |   73 ------------
 src/include/alttabhandlerdefault.h |   55 ---------
 8 files changed, 120 insertions(+), 532 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 9830edd..d1a9fff 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,10 +16,6 @@ mutter_built_sources = \
 mutter_SOURCES= 				\
 	core/async-getprop.c			\
 	core/async-getprop.h			\
-	core/alttabhandler.c			\
-	include/alttabhandler.h			\
-	core/alttabhandlerdefault.c		\
-	include/alttabhandlerdefault.h		\
 	core/bell.c				\
 	core/bell.h				\
 	core/boxes.c				\
@@ -153,7 +149,6 @@ libmutterincludedir = $(includedir)/mutter/mutter-private
 # Headers installed for plugins; introspected information will
 # be extracted into Mutter-<version>.gir
 libmutterinclude_base_headers =		\
-	include/alttabhandler.h			\
 	include/boxes.h				\
 	ui/gradient.h				\
 	include/main.h				\
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index f098f8a..7a3b829 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2047,15 +2047,11 @@ process_tab_grab (MetaDisplay *display,
     action = META_KEYBINDING_ACTION_NONE;
 
   /*
-   * There are currently two different ways of customizing Alt-Tab, you can either
-   * provide a replacement AltTabHandler object, or you can hook into the keybindings
-   * meta_keybindings_set_custom_handler() and call meta_display_begin_grab_op()
-   * yourself with one of the "tabbing" grab ops META_GRAB_OP_KEYBOARD_TABBING_NORMAL,
-   * etc. See meta_display_process_key_event() for the complete list. If screen->tab_handler
-   * is NULL, the latter mechanism is being used. We skip most of our normal
-   * processing and just make sure that the right custom handlers get called.
+   * If there is no tab_pop up object, i.e., there is some custom handler
+   * implementing Alt+Tab & Co., we call this custom handler; we do not
+   * mess about with the grab, as that is up to the handler to deal with.
    */
-  if (!screen->tab_handler)
+  if (!screen->tab_popup)
     {
       if (event->type == KeyRelease)
         {
diff --git a/src/core/screen-private.h b/src/core/screen-private.h
index 64cfb08..f21c8c0 100644
--- a/src/core/screen-private.h
+++ b/src/core/screen-private.h
@@ -37,7 +37,6 @@
 #include "screen.h"
 #include <X11/Xutil.h>
 #include "stack-tracker.h"
-#include "alttabhandler.h"
 #include "ui.h"
 
 typedef struct _MetaMonitorInfo MetaMonitorInfo;
@@ -82,9 +81,8 @@ struct _MetaScreen
   Visual *default_xvisual;
   MetaRectangle rect;  /* Size of screen; rect.x & rect.y are always 0 */
   MetaUI *ui;
-  MetaAltTabHandler *tab_handler;
-  MetaTabPopup *ws_popup;
-  
+  MetaTabPopup *tab_popup, *ws_popup;
+
   MetaWorkspace *active_workspace;
 
   /* This window holds the focus when we don't want to focus
diff --git a/src/core/screen.c b/src/core/screen.c
index 22cd884..5e2197e 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -38,7 +38,6 @@
 #include "stack.h"
 #include "xprops.h"
 #include "compositor.h"
-#include "alttabhandlerdefault.h"
 #include "mutter-marshal.h"
 #include "mutter-enum-types.h"
 
@@ -781,9 +780,9 @@ meta_screen_new (MetaDisplay *display,
   screen->ui = meta_ui_new (screen->display->xdisplay,
                             screen->xscreen);
 
-  screen->tab_handler = NULL;
+  screen->tab_popup = NULL;
   screen->ws_popup = NULL;
-  
+
   screen->stack = meta_stack_new (screen);
   screen->stack_tracker = meta_stack_tracker_new (screen);
 
@@ -1516,58 +1515,146 @@ meta_screen_tab_popup_create (MetaScreen      *screen,
                               MetaTabShowType  show_type,
                               MetaWindow      *initial_selection)
 {
+  MetaTabEntry *entries;
   GList *tab_list;
   GList *tmp;
+  int len;
+  int i;
 
-  g_return_if_fail (screen->tab_handler == NULL);
-
-  screen->tab_handler = meta_alt_tab_handler_new (screen,
-                                                  show_type == META_TAB_SHOW_INSTANTLY);
+  if (screen->tab_popup)
+    return;
 
   tab_list = meta_display_get_tab_list (screen->display,
                                         list_type,
                                         screen,
                                         screen->active_workspace);
-  
-  for (tmp = tab_list; tmp; tmp = tmp->next)
-    meta_alt_tab_handler_add_window (screen->tab_handler, tmp->data);
-  
-  meta_alt_tab_handler_show (screen->tab_handler, initial_selection);
+
+  len = g_list_length (tab_list);
+
+  entries = g_new (MetaTabEntry, len + 1);
+  entries[len].key = NULL;
+  entries[len].title = NULL;
+  entries[len].icon = NULL;
+
+  i = 0;
+  tmp = tab_list;
+  while (i < len)
+    {
+      MetaWindow *window;
+      MetaRectangle r;
+
+      window = tmp->data;
+
+      entries[i].key = (MetaTabEntryKey) window;
+      entries[i].title = window->title;
+      entries[i].icon = g_object_ref (window->icon);
+      entries[i].blank = FALSE;
+      entries[i].hidden = !meta_window_showing_on_its_workspace (window);
+      entries[i].demands_attention = window->wm_state_demands_attention;
+
+      if (show_type == META_TAB_SHOW_INSTANTLY ||
+          !entries[i].hidden                   ||
+          !meta_window_get_icon_geometry (window, &r))
+        meta_window_get_outer_rect (window, &r);
+
+      entries[i].rect = r;
+
+      /* Find inside of highlight rectangle to be used when window is
+       * outlined for tabbing.  This should be the size of the
+       * east/west frame, and the size of the south frame, on those
+       * sides.  On the top it should be the size of the south frame
+       * edge.
+       */
+#define OUTLINE_WIDTH 5
+      /* Top side */
+      if (!entries[i].hidden &&
+          window->frame && window->frame->bottom_height > 0 &&
+          window->frame->child_y >= window->frame->bottom_height)
+        entries[i].inner_rect.y = window->frame->bottom_height;
+      else
+        entries[i].inner_rect.y = OUTLINE_WIDTH;
+
+      /* Bottom side */
+      if (!entries[i].hidden &&
+          window->frame && window->frame->bottom_height != 0)
+        entries[i].inner_rect.height = r.height
+          - entries[i].inner_rect.y - window->frame->bottom_height;
+      else
+        entries[i].inner_rect.height = r.height
+          - entries[i].inner_rect.y - OUTLINE_WIDTH;
+
+      /* Left side */
+      if (!entries[i].hidden && window->frame && window->frame->child_x != 0)
+        entries[i].inner_rect.x = window->frame->child_x;
+      else
+        entries[i].inner_rect.x = OUTLINE_WIDTH;
+
+      /* Right side */
+      if (!entries[i].hidden &&
+          window->frame && window->frame->right_width != 0)
+        entries[i].inner_rect.width = r.width
+          - entries[i].inner_rect.x - window->frame->right_width;
+      else
+        entries[i].inner_rect.width = r.width
+          - entries[i].inner_rect.x - OUTLINE_WIDTH;
+
+      ++i;
+      tmp = tmp->next;
+    }
+
+  if (!meta_prefs_get_no_tab_popup ())
+    screen->tab_popup = meta_ui_tab_popup_new (entries,
+                                               screen->number,
+                                               len,
+                                               5, /* FIXME */
+                                               TRUE);
+
+  for (i = 0; i < len; i++)
+    g_object_unref (entries[i].icon);
+
+  g_free (entries);
+
+  g_list_free (tab_list);
+
+  meta_ui_tab_popup_select (screen->tab_popup,
+                            (MetaTabEntryKey) initial_selection);
+
+  if (show_type != META_TAB_SHOW_INSTANTLY)
+    meta_ui_tab_popup_set_showing (screen->tab_popup, TRUE);
 }
 
 void
 meta_screen_tab_popup_forward (MetaScreen *screen)
 {
-  g_return_if_fail (screen->tab_handler != NULL);
+  g_return_if_fail (screen->tab_popup != NULL);
 
-  meta_alt_tab_handler_forward (screen->tab_handler);
+  meta_ui_tab_popup_forward (screen->tab_popup);
 }
 
 void
 meta_screen_tab_popup_backward (MetaScreen *screen)
 {
-  g_return_if_fail (screen->tab_handler != NULL);
+  g_return_if_fail (screen->tab_popup != NULL);
 
-  meta_alt_tab_handler_backward (screen->tab_handler);
+  meta_ui_tab_popup_backward (screen->tab_popup);
 }
 
 MetaWindow *
 meta_screen_tab_popup_get_selected (MetaScreen *screen)
 {
-  g_return_val_if_fail (screen->tab_handler != NULL, NULL);
+  g_return_val_if_fail (screen->tab_popup != NULL, NULL);
 
-  return meta_alt_tab_handler_get_selected (screen->tab_handler);
+  return (MetaWindow *) meta_ui_tab_popup_get_selected (screen->tab_popup);
 }
 
 void
 meta_screen_tab_popup_destroy (MetaScreen *screen)
 {
-  if (!screen->tab_handler)
-    return;
-
-  meta_alt_tab_handler_destroy (screen->tab_handler);
-  g_object_unref (screen->tab_handler);
-  screen->tab_handler = NULL;
+  if (screen->tab_popup)
+    {
+      meta_ui_tab_popup_free (screen->tab_popup);
+      screen->tab_popup = NULL;
+    }
 }
 
 void
@@ -1580,8 +1667,9 @@ meta_screen_workspace_popup_create (MetaScreen    *screen,
   MetaWorkspaceLayout layout;
   int n_workspaces;
   int current_workspace;
-  
-  g_return_if_fail (screen->ws_popup == NULL);
+
+  if (screen->ws_popup || meta_prefs_get_no_tab_popup ())
+    return;
 
   current_workspace = meta_workspace_index (screen->active_workspace);
   n_workspaces = meta_screen_get_n_workspaces (screen);



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