wayland: Drop old hack to synthesize motion events
mutter now uses Clutter events for the source of its drag support, so we don't need to synthesize X11 events anymore.
This commit is contained in:
parent
666e5f1f98
commit
875bbec949
@ -3301,21 +3301,6 @@ xevent_callback (XEvent *event,
|
|||||||
{
|
{
|
||||||
MetaDisplay *display = data;
|
MetaDisplay *display = data;
|
||||||
|
|
||||||
/* Under Wayland we want to filter out mouse motion events so we can
|
|
||||||
synthesize them from the Clutter events instead. This is
|
|
||||||
necessary because the position in the mouse events is passed to
|
|
||||||
the X server relative to the position of the surface. The X
|
|
||||||
server then translates these back to screen coordinates based on
|
|
||||||
the window position. If we rely on this translatation when
|
|
||||||
dragging a window around then the window will jump around
|
|
||||||
erratically because of the lag between updating the window
|
|
||||||
position from the surface position. Instead we bypass the
|
|
||||||
translation altogether by directly using the Clutter events */
|
|
||||||
if (meta_is_wayland_compositor () &&
|
|
||||||
event->type == GenericEvent &&
|
|
||||||
event->xcookie.evtype == XI_Motion)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return meta_display_handle_xevent (display, event);
|
return meta_display_handle_xevent (display, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,6 @@ struct _MetaWaylandPointer
|
|||||||
|
|
||||||
wl_fixed_t x, y; /* TODO: remove, use ClutterInputDevice instead */
|
wl_fixed_t x, y; /* TODO: remove, use ClutterInputDevice instead */
|
||||||
MetaWaylandSurface *current;
|
MetaWaylandSurface *current;
|
||||||
wl_fixed_t current_x, current_y;
|
|
||||||
|
|
||||||
guint32 button_count;
|
guint32 button_count;
|
||||||
};
|
};
|
||||||
|
@ -83,14 +83,6 @@ struct _MetaWaylandCompositor
|
|||||||
int drm_fd;
|
int drm_fd;
|
||||||
|
|
||||||
MetaWaylandSeat *seat;
|
MetaWaylandSeat *seat;
|
||||||
|
|
||||||
/* This surface is only used to keep drag of the implicit grab when
|
|
||||||
synthesizing XEvents for Mutter */
|
|
||||||
MetaWaylandSurface *implicit_grab_surface;
|
|
||||||
/* Button that was pressed to initiate an implicit grab. The
|
|
||||||
implicit grab will only be released when this button is
|
|
||||||
released */
|
|
||||||
guint32 implicit_grab_button;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void meta_wayland_init (void);
|
void meta_wayland_init (void);
|
||||||
|
@ -409,20 +409,6 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
update_pointer_position_for_actor (MetaWaylandPointer *pointer,
|
|
||||||
ClutterActor *actor)
|
|
||||||
{
|
|
||||||
float ax, ay;
|
|
||||||
|
|
||||||
clutter_actor_transform_stage_point (actor,
|
|
||||||
wl_fixed_to_double (pointer->x),
|
|
||||||
wl_fixed_to_double (pointer->y),
|
|
||||||
&ax, &ay);
|
|
||||||
pointer->current_x = wl_fixed_from_double (ax);
|
|
||||||
pointer->current_y = wl_fixed_from_double (ay);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The actor argument can be NULL in which case a Clutter pick will be
|
/* The actor argument can be NULL in which case a Clutter pick will be
|
||||||
performed to determine the right actor. An actor should only be
|
performed to determine the right actor. An actor should only be
|
||||||
passed if the repick is being performed due to an event in which
|
passed if the repick is being performed due to an event in which
|
||||||
@ -459,16 +445,12 @@ meta_wayland_seat_repick (MetaWaylandSeat *seat,
|
|||||||
MetaWindow *window =
|
MetaWindow *window =
|
||||||
meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor));
|
meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor));
|
||||||
|
|
||||||
update_pointer_position_for_actor (pointer, actor);
|
|
||||||
|
|
||||||
surface = window->surface;
|
surface = window->surface;
|
||||||
}
|
}
|
||||||
else if (META_IS_SHAPED_TEXTURE (actor))
|
else if (META_IS_SHAPED_TEXTURE (actor))
|
||||||
{
|
{
|
||||||
MetaShapedTexture *shaped_texture = META_SHAPED_TEXTURE (actor);
|
MetaShapedTexture *shaped_texture = META_SHAPED_TEXTURE (actor);
|
||||||
|
|
||||||
update_pointer_position_for_actor (pointer, actor);
|
|
||||||
|
|
||||||
surface = meta_shaped_texture_get_wayland_surface (shaped_texture);
|
surface = meta_shaped_texture_get_wayland_surface (shaped_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,9 +444,6 @@ meta_wayland_surface_free (MetaWaylandSurface *surface)
|
|||||||
g_assert (surface != compositor->seat->pointer.focus);
|
g_assert (surface != compositor->seat->pointer.focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compositor->implicit_grab_surface == surface)
|
|
||||||
compositor->implicit_grab_surface = compositor->seat->pointer.current;
|
|
||||||
|
|
||||||
if (surface->resource)
|
if (surface->resource)
|
||||||
wl_resource_set_user_data (surface->resource, NULL);
|
wl_resource_set_user_data (surface->resource, NULL);
|
||||||
g_slice_free (MetaWaylandSurface, surface);
|
g_slice_free (MetaWaylandSurface, surface);
|
||||||
|
@ -533,119 +533,6 @@ stage_destroy_cb (void)
|
|||||||
meta_quit (META_EXIT_SUCCESS);
|
meta_quit (META_EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define N_BUTTONS 5
|
|
||||||
|
|
||||||
static void
|
|
||||||
synthesize_motion_event (MetaWaylandCompositor *compositor,
|
|
||||||
const ClutterEvent *event)
|
|
||||||
{
|
|
||||||
/* We want to synthesize X events for mouse motion events so that we
|
|
||||||
don't have to rely on the X server's window position being
|
|
||||||
synched with the surface position. See the comment in
|
|
||||||
event_callback() in display.c */
|
|
||||||
MetaWaylandSeat *seat = compositor->seat;
|
|
||||||
MetaWaylandPointer *pointer = &seat->pointer;
|
|
||||||
MetaWaylandSurface *surface;
|
|
||||||
XGenericEventCookie generic_event;
|
|
||||||
XIDeviceEvent device_event;
|
|
||||||
unsigned char button_mask[(N_BUTTONS + 7) / 8] = { 0 };
|
|
||||||
MetaDisplay *display = meta_get_display ();
|
|
||||||
ClutterModifierType button_state;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
generic_event.type = GenericEvent;
|
|
||||||
generic_event.serial = 0;
|
|
||||||
generic_event.send_event = False;
|
|
||||||
generic_event.display = display->xdisplay;
|
|
||||||
generic_event.extension = display->xinput_opcode;
|
|
||||||
generic_event.evtype = XI_Motion;
|
|
||||||
/* Mutter assumes the data for the event is already retrieved by GDK
|
|
||||||
* so we don't need the cookie */
|
|
||||||
generic_event.cookie = 0;
|
|
||||||
generic_event.data = &device_event;
|
|
||||||
|
|
||||||
memcpy (&device_event, &generic_event, sizeof (XGenericEvent));
|
|
||||||
|
|
||||||
device_event.time = clutter_event_get_time (event);
|
|
||||||
device_event.deviceid = clutter_event_get_device_id (event);
|
|
||||||
device_event.sourceid = 0; /* not used, not sure what this should be */
|
|
||||||
device_event.detail = 0;
|
|
||||||
device_event.root = DefaultRootWindow (display->xdisplay);
|
|
||||||
device_event.flags = 0 /* not used for motion events */;
|
|
||||||
|
|
||||||
if (compositor->implicit_grab_surface)
|
|
||||||
surface = compositor->implicit_grab_surface;
|
|
||||||
else
|
|
||||||
surface = pointer->current;
|
|
||||||
|
|
||||||
if (surface == pointer->current)
|
|
||||||
{
|
|
||||||
device_event.event_x = wl_fixed_to_int (pointer->current_x);
|
|
||||||
device_event.event_y = wl_fixed_to_int (pointer->current_y);
|
|
||||||
}
|
|
||||||
else if (surface && surface->window)
|
|
||||||
{
|
|
||||||
ClutterActor *window_actor =
|
|
||||||
CLUTTER_ACTOR (meta_window_get_compositor_private (surface->window));
|
|
||||||
|
|
||||||
if (window_actor)
|
|
||||||
{
|
|
||||||
float ax, ay;
|
|
||||||
|
|
||||||
clutter_actor_transform_stage_point (window_actor,
|
|
||||||
wl_fixed_to_double (pointer->x),
|
|
||||||
wl_fixed_to_double (pointer->y),
|
|
||||||
&ax, &ay);
|
|
||||||
|
|
||||||
device_event.event_x = ax;
|
|
||||||
device_event.event_y = ay;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
device_event.event_x = wl_fixed_to_double (pointer->x);
|
|
||||||
device_event.event_y = wl_fixed_to_double (pointer->y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
device_event.event_x = wl_fixed_to_double (pointer->x);
|
|
||||||
device_event.event_y = wl_fixed_to_double (pointer->y);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (surface && surface->window != NULL)
|
|
||||||
device_event.event = surface->window->xwindow;
|
|
||||||
else
|
|
||||||
device_event.event = device_event.root;
|
|
||||||
|
|
||||||
/* Mutter doesn't really know about the sub-windows. This assumes it
|
|
||||||
doesn't care either */
|
|
||||||
device_event.child = device_event.event;
|
|
||||||
device_event.root_x = wl_fixed_to_double (pointer->x);
|
|
||||||
device_event.root_y = wl_fixed_to_double (pointer->y);
|
|
||||||
|
|
||||||
clutter_event_get_state_full (event,
|
|
||||||
&button_state,
|
|
||||||
(ClutterModifierType*)&device_event.mods.base,
|
|
||||||
(ClutterModifierType*)&device_event.mods.latched,
|
|
||||||
(ClutterModifierType*)&device_event.mods.locked,
|
|
||||||
(ClutterModifierType*)&device_event.mods.effective);
|
|
||||||
device_event.mods.effective &= ~button_state;
|
|
||||||
memset (&device_event.group, 0, sizeof (device_event.group));
|
|
||||||
device_event.group.effective = (device_event.mods.effective >> 13) & 0x3;
|
|
||||||
|
|
||||||
for (i = 0; i < N_BUTTONS; i++)
|
|
||||||
if ((button_state & (CLUTTER_BUTTON1_MASK << i)))
|
|
||||||
XISetMask (button_mask, i + 1);
|
|
||||||
device_event.buttons.mask_len = N_BUTTONS + 1;
|
|
||||||
device_event.buttons.mask = button_mask;
|
|
||||||
|
|
||||||
device_event.valuators.mask_len = 0;
|
|
||||||
device_event.valuators.mask = NULL;
|
|
||||||
device_event.valuators.values = NULL;
|
|
||||||
|
|
||||||
meta_display_handle_xevent (display, (XEvent *) &generic_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reset_idletimes (const ClutterEvent *event)
|
reset_idletimes (const ClutterEvent *event)
|
||||||
{
|
{
|
||||||
@ -682,7 +569,6 @@ event_filter_cb (const ClutterEvent *event,
|
|||||||
MetaWaylandSeat *seat = compositor->seat;
|
MetaWaylandSeat *seat = compositor->seat;
|
||||||
MetaWaylandPointer *pointer = &seat->pointer;
|
MetaWaylandPointer *pointer = &seat->pointer;
|
||||||
MetaWaylandSurface *surface;
|
MetaWaylandSurface *surface;
|
||||||
MetaDisplay *display;
|
|
||||||
|
|
||||||
reset_idletimes (event);
|
reset_idletimes (event);
|
||||||
|
|
||||||
@ -721,34 +607,7 @@ event_filter_cb (const ClutterEvent *event,
|
|||||||
CLUTTER_ACTOR (event->any.stage));
|
CLUTTER_ACTOR (event->any.stage));
|
||||||
}
|
}
|
||||||
|
|
||||||
display = meta_get_display ();
|
return FALSE;
|
||||||
if (!display)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
switch (event->type)
|
|
||||||
{
|
|
||||||
case CLUTTER_BUTTON_PRESS:
|
|
||||||
if (compositor->implicit_grab_surface == NULL)
|
|
||||||
{
|
|
||||||
compositor->implicit_grab_button = event->button.button;
|
|
||||||
compositor->implicit_grab_surface = pointer->current;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
case CLUTTER_BUTTON_RELEASE:
|
|
||||||
if (event->type == CLUTTER_BUTTON_RELEASE &&
|
|
||||||
compositor->implicit_grab_surface &&
|
|
||||||
event->button.button == compositor->implicit_grab_button)
|
|
||||||
compositor->implicit_grab_surface = NULL;
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
case CLUTTER_MOTION:
|
|
||||||
synthesize_motion_event (compositor, event);
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user