mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
Prepare for making MetaX11Display conditional
- Stop using CurrentTime, introduce META_CURRENT_TIME - Use g_get_monotonic_time () instead of relying on an X server running and making roundtrip to it https://bugzilla.gnome.org/show_bug.cgi?id=759538
This commit is contained in:
parent
0a8ae8417c
commit
8e7e1eeef5
@ -176,7 +176,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 (XSERVER_TIME_IS_BEFORE (device_event->time, priv->latest_evtime))
|
||||
{
|
||||
@ -547,7 +547,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);
|
||||
|
@ -362,11 +362,14 @@ meta_begin_modal_for_plugin (MetaCompositor *compositor,
|
||||
if (is_modal (display) || display->grab_op != META_GRAB_OP_NONE)
|
||||
return 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;
|
||||
@ -443,9 +446,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);
|
||||
@ -489,10 +491,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 ();
|
||||
|
||||
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);
|
||||
|
||||
@ -558,7 +564,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);
|
||||
}
|
||||
|
@ -595,6 +595,8 @@ enable_compositor (MetaDisplay *display)
|
||||
{
|
||||
MetaX11Display *x11_display = display->x11_display;
|
||||
|
||||
if (x11_display)
|
||||
{
|
||||
if (!META_X11_DISPLAY_HAS_COMPOSITE (x11_display) ||
|
||||
!META_X11_DISPLAY_HAS_DAMAGE (x11_display))
|
||||
{
|
||||
@ -611,6 +613,7 @@ enable_compositor (MetaDisplay *display)
|
||||
meta_warning ("Your version of COMPOSITE is too old.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!display->compositor)
|
||||
display->compositor = meta_compositor_new (display);
|
||||
@ -743,7 +746,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;
|
||||
@ -826,6 +829,7 @@ meta_display_open (void)
|
||||
|
||||
enable_compositor (display);
|
||||
|
||||
if (display->x11_display)
|
||||
meta_x11_display_create_guard_window (display->x11_display);
|
||||
|
||||
/* Set up touch support */
|
||||
@ -849,7 +853,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 ();
|
||||
@ -1182,6 +1186,10 @@ meta_display_get_current_time (MetaDisplay *display)
|
||||
guint32
|
||||
meta_display_get_current_time_roundtrip (MetaDisplay *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);
|
||||
}
|
||||
|
||||
@ -1270,7 +1278,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);
|
||||
|
||||
@ -1352,7 +1362,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;
|
||||
|
@ -269,7 +269,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.
|
||||
@ -410,7 +410,7 @@ meta_display_handle_event (MetaDisplay *display,
|
||||
}
|
||||
#endif
|
||||
|
||||
display->current_time = CurrentTime;
|
||||
display->current_time = META_CURRENT_TIME;
|
||||
return bypass_clutter;
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,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 ())
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5015,7 +5015,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);
|
||||
|
@ -1260,8 +1260,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 ||
|
||||
@ -1275,11 +1275,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.
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
@ -1616,7 +1616,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);
|
||||
}
|
||||
}
|
||||
@ -1631,7 +1631,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);
|
||||
@ -1702,7 +1702,7 @@ meta_selection_bridge_ownership_notify (struct wl_listener *listener,
|
||||
XSetSelectionOwner (xdisplay,
|
||||
selection->selection_atom,
|
||||
selection->window,
|
||||
CurrentTime);
|
||||
META_CURRENT_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ event_get_time (MetaX11Display *x11_display,
|
||||
case CirculateRequest:
|
||||
case MappingNotify:
|
||||
default:
|
||||
return CurrentTime;
|
||||
return META_CURRENT_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1826,7 +1826,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;
|
||||
}
|
||||
|
||||
|
@ -1290,7 +1290,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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user