From b168954ed30d7232f442efe5d6c364fc832c7cb9 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 9 Jun 2002 04:04:19 +0000 Subject: [PATCH] Cleanups to workspace popup patch. Space before all parens in a couple 2002-06-08 Havoc Pennington Cleanups to workspace popup patch. Space before all parens in a couple places. * src/prefs.c (meta_prefs_get_keybinding_action): fix brace indentation, and use while instead of for loop. Take a "mask" argument to avoid ambiguity issues. * src/keybindings.c (handle_workspace_switch): rename from handle_workspace_forward since there's no directionality here (handle_workspace_switch): add a FIXME about how screwed it is that we need a window in order to do our grab. Should be able to grab on a dummy window like no_focus_window or the root window. (process_workspace_switch_grab): rename from tab_grab for clarity, no tab involved here. * src/common.h (enum): have only one grab op for all workspace switching directions, instead of one for each. --- ChangeLog | 20 +++++++++++ src/common.h | 5 +-- src/display.c | 15 ++------- src/keybindings.c | 86 +++++++++++++++++++---------------------------- src/prefs.c | 14 +++++--- src/prefs.h | 4 ++- 6 files changed, 71 insertions(+), 73 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47105c594..8ca21b6a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2002-06-08 Havoc Pennington + + Cleanups to workspace popup patch. Space before all parens + in a couple places. + + * src/prefs.c (meta_prefs_get_keybinding_action): fix brace + indentation, and use while instead of for loop. Take a "mask" + argument to avoid ambiguity issues. + + * src/keybindings.c (handle_workspace_switch): rename from + handle_workspace_forward since there's no directionality here + (handle_workspace_switch): add a FIXME about how screwed it is + that we need a window in order to do our grab. Should be able to + grab on a dummy window like no_focus_window or the root window. + (process_workspace_switch_grab): rename from tab_grab for clarity, + no tab involved here. + + * src/common.h (enum): have only one grab op for all workspace + switching directions, instead of one for each. + 2002-06-08 Havoc Pennington Apply big patch from blackc@speakeasy.net adding a popup window diff --git a/src/common.h b/src/common.h index 476e9ed85..6287a946d 100644 --- a/src/common.h +++ b/src/common.h @@ -102,10 +102,7 @@ typedef enum META_GRAB_OP_KEYBOARD_TABBING_NORMAL, META_GRAB_OP_KEYBOARD_TABBING_DOCK, - META_GRAB_OP_KEYBOARD_WORKSPACE_UP, - META_GRAB_OP_KEYBOARD_WORKSPACE_DOWN, - META_GRAB_OP_KEYBOARD_WORKSPACE_LEFT, - META_GRAB_OP_KEYBOARD_WORKSPACE_RIGHT, + META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING, /* Frame button ops */ META_GRAB_OP_CLICKING_MINIMIZE, diff --git a/src/display.c b/src/display.c index 70b142981..fbaf4d9b0 100644 --- a/src/display.c +++ b/src/display.c @@ -766,10 +766,7 @@ grab_op_is_keyboard (MetaGrabOp op) case META_GRAB_OP_KEYBOARD_RESIZING_NW: case META_GRAB_OP_KEYBOARD_TABBING_NORMAL: case META_GRAB_OP_KEYBOARD_TABBING_DOCK: - case META_GRAB_OP_KEYBOARD_WORKSPACE_UP: - case META_GRAB_OP_KEYBOARD_WORKSPACE_DOWN: - case META_GRAB_OP_KEYBOARD_WORKSPACE_LEFT: - case META_GRAB_OP_KEYBOARD_WORKSPACE_RIGHT: + case META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING: return TRUE; break; @@ -2255,10 +2252,7 @@ meta_display_begin_grab_op (MetaDisplay *display, META_TAB_LIST_DOCKS); break; - case META_GRAB_OP_KEYBOARD_WORKSPACE_UP: - case META_GRAB_OP_KEYBOARD_WORKSPACE_DOWN: - case META_GRAB_OP_KEYBOARD_WORKSPACE_LEFT: - case META_GRAB_OP_KEYBOARD_WORKSPACE_RIGHT: + case META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING: meta_workspace_ensure_tab_popup (display, window->screen); break; @@ -2280,10 +2274,7 @@ meta_display_end_grab_op (MetaDisplay *display, if (display->grab_op == META_GRAB_OP_KEYBOARD_TABBING_NORMAL || display->grab_op == META_GRAB_OP_KEYBOARD_TABBING_DOCK || - display->grab_op == META_GRAB_OP_KEYBOARD_WORKSPACE_LEFT || - display->grab_op == META_GRAB_OP_KEYBOARD_WORKSPACE_RIGHT || - display->grab_op == META_GRAB_OP_KEYBOARD_WORKSPACE_UP || - display->grab_op == META_GRAB_OP_KEYBOARD_WORKSPACE_DOWN) + display->grab_op == META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING) { meta_ui_tab_popup_free (display->grab_window->screen->tab_popup); display->grab_window->screen->tab_popup = NULL; diff --git a/src/keybindings.c b/src/keybindings.c index e561486c4..b28b02b3c 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -94,7 +94,7 @@ static void handle_move_to_workspace (MetaDisplay *display, MetaWindow *window, XEvent *event, MetaKeyBinding *binding); -static void handle_workspace_forward (MetaDisplay *display, +static void handle_workspace_switch (MetaDisplay *display, MetaWindow *window, XEvent *event, MetaKeyBinding *binding); @@ -119,10 +119,10 @@ static gboolean process_tab_grab (MetaDisplay *display, XEvent *event, KeySym keysym); -static gboolean process_workspace_tab_grab (MetaDisplay *display, - MetaWindow *window, - XEvent *event, - KeySym keysym); +static gboolean process_workspace_switch_grab (MetaDisplay *display, + MetaWindow *window, + XEvent *event, + KeySym keysym); static void regrab_screen_bindings (MetaDisplay *display); static void regrab_window_bindings (MetaDisplay *display); @@ -168,13 +168,13 @@ static const MetaKeyHandler screen_handlers[] = { GINT_TO_POINTER (10) }, { META_KEYBINDING_WORKSPACE_12, handle_activate_workspace, GINT_TO_POINTER (11) }, - { META_KEYBINDING_WORKSPACE_LEFT, handle_workspace_forward, + { META_KEYBINDING_WORKSPACE_LEFT, handle_workspace_switch, GINT_TO_POINTER (META_MOTION_LEFT) }, - { META_KEYBINDING_WORKSPACE_RIGHT, handle_workspace_forward, + { META_KEYBINDING_WORKSPACE_RIGHT, handle_workspace_switch, GINT_TO_POINTER (META_MOTION_RIGHT) }, - { META_KEYBINDING_WORKSPACE_UP, handle_workspace_forward, + { META_KEYBINDING_WORKSPACE_UP, handle_workspace_switch, GINT_TO_POINTER (META_MOTION_UP) }, - { META_KEYBINDING_WORKSPACE_DOWN, handle_workspace_forward, + { META_KEYBINDING_WORKSPACE_DOWN, handle_workspace_switch, GINT_TO_POINTER (META_MOTION_DOWN) }, { META_KEYBINDING_SWITCH_WINDOWS, handle_tab_forward, GINT_TO_POINTER (META_TAB_LIST_NORMAL) }, @@ -1097,13 +1097,10 @@ meta_display_process_key_event (MetaDisplay *display, "Processing event for keyboard tabbing\n"); handled = process_tab_grab (display, window, event, keysym); break; - case META_GRAB_OP_KEYBOARD_WORKSPACE_UP: - case META_GRAB_OP_KEYBOARD_WORKSPACE_DOWN: - case META_GRAB_OP_KEYBOARD_WORKSPACE_LEFT: - case META_GRAB_OP_KEYBOARD_WORKSPACE_RIGHT: + case META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING: meta_topic (META_DEBUG_KEYBINDINGS, - "Processing event for keyboard tabbing workspace\n"); - handled = process_workspace_tab_grab (display, window, event, keysym); + "Processing event for keyboard workspace switching\n"); + handled = process_workspace_switch_grab (display, window, event, keysym); break; default: @@ -1282,7 +1279,8 @@ process_tab_grab (MetaDisplay *display, if (is_modifier (display, event->xkey.keycode)) return TRUE; - action = meta_prefs_get_keybinding_action(keysym); + action = meta_prefs_get_keybinding_action (keysym, + display->grab_mask); switch (action) { @@ -1391,10 +1389,10 @@ handle_activate_workspace (MetaDisplay *display, } static gboolean -process_workspace_tab_grab (MetaDisplay *display, - MetaWindow *window, - XEvent *event, - KeySym keysym) +process_workspace_switch_grab (MetaDisplay *display, + MetaWindow *window, + XEvent *event, + KeySym keysym) { MetaScreen *screen; MetaWorkspace *workspace; @@ -1451,7 +1449,8 @@ process_workspace_tab_grab (MetaDisplay *display, MetaWorkspace *target_workspace; MetaKeyBindingAction action; - action = meta_prefs_get_keybinding_action(keysym); + action = meta_prefs_get_keybinding_action (keysym, + display->grab_mask); switch (action) { @@ -1895,31 +1894,11 @@ handle_raise_or_lower (MetaDisplay *display, } } -static MetaGrabOp -op_from_motion_direction (MetaMotionDirection motion) -{ - switch (motion) - { - case META_MOTION_UP: - return META_GRAB_OP_KEYBOARD_WORKSPACE_UP; - case META_MOTION_DOWN: - return META_GRAB_OP_KEYBOARD_WORKSPACE_DOWN; - case META_MOTION_LEFT: - return META_GRAB_OP_KEYBOARD_WORKSPACE_LEFT; - case META_MOTION_RIGHT: - return META_GRAB_OP_KEYBOARD_WORKSPACE_RIGHT; - } - - g_assert_not_reached (); - - return 0; -} - static void -handle_workspace_forward (MetaDisplay *display, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding) +handle_workspace_switch (MetaDisplay *display, + MetaWindow *window, + XEvent *event, + MetaKeyBinding *binding) { int motion; MetaScreen *screen; @@ -1933,6 +1912,11 @@ handle_workspace_forward (MetaDisplay *display, if (screen == NULL) return; + /* FIXME this is all broken, that you need a window to grab on. + * There's no reason we need a window here, in fact it's broken + * that you have to have one. + */ + if (display->focus_window != NULL) { window = display->focus_window; @@ -1949,7 +1933,7 @@ handle_workspace_forward (MetaDisplay *display, if (meta_display_begin_grab_op (display, window, - op_from_motion_direction (motion), + META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING, FALSE, 0, event->xkey.state & ~(display->ignored_modifier_mask), @@ -1957,14 +1941,14 @@ handle_workspace_forward (MetaDisplay *display, 0, 0)) { MetaWorkspace *next; - - next = meta_workspace_get_neighbor(window->screen->active_workspace, - motion); + + next = meta_workspace_get_neighbor (window->screen->active_workspace, + motion); g_assert (next); - + meta_ui_tab_popup_select (window->screen->tab_popup, (MetaTabEntryKey) next); - + /* only after selecting proper window */ meta_ui_tab_popup_set_showing (window->screen->tab_popup, TRUE); diff --git a/src/prefs.c b/src/prefs.c index af5f66f56..fdbc794f3 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -1033,17 +1033,21 @@ meta_prefs_get_auto_raise_delay () } MetaKeyBindingAction -meta_prefs_get_keybinding_action (unsigned int keysym) +meta_prefs_get_keybinding_action (unsigned int keysym, + unsigned long mask) { int i; - for (i = (int) G_N_ELEMENTS (screen_bindings) - 1; i >= 0; --i) + i = G_N_ELEMENTS (screen_bindings) - 1; + while (i >= 0) { - if (screen_bindings[i].keysym == keysym) - { + if (screen_bindings[i].keysym == keysym && + screen_bindings[i].mask == mask) return (MetaKeyBindingAction) i; - } + + --i; } + return META_KEYBINDING_ACTION_NONE; } diff --git a/src/prefs.h b/src/prefs.h index e273acb71..c1ca58505 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -149,7 +149,9 @@ void meta_prefs_get_screen_bindings (const MetaKeyPref **bindings, int *n_bindings); void meta_prefs_get_window_bindings (const MetaKeyPref **bindings, int *n_bindings); -MetaKeyBindingAction meta_prefs_get_keybinding_action (unsigned int keysym); + +MetaKeyBindingAction meta_prefs_get_keybinding_action (unsigned int keysym, + unsigned long mask); #endif