Commit 250d4331 authored by Matthias Clasen's avatar Matthias Clasen

Add device-taking variants of begin_resize/move_drag

This was one of the last places where display->core_pointer was
used in non-deprecated code paths.
parent 3bd00598
......@@ -365,9 +365,11 @@ gdk_window_at_pointer
gdk_window_attributes_type_get_type
gdk_window_beep
gdk_window_begin_move_drag
gdk_window_begin_move_drag_for_device
gdk_window_begin_paint_rect
gdk_window_begin_paint_region
gdk_window_begin_resize_drag
gdk_window_begin_resize_drag_for_device
gdk_window_window_class_get_type
gdk_window_configure_finished
gdk_window_constrain_size
......
......@@ -10448,9 +10448,10 @@ gdk_window_set_functions (GdkWindow *window,
}
/**
* gdk_window_begin_resize_drag:
* gdk_window_begin_resize_drag_for_device:
* @window: a toplevel #GdkWindow
* @edge: the edge or corner from which the drag is started
* @device: the device used for the operation
* @button: the button being used to drag
* @root_x: root window X coordinate of mouse click that began the drag
* @root_y: root window Y coordinate of mouse click that began the drag
......@@ -10462,7 +10463,35 @@ gdk_window_set_functions (GdkWindow *window,
* with window managers that support the <ulink url="http://www.freedesktop.org/Standards/wm-spec">Extended Window Manager Hints</ulink>, but has a
* fallback implementation for other window managers.
*
**/
* Since: 3.4
*/
void
gdk_window_begin_resize_drag_for_device (GdkWindow *window,
GdkWindowEdge edge,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp)
{
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->begin_resize_drag (window, edge, device, button, root_x, root_y, timestamp);
}
/**
* gdk_window_begin_resize_drag:
* @window: a toplevel #GdkWindow
* @edge: the edge or corner from which the drag is started
* @button: the button being used to drag
* @root_x: root window X coordinate of mouse click that began the drag
* @root_y: root window Y coordinate of mouse click that began the drag
* @timestamp: timestamp of mouse click that began the drag (use gdk_event_get_time())
*
* Begins a window resize operation (for a toplevel window).
*
* This function assumes that the drag is controlled by the
* client pointer device, use gdk_window_begin_resize_drag_for_device()
* to begin a drag with a different device.
*/
void
gdk_window_begin_resize_drag (GdkWindow *window,
GdkWindowEdge edge,
......@@ -10471,25 +10500,59 @@ gdk_window_begin_resize_drag (GdkWindow *window,
gint root_y,
guint32 timestamp)
{
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->begin_resize_drag (window, edge, button, root_x, root_y, timestamp);
GdkDeviceManager *device_manager;
GdkDevice *device;
device_manager = gdk_display_get_device_manager (gdk_window_get_display (window));
device = gdk_device_manager_get_client_pointer (device_manager);
gdk_window_begin_resize_drag_for_device (window, edge,
device, button, root_x, root_y, timestamp);
}
/**
* gdk_window_begin_move_drag:
* gdk_window_begin_move_drag_for_device:
* @window: a toplevel #GdkWindow
* @device: the device used for the operation
* @button: the button being used to drag
* @root_x: root window X coordinate of mouse click that began the drag
* @root_y: root window Y coordinate of mouse click that began the drag
* @timestamp: timestamp of mouse click that began the drag
*
* Begins a window move operation (for a toplevel window). You might
* use this function to implement a "window move grip," for
* Begins a window move operation (for a toplevel window).
* You might use this function to implement a "window move grip," for
* example. The function works best with window managers that support
* the <ulink url="http://www.freedesktop.org/Standards/wm-spec">Extended
* Window Manager Hints</ulink>, but has a fallback implementation for
* other window managers.
*
**/
* Since: 3.4
*/
void
gdk_window_begin_move_drag_for_device (GdkWindow *window,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp)
{
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->begin_move_drag (window,
device, button, root_x, root_y, timestamp);
}
/**
* gdk_window_begin_move_drag:
* @window: a toplevel #GdkWindow
* @button: the button being used to drag
* @root_x: root window X coordinate of mouse click that began the drag
* @root_y: root window Y coordinate of mouse click that began the drag
* @timestamp: timestamp of mouse click that began the drag
*
* Begins a window move operation (for a toplevel window).
*
* This function assumes that the drag is controlled by the
* client pointer device, use gdk_window_begin_move_drag_for_device()
* to begin a drag with a different device.
*/
void
gdk_window_begin_move_drag (GdkWindow *window,
gint button,
......@@ -10497,7 +10560,12 @@ gdk_window_begin_move_drag (GdkWindow *window,
gint root_y,
guint32 timestamp)
{
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->begin_move_drag (window, button, root_x, root_y, timestamp);
GdkDeviceManager *device_manager;
GdkDevice *device;
device_manager = gdk_display_get_device_manager (gdk_window_get_display (window));
device = gdk_device_manager_get_client_pointer (device_manager);
gdk_window_begin_move_drag_for_device (window, device, button, root_x, root_y, timestamp);
}
/**
......
......@@ -784,19 +784,32 @@ void gdk_window_register_dnd (GdkWindow *window);
GdkDragProtocol
gdk_window_get_drag_protocol(GdkWindow *window,
GdkWindow **target);
void gdk_window_begin_resize_drag (GdkWindow *window,
GdkWindowEdge edge,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
void gdk_window_begin_move_drag (GdkWindow *window,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
GdkWindow **target);
void gdk_window_begin_resize_drag (GdkWindow *window,
GdkWindowEdge edge,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
void gdk_window_begin_resize_drag_for_device (GdkWindow *window,
GdkWindowEdge edge,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
void gdk_window_begin_move_drag (GdkWindow *window,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
void gdk_window_begin_move_drag_for_device (GdkWindow *window,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
/* Interface for dirty-region queueing */
void gdk_window_invalidate_rect (GdkWindow *window,
......
......@@ -231,16 +231,18 @@ struct _GdkWindowImplClass
void (* set_functions) (GdkWindow *window,
GdkWMFunction functions);
void (* begin_resize_drag) (GdkWindow *window,
GdkWindowEdge edge,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
GdkWindowEdge edge,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
void (* begin_move_drag) (GdkWindow *window,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
void (* enable_synchronized_configure) (GdkWindow *window);
void (* configure_finished) (GdkWindow *window);
void (* set_opacity) (GdkWindow *window,
......
......@@ -3953,6 +3953,7 @@ gdk_window_x11_set_static_gravities (GdkWindow *window,
static void
wmspec_moveresize (GdkWindow *window,
gint direction,
GdkDevice *device,
gint root_x,
gint root_y,
guint32 timestamp)
......@@ -3962,7 +3963,7 @@ wmspec_moveresize (GdkWindow *window,
XClientMessageEvent xclient;
/* Release passive grab */
gdk_device_ungrab (display->core_pointer, timestamp);
gdk_device_ungrab (device, timestamp);
memset (&xclient, 0, sizeof (xclient));
xclient.type = ClientMessage;
......@@ -3991,6 +3992,7 @@ struct _MoveResizeData
GdkWindow *moveresize_emulation_window;
gboolean is_resize;
GdkWindowEdge resize_edge;
GdkDevice *device;
gint moveresize_button;
gint moveresize_x;
gint moveresize_y;
......@@ -4018,6 +4020,7 @@ struct _MoveResizeData
static void
wmspec_resize_drag (GdkWindow *window,
GdkWindowEdge edge,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
......@@ -4068,7 +4071,7 @@ wmspec_resize_drag (GdkWindow *window,
return;
}
wmspec_moveresize (window, direction, root_x, root_y, timestamp);
wmspec_moveresize (window, direction, device, root_x, root_y, timestamp);
}
static MoveResizeData *
......@@ -4346,7 +4349,7 @@ create_moveresize_window (MoveResizeData *mv_resize,
gdk_window_show (mv_resize->moveresize_emulation_window);
status = gdk_device_grab (gdk_window_get_display (mv_resize->moveresize_emulation_window)->core_pointer,
status = gdk_device_grab (mv_resize->device,
mv_resize->moveresize_emulation_window,
GDK_OWNERSHIP_NONE,
FALSE,
......@@ -4440,6 +4443,7 @@ calculate_unmoving_origin (MoveResizeData *mv_resize)
static void
emulate_resize_drag (GdkWindow *window,
GdkWindowEdge edge,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
......@@ -4450,6 +4454,7 @@ emulate_resize_drag (GdkWindow *window,
mv_resize->is_resize = TRUE;
mv_resize->moveresize_button = button;
mv_resize->resize_edge = edge;
mv_resize->device = device;
mv_resize->moveresize_x = root_x;
mv_resize->moveresize_y = root_y;
mv_resize->moveresize_window = g_object_ref (window);
......@@ -4469,6 +4474,7 @@ emulate_resize_drag (GdkWindow *window,
static void
emulate_move_drag (GdkWindow *window,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
......@@ -4477,6 +4483,7 @@ emulate_move_drag (GdkWindow *window,
MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
mv_resize->is_resize = FALSE;
mv_resize->device = device;
mv_resize->moveresize_button = button;
mv_resize->moveresize_x = root_x;
mv_resize->moveresize_y = root_y;
......@@ -4490,11 +4497,12 @@ emulate_move_drag (GdkWindow *window,
static void
gdk_x11_window_begin_resize_drag (GdkWindow *window,
GdkWindowEdge edge,
gint button,
gint root_x,
gint root_y,
guint32 timestamp)
GdkWindowEdge edge,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp)
{
if (GDK_WINDOW_DESTROYED (window) ||
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
......@@ -4502,13 +4510,14 @@ gdk_x11_window_begin_resize_drag (GdkWindow *window,
if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE")))
wmspec_resize_drag (window, edge, button, root_x, root_y, timestamp);
wmspec_resize_drag (window, edge, device, button, root_x, root_y, timestamp);
else
emulate_resize_drag (window, edge, button, root_x, root_y, timestamp);
emulate_resize_drag (window, edge, device, button, root_x, root_y, timestamp);
}
static void
gdk_x11_window_begin_move_drag (GdkWindow *window,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
......@@ -4520,10 +4529,10 @@ gdk_x11_window_begin_move_drag (GdkWindow *window,
if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE")))
wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE, root_x, root_y,
wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE, device, root_x, root_y,
timestamp);
else
emulate_move_drag (window, button, root_x, root_y, timestamp);
emulate_move_drag (window, device, button, root_x, root_y, timestamp);
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment