mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 00:50:42 -05:00
stack: Add a function to get a sorted list of focus candidates
Use a static function if a window can be the default focus window, and use such
function to return a filtered list of the stack.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/669
(cherry picked from commit 2439255f32
)
This commit is contained in:
parent
7951ddab40
commit
7d54c5621c
@ -1176,6 +1176,27 @@ window_contains_point (MetaWindow *window,
|
|||||||
return POINT_IN_RECT (root_x, root_y, rect);
|
return POINT_IN_RECT (root_x, root_y, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
window_can_get_default_focus (MetaWindow *window)
|
||||||
|
{
|
||||||
|
if (window->unmaps_pending > 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (window->unmanaging)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!(window->input || window->take_focus))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!meta_window_should_be_showing (window))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (window->type == META_WINDOW_DOCK)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static MetaWindow*
|
static MetaWindow*
|
||||||
get_default_focus_window (MetaStack *stack,
|
get_default_focus_window (MetaStack *stack,
|
||||||
MetaWorkspace *workspace,
|
MetaWorkspace *workspace,
|
||||||
@ -1203,24 +1224,12 @@ get_default_focus_window (MetaStack *stack,
|
|||||||
if (window == not_this_one)
|
if (window == not_this_one)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (window->unmaps_pending > 0)
|
if (!window_can_get_default_focus (window))
|
||||||
continue;
|
|
||||||
|
|
||||||
if (window->unmanaging)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!(window->input || window->take_focus))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!meta_window_should_be_showing (window))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (must_be_at_point && !window_contains_point (window, root_x, root_y))
|
if (must_be_at_point && !window_contains_point (window, root_x, root_y))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (window->type == META_WINDOW_DOCK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1275,6 +1284,26 @@ meta_stack_list_windows (MetaStack *stack,
|
|||||||
return workspace_windows;
|
return workspace_windows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GList *
|
||||||
|
meta_stack_get_default_focus_candidates (MetaStack *stack,
|
||||||
|
MetaWorkspace *workspace)
|
||||||
|
{
|
||||||
|
GList *windows = meta_stack_list_windows (stack, workspace);
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
for (l = windows; l;)
|
||||||
|
{
|
||||||
|
GList *next = l->next;
|
||||||
|
|
||||||
|
if (!window_can_get_default_focus (l->data))
|
||||||
|
windows = g_list_delete_link (windows, l);
|
||||||
|
|
||||||
|
l = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return windows;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
meta_stack_windows_cmp (MetaStack *stack,
|
meta_stack_windows_cmp (MetaStack *stack,
|
||||||
MetaWindow *window_a,
|
MetaWindow *window_a,
|
||||||
|
@ -337,6 +337,21 @@ MetaWindow* meta_stack_get_default_focus_window_at_point (MetaStack *stack,
|
|||||||
int root_x,
|
int root_x,
|
||||||
int root_y);
|
int root_y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* meta_stack_get_default_focus_candidates:
|
||||||
|
* @stack: The stack to examine.
|
||||||
|
* @workspace: If not %NULL, only windows on this workspace will be
|
||||||
|
* returned; otherwise all windows in the stack will be
|
||||||
|
* returned.
|
||||||
|
*
|
||||||
|
* Returns all the focus candidate windows in the stack, in order.
|
||||||
|
*
|
||||||
|
* Returns: (transfer container) (element-type Meta.Window):
|
||||||
|
* A #GList of #MetaWindow, in stacking order, honouring layers.
|
||||||
|
*/
|
||||||
|
GList * meta_stack_get_default_focus_candidates (MetaStack *stack,
|
||||||
|
MetaWorkspace *workspace);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_stack_list_windows:
|
* meta_stack_list_windows:
|
||||||
* @stack: The stack to examine.
|
* @stack: The stack to examine.
|
||||||
|
Loading…
Reference in New Issue
Block a user