Skip to content

Commit

Permalink
Revert "workspace: Don't try to use per-workspace MRU lists as a hint…
Browse files Browse the repository at this point in the history
… for focusing"

This reverts commit f96255b.

Fixes mate-desktop#647
  • Loading branch information
balazs-endresz committed Oct 26, 2022
1 parent 4bd4942 commit 2abf33f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion doc/how-to-get-focus-right.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ end of the discussion for how these special cases are handled.) The
basics are easy:

Focus method Behavior
click Focus the window on top
click When a user clicks on a window, focus it
sloppy When an EnterNotify is received, focus the window
mouse Same as sloppy, but also defocus when mouse enters DESKTOP
window
Expand Down
42 changes: 36 additions & 6 deletions src/core/workspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

void meta_workspace_queue_calc_showing (MetaWorkspace *workspace);
static void set_active_space_hint (MetaScreen *screen);
static void focus_ancestor_or_top_window (MetaWorkspace *workspace,
static void focus_ancestor_or_mru_window (MetaWorkspace *workspace,
MetaWindow *not_this_one,
guint32 timestamp);
static void free_this (gpointer candidate,
Expand Down Expand Up @@ -972,7 +972,7 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,

if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK ||
!workspace->screen->display->mouse_mode)
focus_ancestor_or_top_window (workspace, not_this_one, timestamp);
focus_ancestor_or_mru_window (workspace, not_this_one, timestamp);
else
{
MetaWindow * window;
Expand Down Expand Up @@ -1009,7 +1009,7 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
}
}
else if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_SLOPPY)
focus_ancestor_or_top_window (workspace, not_this_one, timestamp);
focus_ancestor_or_mru_window (workspace, not_this_one, timestamp);
else if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_MOUSE)
{
meta_topic (META_DEBUG_FOCUS,
Expand All @@ -1036,11 +1036,13 @@ record_ancestor (MetaWindow *window,
* window on active workspace
*/
static void
focus_ancestor_or_top_window (MetaWorkspace *workspace,
focus_ancestor_or_mru_window (MetaWorkspace *workspace,
MetaWindow *not_this_one,
guint32 timestamp)
{
MetaWindow *window = NULL;
MetaWindow *desktop_window = NULL;
GList *tmp;

if (not_this_one)
meta_topic (META_DEBUG_FOCUS,
Expand Down Expand Up @@ -1071,8 +1073,36 @@ focus_ancestor_or_top_window (MetaWorkspace *workspace,
}
}

window = meta_stack_get_default_focus_window (workspace->screen->stack,
workspace, NULL);
/* No ancestor, look for the MRU window */
tmp = workspace->mru_list;

while (tmp)
{
MetaWindow* tmp_window;
tmp_window = ((MetaWindow*) tmp->data);
if (tmp_window != not_this_one &&
meta_window_showing_on_its_workspace (tmp_window) &&
tmp_window->type != META_WINDOW_DOCK &&
tmp_window->type != META_WINDOW_DESKTOP)
{
window = tmp->data;
break;
}
else if (tmp_window != not_this_one &&
desktop_window == NULL &&
meta_window_showing_on_its_workspace (tmp_window) &&
tmp_window->type == META_WINDOW_DESKTOP)
{
/* Found the most recently used desktop window */
desktop_window = tmp_window;
}

tmp = tmp->next;
}

/* If no window was found, default to the MRU desktop-window */
if (window == NULL)
window = desktop_window;

if (window)
{
Expand Down
11 changes: 0 additions & 11 deletions src/core/workspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ struct _MetaWorkspace
MetaScreen *screen;

GList *windows;

/* The "MRU list", or "most recently used" list, is a list of
* MetaWindows ordered based on the time the the user interacted
* with the window most recently.
*
* For historical reasons, we keep an MRU list per workspace.
* It used to be used to calculate the default focused window,
* but isn't anymore, as the window next in the stacking order
* can sometimes be not the window the user interacted with last,
*/

GList *mru_list;

GList *list_containing_self;
Expand Down

0 comments on commit 2abf33f

Please sign in to comment.