GNOME Bugzilla – Bug 107072
Make Alt+Esc cycle through tasklist buttons not windows for minimized windows
Last modified: 2005-10-03 20:03:05 UTC
See original discussion bug #89416 we want to focus the tasklist button instead of the window itself.
This would be pretty nice, requires some thought to implement but not rocket science.
Before this gets implemented (which it doesn't look like there's any rush to do) I'm going to argue that this behaviour is broken from a UI perspective. First I'll explain why I think the current Alt+Tab behaviour is broken and why I use Alt+Esc instead. Alt+Tab shows the popup with icons and window titles and also shows a floating window highlight in space. Based on those 2 pieces of information in 2 different locations on the screen, one has to guess whether this is the window you want or not. In comes Alt+Esc, which shows you what the screen will look like when you let go of the Alt key. No more guessing. This is a really nice invariant which should be preserved. In fact, I have Alt+Tab mapped to cycle in my local setup because it is more intuitive and I work faster with it. Implementing the bug as described will break the invariant. Well, it's broken right now anyway, but don't go out of your way to break it further, please.
Created attachment 51207 [details] [review] Preserve the Alt+Esc visibility invariant This patch preserves the invariant I described with respect to minimized windows. When Alt+Escaping onto them, they are unminimized and raised. When you Alt+Esc past them, they are once again minimized.
Comment on attachment 51207 [details] [review] Preserve the Alt+Esc visibility invariant --- metacity-2.11.2/src/keybindings.c +++ metacity-2.11.2/src/keybindings.c @@ -3130,7 +3130,11 @@ meta_ui_tab_popup_set_showing (screen->tab_popup, TRUE); else - meta_window_raise (initial_selection); + { + meta_window_raise (initial_selection); + target_window->tab_unminimized = target_window->minimized; + meta_window_unminimize (target_window); + } } } } [rcohen@localhost src]$ fst record [rcohen@localhost src]$ fst record [rcohen@localhost src]$ fst fs_diff > ../../../ .fst/ metacity-alt-tab.patch FST/ pristine/ metacity-alt-tab-minimize.patch src/ [rcohen@localhost src]$ fst fs_diff > ../../../metacity-alt-tab-minimize.patch [rcohen@localhost src]$ fst record [rcohen@localhost src]$ fst fs_diff > ../../../metacity-alt-tab-minimize.patch [rcohen@localhost src]$ killall metacity [rcohen@localhost src]$ cat ../../../metacity-alt-tab-minimize.patch --- metacity-2.11.2/src/keybindings.c +++ metacity-2.11.2/src/keybindings.c @@ -2407,6 +2407,8 @@ XEvent *event, KeySym keysym) { + Window prev_xwindow; + MetaWindow *prev_window; MetaKeyBindingAction action; gboolean popup_not_showing; gboolean backward; @@ -2434,6 +2436,8 @@ if (target_window) { + target_window->tab_unminimized = 0; + meta_topic (META_DEBUG_KEYBINDINGS, "Activating target window\n"); @@ -2501,6 +2505,11 @@ if (key_used) { + prev_xwindow = + (Window) meta_ui_tab_popup_get_selected (screen->tab_popup); + prev_window = + meta_display_lookup_x_window (display, prev_xwindow); + meta_topic (META_DEBUG_KEYBINDINGS, "Key pressed, moving tab focus in popup\n"); @@ -2527,10 +2536,18 @@ (Window) meta_ui_tab_popup_get_selected (screen->tab_popup); target_window = meta_display_lookup_x_window (display, target_xwindow); - + + if (prev_window && prev_window->tab_unminimized) + { + prev_window->tab_unminimized = 0; + meta_window_minimize (prev_window); + } + if (target_window) { meta_window_raise (target_window); + target_window->tab_unminimized = target_window->minimized; + meta_window_unminimize (target_window); } } } @@ -2544,6 +2561,17 @@ "Syncing to old stack positions.\n"); meta_stack_set_positions (screen->stack, screen->display->grab_old_window_stacking); + + prev_xwindow = + (Window) meta_ui_tab_popup_get_selected (screen->tab_popup); + prev_window = + meta_display_lookup_x_window (display, prev_xwindow); + + if (prev_window && prev_window->tab_unminimized) + { + meta_window_minimize (prev_window); + prev_window->tab_unminimized = 0; + } } return key_used; @@ -3102,7 +3130,11 @@ meta_ui_tab_popup_set_showing (screen->tab_popup, TRUE); else - meta_window_raise (initial_selection); + { + meta_window_raise (initial_selection); + initial_selection->tab_unminimized = initial_selection->minimized; + meta_window_unminimize (initial_selection); + } } } } --- metacity-2.11.2/src/window.c +++ metacity-2.11.2/src/window.c @@ -437,6 +437,7 @@ window->shaded = FALSE; window->initially_iconic = FALSE; window->minimized = FALSE; + window->tab_unminimized = FALSE; window->iconic = FALSE; window->mapped = attrs->map_state != IsUnmapped; /* if already mapped, no need to worry about focus-on-first-time-showing */ --- metacity-2.11.2/src/window.h +++ metacity-2.11.2/src/window.h @@ -124,6 +124,7 @@ /* Minimize is the state controlled by the minimize button */ guint minimized : 1; + guint tab_unminimized : 1; /* Whether the window is mapped; actual server-side state * see also unmaps_pending
Apologies, I didn't expect bugzilla to post the updated patch like that. Anyway, that's a new version with a couple of bugs fixed.
I really like this patch, especially when used in tandem with the one in bug 314285. A couple of notes, Ross: - Please use the -p option for diff when generating patches; it makes patch review much easier. - Since we're using tab_unminimized as a boolean, I'd prefer to assign "FALSE" to it instead of "0", just to make it clearer what its use is. Since the updated patch got kind of borked above and I had to manually make the changes (copying and pasting into a patch file didn't work), I'll attach that fixed up patch in just a moment for those that want to try it out more easily.
Oh, I forgot to mention: this suffers from the same bug as 314285, namely that if you mix alt-tab and alt-esc you get weird results. But, given that it's a bug that we even allow alt-tab and alt-esc to be mixed, I'm not sure that should block this.
Created attachment 52921 [details] [review] Ross' updated patch
Thanks! 2005-10-03 Elijah Newren <newren@gmail.com> Patch from Ross Cohen to make alt-esc (show windows instantly) actually show minimized windows too. Fixes #107072. * src/keybindings.c (process_tab_grab): initialize tab_unminimized to FALSE for the target window when starting the grab, when advancing through the list check to find the previous window and re-minimize it if it was tab-unminimized, unminimize the new window we're alt-esc'ing to if it's minimized, (do_choose_window): raise and unminimize the initial window as well in alt-esc'ing * src/window.h (struct _MetaWindow): add a tab_unminimized field * src/window.c (meta_window_new_with_attrs): initialize tab_unminimized to false