[mutter/wip/exalm/focused-appearance: 992/993] 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: 992/993] window: Make default focus window on each workspace appear focused
- Date: Fri, 29 Jan 2021 19:40:43 +0000 (UTC)
commit 541730a9b413da3c4dbcba2ba3e709249a23a703
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 | 20 ++++++++++++++++++--
src/core/workspace.c | 30 ++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 2 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 39fd38d125..83d3a5813f 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -716,6 +716,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 94db840675..bc02ac0be3 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
@@ -4911,6 +4915,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
*/
@@ -5210,7 +5217,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);
@@ -7312,7 +7319,16 @@ 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;
+
+ workspace_manager = window->display->workspace_manager;
+ workspace = meta_window_get_workspace (window);
+
+ if (workspace && workspace != workspace_manager->active_workspace)
+ return window == meta_workspace_get_default_focus_window (workspace);
+ else
+ return window->has_focus || !window->attached_focus_window;
}
gboolean
diff --git a/src/core/workspace.c b/src/core/workspace.c
index e05a963243..f73aead68e 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -365,10 +365,31 @@ meta_workspace_remove (MetaWorkspace *workspace)
*/
}
+static void
+workspace_default_focus_changed (MetaWorkspace *workspace,
+ MetaWindow *not_this_one)
+{
+ g_autoptr (GSList) windows = NULL;
+ GSList *l;
+
+ windows = meta_display_list_windows (workspace->display, META_LIST_DEFAULT);
+ for (l = windows; l; l = l->next)
+ {
+ MetaWindow *window = META_WINDOW (l->data);
+
+ if (meta_window_located_on_workspace (window, workspace) &&
+ window != not_this_one)
+ meta_window_appears_focused_changed (window);
+ }
+ }
+}
+
void
meta_workspace_add_window (MetaWorkspace *workspace,
MetaWindow *window)
{
+ MetaWorkspaceManager *workspace_manager = workspace->display->workspace_manager;
+
COGL_TRACE_BEGIN_SCOPED (MetaWorkspaceAddWindow,
"Workspace (add window)");
@@ -385,6 +406,9 @@ meta_workspace_add_window (MetaWorkspace *workspace,
meta_workspace_invalidate_work_area (workspace);
}
+ if (workspace != workspace_manager->active_workspace)
+ workspace_default_focus_changed (workspace, window);
+
g_signal_emit (workspace, signals[WINDOW_ADDED], 0, window);
g_object_notify_by_pspec (G_OBJECT (workspace), obj_props[PROP_N_WINDOWS]);
}
@@ -393,6 +417,8 @@ void
meta_workspace_remove_window (MetaWorkspace *workspace,
MetaWindow *window)
{
+ MetaWorkspaceManager *workspace_manager = workspace->display->workspace_manager;
+
COGL_TRACE_BEGIN_SCOPED (MetaWorkspaceRemoveWindow,
"Workspace (remove window)");
@@ -409,6 +435,9 @@ meta_workspace_remove_window (MetaWorkspace *workspace,
meta_workspace_invalidate_work_area (workspace);
}
+ if (workspace != workspace_manager->active_workspace)
+ workspace_default_focus_changed (workspace, window);
+
g_signal_emit (workspace, signals[WINDOW_REMOVED], 0, window);
g_object_notify (G_OBJECT (workspace), "n-windows");
}
@@ -657,6 +686,7 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
if (focus_this)
{
meta_window_activate (focus_this, timestamp);
+ workspace_default_focus_changed (workspace, focus_this);
}
else if (move_window)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]