window: Use toplevel begin_move/resize api

The GdkSurface api for this is going away.
This commit is contained in:
Matthias Clasen 2020-05-17 12:06:26 -04:00
parent 309a7aa253
commit f316fe0f58
3 changed files with 31 additions and 26 deletions

View File

@ -1218,12 +1218,14 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
GdkEventSequence *sequence;
GtkWindowRegion region;
GdkEvent *event;
GdkDevice *device;
guint button;
double tx, ty;
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
device = gtk_gesture_get_device (GTK_GESTURE (gesture));
if (!event)
return;
@ -1234,8 +1236,7 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
if (priv->maximized)
return;
if (gdk_display_device_is_grabbed (gtk_widget_get_display (GTK_WIDGET (window)),
gtk_gesture_get_device (GTK_GESTURE (gesture))))
if (gdk_display_device_is_grabbed (gtk_widget_get_display (GTK_WIDGET (window)), device))
return;
region = get_active_region_type (window, x, y);
@ -1246,12 +1247,12 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
gdk_event_get_position (event, &tx, &ty);
gdk_surface_begin_resize_drag (priv->surface,
(GdkSurfaceEdge) region,
gdk_event_get_device ((GdkEvent *) event),
GDK_BUTTON_PRIMARY,
tx, ty,
gdk_event_get_time (event));
gdk_toplevel_begin_resize (GDK_TOPLEVEL (priv->surface),
(GdkSurfaceEdge) region,
device,
GDK_BUTTON_PRIMARY,
tx, ty,
gdk_event_get_time (event));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
}

View File

@ -113,11 +113,12 @@ move_window_clicked (GtkModelButton *button,
GtkNative *native = gtk_widget_get_native (GTK_WIDGET (self));
GdkSurface *surface = gtk_native_get_surface (native);
gdk_surface_begin_move_drag (surface,
NULL,
0, /* 0 means "use keyboard" */
0, 0,
GDK_CURRENT_TIME);
if (GDK_IS_TOPLEVEL (surface))
gdk_toplevel_begin_move (GDK_TOPLEVEL (surface),
NULL,
0, /* 0 means "use keyboard" */
0, 0,
GDK_CURRENT_TIME);
}
static void
@ -127,12 +128,13 @@ resize_window_clicked (GtkModelButton *button,
GtkNative *native = gtk_widget_get_native (GTK_WIDGET (self));
GdkSurface *surface = gtk_native_get_surface (native);
gdk_surface_begin_resize_drag (surface,
0,
NULL,
0, /* 0 means "use keyboard" */
0, 0,
GDK_CURRENT_TIME);
if (GDK_IS_TOPLEVEL (surface))
gdk_toplevel_begin_resize (GDK_TOPLEVEL (surface),
0,
NULL,
0, /* 0 means "use keyboard" */
0, 0,
GDK_CURRENT_TIME);
}
static void
@ -475,17 +477,19 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
native = gtk_widget_get_native (GTK_WIDGET (self));
gtk_widget_translate_coordinates (GTK_WIDGET (self),
GTK_WIDGET (native),
start_x, start_y,
&window_x, &window_y);
surface = gtk_native_get_surface (native);
gdk_surface_begin_move_drag (surface,
gtk_gesture_get_device (GTK_GESTURE (gesture)),
gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)),
window_x, window_y,
gtk_event_controller_get_current_event_time (GTK_EVENT_CONTROLLER (gesture)));
if (GDK_IS_TOPLEVEL (surface))
gdk_toplevel_begin_move (GDK_TOPLEVEL (surface),
gtk_gesture_get_device (GTK_GESTURE (gesture)),
gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)),
window_x, window_y,
gtk_event_controller_get_current_event_time (GTK_EVENT_CONTROLLER (gesture)));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (self->click_gesture));

View File

@ -28,7 +28,7 @@ start_resize (GtkGestureClick *gesture,
gtk_widget_translate_coordinates (widget, GTK_WIDGET (gtk_widget_get_root (widget)),
xx, yy, &xx, &yy);
gdk_surface_begin_resize_drag (surface, edge, gdk_event_get_device (event), button, xx, yy, timestamp);
gdk_toplevel_begin_resize (GDK_TOPLEVEL (surface), edge, gdk_event_get_device (event), button, xx, yy, timestamp);
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
}
@ -76,7 +76,7 @@ start_move (GtkGestureClick *gesture,
gtk_widget_translate_coordinates (widget, GTK_WIDGET (gtk_widget_get_root (widget)),
xx, yy, &xx, &yy);
gdk_surface_begin_move_drag (surface, gdk_event_get_device (event), button, xx, yy, timestamp);
gdk_toplevel_begin_move (GDK_TOPLEVEL (surface), gdk_event_get_device (event), button, xx, yy, timestamp);
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
}