[mutter] stack: Add a function to get a sorted list of focus candidates
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] stack: Add a function to get a sorted list of focus candidates
- Date: Mon, 8 Jul 2019 10:02:55 +0000 (UTC)
commit 2439255f32b4e775d4427c92a6797b8bd33e7d5a
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Wed Jul 3 18:48:07 2019 +0200
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
src/core/stack.c | 55 ++++++++++++++++++++++++++++++++++++++++++-------------
src/core/stack.h | 15 +++++++++++++++
2 files changed, 57 insertions(+), 13 deletions(-)
---
diff --git a/src/core/stack.c b/src/core/stack.c
index 5a2f83301..ac838fe4f 100644
--- a/src/core/stack.c
+++ b/src/core/stack.c
@@ -1057,6 +1057,27 @@ window_contains_point (MetaWindow *window,
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 (!meta_window_is_focusable (window))
+ return FALSE;
+
+ if (!meta_window_should_be_showing (window))
+ return FALSE;
+
+ if (window->type == META_WINDOW_DOCK)
+ return FALSE;
+
+ return TRUE;
+}
+
static MetaWindow*
get_default_focus_window (MetaStack *stack,
MetaWorkspace *workspace,
@@ -1084,24 +1105,12 @@ get_default_focus_window (MetaStack *stack,
if (window == not_this_one)
continue;
- if (window->unmaps_pending > 0)
- continue;
-
- if (window->unmanaging)
- continue;
-
- if (!meta_window_is_focusable (window))
- continue;
-
- if (!meta_window_should_be_showing (window))
+ if (!window_can_get_default_focus (window))
continue;
if (must_be_at_point && !window_contains_point (window, root_x, root_y))
continue;
- if (window->type == META_WINDOW_DOCK)
- continue;
-
return window;
}
@@ -1156,6 +1165,26 @@ meta_stack_list_windows (MetaStack *stack,
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
meta_stack_windows_cmp (MetaStack *stack,
MetaWindow *window_a,
diff --git a/src/core/stack.h b/src/core/stack.h
index 00d1cfe54..58361b218 100644
--- a/src/core/stack.h
+++ b/src/core/stack.h
@@ -308,6 +308,21 @@ MetaWindow* meta_stack_get_default_focus_window_at_point (MetaStack *stack,
int root_x,
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:
* @stack: The stack to examine.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]