cursor-tracker: Check if coordinates are NULL
To avoid a SEGV on X11. Passing NULL coordinates is perfectly valid if you are only seeking to get the `mods`. Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1484 https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1519
This commit is contained in:
parent
232dcad64f
commit
ebe8cd3704
@ -465,18 +465,26 @@ meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_pointer_position_gdk (int *x,
|
get_pointer_position_gdk (graphene_point_t *point,
|
||||||
int *y,
|
int *mods)
|
||||||
int *mods)
|
|
||||||
{
|
{
|
||||||
GdkSeat *gseat;
|
GdkSeat *gseat;
|
||||||
GdkDevice *gdevice;
|
GdkDevice *gdevice;
|
||||||
GdkScreen *gscreen;
|
GdkScreen *gscreen;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
gseat = gdk_display_get_default_seat (gdk_display_get_default ());
|
gseat = gdk_display_get_default_seat (gdk_display_get_default ());
|
||||||
gdevice = gdk_seat_get_pointer (gseat);
|
gdevice = gdk_seat_get_pointer (gseat);
|
||||||
|
|
||||||
gdk_device_get_position (gdevice, &gscreen, x, y);
|
/* Even if point is NULL we need this to get gscreen */
|
||||||
|
gdk_device_get_position (gdevice, &gscreen, &x, &y);
|
||||||
|
|
||||||
|
if (point)
|
||||||
|
{
|
||||||
|
point->x = x;
|
||||||
|
point->y = y;
|
||||||
|
}
|
||||||
|
|
||||||
if (mods)
|
if (mods)
|
||||||
gdk_device_get_state (gdevice,
|
gdk_device_get_state (gdevice,
|
||||||
gdk_screen_get_root_window (gscreen),
|
gdk_screen_get_root_window (gscreen),
|
||||||
@ -509,17 +517,9 @@ meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker,
|
|||||||
we forward to xwayland.
|
we forward to xwayland.
|
||||||
*/
|
*/
|
||||||
if (meta_is_wayland_compositor ())
|
if (meta_is_wayland_compositor ())
|
||||||
{
|
get_pointer_position_clutter (coords, (int *) mods);
|
||||||
get_pointer_position_clutter (coords, (int*)mods);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
get_pointer_position_gdk (coords, (int *) mods);
|
||||||
int x, y;
|
|
||||||
|
|
||||||
get_pointer_position_gdk (&x, &y, (int*)mods);
|
|
||||||
coords->x = x;
|
|
||||||
coords->y = y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user