[mutter/wip/exalm/focused-appearance: 3/4] window: Make default focus window on each workspace appear focused
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/exalm/focused-appearance: 3/4] window: Make default focus window on each workspace appear focused
- Date: Mon, 14 Oct 2019 23:08:28 +0000 (UTC)
commit 110542fc9a5f19693db9a7e371b6cab889c9acff
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Sat Oct 12 23:55:26 2019 +0500
window: Make default focus window on each workspace appear focused
Makes workspace transitions in gnome-shell look more seamless, since
both outgoing and incoming workspace have focused windows.
This is only done for click focus mode, since it's not known which
window would be focused for the other modes.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/850
src/core/window-private.h | 2 ++
src/core/window.c | 21 +++++++++++++++++++--
src/core/workspace.c | 25 +++++++++++++++++++++++++
3 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index dd89fdc90..4715c6692 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -680,6 +680,8 @@ void meta_window_get_session_geometry (MetaWindow *window,
void meta_window_update_unfocused_button_grabs (MetaWindow *window);
+void meta_window_appears_focused_changed (MetaWindow *window);
+
void meta_window_set_focused_internal (MetaWindow *window,
gboolean focused);
diff --git a/src/core/window.c b/src/core/window.c
index e276b1e59..7f04bf7d2 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -251,6 +251,10 @@ prefs_changed_callback (MetaPreference pref,
meta_window_recalc_features (window);
meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
}
+ else if (pref == META_PREF_FOCUS_MODE)
+ {
+ meta_window_appears_focused_changed (window);
+ }
}
static void
@@ -4860,6 +4864,9 @@ set_workspace_state (MetaWindow *window,
}
}
+ if (!window->constructing)
+ meta_window_appears_focused_changed (window);
+
/* queue a move_resize since changing workspaces may change
* the relevant struts
*/
@@ -5159,7 +5166,7 @@ meta_window_change_workspace_by_index (MetaWindow *window,
meta_window_change_workspace (window, workspace);
}
-static void
+void
meta_window_appears_focused_changed (MetaWindow *window)
{
set_net_wm_state (window);
@@ -7234,7 +7241,17 @@ meta_window_get_frame (MetaWindow *window)
gboolean
meta_window_appears_focused (MetaWindow *window)
{
- return window->has_focus || (window->attached_focus_window != NULL);
+ MetaWorkspaceManager *workspace_manager;
+ MetaWorkspace *workspace;
+ MetaWindow *default_window = NULL;
+
+ workspace_manager = window->display->workspace_manager;
+ workspace = meta_window_get_workspace (window);
+
+ if (workspace && workspace != workspace_manager->active_workspace)
+ default_window = meta_workspace_get_default_focus_window (workspace);
+
+ return window->has_focus || (window->attached_focus_window != NULL) || (window == default_window);
}
gboolean
diff --git a/src/core/workspace.c b/src/core/workspace.c
index 3ed91b58c..85cb3f223 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -356,10 +356,26 @@ meta_workspace_remove (MetaWorkspace *workspace)
*/
}
+static void
+update_default_focus (MetaWorkspace *workspace,
+ MetaWindow *not_this_one)
+{
+ GList *l;
+
+ for (l = workspace->windows; l; l = l->next) {
+ MetaWindow *window = META_WINDOW (l->data);
+
+ if (window != not_this_one)
+ meta_window_appears_focused_changed (window);
+ }
+}
+
void
meta_workspace_add_window (MetaWorkspace *workspace,
MetaWindow *window)
{
+ MetaWorkspaceManager *manager = workspace->display->workspace_manager;
+
COGL_TRACE_BEGIN_SCOPED (MetaWorkspaceAddWindow,
"Workspace (add window)");
@@ -376,6 +392,9 @@ meta_workspace_add_window (MetaWorkspace *workspace,
meta_workspace_invalidate_work_area (workspace);
}
+ if (workspace != manager->active_workspace)
+ update_default_focus (workspace, window);
+
g_signal_emit (workspace, signals[WINDOW_ADDED], 0, window);
g_object_notify_by_pspec (G_OBJECT (workspace), obj_props[PROP_N_WINDOWS]);
}
@@ -384,6 +403,8 @@ void
meta_workspace_remove_window (MetaWorkspace *workspace,
MetaWindow *window)
{
+ MetaWorkspaceManager *manager = workspace->display->workspace_manager;
+
COGL_TRACE_BEGIN_SCOPED (MetaWorkspaceRemoveWindow,
"Workspace (remove window)");
@@ -400,6 +421,9 @@ meta_workspace_remove_window (MetaWorkspace *workspace,
meta_workspace_invalidate_work_area (workspace);
}
+ if (workspace != manager->active_workspace)
+ update_default_focus (workspace, NULL);
+
g_signal_emit (workspace, signals[WINDOW_REMOVED], 0, window);
g_object_notify (G_OBJECT (workspace), "n-windows");
}
@@ -644,6 +668,7 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
if (focus_this)
{
meta_window_activate (focus_this, timestamp);
+ update_default_focus (workspace, focus_this);
}
else if (move_window)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]