stack: Flatten and simplify the default focus window logic
This commit is contained in:
parent
1f15c85c00
commit
f11bf44525
@ -1705,8 +1705,8 @@ get_default_focus_window (MetaStack *stack,
|
|||||||
MetaWindow *topmost_in_group;
|
MetaWindow *topmost_in_group;
|
||||||
MetaWindow *topmost_overall;
|
MetaWindow *topmost_overall;
|
||||||
MetaGroup *not_this_one_group;
|
MetaGroup *not_this_one_group;
|
||||||
GList *link;
|
GList *l;
|
||||||
|
|
||||||
transient_parent = NULL;
|
transient_parent = NULL;
|
||||||
topmost_in_group = NULL;
|
topmost_in_group = NULL;
|
||||||
topmost_overall = NULL;
|
topmost_overall = NULL;
|
||||||
@ -1718,49 +1718,50 @@ get_default_focus_window (MetaStack *stack,
|
|||||||
stack_ensure_sorted (stack);
|
stack_ensure_sorted (stack);
|
||||||
|
|
||||||
/* top of this layer is at the front of the list */
|
/* top of this layer is at the front of the list */
|
||||||
link = stack->sorted;
|
for (l = stack->sorted; l != NULL; l = l->next)
|
||||||
|
|
||||||
while (link)
|
|
||||||
{
|
{
|
||||||
MetaWindow *window = link->data;
|
MetaWindow *window = l->data;
|
||||||
|
|
||||||
if (window &&
|
if (!window)
|
||||||
window != not_this_one &&
|
continue;
|
||||||
(window->unmaps_pending == 0) &&
|
|
||||||
!window->minimized &&
|
if (window == not_this_one)
|
||||||
(window->input || window->take_focus) &&
|
continue;
|
||||||
(workspace == NULL ||
|
|
||||||
meta_window_located_on_workspace (window, workspace)))
|
if (window->unmaps_pending > 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (window->minimized)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!(window->input || window->take_focus))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (workspace != NULL && !meta_window_located_on_workspace (window, workspace))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (must_be_at_point && !window_contains_point (window, root_x, root_y))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (not_this_one != NULL)
|
||||||
{
|
{
|
||||||
if (not_this_one != NULL)
|
if (transient_parent == NULL &&
|
||||||
{
|
not_this_one->xtransient_for != None &&
|
||||||
if (transient_parent == NULL &&
|
not_this_one->xtransient_for == window->xwindow)
|
||||||
not_this_one->xtransient_for != None &&
|
transient_parent = window;
|
||||||
not_this_one->xtransient_for == window->xwindow &&
|
|
||||||
(!must_be_at_point ||
|
|
||||||
window_contains_point (window, root_x, root_y)))
|
|
||||||
transient_parent = window;
|
|
||||||
|
|
||||||
if (topmost_in_group == NULL &&
|
if (topmost_in_group == NULL &&
|
||||||
not_this_one_group != NULL &&
|
not_this_one_group != NULL &&
|
||||||
not_this_one_group == meta_window_get_group (window) &&
|
not_this_one_group == meta_window_get_group (window))
|
||||||
(!must_be_at_point ||
|
topmost_in_group = window;
|
||||||
window_contains_point (window, root_x, root_y)))
|
|
||||||
topmost_in_group = window;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (topmost_overall == NULL &&
|
|
||||||
window->type != META_WINDOW_DOCK &&
|
|
||||||
(!must_be_at_point ||
|
|
||||||
window_contains_point (window, root_x, root_y)))
|
|
||||||
topmost_overall = window;
|
|
||||||
|
|
||||||
/* We could try to bail out early here for efficiency in
|
|
||||||
* some cases, but it's just not worth the code.
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
link = link->next;
|
if (topmost_overall == NULL && window->type != META_WINDOW_DOCK)
|
||||||
|
topmost_overall = window;
|
||||||
|
|
||||||
|
/* We could try to bail out early here for efficiency in
|
||||||
|
* some cases, but it's just not worth the code.
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transient_parent)
|
if (transient_parent)
|
||||||
|
Loading…
Reference in New Issue
Block a user