Skip to content

Commit

Permalink
Fix deprecation warnings
Browse files Browse the repository at this point in the history
Remove use of GdkDeviceManager as it's deprecated in GTK4,
it's used in sugar-gesture-grabber.c to set the device and source device
of events, events generally have that field set already or it returns
NULL where they're not set.

Signed-off-by: Chihurumnaya Ibiam <[email protected]>
  • Loading branch information
chimosky committed Jan 24, 2024
1 parent 158fccb commit 2ffda86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/sugar3/sugar-cursor-tracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ _set_cursor_visibility (SugarCursorTracker *tracker,
display = gdk_display_get_default ();
xdisplay = GDK_DISPLAY_XDISPLAY (display);

gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);

if (visible == TRUE) {
if (priv->cursor_shown == FALSE) {
Expand All @@ -104,7 +104,7 @@ _set_cursor_visibility (SugarCursorTracker *tracker,
}
}

if (gdk_error_trap_pop ()) {
if (gdk_x11_display_error_trap_pop (display)) {
g_warning ("An error occurred trying to %s the cursor",
FALSE ? "show" : "hide");
}
Expand Down
17 changes: 4 additions & 13 deletions src/sugar3/sugar-gesture-grabber.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ _sugar_gesture_grabber_notify_touch (SugarGestureGrabber *grabber,
if (data->consumed)
continue;

gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
XIAllowTouchEvents (gdk_x11_display_get_xdisplay (display),
gdk_x11_device_get_id (data->device),
GPOINTER_TO_INT (data->sequence),
gdk_x11_window_get_xid (priv->root_window),
(handled) ? XIAcceptTouch : XIRejectTouch);

gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
data->consumed = TRUE;
}
}
Expand Down Expand Up @@ -243,11 +243,9 @@ filter_function (GdkXEvent *xevent,
gpointer user_data)
{
XGenericEventCookie *xge = xevent;
GdkDeviceManager *device_manager;
SugarGestureGrabber *grabber;
SugarGestureGrabberPrivate *priv;
gboolean handled = FALSE;
GdkDevice *device;
XIDeviceEvent *ev;
GdkDisplay *display;
GdkEvent *event;
Expand All @@ -259,7 +257,6 @@ filter_function (GdkXEvent *xevent,
priv = grabber->priv;

display = gdk_window_get_display (priv->root_window);
device_manager = gdk_display_get_device_manager (display);
ev = (XIDeviceEvent *) xge->data;

switch (ev->evtype) {
Expand Down Expand Up @@ -288,21 +285,15 @@ filter_function (GdkXEvent *xevent,
event->touch.sequence = GINT_TO_POINTER (ev->detail);
event->touch.emulating_pointer = (ev->flags & XITouchEmulatingPointer);

device = gdk_x11_device_manager_lookup (device_manager, ev->deviceid);
gdk_event_set_device (event, device);

device = gdk_x11_device_manager_lookup (device_manager, ev->sourceid);
gdk_event_set_source_device (event, device);

handled = _sugar_gesture_grabber_run_controllers (grabber, event);

if (!handled) {
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
XIAllowTouchEvents (gdk_x11_display_get_xdisplay (display),
ev->deviceid, ev->detail,
gdk_x11_window_get_xid (priv->root_window),
XIRejectTouch);
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
} else if (event->type == GDK_TOUCH_BEGIN) {
_sugar_gesture_grabber_add_touch (grabber,
event->touch.device,
Expand Down

0 comments on commit 2ffda86

Please sign in to comment.