Skip to content

Commit

Permalink
Add setting to raise windows on alt+tab popup
Browse files Browse the repository at this point in the history
  • Loading branch information
sparkida authored and lukefromdc committed Jan 18, 2023
1 parent dcd5d21 commit d83cb24
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/core/keybindings.c
Expand Up @@ -2128,12 +2128,16 @@ process_tab_grab (MetaDisplay *display,
return TRUE;

key = meta_ui_tab_popup_get_selected (screen->tab_popup);
prev_window = meta_display_lookup_x_window (display, (Window) key);
prev_window = meta_display_lookup_x_window (display, (Window) key);
action = display_get_keybinding_action (display,
keysym,
event->xkey.keycode,
display->grab_mask);

gboolean raise_windows;
raise_windows = meta_prefs_get_alt_tab_raise_windows ();
gboolean escaped_alt_tab = FALSE;

/* Cancel when alt-Escape is pressed during using alt-Tab, and vice
* versa.
*/
Expand All @@ -2153,6 +2157,15 @@ process_tab_grab (MetaDisplay *display,
case META_GRAB_OP_KEYBOARD_ESCAPING_DOCK:
/* carry on */
break;
case META_GRAB_OP_KEYBOARD_TABBING_NORMAL:
// handle escape pressed when using raise_windows with alt+tab
// in order to restore selected window in stack
if (raise_windows)
{
escaped_alt_tab = TRUE;
break;
}
return FALSE;
default:
return FALSE;
}
Expand Down Expand Up @@ -2223,7 +2236,7 @@ process_tab_grab (MetaDisplay *display,
case META_KEYBINDING_ACTION_CYCLE_WINDOWS:
case META_KEYBINDING_ACTION_CYCLE_GROUP:
popup_not_showing = TRUE;
key_used = TRUE;
key_used = !escaped_alt_tab;
break;
case META_KEYBINDING_ACTION_CYCLE_PANELS_BACKWARD:
case META_KEYBINDING_ACTION_CYCLE_WINDOWS_BACKWARD:
Expand Down Expand Up @@ -2288,7 +2301,7 @@ process_tab_grab (MetaDisplay *display,
else if (direction == UP)
meta_ui_tab_popup_up (screen->tab_popup);

if (popup_not_showing)
if (popup_not_showing || raise_windows)
{
/* We can't actually change window focus, due to the grab.
* but raise the window.
Expand Down
17 changes: 17 additions & 0 deletions src/core/prefs.c
Expand Up @@ -56,6 +56,7 @@
#define KEY_GENERAL_CENTER_NEW_WINDOWS "center-new-windows"
#define KEY_GENERAL_ICON_SIZE "icon-size"
#define KEY_GENERAL_ALT_TAB_MAX_COLUMNS "alt-tab-max-columns"
#define KEY_GENERAL_ALT_TAB_RAISE_WINDOWS "alt-tab-raise-windows"
#define KEY_GENERAL_ALT_TAB_EXPAND_TO_FIT_TITLE "alt-tab-expand-to-fit-title"

#define KEY_COMMAND_SCHEMA "org.mate.Marco.keybinding-commands"
Expand Down Expand Up @@ -121,6 +122,7 @@ static char *cursor_theme = NULL;
static int cursor_size = 24;
static int icon_size = META_DEFAULT_ICON_SIZE;
static int alt_tab_max_columns = META_DEFAULT_ALT_TAB_MAX_COLUMNS;
static gboolean alt_tab_raise_windows = META_DEFAULT_ALT_TAB_RAISE_WINDOWS;
static gboolean alt_tab_expand_to_fit_title = META_DEFAULT_ALT_TAB_EXPAND_TO_FIT_TITLE;
static gboolean use_force_compositor_manager = FALSE;
static gboolean force_compositor_manager = FALSE;
Expand Down Expand Up @@ -458,6 +460,12 @@ static MetaBoolPreference preferences_bool[] =
&alt_tab_expand_to_fit_title,
META_DEFAULT_ALT_TAB_EXPAND_TO_FIT_TITLE,
},
{ "alt-tab-raise-windows",
KEY_GENERAL_SCHEMA,
META_PREF_ALT_TAB_RAISE_WINDOWS,
&alt_tab_raise_windows,
META_DEFAULT_ALT_TAB_RAISE_WINDOWS,
},
{ NULL, NULL, 0, NULL, FALSE },
};

Expand Down Expand Up @@ -1161,6 +1169,12 @@ meta_prefs_get_alt_tab_expand_to_fit_title (void)
return alt_tab_expand_to_fit_title;
}

gboolean
meta_prefs_get_alt_tab_raise_windows (void)
{
return alt_tab_raise_windows;
}

gboolean
meta_prefs_is_in_skip_list (char *class)
{
Expand Down Expand Up @@ -1682,6 +1696,9 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_ALT_TAB_EXPAND_TO_FIT_TITLE:
return "ALT_TAB_EXPAND_TO_FIT_TITLE";

case META_PREF_ALT_TAB_RAISE_WINDOWS:
return "ALT_TAB_RAISE_WINDOWS";

case META_PREF_COMPOSITING_MANAGER:
return "COMPOSITING_MANAGER";

Expand Down
1 change: 1 addition & 0 deletions src/include/common.h
Expand Up @@ -351,6 +351,7 @@ typedef enum
#define META_MIN_ALT_TAB_MAX_COLUMNS 1
#define META_MAX_ALT_TAB_MAX_COLUMNS 64

#define META_DEFAULT_ALT_TAB_RAISE_WINDOWS FALSE
#define META_DEFAULT_ALT_TAB_EXPAND_TO_FIT_TITLE FALSE

#endif
2 changes: 2 additions & 0 deletions src/include/prefs.h
Expand Up @@ -62,6 +62,7 @@ typedef enum
META_PREF_CURSOR_SIZE,
META_PREF_ICON_SIZE,
META_PREF_ALT_TAB_MAX_COLUMNS,
META_PREF_ALT_TAB_RAISE_WINDOWS,
META_PREF_ALT_TAB_EXPAND_TO_FIT_TITLE,
META_PREF_COMPOSITING_MANAGER,
META_PREF_COMPOSITING_FAST_ALT_TAB,
Expand Down Expand Up @@ -137,6 +138,7 @@ int meta_prefs_get_cursor_size (void);
int meta_prefs_get_icon_size (void);
int meta_prefs_get_alt_tab_max_columns (void);
gboolean meta_prefs_get_alt_tab_expand_to_fit_title (void);
gboolean meta_prefs_get_alt_tab_raise_windows (void);
gboolean meta_prefs_get_compositing_manager (void);
gboolean meta_prefs_get_compositing_fast_alt_tab (void);
gboolean meta_prefs_get_center_new_windows (void);
Expand Down
5 changes: 5 additions & 0 deletions src/org.mate.marco.gschema.xml
Expand Up @@ -218,6 +218,11 @@
<summary>Expand the alt-tab popup window to fit longer window titles</summary>
<description>The popup window may be expanded up to the width determined by the config parameter 'alt-tab-max-columns'.</description>
</key>
<key name="alt-tab-raise-windows" type="b">
<default>false</default>
<summary>Raise windows to surface while cycling alt-tab popup</summary>
<description>While using the popup window, selected windows will be raised to make them easy to identify.</description>
</key>
</schema>

<schema id="org.mate.Marco.workspace-names" path="/org/mate/marco/workspace-names/">
Expand Down

0 comments on commit d83cb24

Please sign in to comment.