From 225f2cf768c745fe13c9d7e90d340fd2a15d6c5b Mon Sep 17 00:00:00 2001 From: Ernestas Kulik Date: Sun, 17 Apr 2016 20:12:02 +0300 Subject: eel-canvas: use GdkSeat operations Some GdkDisplay operations have been deprecated in GDK 3.20. This commit replaces the deprecated code in eel_canvas_item_grab() and eel_canvas_item_ungrab() functions with new GdkSeat operations. https://bugzilla.gnome.org/show_bug.cgi?id=762235 --- eel/eel-canvas.c | 83 +++++++++++++++++++---------------------- eel/eel-canvas.h | 15 ++++---- src/nautilus-canvas-container.c | 23 ++++++------ 3 files changed, 57 insertions(+), 64 deletions(-) diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index 45f3665e4..0cd3b1ab2 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -311,7 +311,7 @@ eel_canvas_item_dispose (GObject *object) item->canvas->need_repick = TRUE; } - eel_canvas_item_ungrab (item, GDK_CURRENT_TIME); + eel_canvas_item_ungrab (item); if (item == item->canvas->focused_item) item->canvas->focused_item = NULL; @@ -824,34 +824,42 @@ eel_canvas_item_hide (EelCanvasItem *item) } +/* + * Prepare the window for grabbing, i.e. show it. + */ +static void +seat_grab_prepare_window (GdkSeat *seat, + GdkWindow *window, + gpointer user_data) +{ + gdk_window_show (window); +} + /** * eel_canvas_item_grab: * @item: A canvas item. * @event_mask: Mask of events that will be sent to this item. * @cursor: If non-NULL, the cursor that will be used while the grab is active. - * @etime: The timestamp required for grabbing the mouse, or GDK_CURRENT_TIME. + * @event: The event, triggering the grab, if any. * * Specifies that all events that match the specified event mask should be sent - * to the specified item, and also grabs the mouse by calling - * gdk_pointer_grab(). The event mask is also used when grabbing the pointer. + * to the specified item, and also grabs the seat by calling gdk_seat_grab(). * If @cursor is not NULL, then that cursor is used while the grab is active. - * The @etime parameter is the timestamp required for grabbing the mouse. * - * Return value: If an item was already grabbed, it returns %GDK_GRAB_ALREADY_GRABBED. If + * Return value: If an item was already grabbed, it returns %GDK_GRAB_ALREADY_GRABBED. If * the specified item was hidden by calling eel_canvas_item_hide(), then it - * returns %GDK_GRAB_NOT_VIEWABLE. Else, it returns the result of calling - * gdk_pointer_grab(). + * returns %GDK_GRAB_NOT_VIEWABLE. Else, it returns the result of calling + * gdk_seat_grab(). **/ GdkGrabStatus eel_canvas_item_grab (EelCanvasItem *item, GdkEventMask event_mask, GdkCursor *cursor, - guint32 timestamp) + const GdkEvent *event) { GdkGrabStatus retval; GdkDisplay *display; - GdkDeviceManager *manager; - GdkDevice *device; + GdkSeat *seat; g_return_val_if_fail (EEL_IS_CANVAS_ITEM (item), GDK_GRAB_NOT_VIEWABLE); g_return_val_if_fail (gtk_widget_get_mapped (GTK_WIDGET (item->canvas)), @@ -864,16 +872,16 @@ eel_canvas_item_grab (EelCanvasItem *item, return GDK_GRAB_NOT_VIEWABLE; display = gtk_widget_get_display (GTK_WIDGET (item->canvas)); - manager = gdk_display_get_device_manager (display); - device = gdk_device_manager_get_client_pointer (manager); + seat = gdk_display_get_default_seat (display); - retval = gdk_device_grab (device, - gtk_layout_get_bin_window (GTK_LAYOUT (item->canvas)), - GDK_OWNERSHIP_NONE, - FALSE, - event_mask, - cursor, - timestamp); + retval = gdk_seat_grab (seat, + gtk_layout_get_bin_window (GTK_LAYOUT (item->canvas)), + GDK_SEAT_CAPABILITY_ALL_POINTING, + FALSE, + cursor, + event, + seat_grab_prepare_window, + NULL); if (retval != GDK_GRAB_SUCCESS) return retval; @@ -889,17 +897,15 @@ eel_canvas_item_grab (EelCanvasItem *item, /** * eel_canvas_item_ungrab: * @item: A canvas item that holds a grab. - * @etime: The timestamp for ungrabbing the mouse. * * Ungrabs the item, which must have been grabbed in the canvas, and ungrabs the - * mouse. + * seat. **/ void -eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime) +eel_canvas_item_ungrab (EelCanvasItem *item) { GdkDisplay *display; - GdkDeviceManager *manager; - GdkDevice *device; + GdkSeat *seat; g_return_if_fail (EEL_IS_CANVAS_ITEM (item)); @@ -907,11 +913,10 @@ eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime) return; display = gtk_widget_get_display (GTK_WIDGET (item->canvas)); - manager = gdk_display_get_device_manager (display); - device = gdk_device_manager_get_client_pointer (manager); + seat = gdk_display_get_default_seat (display); item->canvas->grabbed_item = NULL; - gdk_device_ungrab (device, etime); + gdk_seat_ungrab (seat); } /** @@ -2034,7 +2039,7 @@ shutdown_transients (EelCanvas *canvas) } if (canvas->grabbed_item) { - eel_canvas_item_ungrab (canvas->grabbed_item, GDK_CURRENT_TIME); + eel_canvas_item_ungrab (canvas->grabbed_item); } remove_idle (canvas); @@ -2393,30 +2398,20 @@ emit_event (EelCanvas *canvas, GdkEvent *event) case GDK_ENTER_NOTIFY: case GDK_LEAVE_NOTIFY: eel_canvas_window_to_world (canvas, - ev.crossing.x, ev.crossing.y, - &ev.crossing.x, &ev.crossing.y); + ev.crossing.x, ev.crossing.y, + &ev.crossing.x, &ev.crossing.y); break; case GDK_MOTION_NOTIFY: - eel_canvas_window_to_world (canvas, - ev.motion.x, ev.motion.y, - &ev.motion.x, &ev.motion.y); - break; - case GDK_BUTTON_PRESS: case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS: + case GDK_BUTTON_RELEASE: eel_canvas_window_to_world (canvas, - ev.motion.x, ev.motion.y, - &ev.motion.x, &ev.motion.y); + ev.motion.x, ev.motion.y, + &ev.motion.x, &ev.motion.y); break; - case GDK_BUTTON_RELEASE: - eel_canvas_window_to_world (canvas, - ev.motion.x, ev.motion.y, - &ev.motion.x, &ev.motion.y); - break; - default: break; } diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h index adff7f773..5758c1bde 100644 --- a/eel/eel-canvas.h +++ b/eel/eel-canvas.h @@ -239,20 +239,19 @@ void eel_canvas_item_show (EelCanvasItem *item); */ void eel_canvas_item_hide (EelCanvasItem *item); -/* Grab the mouse for the specified item. Only the events in event_mask will be - * reported. If cursor is non-NULL, it will be used during the duration of the - * grab. Time is a proper X event time parameter. Returns the same values as - * XGrabPointer(). +/* Grab the seat for the specified item. Only the events in event_mask will be + * reported. If cursor is non-NULL, it will be used during the duration of the + * grab. event is the event, triggering the grab. Returns the same values as gdk_seat_grab(). */ GdkGrabStatus eel_canvas_item_grab (EelCanvasItem *item, GdkEventMask event_mask, GdkCursor *cursor, - guint32 etime); + const GdkEvent* event); -/* Ungrabs the mouse -- the specified item must be the same that was passed to - * eel_canvas_item_grab(). Time is a proper X event time parameter. +/* Ungrabs the seat -- the specified item must be the same that was passed to + * eel_canvas_item_grab(). */ -void eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime); +void eel_canvas_item_ungrab (EelCanvasItem *item); /* These functions convert from a coordinate system to another. "w" is world * coordinates and "i" is item coordinates. diff --git a/src/nautilus-canvas-container.c b/src/nautilus-canvas-container.c index e7c1eea84..2f0bd3b8a 100644 --- a/src/nautilus-canvas-container.c +++ b/src/nautilus-canvas-container.c @@ -2498,12 +2498,12 @@ start_rubberbanding (NautilusCanvasContainer *container, (GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK), - NULL, event->time); + NULL, + (GdkEvent *)event); } static void -stop_rubberbanding (NautilusCanvasContainer *container, - guint32 time) +stop_rubberbanding (NautilusCanvasContainer *container) { NautilusCanvasRubberbandInfo *band_info; GList *icons; @@ -2520,7 +2520,7 @@ stop_rubberbanding (NautilusCanvasContainer *container, g_object_get (gtk_settings_get_default (), "gtk-enable-animations", &enable_animation, NULL); /* Destroy this canvas item; the parent will unref it. */ - eel_canvas_item_ungrab (band_info->selection_rectangle, time); + eel_canvas_item_ungrab (band_info->selection_rectangle); eel_canvas_item_lower_to_bottom (band_info->selection_rectangle); if (enable_animation) { nautilus_selection_canvas_item_fade_out (NAUTILUS_SELECTION_CANVAS_ITEM (band_info->selection_rectangle), 150); @@ -4181,7 +4181,8 @@ clear_drag_state (NautilusCanvasContainer *container) } static gboolean -start_stretching (NautilusCanvasContainer *container) +start_stretching (NautilusCanvasContainer *container, + GdkEvent *event) { NautilusCanvasContainerDetails *details; NautilusCanvasIcon *icon; @@ -4236,7 +4237,7 @@ start_stretching (NautilusCanvasContainer *container) (GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), cursor, - GDK_CURRENT_TIME); + event); if (cursor) g_object_unref (cursor); @@ -4339,8 +4340,7 @@ keyboard_stretching (NautilusCanvasContainer *container, static void ungrab_stretch_icon (NautilusCanvasContainer *container) { - eel_canvas_item_ungrab (EEL_CANVAS_ITEM (container->details->stretch_icon->item), - GDK_CURRENT_TIME); + eel_canvas_item_ungrab (EEL_CANVAS_ITEM (container->details->stretch_icon->item)); } static void @@ -4417,7 +4417,7 @@ button_release_event (GtkWidget *widget, details = container->details; if (event->button == RUBBERBAND_BUTTON && details->rubberband_info.active) { - stop_rubberbanding (container, event->time); + stop_rubberbanding (container); return TRUE; } @@ -4684,8 +4684,7 @@ grab_notify_cb (GtkWidget *widget, * up (e.g. authentication or an error). Stop * the rubberbanding so that we can handle the * dialog. */ - stop_rubberbanding (container, - GDK_CURRENT_TIME); + stop_rubberbanding (container); } } @@ -5335,7 +5334,7 @@ handle_canvas_button_press (NautilusCanvasContainer *container, * If so, it won't modify the selection. */ if (icon == container->details->stretch_icon) { - if (start_stretching (container)) { + if (start_stretching (container, (GdkEvent *)event)) { return TRUE; } } -- cgit v1.2.1