diff --git a/ChangeLog b/ChangeLog index 22b7b853a..82aa0466c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2006-04-14 Thomas Thurman + + Add a tabbing function, bound to alt-f6 by default, to cycle + through the windows of the current application. Fixes #164831. + + * src/common.h: two new MetaGrabOpts values for group switching + * src/display.c (ping_data_free, meta_display_in_grab_op, + IN_TAB_CHAIN): adapt to new MetaGrabOpts + * src/display.h: new enum value for MetaTabList for group switching + * src/keybindings.c (meta_display_process_key_event): + adapt to new MetaGrabOpts + (process_tab_grab): adapt to new MetaGrabOpts, and use switch + statement for cancelling instead of if statement + * src/metacity.schemas.in: new keybindings + * src/prefs.c, src/prefs.h: handle new keybindings + * src/window.h: define META_WINDOW_IN_GROUP_TAB_CHAIN macro + 2006-04-14 Elijah Newren * HACKING: Include reasons why gdk/gtk.h and core includes like diff --git a/src/common.h b/src/common.h index 33059eb89..24f208db2 100644 --- a/src/common.h +++ b/src/common.h @@ -116,6 +116,11 @@ typedef enum /* Alt+Esc */ META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL, META_GRAB_OP_KEYBOARD_ESCAPING_DOCK, + + META_GRAB_OP_KEYBOARD_ESCAPING_GROUP, + + /* Alt+F6 */ + META_GRAB_OP_KEYBOARD_TABBING_GROUP, META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING, diff --git a/src/display.c b/src/display.c index 0b2b05fcc..dd43935a6 100644 --- a/src/display.c +++ b/src/display.c @@ -70,8 +70,10 @@ #define GRAB_OP_IS_WINDOW_SWITCH(g) \ (g == META_GRAB_OP_KEYBOARD_TABBING_NORMAL || \ g == META_GRAB_OP_KEYBOARD_TABBING_DOCK || \ + g == META_GRAB_OP_KEYBOARD_TABBING_GROUP || \ g == META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL || \ - g == META_GRAB_OP_KEYBOARD_ESCAPING_DOCK) + g == META_GRAB_OP_KEYBOARD_ESCAPING_DOCK || \ + g == META_GRAB_OP_KEYBOARD_ESCAPING_GROUP) typedef struct { @@ -122,6 +124,8 @@ static void prefs_changed_callback (MetaPreference pref, static void sanity_check_timestamps (MetaDisplay *display, Time known_good_timestamp); +MetaGroup* get_focussed_group (MetaDisplay *display); + static void ping_data_free (MetaPingData *ping_data) { @@ -1111,8 +1115,10 @@ 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_TABBING_GROUP: case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL: case META_GRAB_OP_KEYBOARD_ESCAPING_DOCK: + case META_GRAB_OP_KEYBOARD_ESCAPING_GROUP: case META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING: return TRUE; @@ -3493,6 +3499,15 @@ meta_display_begin_grab_op (MetaDisplay *display, META_TAB_LIST_DOCKS, META_TAB_SHOW_INSTANTLY); break; + case META_GRAB_OP_KEYBOARD_TABBING_GROUP: + meta_screen_ensure_tab_popup (screen, + META_TAB_LIST_GROUP, + META_TAB_SHOW_ICON); + break; + case META_GRAB_OP_KEYBOARD_ESCAPING_GROUP: + meta_screen_ensure_tab_popup (screen, + META_TAB_LIST_GROUP, + META_TAB_SHOW_INSTANTLY); case META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING: meta_screen_ensure_workspace_popup (screen); @@ -4198,7 +4213,18 @@ meta_display_window_has_pending_pings (MetaDisplay *display, return FALSE; } -#define IN_TAB_CHAIN(w,t) (((t) == META_TAB_LIST_NORMAL && META_WINDOW_IN_NORMAL_TAB_CHAIN (w)) || ((t) == META_TAB_LIST_DOCKS && META_WINDOW_IN_DOCK_TAB_CHAIN (w))) +MetaGroup* +get_focussed_group (MetaDisplay *display) +{ + if (display->focus_window) + return display->focus_window->group; + else + return NULL; +} + +#define IN_TAB_CHAIN(w,t) (((t) == META_TAB_LIST_NORMAL && META_WINDOW_IN_NORMAL_TAB_CHAIN (w)) \ + || ((t) == META_TAB_LIST_DOCKS && META_WINDOW_IN_DOCK_TAB_CHAIN (w)) \ + || ((t) == META_TAB_LIST_GROUP && META_WINDOW_IN_GROUP_TAB_CHAIN (w, get_focussed_group(w->display)))) static MetaWindow* find_tab_forward (MetaDisplay *display, diff --git a/src/display.h b/src/display.h index 361edf719..150754df5 100644 --- a/src/display.h +++ b/src/display.h @@ -494,7 +494,8 @@ gboolean meta_display_window_has_pending_pings (MetaDisplay *display, typedef enum { META_TAB_LIST_NORMAL, - META_TAB_LIST_DOCKS + META_TAB_LIST_DOCKS, + META_TAB_LIST_GROUP } MetaTabList; typedef enum diff --git a/src/keybindings.c b/src/keybindings.c index d48e5ec46..201293a8f 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -1,5 +1,4 @@ -/* Metacity Keybindings */ - +/* Metacity Keybindings */ /* * Copyright (C) 2001 Havoc Pennington * Copyright (C) 2002 Red Hat Inc. @@ -280,6 +279,14 @@ static const MetaKeyHandler screen_handlers[] = { GINT_TO_POINTER (META_TAB_LIST_DOCKS) }, { META_KEYBINDING_SWITCH_PANELS_BACKWARD, handle_tab_backward, GINT_TO_POINTER (META_TAB_LIST_DOCKS) }, + { META_KEYBINDING_SWITCH_GROUP, handle_tab_forward, + GINT_TO_POINTER (META_TAB_LIST_GROUP) }, + { META_KEYBINDING_SWITCH_GROUP_BACKWARD, handle_tab_backward, + GINT_TO_POINTER (META_TAB_LIST_GROUP) }, + { META_KEYBINDING_CYCLE_GROUP, handle_cycle_forward, + GINT_TO_POINTER (META_TAB_LIST_GROUP) }, + { META_KEYBINDING_CYCLE_GROUP_BACKWARD, handle_cycle_backward, + GINT_TO_POINTER (META_TAB_LIST_GROUP) }, { META_KEYBINDING_CYCLE_WINDOWS, handle_cycle_forward, GINT_TO_POINTER (META_TAB_LIST_NORMAL) }, { META_KEYBINDING_CYCLE_WINDOWS_BACKWARD, handle_cycle_backward, @@ -1662,8 +1669,10 @@ meta_display_process_key_event (MetaDisplay *display, 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); @@ -2333,12 +2342,16 @@ process_tab_grab (MetaDisplay *display, /* CYCLE_* are traditionally Escape-based actions, * and should cancel traditionally Tab-based ones. */ - if (display->grab_op == META_GRAB_OP_KEYBOARD_TABBING_NORMAL || - display->grab_op == META_GRAB_OP_KEYBOARD_TABBING_DOCK) + switch (display->grab_op) { + case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL: + case META_GRAB_OP_KEYBOARD_ESCAPING_DOCK: + /* carry on */ + break; + default: return FALSE; } - break; + break; case META_KEYBINDING_ACTION_SWITCH_PANELS: case META_KEYBINDING_ACTION_SWITCH_WINDOWS: case META_KEYBINDING_ACTION_SWITCH_PANELS_BACKWARD: @@ -2346,9 +2359,13 @@ process_tab_grab (MetaDisplay *display, /* SWITCH_* are traditionally Tab-based actions, * and should cancel traditionally Escape-based ones. */ - if (display->grab_op == META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL || - display->grab_op == META_GRAB_OP_KEYBOARD_ESCAPING_DOCK) + switch (display->grab_op) { + case META_GRAB_OP_KEYBOARD_TABBING_NORMAL: + case META_GRAB_OP_KEYBOARD_TABBING_DOCK: + /* carry on */ + break; + default: /* Also, we must re-lower and re-minimize whatever window * we'd previously raised and unminimized. */ @@ -2362,6 +2379,21 @@ process_tab_grab (MetaDisplay *display, return FALSE; } break; + case META_KEYBINDING_ACTION_CYCLE_GROUP: + case META_KEYBINDING_ACTION_CYCLE_GROUP_BACKWARD: + case META_KEYBINDING_ACTION_SWITCH_GROUP: + case META_KEYBINDING_ACTION_SWITCH_GROUP_BACKWARD: + switch (display->grab_op) + { + case META_GRAB_OP_KEYBOARD_ESCAPING_GROUP: + case META_GRAB_OP_KEYBOARD_TABBING_GROUP: + /* carry on */ + break; + default: + return FALSE; + } + + break; default: break; } @@ -2374,21 +2406,25 @@ process_tab_grab (MetaDisplay *display, { case META_KEYBINDING_ACTION_CYCLE_PANELS: case META_KEYBINDING_ACTION_CYCLE_WINDOWS: + case META_KEYBINDING_ACTION_CYCLE_GROUP: popup_not_showing = TRUE; key_used = TRUE; break; case META_KEYBINDING_ACTION_CYCLE_PANELS_BACKWARD: case META_KEYBINDING_ACTION_CYCLE_WINDOWS_BACKWARD: + case META_KEYBINDING_ACTION_CYCLE_GROUP_BACKWARD: popup_not_showing = TRUE; key_used = TRUE; backward = TRUE; break; case META_KEYBINDING_ACTION_SWITCH_PANELS: case META_KEYBINDING_ACTION_SWITCH_WINDOWS: + case META_KEYBINDING_ACTION_SWITCH_GROUP: key_used = TRUE; break; case META_KEYBINDING_ACTION_SWITCH_PANELS_BACKWARD: case META_KEYBINDING_ACTION_SWITCH_WINDOWS_BACKWARD: + case META_KEYBINDING_ACTION_SWITCH_GROUP_BACKWARD: key_used = TRUE; backward = TRUE; break; @@ -2904,6 +2940,8 @@ tab_op_from_tab_type (MetaTabList type) return META_GRAB_OP_KEYBOARD_TABBING_NORMAL; case META_TAB_LIST_DOCKS: return META_GRAB_OP_KEYBOARD_TABBING_DOCK; + case META_TAB_LIST_GROUP: + return META_GRAB_OP_KEYBOARD_TABBING_GROUP; } g_assert_not_reached (); @@ -2920,6 +2958,8 @@ cycle_op_from_tab_type (MetaTabList type) return META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL; case META_TAB_LIST_DOCKS: return META_GRAB_OP_KEYBOARD_ESCAPING_DOCK; + case META_TAB_LIST_GROUP: + return META_GRAB_OP_KEYBOARD_ESCAPING_GROUP; } g_assert_not_reached (); diff --git a/src/metacity.schemas.in b/src/metacity.schemas.in index 6bef6ae59..b16b3d31c 100644 --- a/src/metacity.schemas.in +++ b/src/metacity.schemas.in @@ -1186,6 +1186,108 @@ you set + + /schemas/apps/metacity/global_keybindings/cycle_group + /apps/metacity/global_keybindings/cycle_group + metacity + string + disabled + + Move between windows of an application immediately + + The keybinding used to move focus between windows of an + application without a popup window. + Holding the "shift" key while using this binding reverses + the direction of movement. + + The format looks like "<Control>a" or + "<Shift><Alt>F1". + + The parser is fairly liberal and allows lower or upper case, + and also abbreviations such as "<Ctl>" and + "<Ctrl>". If you set the option to the special string + "disabled", then there will be no keybinding for this + action. + + + + + + /schemas/apps/metacity/global_keybindings/cycle_group_backward + /apps/metacity/global_keybindings/cycle_group_backward + metacity + string + disabled + + Move backwards between windows of an application immediately + + The keybinding used to move focus backwards between windows + of an application without a popup window. Holding "shift" + together with this binding makes the direction go forward again. + + The format looks like "<Control>a" or + "<Shift><Alt>F1". + + The parser is fairly liberal and allows lower or upper case, + and also abbreviations such as "<Ctl>" and + "<Ctrl>". If you set the option to the special string + "disabled", then there will be no keybinding for this + action. + + + + + + /schemas/apps/metacity/global_keybindings/switch_group + /apps/metacity/global_keybindings/switch_group + metacity + string + <Alt>F6 + + Move between windows of an application with popup + + The keybinding used to move focus between windows of an + application, using a popup window. + (Traditionally <Alt>F6) Holding the "shift" key + while using this binding reverses the direction of movement. + + The format looks like "<Control>a" or + "<Shift><Alt>F1". + + The parser is fairly liberal and allows lower or upper case, + and also abbreviations such as "<Ctl>" and + "<Ctrl>". If you set the option to the special string + "disabled", then there will be no keybinding for this + action. + + + + + + /schemas/apps/metacity/global_keybindings/switch_group_backward + /apps/metacity/global_keybindings/switch_group_backward + metacity + string + disabled + + Move backwards between windows of an application with popup + + The keybinding used to move focus backwards between windows + of an application, using a popup window. Holding "shift" + together with this binding makes the direction go forward again. + + The format looks like "<Control>a" or + "<Shift><Alt>F1". + + The parser is fairly liberal and allows lower or upper case, + and also abbreviations such as "<Ctl>" and + "<Ctrl>". If you set the option to the special string + "disabled", then there will be no keybinding for this + action. + + + + /schemas/apps/metacity/global_keybindings/cycle_windows /apps/metacity/global_keybindings/cycle_windows diff --git a/src/prefs.c b/src/prefs.c index a6e6ea7cd..217f883f1 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -1753,10 +1753,14 @@ static MetaKeyPref screen_bindings[] = { { META_KEYBINDING_WORKSPACE_RIGHT, 0, 0, FALSE }, { META_KEYBINDING_WORKSPACE_UP, 0, 0, FALSE }, { META_KEYBINDING_WORKSPACE_DOWN, 0, 0, FALSE }, + { META_KEYBINDING_SWITCH_GROUP, 0, 0, TRUE }, + { META_KEYBINDING_SWITCH_GROUP_BACKWARD, 0, 0, TRUE }, { META_KEYBINDING_SWITCH_WINDOWS, 0, 0, TRUE }, { META_KEYBINDING_SWITCH_WINDOWS_BACKWARD, 0, 0, TRUE }, { META_KEYBINDING_SWITCH_PANELS, 0, 0, TRUE }, { META_KEYBINDING_SWITCH_PANELS_BACKWARD, 0, 0, TRUE }, + { META_KEYBINDING_CYCLE_GROUP, 0, 0, TRUE }, + { META_KEYBINDING_CYCLE_GROUP_BACKWARD, 0, 0, TRUE }, { META_KEYBINDING_CYCLE_WINDOWS, 0, 0, TRUE }, { META_KEYBINDING_CYCLE_WINDOWS_BACKWARD, 0, 0, TRUE }, { META_KEYBINDING_CYCLE_PANELS, 0, 0, TRUE }, @@ -1856,6 +1860,7 @@ static MetaSimpleKeyMapping screen_string_bindings[] = { { META_KEYBINDING_WORKSPACE_DOWN, "Down" }, { META_KEYBINDING_SWITCH_WINDOWS, "Tab" }, { META_KEYBINDING_SWITCH_PANELS, "Tab" }, + { META_KEYBINDING_CYCLE_GROUP, "F6" }, { META_KEYBINDING_CYCLE_WINDOWS, "Escape" }, { META_KEYBINDING_CYCLE_PANELS, "Escape" }, { META_KEYBINDING_SHOW_DESKTOP, "d" }, diff --git a/src/prefs.h b/src/prefs.h index 63f3b55e4..8ae3e7ed9 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -120,10 +120,14 @@ gboolean meta_prefs_get_compositing_manager (void); #define META_KEYBINDING_WORKSPACE_RIGHT "switch_to_workspace_right" #define META_KEYBINDING_WORKSPACE_UP "switch_to_workspace_up" #define META_KEYBINDING_WORKSPACE_DOWN "switch_to_workspace_down" +#define META_KEYBINDING_SWITCH_GROUP "switch_group" +#define META_KEYBINDING_SWITCH_GROUP_BACKWARD "switch_group_backward" #define META_KEYBINDING_SWITCH_WINDOWS "switch_windows" #define META_KEYBINDING_SWITCH_WINDOWS_BACKWARD "switch_windows_backward" #define META_KEYBINDING_SWITCH_PANELS "switch_panels" #define META_KEYBINDING_SWITCH_PANELS_BACKWARD "switch_panels_backward" +#define META_KEYBINDING_CYCLE_GROUP "cycle_group" +#define META_KEYBINDING_CYCLE_GROUP_BACKWARD "cycle_group_backward" #define META_KEYBINDING_CYCLE_WINDOWS "cycle_windows" #define META_KEYBINDING_CYCLE_WINDOWS_BACKWARD "cycle_windows_backward" #define META_KEYBINDING_CYCLE_PANELS "cycle_panels" @@ -221,10 +225,14 @@ typedef enum _MetaKeyBindingAction META_KEYBINDING_ACTION_WORKSPACE_RIGHT, META_KEYBINDING_ACTION_WORKSPACE_UP, META_KEYBINDING_ACTION_WORKSPACE_DOWN, + META_KEYBINDING_ACTION_SWITCH_GROUP, + META_KEYBINDING_ACTION_SWITCH_GROUP_BACKWARD, META_KEYBINDING_ACTION_SWITCH_WINDOWS, META_KEYBINDING_ACTION_SWITCH_WINDOWS_BACKWARD, META_KEYBINDING_ACTION_SWITCH_PANELS, META_KEYBINDING_ACTION_SWITCH_PANELS_BACKWARD, + META_KEYBINDING_ACTION_CYCLE_GROUP, + META_KEYBINDING_ACTION_CYCLE_GROUP_BACKWARD, META_KEYBINDING_ACTION_CYCLE_WINDOWS, META_KEYBINDING_ACTION_CYCLE_WINDOWS_BACKWARD, META_KEYBINDING_ACTION_CYCLE_PANELS, diff --git a/src/window.h b/src/window.h index 49ac0293d..f3eb4d38b 100644 --- a/src/window.h +++ b/src/window.h @@ -542,6 +542,8 @@ gboolean meta_window_same_application (MetaWindow *window, (((w)->input || (w)->take_focus ) && META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) && (!(w)->skip_taskbar)) #define META_WINDOW_IN_DOCK_TAB_CHAIN(w) \ (((w)->input || (w)->take_focus) && ! META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w)) +#define META_WINDOW_IN_GROUP_TAB_CHAIN(w, g) \ + (((w)->input || (w)->take_focus) && (!g || meta_window_get_group(w)==g)) void meta_window_refresh_resize_popup (MetaWindow *window);