diff options
author | raveit65 <[email protected]> | 2016-06-26 20:45:02 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2016-07-04 14:40:52 +0200 |
commit | fecfeff6c34c1ac11c4803cb3ffc0b6722bd93b7 (patch) | |
tree | 8373fac6cec406f42152b9731be65d8fa3e4e5ea | |
parent | 8e7097e89a04156ae0d2dc487f630e259ec6fb76 (diff) | |
download | caja-fecfeff6c34c1ac11c4803cb3ffc0b6722bd93b7.tar.bz2 caja-fecfeff6c34c1ac11c4803cb3ffc0b6722bd93b7.tar.xz |
Gtk+-3.20 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
taken from:
https://git.gnome.org/browse/nautilus/commit/?id=225f2cf
-rw-r--r-- | eel/eel-canvas.c | 113 | ||||
-rw-r--r-- | eel/eel-canvas.h | 18 | ||||
-rw-r--r-- | libcaja-private/caja-icon-container.c | 39 |
3 files changed, 164 insertions, 6 deletions
diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index 1e45224d..ae4faaa7 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -342,7 +342,11 @@ eel_canvas_item_dispose (GObject *object) } #if GTK_CHECK_VERSION(3, 0, 0) +#if GTK_CHECK_VERSION(3, 20, 0) + eel_canvas_item_ungrab (item); +#else eel_canvas_item_ungrab (item, GDK_CURRENT_TIME); +#endif #else if (item == item->canvas->grabbed_item) { @@ -873,12 +877,40 @@ eel_canvas_item_hide (EelCanvasItem *item) } } +#if GTK_CHECK_VERSION(3, 20, 0) +/* + * 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. + * @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 seat by calling gdk_seat_grab(). + * If @cursor is not NULL, then that cursor is used while the grab is active. + * + * 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_seat_grab(). + **/ +#else +/** + * 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. * * Specifies that all events that match the specified event mask should be sent @@ -892,17 +924,26 @@ eel_canvas_item_hide (EelCanvasItem *item) * returns %GDK_GRAB_NOT_VIEWABLE. Else, it returns the result of calling * gdk_pointer_grab(). **/ +#endif #if GTK_CHECK_VERSION(3, 0, 0) GdkGrabStatus eel_canvas_item_grab (EelCanvasItem *item, GdkEventMask event_mask, GdkCursor *cursor, +#if GTK_CHECK_VERSION(3, 20, 0) + const GdkEvent *event) +{ + GdkGrabStatus retval; + GdkDisplay *display; + GdkSeat *seat; +#else guint32 timestamp) { GdkGrabStatus retval; GdkDisplay *display; GdkDeviceManager *manager; GdkDevice *device; +#endif 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)), @@ -915,6 +956,18 @@ eel_canvas_item_grab (EelCanvasItem *item, return GDK_GRAB_NOT_VIEWABLE; display = gtk_widget_get_display (GTK_WIDGET (item->canvas)); +#if GTK_CHECK_VERSION(3, 20, 0) + seat = gdk_display_get_default_seat (display); + + 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); +#else manager = gdk_display_get_device_manager (display); device = gdk_device_manager_get_client_pointer (manager); @@ -925,6 +978,7 @@ eel_canvas_item_grab (EelCanvasItem *item, event_mask, cursor, timestamp); +#endif #else int eel_canvas_item_grab (EelCanvasItem *item, guint event_mask, GdkCursor *cursor, guint32 etime) @@ -959,7 +1013,15 @@ eel_canvas_item_grab (EelCanvasItem *item, guint event_mask, GdkCursor *cursor, return retval; } - +#if GTK_CHECK_VERSION(3, 20, 0) +/** + * eel_canvas_item_ungrab: + * @item: A canvas item that holds a grab. + * + * Ungrabs the item, which must have been grabbed in the canvas, and ungrabs the + * seat. + **/ +#else /** * eel_canvas_item_ungrab: * @item: A canvas item that holds a grab. @@ -968,14 +1030,32 @@ eel_canvas_item_grab (EelCanvasItem *item, guint event_mask, GdkCursor *cursor, * Ungrabs the item, which must have been grabbed in the canvas, and ungrabs the * mouse. **/ +#endif +#if GTK_CHECK_VERSION(3, 0, 0) void +#if GTK_CHECK_VERSION(3, 20, 0) +eel_canvas_item_ungrab (EelCanvasItem *item) +{ + GdkDisplay *display; + GdkSeat *seat; + + g_return_if_fail (EEL_IS_CANVAS_ITEM (item)); + + if (item->canvas->grabbed_item != item) + return; + + display = gtk_widget_get_display (GTK_WIDGET (item->canvas)); + seat = gdk_display_get_default_seat (display); + + item->canvas->grabbed_item = NULL; + gdk_seat_ungrab (seat); +} +#else eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime) { GdkDisplay *display; -#if GTK_CHECK_VERSION(3, 0, 0) GdkDeviceManager *manager; GdkDevice *device; -#endif g_return_if_fail (EEL_IS_CANVAS_ITEM (item)); @@ -983,17 +1063,29 @@ eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime) return; display = gtk_widget_get_display (GTK_WIDGET (item->canvas)); -#if GTK_CHECK_VERSION(3, 0, 0) manager = gdk_display_get_device_manager (display); device = gdk_device_manager_get_client_pointer (manager); item->canvas->grabbed_item = NULL; gdk_device_ungrab (device, etime); +} +#endif #else +void +eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime) +{ + GdkDisplay *display; + + g_return_if_fail (EEL_IS_CANVAS_ITEM (item)); + + if (item->canvas->grabbed_item != item) + return; + + display = gtk_widget_get_display (GTK_WIDGET (item->canvas)); item->canvas->grabbed_item = NULL; gdk_display_pointer_ungrab (display, etime); -#endif } +#endif /** * eel_canvas_item_w2i: @@ -2324,7 +2416,9 @@ shutdown_transients (EelCanvas *canvas) if (canvas->grabbed_item) { -#if GTK_CHECK_VERSION(3, 0, 0) +#if GTK_CHECK_VERSION(3, 20, 0) + eel_canvas_item_ungrab (canvas->grabbed_item); +#elif GTK_CHECK_VERSION(3, 0, 0) eel_canvas_item_ungrab (canvas->grabbed_item, GDK_CURRENT_TIME); #else GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (canvas)); @@ -2732,24 +2826,31 @@ emit_event (EelCanvas *canvas, GdkEvent *event) break; case GDK_MOTION_NOTIFY: +#if !GTK_CHECK_VERSION(3, 20, 0) eel_canvas_window_to_world (canvas, ev.motion.x, ev.motion.y, &ev.motion.x, &ev.motion.y); break; +#endif case GDK_BUTTON_PRESS: case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS: +#if GTK_CHECK_VERSION(3, 20, 0) + case GDK_BUTTON_RELEASE: +#endif eel_canvas_window_to_world (canvas, ev.motion.x, ev.motion.y, &ev.motion.x, &ev.motion.y); break; +#if !GTK_CHECK_VERSION(3, 20, 0) case GDK_BUTTON_RELEASE: eel_canvas_window_to_world (canvas, ev.motion.x, ev.motion.y, &ev.motion.x, &ev.motion.y); break; +#endif default: break; diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h index f641087a..fcb4cb3d 100644 --- a/eel/eel-canvas.h +++ b/eel/eel-canvas.h @@ -250,25 +250,43 @@ extern "C" { */ void eel_canvas_item_hide (EelCanvasItem *item); +#if GTK_CHECK_VERSION(3, 20, 0) + /* 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(). + */ +#else /* 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(). */ +#endif #if GTK_CHECK_VERSION (3, 0, 0) GdkGrabStatus eel_canvas_item_grab (EelCanvasItem *item, GdkEventMask event_mask, GdkCursor *cursor, +#if GTK_CHECK_VERSION(3, 20, 0) + const GdkEvent* event); +#else guint32 etime); +#endif #else int eel_canvas_item_grab (EelCanvasItem *item, unsigned int event_mask, GdkCursor *cursor, guint32 etime); #endif +#if GTK_CHECK_VERSION(3, 20, 0) + /* 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); +#else /* 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. */ void eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime); +#endif /* These functions convert from a coordinate system to another. "w" is world * coordinates and "i" is item coordinates. diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 91f8b82d..00305f18 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -2974,7 +2974,12 @@ start_rubberbanding (CajaIconContainer *container, (GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK), +#if GTK_CHECK_VERSION(3, 20, 0) + NULL, + (GdkEvent *)event); +#else NULL, event->time); +#endif } @@ -3066,8 +3071,12 @@ start_rubberbanding (CajaIconContainer *container, #endif static void +#if GTK_CHECK_VERSION(3, 20, 0) +stop_rubberbanding (CajaIconContainer *container) +#else stop_rubberbanding (CajaIconContainer *container, guint32 time) +#endif { CajaIconRubberbandInfo *band_info; GList *icons; @@ -3081,7 +3090,11 @@ stop_rubberbanding (CajaIconContainer *container, band_info->active = FALSE; /* Destroy this canvas item; the parent will unref it. */ +#if GTK_CHECK_VERSION(3, 20, 0) + eel_canvas_item_ungrab (band_info->selection_rectangle); +#else eel_canvas_item_ungrab (band_info->selection_rectangle, time); +#endif eel_canvas_item_destroy (band_info->selection_rectangle); band_info->selection_rectangle = NULL; @@ -4982,7 +4995,12 @@ clear_drag_state (CajaIconContainer *container) } static gboolean +#if GTK_CHECK_VERSION(3, 20, 0) +start_stretching (CajaIconContainer *container, + GdkEvent *event) +#else start_stretching (CajaIconContainer *container) +#endif { CajaIconContainerDetails *details; CajaIcon *icon; @@ -5040,7 +5058,11 @@ start_stretching (CajaIconContainer *container) (GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), cursor, +#if GTK_CHECK_VERSION(3, 20, 0) + event); +#else GDK_CURRENT_TIME); +#endif if (cursor) #if GTK_CHECK_VERSION(3,0,0) g_object_unref (cursor); @@ -5152,8 +5174,12 @@ keyboard_stretching (CajaIconContainer *container, static void ungrab_stretch_icon (CajaIconContainer *container) { +#if GTK_CHECK_VERSION(3, 20, 0) + eel_canvas_item_ungrab (EEL_CANVAS_ITEM (container->details->stretch_icon->item)); +#else eel_canvas_item_ungrab (EEL_CANVAS_ITEM (container->details->stretch_icon->item), GDK_CURRENT_TIME); +#endif } static void @@ -5236,7 +5262,11 @@ button_release_event (GtkWidget *widget, if (event->button == RUBBERBAND_BUTTON && details->rubberband_info.active) { +#if GTK_CHECK_VERSION(3, 20, 0) + stop_rubberbanding (container); +#else stop_rubberbanding (container, event->time); +#endif return TRUE; } @@ -6276,8 +6306,12 @@ grab_notify_cb (GtkWidget *widget, * up (e.g. authentication or an error). Stop * the rubberbanding so that we can handle the * dialog. */ +#if GTK_CHECK_VERSION(3, 20, 0) + stop_rubberbanding (container); +#else stop_rubberbanding (container, GDK_CURRENT_TIME); +#endif } } @@ -7162,8 +7196,13 @@ handle_icon_button_press (CajaIconContainer *container, */ if (icon == container->details->stretch_icon) { +#if GTK_CHECK_VERSION(3, 20, 0) + if (start_stretching (container, (GdkEvent *)event)) + { +#else if (start_stretching (container)) { +#endif return TRUE; } } |