[mutter/wip/xwayland-on-demand: 19/32] Prepare for making MetaX11Display conditional
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/xwayland-on-demand: 19/32] Prepare for making MetaX11Display conditional
- Date: Mon, 28 Aug 2017 02:53:17 +0000 (UTC)
commit 4c40b7591d040b86679f6ba1b5b9faece6cb48b4
Author: Armin Krezović <krezovic armin gmail com>
Date: Sat Aug 26 22:24:21 2017 +0200
Prepare for making MetaX11Display conditional
- Stop using CurrentTime, introduce META_CURRENT_TIME
- Add signals for signaling when MetaX11Display is opened
or closed down
- Use g_get_monotonic_time () instead of relying on an
X server running and making roundtrip to it
src/backends/x11/meta-backend-x11.c | 4 +-
src/compositor/compositor.c | 27 ++++++++-----
src/core/display.c | 68 +++++++++++++++++++++++---------
src/core/events.c | 4 +-
src/core/main.c | 2 +-
src/core/restart.c | 2 +-
src/core/window.c | 2 +-
src/core/workspace.c | 8 ++--
src/meta/common.h | 3 +
src/wayland/meta-xwayland-selection.c | 8 ++--
src/x11/events.c | 4 +-
src/x11/meta-x11-display.c | 2 +-
12 files changed, 87 insertions(+), 47 deletions(-)
---
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index 2c49690..d4b825f 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -110,7 +110,7 @@ translate_device_event (MetaBackendX11 *x11,
meta_backend_x11_translate_device_event (x11, device_event);
- if (!device_event->send_event && device_event->time != CurrentTime)
+ if (!device_event->send_event && device_event->time != META_CURRENT_TIME)
{
if (device_event->time < priv->latest_evtime)
{
@@ -484,7 +484,7 @@ meta_backend_x11_grab_device (MetaBackend *backend,
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
int ret;
- if (timestamp != CurrentTime)
+ if (timestamp != META_CURRENT_TIME)
timestamp = MAX (timestamp, priv->latest_evtime);
XISetMask (mask.mask, XI_ButtonPress);
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 8c4e201..e3b47ca 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -362,11 +362,14 @@ meta_begin_modal_for_plugin (MetaCompositor *compositor,
if (is_modal (display) || display->grab_op != META_GRAB_OP_NONE)
return FALSE;
- /* XXX: why is this needed? */
- XIUngrabDevice (display->x11_display->xdisplay,
- META_VIRTUAL_CORE_POINTER_ID,
- timestamp);
- XSync (display->x11_display->xdisplay, False);
+ if (display->x11_display)
+ {
+ /* XXX: why is this needed? */
+ XIUngrabDevice (display->x11_display->xdisplay,
+ META_VIRTUAL_CORE_POINTER_ID,
+ timestamp);
+ XSync (display->x11_display->xdisplay, False);
+ }
if (!grab_devices (options, timestamp))
return FALSE;
@@ -438,9 +441,8 @@ after_stage_paint (ClutterStage *stage,
}
static void
-redirect_windows (MetaDisplay *display)
+redirect_windows (MetaX11Display *x11_display)
{
- MetaX11Display *x11_display = meta_display_get_x11_display (display);
Display *xdisplay = meta_x11_display_get_xdisplay (x11_display);
Window xroot = meta_x11_display_get_xroot (x11_display);
int screen_number = meta_x11_display_get_screen_number (x11_display);
@@ -484,10 +486,14 @@ void
meta_compositor_manage (MetaCompositor *compositor)
{
MetaDisplay *display = compositor->display;
- Display *xdisplay = display->x11_display->xdisplay;
+ Display *xdisplay = NULL;
MetaBackend *backend = meta_get_backend ();
- meta_x11_display_set_cm_selection (display->x11_display);
+ if (display->x11_display)
+ {
+ xdisplay = display->x11_display->xdisplay;
+ meta_x11_display_set_cm_selection (display->x11_display);
+ }
compositor->stage = meta_backend_get_stage (backend);
@@ -553,7 +559,8 @@ meta_compositor_manage (MetaCompositor *compositor)
compositor->have_x11_sync_object = meta_sync_ring_init (xdisplay);
}
- redirect_windows (display);
+ if (display->x11_display)
+ redirect_windows (display->x11_display);
compositor->plugin_mgr = meta_plugin_manager_new (compositor);
}
diff --git a/src/core/display.c b/src/core/display.c
index 007ebde..0f25e93 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -117,6 +117,8 @@ G_DEFINE_TYPE(MetaDisplay, meta_display, G_TYPE_OBJECT);
enum
{
CURSOR_UPDATED,
+ X11_DISPLAY_OPENED,
+ X11_DISPLAY_CLOSING,
OVERLAY_KEY,
ACCELERATOR_ACTIVATED,
MODIFIERS_ACCELERATOR_ACTIVATED,
@@ -228,6 +230,22 @@ meta_display_class_init (MetaDisplayClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE, 0);
+ display_signals[X11_DISPLAY_OPENED] =
+ g_signal_new ("x11-display-opened",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
+ display_signals[X11_DISPLAY_CLOSING] =
+ g_signal_new ("x11-display-closing",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
display_signals[OVERLAY_KEY] =
g_signal_new ("overlay-key",
G_TYPE_FROM_CLASS (klass),
@@ -574,21 +592,24 @@ enable_compositor (MetaDisplay *display)
{
MetaX11Display *x11_display = display->x11_display;
- if (!META_X11_DISPLAY_HAS_COMPOSITE (x11_display) ||
- !META_X11_DISPLAY_HAS_DAMAGE (x11_display))
+ if (x11_display)
{
- meta_warning ("Missing %s extension required for compositing",
- !META_X11_DISPLAY_HAS_COMPOSITE (x11_display) ?
- "composite" : "damage");
- return;
- }
+ if (!META_X11_DISPLAY_HAS_COMPOSITE (x11_display) ||
+ !META_X11_DISPLAY_HAS_DAMAGE (x11_display))
+ {
+ meta_warning ("Missing %s extension required for compositing",
+ !META_X11_DISPLAY_HAS_COMPOSITE (x11_display) ?
+ "composite" : "damage");
+ return;
+ }
- int version = (x11_display->composite_major_version * 10) +
- x11_display->composite_minor_version;
- if (version < 3)
- {
- meta_warning ("Your version of COMPOSITE is too old.");
- return;
+ int version = (x11_display->composite_major_version * 10) +
+ x11_display->composite_minor_version;
+ if (version < 3)
+ {
+ meta_warning ("Your version of COMPOSITE is too old.");
+ return;
+ }
}
if (!display->compositor)
@@ -721,7 +742,7 @@ meta_display_open (void)
++i;
}
- display->current_time = CurrentTime;
+ display->current_time = META_CURRENT_TIME;
display->sentinel_counter = 0;
display->grab_resize_timeout_id = 0;
@@ -766,6 +787,7 @@ meta_display_open (void)
x11_display = meta_x11_display_new (display, &error);
g_assert (x11_display != NULL); /* Required, for now */
display->x11_display = x11_display;
+ g_signal_emit (display, display_signals[X11_DISPLAY_OPENED], 0);
timestamp = display->x11_display->timestamp;
@@ -801,7 +823,8 @@ meta_display_open (void)
enable_compositor (display);
- meta_x11_display_create_guard_window (display->x11_display);
+ if (display->x11_display)
+ meta_x11_display_create_guard_window (display->x11_display);
/* Set up touch support */
display->gesture_tracker = meta_gesture_tracker_new ();
@@ -824,7 +847,7 @@ meta_display_open (void)
else
meta_x11_display_focus_the_no_focus_window (display->x11_display, timestamp);
}
- else
+ else if (display->x11_display)
meta_x11_display_focus_the_no_focus_window (display->x11_display, timestamp);
meta_idle_monitor_init_dbus ();
@@ -997,6 +1020,7 @@ meta_display_close (MetaDisplay *display,
if (display->x11_display)
{
+ g_signal_emit (display, display_signals[X11_DISPLAY_CLOSING], 0);
g_object_run_dispose (G_OBJECT (display->x11_display));
g_clear_object (&display->x11_display);
}
@@ -1154,7 +1178,11 @@ meta_display_get_current_time (MetaDisplay *display)
guint32
meta_display_get_current_time_roundtrip (MetaDisplay *display)
{
- return meta_x11_display_get_current_time_roundtrip (display->x11_display);
+ if (meta_is_wayland_compositor ())
+ /* Xwayland uses monotonic clock, so lets use it here as well */
+ return (guint32) (g_get_monotonic_time () / 1000);
+ else
+ return meta_x11_display_get_current_time_roundtrip (display->x11_display);
}
/**
@@ -1242,7 +1270,9 @@ meta_display_sync_wayland_input_focus (MetaDisplay *display)
MetaWindow *focus_window = NULL;
MetaBackend *backend = meta_get_backend ();
MetaStage *stage = META_STAGE (meta_backend_get_stage (backend));
- gboolean is_focus_xwindow =
+ gboolean is_focus_xwindow = FALSE;
+
+ if (display->x11_display)
meta_x11_display_xwindow_is_a_no_focus_window (display->x11_display,
display->x11_display->focus_xwindow);
@@ -1324,7 +1354,7 @@ meta_display_timestamp_too_old (MetaDisplay *display,
* timestamp_too_old_or_in_future).
*/
- if (*timestamp == CurrentTime)
+ if (*timestamp == META_CURRENT_TIME)
{
*timestamp = meta_display_get_current_time_roundtrip (display);
return FALSE;
diff --git a/src/core/events.c b/src/core/events.c
index f55e83c..674282a 100644
--- a/src/core/events.c
+++ b/src/core/events.c
@@ -276,7 +276,7 @@ meta_display_handle_event (MetaDisplay *display,
event->type == CLUTTER_BUTTON_PRESS ||
event->type == CLUTTER_TOUCH_BEGIN))
{
- if (CurrentTime == display->current_time)
+ if (META_CURRENT_TIME == display->current_time)
{
/* We can't use missing (i.e. invalid) timestamps to set user time,
* nor do we want to use them to sanity check other timestamps.
@@ -417,7 +417,7 @@ meta_display_handle_event (MetaDisplay *display,
}
#endif
- display->current_time = CurrentTime;
+ display->current_time = META_CURRENT_TIME;
return bypass_clutter;
}
diff --git a/src/core/main.c b/src/core/main.c
index dc1f1c4..64c94b1 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -294,7 +294,7 @@ meta_finalize (void)
if (display)
meta_display_close (display,
- CurrentTime); /* I doubt correct timestamps matter here */
+ META_CURRENT_TIME); /* I doubt correct timestamps matter here */
#ifdef HAVE_WAYLAND
if (meta_is_wayland_compositor ())
diff --git a/src/core/restart.c b/src/core/restart.c
index dec799b..cce79d4 100644
--- a/src/core/restart.c
+++ b/src/core/restart.c
@@ -195,7 +195,7 @@ meta_restart_finish (void)
MetaDisplay *display = meta_get_display ();
Display *xdisplay = meta_x11_display_get_xdisplay (display->x11_display);
Atom atom_restart_helper = XInternAtom (xdisplay, "_MUTTER_RESTART_HELPER", False);
- XSetSelectionOwner (xdisplay, atom_restart_helper, None, CurrentTime);
+ XSetSelectionOwner (xdisplay, atom_restart_helper, None, META_CURRENT_TIME);
}
}
diff --git a/src/core/window.c b/src/core/window.c
index 7a6d961..4b50ce0 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4708,7 +4708,7 @@ meta_window_change_workspace_by_index (MetaWindow *window,
meta_display_get_workspace_by_index (display, space_index);
if (!workspace && append)
- workspace = meta_display_append_new_workspace (display, FALSE, CurrentTime);
+ workspace = meta_display_append_new_workspace (display, FALSE, META_CURRENT_TIME);
if (workspace)
meta_window_change_workspace (window, workspace);
diff --git a/src/core/workspace.c b/src/core/workspace.c
index f06578e..d0380e1 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -1256,8 +1256,8 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
MetaWindow *not_this_one,
guint32 timestamp)
{
- if (timestamp == CurrentTime)
- meta_warning ("CurrentTime used to choose focus window; "
+ if (timestamp == META_CURRENT_TIME)
+ meta_warning ("META_CURRENT_TIME used to choose focus window; "
"focus window may not be correct.\n");
if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK ||
@@ -1271,11 +1271,11 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
window->type != META_WINDOW_DOCK &&
window->type != META_WINDOW_DESKTOP)
{
- if (timestamp == CurrentTime)
+ if (timestamp == META_CURRENT_TIME)
{
/* We would like for this to never happen. However, if
- * it does happen then we kludge since using CurrentTime
+ * it does happen then we kludge since using META_CURRENT_TIME
* can mean ugly race conditions--and we can avoid these
* by allowing EnterNotify events (which come with
* timestamps) to handle focus.
diff --git a/src/meta/common.h b/src/meta/common.h
index ba98756..d5dae61 100644
--- a/src/meta/common.h
+++ b/src/meta/common.h
@@ -43,6 +43,9 @@
#define META_VIRTUAL_CORE_POINTER_ID 2
#define META_VIRTUAL_CORE_KEYBOARD_ID 3
+/* Replacement for X11 CurrentTime */
+#define META_CURRENT_TIME 0L
+
/**
* MetaFrameFlags:
* @META_FRAME_ALLOWS_DELETE: frame allows delete
diff --git a/src/wayland/meta-xwayland-selection.c b/src/wayland/meta-xwayland-selection.c
index 3470791..7c5b7d0 100644
--- a/src/wayland/meta-xwayland-selection.c
+++ b/src/wayland/meta-xwayland-selection.c
@@ -467,7 +467,7 @@ x11_selection_data_send_finished (MetaSelectionBridge *selection,
gdk_x11_get_xatom_by_name ("DELETE"),
gdk_x11_get_xatom_by_name ("_META_SELECTION"),
selection->window,
- CurrentTime);
+ META_CURRENT_TIME);
}
xdnd_send_finished (selection->x11_selection->selection_data,
@@ -1617,7 +1617,7 @@ meta_xwayland_selection_handle_xfixes_selection_notify (MetaWaylandCompositor *c
gdk_x11_get_xatom_by_name ("TARGETS"),
gdk_x11_get_xatom_by_name ("_META_SELECTION"),
selection->window,
- CurrentTime);
+ META_CURRENT_TIME);
XFlush (xdisplay);
}
}
@@ -1632,7 +1632,7 @@ meta_xwayland_selection_handle_xfixes_selection_notify (MetaWaylandCompositor *c
if (event->owner != None && event->owner != selection->window &&
focus && meta_xwayland_is_xwayland_surface (focus))
{
- selection->client_message_timestamp = CurrentTime;
+ selection->client_message_timestamp = META_CURRENT_TIME;
selection->source = meta_wayland_data_source_xwayland_new (selection);
meta_wayland_data_device_set_dnd_source (&compositor->seat->data_device,
selection->source);
@@ -1703,7 +1703,7 @@ meta_selection_bridge_ownership_notify (struct wl_listener *listener,
XSetSelectionOwner (xdisplay,
selection->selection_atom,
selection->window,
- CurrentTime);
+ META_CURRENT_TIME);
}
}
diff --git a/src/x11/events.c b/src/x11/events.c
index 6863280..0cf03c4 100644
--- a/src/x11/events.c
+++ b/src/x11/events.c
@@ -241,7 +241,7 @@ event_get_time (MetaX11Display *x11_display,
case CirculateRequest:
case MappingNotify:
default:
- return CurrentTime;
+ return META_CURRENT_TIME;
}
}
@@ -1818,7 +1818,7 @@ meta_x11_display_handle_xevent (MetaX11Display *x11_display,
bypass_gtk = TRUE;
}
- display->current_time = CurrentTime;
+ display->current_time = META_CURRENT_TIME;
return bypass_gtk;
}
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index ddc9826..1357981 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -1285,7 +1285,7 @@ meta_x11_display_get_current_time_roundtrip (MetaX11Display *x11_display)
guint32 timestamp;
timestamp = meta_display_get_current_time (x11_display->display);
- if (timestamp == CurrentTime)
+ if (timestamp == META_CURRENT_TIME)
{
XEvent property_event;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]