[mutter] x11: Let X11 connection owners call XSynchronize() themselves
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] x11: Let X11 connection owners call XSynchronize() themselves
- Date: Fri, 3 Jun 2022 15:14:19 +0000 (UTC)
commit fdde7e0f3706ff1aab72fd41f52acae98d37c79c
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Mon May 30 20:27:02 2022 +0200
x11: Let X11 connection owners call XSynchronize() themselves
Only make the context carry the boolean state, but move the two libX11
calls into their corresponding connection handler objects.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2444>
src/backends/x11/meta-backend-x11.c | 3 +++
src/core/display.c | 41 -------------------------------------
src/core/meta-context-main.c | 14 ++++++++++++-
src/core/meta-context-private.h | 9 ++++++++
src/core/meta-context.c | 8 ++++++++
src/core/util-private.h | 3 ---
src/meta/util.h | 3 ---
src/tests/meta-context-test.c | 13 ++++++++++--
src/x11/meta-x11-display.c | 7 +++----
9 files changed, 47 insertions(+), 54 deletions(-)
---
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index 056a16ad71..969b64dddb 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -821,6 +821,7 @@ meta_backend_x11_initable_init (GInitable *initable,
GCancellable *cancellable,
GError **error)
{
+ MetaContext *context = meta_backend_get_context (META_BACKEND (initable));
MetaBackendX11 *x11 = META_BACKEND_X11 (initable);
MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
Display *xdisplay;
@@ -842,6 +843,8 @@ meta_backend_x11_initable_init (GInitable *initable,
return FALSE;
}
+ XSynchronize (xdisplay, meta_context_is_x11_sync (context));
+
priv->xdisplay = xdisplay;
priv->xscreen = DefaultScreenOfDisplay (xdisplay);
priv->xcb = XGetXCBConnection (priv->xdisplay);
diff --git a/src/core/display.c b/src/core/display.c
index 2145fde0db..ee1c372bf8 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -2117,47 +2117,6 @@ meta_display_queue_retheme_all_windows (MetaDisplay *display)
g_slist_free (windows);
}
-/*
- * Stores whether syncing is currently enabled.
- */
-static gboolean is_syncing = FALSE;
-
-/**
- * meta_is_syncing:
- *
- * Returns whether X synchronisation is currently enabled.
- *
- * FIXME: This is *only* called by meta_display_open(), but by that time
- * we have already turned syncing on or off on startup, and we don't
- * have any way to do so while Mutter is running, so it's rather
- * pointless.
- *
- * Returns: %TRUE if we must wait for events whenever we send X requests;
- * %FALSE otherwise.
- */
-gboolean
-meta_is_syncing (void)
-{
- return is_syncing;
-}
-
-/**
- * meta_set_syncing:
- * @setting: whether to turn syncing on or off
- *
- * A handy way to turn on synchronisation on or off for every display.
- */
-void
-meta_set_syncing (gboolean setting)
-{
- if (setting != is_syncing)
- {
- is_syncing = setting;
- if (meta_get_display ())
- XSynchronize (meta_get_display ()->x11_display->xdisplay, is_syncing);
- }
-}
-
/**
* meta_display_ping_timeout:
* @data: All the information about this ping. It is a #MetaPingData
diff --git a/src/core/meta-context-main.c b/src/core/meta-context-main.c
index d2445e369a..5baa7c9f5c 100644
--- a/src/core/meta-context-main.c
+++ b/src/core/meta-context-main.c
@@ -391,7 +391,6 @@ meta_context_main_setup (MetaContext *context,
return FALSE;
meta_context_set_unsafe_mode (context, context_main->options.unsafe_mode);
- meta_set_syncing (context_main->options.x11.sync || g_getenv ("MUTTER_SYNC"));
#ifdef HAVE_NATIVE_BACKEND
if (!add_persistent_virtual_monitors (context_main, error))
@@ -503,6 +502,16 @@ meta_context_main_notify_ready (MetaContext *context)
g_clear_pointer (&context_main->options.sm.save_file, g_free);
}
+#ifdef HAVE_X11
+static gboolean
+meta_context_main_is_x11_sync (MetaContext *context)
+{
+ MetaContextMain *context_main = META_CONTEXT_MAIN (context);
+
+ return context_main->options.x11.sync || g_getenv ("MUTTER_SYNC");
+}
+#endif
+
#ifdef HAVE_NATIVE_BACKEND
static gboolean
add_virtual_monitor_cb (const char *option_name,
@@ -706,6 +715,9 @@ meta_context_main_class_init (MetaContextMainClass *klass)
context_class->setup = meta_context_main_setup;
context_class->create_backend = meta_context_main_create_backend;
context_class->notify_ready = meta_context_main_notify_ready;
+#ifdef HAVE_X11
+ context_class->is_x11_sync = meta_context_main_is_x11_sync;
+#endif
}
static void
diff --git a/src/core/meta-context-private.h b/src/core/meta-context-private.h
index 87f5261f54..c8b9066a7f 100644
--- a/src/core/meta-context-private.h
+++ b/src/core/meta-context-private.h
@@ -49,6 +49,10 @@ struct _MetaContextClass
GError **error);
void (* notify_ready) (MetaContext *context);
+
+#ifdef HAVE_X11
+ gboolean (* is_x11_sync) (MetaContext *context);
+#endif
};
const char * meta_context_get_name (MetaContext *context);
@@ -64,4 +68,9 @@ MetaWaylandCompositor * meta_context_get_wayland_compositor (MetaContext *contex
MetaX11DisplayPolicy meta_context_get_x11_display_policy (MetaContext *context);
+#ifdef HAVE_X11
+META_EXPORT_TEST
+gboolean meta_context_is_x11_sync (MetaContext *context);
+#endif
+
#endif /* META_CONTEXT_PRIVATE_H */
diff --git a/src/core/meta-context.c b/src/core/meta-context.c
index 4363e14e11..d50956b9c1 100644
--- a/src/core/meta-context.c
+++ b/src/core/meta-context.c
@@ -245,6 +245,14 @@ meta_context_get_x11_display_policy (MetaContext *context)
return META_CONTEXT_GET_CLASS (context)->get_x11_display_policy (context);
}
+#ifdef HAVE_X11
+gboolean
+meta_context_is_x11_sync (MetaContext *context)
+{
+ return META_CONTEXT_GET_CLASS (context)->is_x11_sync (context);
+}
+#endif
+
static gboolean
meta_context_real_configure (MetaContext *context,
int *argc,
diff --git a/src/core/util-private.h b/src/core/util-private.h
index ff9d7ce426..fa9f2be4be 100644
--- a/src/core/util-private.h
+++ b/src/core/util-private.h
@@ -37,9 +37,6 @@
void meta_set_verbose (gboolean setting);
void meta_set_debugging (gboolean setting);
-META_EXPORT_TEST
-void meta_set_syncing (gboolean setting);
-
void meta_set_replace_current_wm (gboolean setting);
void meta_set_is_wayland_compositor (gboolean setting);
diff --git a/src/meta/util.h b/src/meta/util.h
index 79de380d82..6c54f55791 100644
--- a/src/meta/util.h
+++ b/src/meta/util.h
@@ -32,9 +32,6 @@
META_EXPORT
gboolean meta_is_verbose (void);
-META_EXPORT
-gboolean meta_is_syncing (void);
-
META_EXPORT
gboolean meta_is_wayland_compositor (void);
diff --git a/src/tests/meta-context-test.c b/src/tests/meta-context-test.c
index c07a66b7b5..5a4e48876b 100644
--- a/src/tests/meta-context-test.c
+++ b/src/tests/meta-context-test.c
@@ -136,8 +136,6 @@ meta_context_test_setup (MetaContext *context,
settings,
META_EXPERIMENTAL_FEATURE_SCALE_MONITOR_FRAMEBUFFER);
- meta_set_syncing (!!g_getenv ("MUTTER_SYNC"));
-
return TRUE;
}
@@ -203,6 +201,14 @@ meta_context_test_notify_ready (MetaContext *context)
{
}
+#ifdef HAVE_X11
+static gboolean
+meta_context_test_is_x11_sync (MetaContext *context)
+{
+ return !!g_getenv ("MUTTER_SYNC");
+}
+#endif
+
static gboolean
run_tests_idle (gpointer user_data)
{
@@ -329,6 +335,9 @@ meta_context_test_class_init (MetaContextTestClass *klass)
context_class->setup = meta_context_test_setup;
context_class->create_backend = meta_context_test_create_backend;
context_class->notify_ready = meta_context_test_notify_ready;
+#ifdef HAVE_X11
+ context_class->is_x11_sync = meta_context_test_is_x11_sync;
+#endif
signals[BEFORE_TESTS] =
g_signal_new ("before-tests",
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index 9a2f02e9e4..bb5f4bf50b 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -1136,6 +1136,7 @@ on_window_visibility_updated (MetaDisplay *display,
MetaX11Display *
meta_x11_display_new (MetaDisplay *display, GError **error)
{
+ MetaContext *context = meta_display_get_context (display);
MetaX11Display *x11_display;
Display *xdisplay;
Screen *xscreen;
@@ -1168,10 +1169,11 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
gdk_display = g_steal_pointer (&prepared_gdk_display);
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display);
+ XSynchronize (xdisplay, meta_context_is_x11_sync (context));
+
#ifdef HAVE_WAYLAND
if (meta_is_wayland_compositor ())
{
- MetaContext *context = meta_display_get_context (display);
MetaWaylandCompositor *compositor =
meta_context_get_wayland_compositor (context);
@@ -1179,9 +1181,6 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
}
#endif
- if (meta_is_syncing ())
- XSynchronize (xdisplay, True);
-
replace_current_wm =
meta_context_is_replacing (meta_backend_get_context (backend));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]