1
0
Fork 0

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>
This commit is contained in:
Jonas Ådahl 2022-05-30 20:27:02 +02:00 committed by Marge Bot
parent 9a68fb19e4
commit fdde7e0f37
9 changed files with 47 additions and 54 deletions

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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 */

View file

@ -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,

View file

@ -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);

View file

@ -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);

View file

@ -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",

View file

@ -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));