mutter/mutter-fix-initial-suspended-state.patch

183 lines
6.3 KiB
Diff

diff --unified --recursive --text --new-file --color mutter-45.3.old/src/core/window.c mutter-45.3.new/src/core/window.c
--- mutter-45.3.old/src/core/window.c 2024-01-07 07:34:55.000000000 +0800
+++ mutter-45.3.new/src/core/window.c 2024-06-04 16:54:29.485138788 +0800
@@ -165,6 +165,8 @@
MetaTileMode mode);
static void update_edge_constraints (MetaWindow *window);
+static void set_hidden_suspended_state (MetaWindow *window);
+
static void initable_iface_init (GInitableIface *initable_iface);
typedef struct _MetaWindowPrivate
@@ -750,9 +752,6 @@
static void
meta_window_init (MetaWindow *window)
{
- MetaWindowPrivate *priv = meta_window_get_instance_private (window);
-
- priv->suspend_state = META_WINDOW_SUSPEND_STATE_SUSPENDED;
window->stamp = next_window_stamp++;
meta_prefs_add_listener (prefs_changed_callback, window);
window->is_alive = TRUE;
@@ -1026,6 +1025,7 @@
meta_window_constructed (GObject *object)
{
MetaWindow *window = META_WINDOW (object);
+ MetaWindowPrivate *priv = meta_window_get_instance_private (window);
MetaDisplay *display = window->display;
MetaContext *context = meta_display_get_context (display);
MetaBackend *backend = meta_context_get_backend (context);
@@ -1381,6 +1381,11 @@
!window->initially_iconic)
unminimize_window_and_all_transient_parents (window);
+ /* There is a slim chance we'll hit time out before a extremely slow client
+ * managed to become active, but unlikely enough. */
+ priv->suspend_state = META_WINDOW_SUSPEND_STATE_HIDDEN;
+ set_hidden_suspended_state (window);
+
window->constructing = FALSE;
}
@@ -1716,9 +1721,9 @@
return TRUE;
}
-gboolean
-meta_window_should_be_showing_on_workspace (MetaWindow *window,
- MetaWorkspace *workspace)
+
+static gboolean
+meta_window_is_showable (MetaWindow *window)
{
#ifdef HAVE_WAYLAND
if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND &&
@@ -1730,12 +1735,72 @@
window->decorated && !window->frame)
return FALSE;
- /* Windows should be showing if they're located on the
- * workspace and they're showing on their own workspace. */
+ return TRUE;
+}
+
+/**
+ * meta_window_should_show_on_workspace:
+ *
+ * Tells whether a window should be showing on the passed workspace, without
+ * taking into account whether it can immediately be shown. Whether it can be
+ * shown or not depends on what windowing system it was created from.
+ *
+ * Returns: %TRUE if the window should show.
+ */
+static gboolean
+meta_window_should_show_on_workspace (MetaWindow *window,
+ MetaWorkspace *workspace)
+{
return (meta_window_located_on_workspace (window, workspace) &&
meta_window_showing_on_its_workspace (window));
}
+/**
+ * meta_window_should_show:
+ *
+ * Tells whether a window should be showing on the current workspace, without
+ * taking into account whether it can immediately be shown. Whether it can be
+ * shown or not depends on what windowing system it was created from.
+ *
+ * Returns: %TRUE if the window should show.
+ */
+gboolean
+meta_window_should_show (MetaWindow *window)
+{
+ MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
+ MetaWorkspace *active_workspace = workspace_manager->active_workspace;
+
+ return meta_window_should_show_on_workspace (window, active_workspace);
+}
+
+/**
+ * meta_window_should_be_showing_on_workspace:
+ *
+ * Tells whether a window should be showing on the passed workspace, while
+ * taking whether it can be immediately be shown. Whether it can be shown or
+ * not depends on what windowing system it was created from.
+ *
+ * Returns: %TRUE if the window should and can be shown.
+ */
+gboolean
+meta_window_should_be_showing_on_workspace (MetaWindow *window,
+ MetaWorkspace *workspace)
+{
+ if (!meta_window_is_showable (window))
+ return FALSE;
+
+ return meta_window_should_show_on_workspace (window, workspace);
+}
+
+/**
+ * meta_window_should_be_showing:
+ *
+ * Tells whether a window should be showing on the current workspace, while
+ * taking whether it can be immediately be shown. Whether it can be shown or
+ * not depends on what windowing system it was created from.
+ *
+ * Returns: %TRUE if the window should and can be shown.
+ */
gboolean
meta_window_should_be_showing (MetaWindow *window)
{
@@ -2132,6 +2197,19 @@
}
static void
+set_hidden_suspended_state (MetaWindow *window)
+{
+ MetaWindowPrivate *priv = meta_window_get_instance_private (window);
+
+ priv->suspend_state = META_WINDOW_SUSPEND_STATE_HIDDEN;
+ g_return_if_fail (!priv->suspend_timoeut_id);
+ priv->suspend_timoeut_id =
+ g_timeout_add_seconds (SUSPEND_HIDDEN_TIMEOUT_S,
+ enter_suspend_state_cb,
+ window);
+}
+
+static void
update_suspend_state (MetaWindow *window)
{
MetaWindowPrivate *priv = meta_window_get_instance_private (window);
@@ -2148,13 +2226,8 @@
}
else if (priv->suspend_state == META_WINDOW_SUSPEND_STATE_ACTIVE)
{
- priv->suspend_state = META_WINDOW_SUSPEND_STATE_HIDDEN;
+ set_hidden_suspended_state (window);
g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_SUSPEND_STATE]);
- g_return_if_fail (!priv->suspend_timoeut_id);
- priv->suspend_timoeut_id =
- g_timeout_add_seconds (SUSPEND_HIDDEN_TIMEOUT_S,
- enter_suspend_state_cb,
- window);
}
}
diff --unified --recursive --text --new-file --color mutter-45.3.old/src/core/window-private.h mutter-45.3.new/src/core/window-private.h
--- mutter-45.3.old/src/core/window-private.h 2024-01-07 07:34:55.000000000 +0800
+++ mutter-45.3.new/src/core/window-private.h 2024-06-04 16:49:30.834738705 +0800
@@ -679,9 +679,12 @@
gboolean meta_window_should_be_showing_on_workspace (MetaWindow *window,
MetaWorkspace *workspace);
-/* Return whether the window should be currently mapped */
+META_EXPORT_TEST
gboolean meta_window_should_be_showing (MetaWindow *window);
+META_EXPORT_TEST
+gboolean meta_window_should_show (MetaWindow *window);
+
void meta_window_update_struts (MetaWindow *window);
/* gets position we need to set to stay in current position,