summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-07-03 11:52:58 +0200
committerAlexander Larsson <alexl@redhat.com>2013-07-03 12:07:05 +0200
commit42306022a04c681868be4b250d353950ca300c0c (patch)
tree10b8d5e8b9df3f3e4ce1aaa30caa9c697cf12676
parent0c990645de3f0c8cd9fe07b71c3b0ca7477ade7a (diff)
downloadgtk+-wip/window-scales.tar.gz
gdk: Convert mouse position to doubles, add new getterswip/window-scales
We've long had double precision mouse coordinates on wayland (e.g. when rotating a window) but with the new scaling we even have it on X (and, its also in Xinput2), so convert all the internal mouse/device position getters to use doubles and add new accessors for the public APIs that take doubles instead of ints.
-rw-r--r--gdk/broadway/gdkdevice-broadway.c40
-rw-r--r--gdk/broadway/gdkwindow-broadway.c4
-rw-r--r--gdk/gdkdevice.c131
-rw-r--r--gdk/gdkdevice.h11
-rw-r--r--gdk/gdkdeviceprivate.h32
-rw-r--r--gdk/gdkdisplay.c41
-rw-r--r--gdk/gdkinternals.h6
-rw-r--r--gdk/gdkoffscreenwindow.c16
-rw-r--r--gdk/gdkwindow.c68
-rw-r--r--gdk/gdkwindow.h6
-rw-r--r--gdk/gdkwindowimpl.h4
-rw-r--r--gdk/quartz/gdkdevice-core-quartz.c32
-rw-r--r--gdk/quartz/gdkwindow-quartz.c8
-rw-r--r--gdk/wayland/gdkdevice-wayland.c24
-rw-r--r--gdk/wayland/gdkscreen-wayland.c2
-rw-r--r--gdk/wayland/gdkwindow-wayland.c4
-rw-r--r--gdk/win32/gdkdevice-virtual.c24
-rw-r--r--gdk/win32/gdkdevice-win32.c28
-rw-r--r--gdk/win32/gdkdevice-wintab.c24
-rw-r--r--gdk/win32/gdkwindow-win32.c4
-rw-r--r--gdk/x11/gdkdevice-core-x11.c63
-rw-r--r--gdk/x11/gdkdevice-xi2.c52
-rw-r--r--gdk/x11/gdkwindow-x11.c4
23 files changed, 381 insertions, 247 deletions
diff --git a/gdk/broadway/gdkdevice-broadway.c b/gdk/broadway/gdkdevice-broadway.c
index f8dec2308b..3c89479bb6 100644
--- a/gdk/broadway/gdkdevice-broadway.c
+++ b/gdk/broadway/gdkdevice-broadway.c
@@ -38,16 +38,16 @@ static void gdk_broadway_device_set_window_cursor (GdkDevice *device,
GdkCursor *cursor);
static void gdk_broadway_device_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y);
+ gdouble x,
+ gdouble y);
static void gdk_broadway_device_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_broadway_device_grab (GdkDevice *device,
GdkWindow *window,
@@ -59,8 +59,8 @@ static GdkGrabStatus gdk_broadway_device_grab (GdkDevice *device,
static void gdk_broadway_device_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_broadway_device_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_broadway_device_select_window_events (GdkDevice *device,
@@ -114,14 +114,14 @@ gdk_broadway_device_get_state (GdkDevice *device,
gdouble *axes,
GdkModifierType *mask)
{
- gint x_int, y_int;
+ gdouble x, y;
- gdk_window_get_device_position (window, device, &x_int, &y_int, mask);
+ gdk_window_get_device_position_double (window, device, &x, &y, mask);
if (axes)
{
- axes[0] = x_int;
- axes[1] = y_int;
+ axes[0] = x;
+ axes[1] = y;
}
}
@@ -135,8 +135,8 @@ gdk_broadway_device_set_window_cursor (GdkDevice *device,
static void
gdk_broadway_device_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
}
@@ -145,10 +145,10 @@ gdk_broadway_device_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkWindow *toplevel;
@@ -335,8 +335,8 @@ gdk_broadway_device_ungrab (GdkDevice *device,
static GdkWindow *
gdk_broadway_device_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
diff --git a/gdk/broadway/gdkwindow-broadway.c b/gdk/broadway/gdkwindow-broadway.c
index fe7396ec72..03d52dfca2 100644
--- a/gdk/broadway/gdkwindow-broadway.c
+++ b/gdk/broadway/gdkwindow-broadway.c
@@ -750,8 +750,8 @@ gdk_broadway_window_get_frame_extents (GdkWindow *window,
static gboolean
gdk_window_broadway_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
GdkWindow *child;
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index 3147d9e6a0..ced0976ec9 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -24,6 +24,9 @@
#include "gdkinternals.h"
#include "gdkintl.h"
+/* for the use of round() */
+#include "fallback-c89.c"
+
/**
* SECTION:gdkdevice
* @Short_description: Object representing an input device
@@ -406,28 +409,28 @@ gdk_device_get_state (GdkDevice *device,
}
/**
- * gdk_device_get_position:
+ * gdk_device_get_position_double:
* @device: pointer device to query status about.
* @screen: (out) (transfer none) (allow-none): location to store the #GdkScreen
* the @device is on, or %NULL.
* @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
* @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
*
- * Gets the current location of @device. As a slave device
+ * Gets the current location of @device in double precision. As a slave device
* coordinates are those of its master pointer, This function
* may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
* unless there is an ongoing grab on them, see gdk_device_grab().
*
- * Since: 3.0
+ * Since: 3.10
**/
void
-gdk_device_get_position (GdkDevice *device,
- GdkScreen **screen,
- gint *x,
- gint *y)
+gdk_device_get_position_double (GdkDevice *device,
+ GdkScreen **screen,
+ gdouble *x,
+ gdouble *y)
{
GdkDisplay *display;
- gint tmp_x, tmp_y;
+ gdouble tmp_x, tmp_y;
GdkScreen *default_screen;
GdkWindow *root;
@@ -456,15 +459,47 @@ gdk_device_get_position (GdkDevice *device,
}
/**
- * gdk_device_get_window_at_position:
+ * gdk_device_get_position:
+ * @device: pointer device to query status about.
+ * @screen: (out) (transfer none) (allow-none): location to store the #GdkScreen
+ * the @device is on, or %NULL.
+ * @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
+ * @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
+ *
+ * Gets the current location of @device. As a slave device
+ * coordinates are those of its master pointer, This function
+ * may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
+ * unless there is an ongoing grab on them, see gdk_device_grab().
+ *
+ * Since: 3.0
+ **/
+void
+gdk_device_get_position (GdkDevice *device,
+ GdkScreen **screen,
+ gint *x,
+ gint *y)
+{
+ gdouble tmp_x, tmp_y;
+
+ gdk_device_get_position_double (device, screen, &tmp_x, &tmp_y);
+ if (x)
+ *x = round (tmp_x);
+ if (y)
+ *y = round (tmp_y);
+}
+
+
+/**
+ * gdk_device_get_window_at_position_double:
* @device: pointer #GdkDevice to query info to.
* @win_x: (out) (allow-none): return location for the X coordinate of the device location,
* relative to the window origin, or %NULL.
* @win_y: (out) (allow-none): return location for the Y coordinate of the device location,
* relative to the window origin, or %NULL.
*
- * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y. Returns
- * %NULL if the window tree under @device is not known to GDK (for example, belongs to another application).
+ * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y in
+ * double precision. Returns %NULL if the window tree under @device is not known to GDK (for example,
+ * belongs to another application).
*
* As a slave device coordinates are those of its master pointer, This
* function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
@@ -475,11 +510,11 @@ gdk_device_get_position (GdkDevice *device,
* Since: 3.0
**/
GdkWindow *
-gdk_device_get_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y)
+gdk_device_get_window_at_position_double (GdkDevice *device,
+ gdouble *win_x,
+ gdouble *win_y)
{
- gint tmp_x, tmp_y;
+ gdouble tmp_x, tmp_y;
GdkWindow *window;
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
@@ -492,15 +527,9 @@ gdk_device_get_window_at_position (GdkDevice *device,
/* This might need corrections, as the native window returned
may contain client side children */
if (window)
- {
- double xx, yy;
-
- window = _gdk_window_find_descendant_at (window,
- tmp_x, tmp_y,
- &xx, &yy);
- tmp_x = floor (xx + 0.5);
- tmp_y = floor (yy + 0.5);
- }
+ window = _gdk_window_find_descendant_at (window,
+ tmp_x, tmp_y,
+ &tmp_x, &tmp_y);
if (win_x)
*win_x = tmp_x;
@@ -511,6 +540,44 @@ gdk_device_get_window_at_position (GdkDevice *device,
}
/**
+ * gdk_device_get_window_at_position:
+ * @device: pointer #GdkDevice to query info to.
+ * @win_x: (out) (allow-none): return location for the X coordinate of the device location,
+ * relative to the window origin, or %NULL.
+ * @win_y: (out) (allow-none): return location for the Y coordinate of the device location,
+ * relative to the window origin, or %NULL.
+ *
+ * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y. Returns
+ * %NULL if the window tree under @device is not known to GDK (for example, belongs to another application).
+ *
+ * As a slave device coordinates are those of its master pointer, This
+ * function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
+ * unless there is an ongoing grab on them, see gdk_device_grab().
+ *
+ * Returns: (transfer none): the #GdkWindow under the device position, or %NULL.
+ *
+ * Since: 3.0
+ **/
+GdkWindow *
+gdk_device_get_window_at_position (GdkDevice *device,
+ gint *win_x,
+ gint *win_y)
+{
+ gdouble tmp_x, tmp_y;
+ GdkWindow *window;
+
+ window =
+ gdk_device_get_window_at_position_double (device, &tmp_x, &tmp_y);
+
+ if (win_x)
+ *win_x = round (tmp_x);
+ if (win_y)
+ *win_y = round (tmp_y);
+
+ return window;
+}
+
+/**
* gdk_device_get_history: (skip)
* @device: a #GdkDevice
* @window: the window with respect to which which the event coordinates will be reported
@@ -1535,8 +1602,8 @@ _gdk_device_translate_window_coord (GdkDevice *device,
gboolean
_gdk_device_translate_screen_coord (GdkDevice *device,
GdkWindow *window,
- gint window_root_x,
- gint window_root_y,
+ gdouble window_root_x,
+ gdouble window_root_y,
guint index_,
gdouble value,
gdouble *axis_value)
@@ -1616,10 +1683,10 @@ _gdk_device_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GDK_DEVICE_GET_CLASS (device)->query_state (device,
@@ -1635,8 +1702,8 @@ _gdk_device_query_state (GdkDevice *device,
GdkWindow *
_gdk_device_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h
index dfa7051209..3350a2d1d1 100644
--- a/gdk/gdkdevice.h
+++ b/gdk/gdkdevice.h
@@ -198,6 +198,17 @@ GdkWindow *
(GdkDevice *device,
gint *win_x,
gint *win_y);
+GDK_AVAILABLE_IN_3_10
+void gdk_device_get_position_double (GdkDevice *device,
+ GdkScreen **screen,
+ gdouble *x,
+ gdouble *y);
+GDK_AVAILABLE_IN_3_10
+GdkWindow *
+ gdk_device_get_window_at_position_double
+ (GdkDevice *device,
+ gdouble *win_x,
+ gdouble *win_y);
GDK_AVAILABLE_IN_ALL
gboolean gdk_device_get_history (GdkDevice *device,
GdkWindow *window,
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index f30dbdb2a0..a8526b545b 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -80,16 +80,16 @@ struct _GdkDeviceClass
void (* warp) (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y);
+ gdouble x,
+ gdouble y);
void (* query_state) (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
GdkGrabStatus (* grab) (GdkDevice *device,
GdkWindow *window,
@@ -102,8 +102,8 @@ struct _GdkDeviceClass
guint32 time_);
GdkWindow * (* window_at_position) (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ double *win_x,
+ double *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
void (* select_window_events) (GdkDevice *device,
@@ -140,8 +140,8 @@ gboolean _gdk_device_translate_window_coord (GdkDevice *device,
gboolean _gdk_device_translate_screen_coord (GdkDevice *device,
GdkWindow *window,
- gint window_root_x,
- gint window_root_y,
+ gdouble window_root_x,
+ gdouble window_root_y,
guint index,
gdouble value,
gdouble *axis_value);
@@ -162,14 +162,14 @@ void _gdk_device_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
GdkWindow * _gdk_device_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 1c14d3e617..10928698fd 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -32,8 +32,11 @@
#include "gdkmarshalers.h"
#include "gdkscreen.h"
+#include <math.h>
#include <glib.h>
+/* for the use of round() */
+#include "fallback-c89.c"
/**
* SECTION:gdkdisplay
@@ -546,7 +549,7 @@ gdk_display_get_pointer (GdkDisplay *display,
{
GdkScreen *default_screen;
GdkWindow *root;
- gint tmp_x, tmp_y;
+ gdouble tmp_x, tmp_y;
GdkModifierType tmp_mask;
g_return_if_fail (GDK_IS_DISPLAY (display));
@@ -569,9 +572,9 @@ gdk_display_get_pointer (GdkDisplay *display,
if (screen)
*screen = gdk_window_get_screen (root);
if (x)
- *x = tmp_x;
+ *x = round (tmp_x);
if (y)
- *y = tmp_y;
+ *y = round (tmp_y);
if (mask)
*mask = tmp_mask;
}
@@ -792,7 +795,7 @@ synthesize_crossing_events (GdkDisplay *display,
{
GdkWindow *src_toplevel, *dest_toplevel;
GdkModifierType state;
- int x, y;
+ double x, y;
if (src_window)
src_toplevel = gdk_window_get_toplevel (src_window);
@@ -810,9 +813,9 @@ synthesize_crossing_events (GdkDisplay *display,
src_toplevel == dest_toplevel)
{
/* Same toplevels */
- gdk_window_get_device_position (dest_toplevel,
- device,
- &x, &y, &state);
+ gdk_window_get_device_position_double (dest_toplevel,
+ device,
+ &x, &y, &state);
_gdk_synthesize_crossing_events (display,
src_window,
dest_window,
@@ -825,9 +828,9 @@ synthesize_crossing_events (GdkDisplay *display,
}
else if (dest_toplevel == NULL)
{
- gdk_window_get_device_position (src_toplevel,
- device,
- &x, &y, &state);
+ gdk_window_get_device_position_double (src_toplevel,
+ device,
+ &x, &y, &state);
_gdk_synthesize_crossing_events (display,
src_window,
NULL,
@@ -841,9 +844,9 @@ synthesize_crossing_events (GdkDisplay *display,
else
{
/* Different toplevels */
- gdk_window_get_device_position (src_toplevel,
- device,
- &x, &y, &state);
+ gdk_window_get_device_position_double (src_toplevel,
+ device,
+ &x, &y, &state);
_gdk_synthesize_crossing_events (display,
src_window,
NULL,
@@ -853,9 +856,9 @@ synthesize_crossing_events (GdkDisplay *display,
time,
NULL,
serial, FALSE);
- gdk_window_get_device_position (dest_toplevel,
- device,
- &x, &y, &state);
+ gdk_window_get_device_position_double (dest_toplevel,
+ device,
+ &x, &y, &state);
_gdk_synthesize_crossing_events (display,
NULL,
dest_window,
@@ -876,7 +879,7 @@ get_current_toplevel (GdkDisplay *display,
GdkModifierType *state_out)
{
GdkWindow *pointer_window;
- int x, y;
+ gdouble x, y;
GdkModifierType state;
pointer_window = _gdk_device_window_at_position (device, &x, &y, &state, TRUE);
@@ -887,8 +890,8 @@ get_current_toplevel (GdkDisplay *display,
GDK_WINDOW_TYPE (pointer_window) == GDK_WINDOW_FOREIGN))
pointer_window = NULL;
- *x_out = x;
- *y_out = y;
+ *x_out = round (x);
+ *y_out = round (y);
*state_out = state;
return pointer_window;
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index e7eb9d5b40..87d9941874 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -358,7 +358,7 @@ void _gdk_window_invalidate_for_expose (GdkWindow *window,
cairo_region_t *region);
GdkWindow * _gdk_window_find_child_at (GdkWindow *window,
- int x, int y);
+ double x, double y);
GdkWindow * _gdk_window_find_descendant_at (GdkWindow *toplevel,
double x, double y,
double *found_x,
@@ -380,8 +380,8 @@ void _gdk_synthesize_crossing_events (GdkDisplay *display,
GdkDevice *device,
GdkDevice *source_device,
GdkCrossingMode mode,
- gint toplevel_x,
- gint toplevel_y,
+ gdouble toplevel_x,
+ gdouble toplevel_y,
GdkModifierType mask,
guint32 time_,
GdkEvent *event_in_queue,
diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c
index 454ca8944c..86b77a190c 100644
--- a/gdk/gdkoffscreenwindow.c
+++ b/gdk/gdkoffscreenwindow.c
@@ -280,12 +280,12 @@ gdk_offscreen_window_get_root_coords (GdkWindow *window,
static gboolean
gdk_offscreen_window_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
GdkOffscreenWindow *offscreen;
- int tmpx, tmpy;
+ double tmpx, tmpy;
double dtmpx, dtmpy;
GdkModifierType tmpmask;
@@ -296,18 +296,18 @@ gdk_offscreen_window_get_device_state (GdkWindow *window,
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
if (offscreen->embedder != NULL)
{
- gdk_window_get_device_position (offscreen->embedder, device, &tmpx, &tmpy, &tmpmask);
+ gdk_window_get_device_position_double (offscreen->embedder, device, &tmpx, &tmpy, &tmpmask);
from_embedder (window,
tmpx, tmpy,
&dtmpx, &dtmpy);
- tmpx = floor (dtmpx + 0.5);
- tmpy = floor (dtmpy + 0.5);
+ tmpx = dtmpx;
+ tmpy = dtmpy;
}
if (x)
- *x = tmpx;
+ *x = round (tmpx);
if (y)
- *y = tmpy;
+ *y = round (tmpy);
if (mask)
*mask = tmpmask;
return TRUE;
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index fa8732566b..9fe3fe7c6c 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -4425,30 +4425,30 @@ gdk_window_get_pointer (GdkWindow *window,
}
/**
- * gdk_window_get_device_position:
+ * gdk_window_get_device_position_double:
* @window: a #GdkWindow.
* @device: pointer #GdkDevice to query to.
* @x: (out) (allow-none): return location for the X coordinate of @device, or %NULL.
* @y: (out) (allow-none): return location for the Y coordinate of @device, or %NULL.
* @mask: (out) (allow-none): return location for the modifier mask, or %NULL.
*
- * Obtains the current device position and modifier state.
+ * Obtains the current device position in doubles and modifier state.
* The position is given in coordinates relative to the upper left
* corner of @window.
*
* Return value: (transfer none): The window underneath @device (as with
* gdk_device_get_window_at_position()), or %NULL if the window is not known to GDK.
*
- * Since: 3.0
+ * Since: 3.10
**/
GdkWindow *
-gdk_window_get_device_position (GdkWindow *window,
- GdkDevice *device,
- gint *x,
- gint *y,
- GdkModifierType *mask)
+gdk_window_get_device_position_double (GdkWindow *window,
+ GdkDevice *device,
+ double *x,
+ double *y,
+ GdkModifierType *mask)
{
- gint tmp_x, tmp_y;
+ gdouble tmp_x, tmp_y;
GdkModifierType tmp_mask;
gboolean normal_child;
@@ -4479,6 +4479,44 @@ gdk_window_get_device_position (GdkWindow *window,
}
/**
+ * gdk_window_get_device_position:
+ * @window: a #GdkWindow.
+ * @device: pointer #GdkDevice to query to.
+ * @x: (out) (allow-none): return location for the X coordinate of @device, or %NULL.
+ * @y: (out) (allow-none): return location for the Y coordinate of @device, or %NULL.
+ * @mask: (out) (allow-none): return location for the modifier mask, or %NULL.
+ *
+ * Obtains the current device position and modifier state.
+ * The position is given in coordinates relative to the upper left
+ * corner of @window.
+ *
+ * Use gdk_window_get_device_position_double() if you need subpixel precision.
+ *
+ * Return value: (transfer none): The window underneath @device (as with
+ * gdk_device_get_window_at_position()), or %NULL if the window is not known to GDK.
+ *
+ * Since: 3.0
+ **/
+GdkWindow *
+gdk_window_get_device_position (GdkWindow *window,
+ GdkDevice *device,
+ gint *x,
+ gint *y,
+ GdkModifierType *mask)
+{
+ gdouble tmp_x, tmp_y;
+
+ window = gdk_window_get_device_position_double (window, device,
+ &tmp_x, &tmp_y, mask);
+ if (x)
+ *x = round (tmp_x);
+ if (y)
+ *y = round (tmp_y);
+
+ return window;
+}
+
+/**
* gdk_get_default_root_window:
*
* Obtains the root window (parent all other windows are inside)
@@ -6953,8 +6991,8 @@ pick_embedded_child (GdkWindow *window,
GdkWindow *
_gdk_window_find_child_at (GdkWindow *window,
- int x,
- int y)
+ double x,
+ double y)
{
GdkWindow *sub;
double child_x, child_y;
@@ -7395,8 +7433,8 @@ send_crossing_event (GdkDisplay *display,
GdkWindow *subwindow,
GdkDevice *device,
GdkDevice *source_device,
- gint toplevel_x,
- gint toplevel_y,
+ gdouble toplevel_x,
+ gdouble toplevel_y,
GdkModifierType mask,
guint32 time_,
GdkEvent *event_in_queue,
@@ -7511,8 +7549,8 @@ _gdk_synthesize_crossing_events (GdkDisplay *display,
GdkDevice *device,
GdkDevice *source_device,
GdkCrossingMode mode,
- gint toplevel_x,
- gint toplevel_y,
+ double toplevel_x,
+ double toplevel_y,
GdkModifierType mask,
guint32 time_,
GdkEvent *event_in_queue,
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index 0c394d8c4d..eff71783cc 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -845,6 +845,12 @@ GdkWindow * gdk_window_get_device_position (GdkWindow *window,
gint *x,
gint *y,
GdkModifierType *mask);
+GDK_AVAILABLE_IN_3_10
+GdkWindow * gdk_window_get_device_position_double (GdkWindow *window,
+ GdkDevice *device,
+ gdouble *x,
+ gdouble *y,
+ GdkModifierType *mask);
GDK_AVAILABLE_IN_ALL
GdkWindow * gdk_window_get_parent (GdkWindow *window);
GDK_AVAILABLE_IN_ALL
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index 7f136a59bb..b1117a7177 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -98,8 +98,8 @@ struct _GdkWindowImplClass
gint *root_y);
gboolean (* get_device_state) (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask);
gboolean (* begin_paint_region) (GdkWindow *window,
const cairo_region_t *region);
diff --git a/gdk/quartz/gdkdevice-core-quartz.c b/gdk/quartz/gdkdevice-core-quartz.c
index 8598cf62a7..b28662096d 100644
--- a/gdk/quartz/gdkdevice-core-quartz.c
+++ b/gdk/quartz/gdkdevice-core-quartz.c
@@ -58,10 +58,10 @@ static void gdk_quartz_device_core_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_quartz_device_core_grab (GdkDevice *device,
GdkWindow *window,
@@ -73,8 +73,8 @@ static GdkGrabStatus gdk_quartz_device_core_grab (GdkDevice *device,
static void gdk_quartz_device_core_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_quartz_device_core_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_quartz_device_core_select_window_events (GdkDevice *device,
@@ -181,8 +181,8 @@ gdk_quartz_device_core_set_window_cursor (GdkDevice *device,
static void
gdk_quartz_device_core_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
CGDisplayMoveCursorToPoint (CGMainDisplayID (), CGPointMake (x, y));
}
@@ -190,8 +190,8 @@ gdk_quartz_device_core_warp (GdkDevice *device,
static GdkWindow *
gdk_quartz_device_core_query_state_helper (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
GdkWindow *toplevel;
@@ -260,10 +260,10 @@ gdk_quartz_device_core_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkWindow *found_window;
@@ -318,8 +318,8 @@ gdk_quartz_device_core_ungrab (GdkDevice *device,
static GdkWindow *
gdk_quartz_device_core_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index d6f45bbb30..05b3b77beb 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -1818,8 +1818,8 @@ gdk_quartz_window_get_root_origin (GdkWindow *window,
static GdkWindow *
gdk_window_quartz_get_device_state_helper (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
NSPoint point;
@@ -1880,8 +1880,8 @@ gdk_window_quartz_get_device_state_helper (GdkWindow *window,
static gboolean
gdk_window_quartz_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
return gdk_window_quartz_get_device_state_helper (window,
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index cd4a6955aa..292509660d 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -135,14 +135,14 @@ gdk_wayland_device_get_state (GdkDevice *device,
gdouble *axes,
GdkModifierType *mask)
{
- gint x_int, y_int;
+ gdouble x, y;
- gdk_window_get_device_position (window, device, &x_int, &y_int, mask);
+ gdk_window_get_device_position_double (window, device, &x, &y, mask);
if (axes)
{
- axes[0] = x_int;
- axes[1] = y_int;
+ axes[0] = x;
+ axes[1] = y;
}
}
@@ -228,8 +228,8 @@ gdk_wayland_device_set_window_cursor (GdkDevice *device,
static void
gdk_wayland_device_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
}
@@ -238,10 +238,10 @@ gdk_wayland_device_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkWaylandDeviceData *wd;
@@ -345,8 +345,8 @@ gdk_wayland_device_ungrab (GdkDevice *device,
static GdkWindow *
gdk_wayland_device_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c
index 7fa9add755..6768fabea1 100644
--- a/gdk/wayland/gdkscreen-wayland.c
+++ b/gdk/wayland/gdkscreen-wayland.c
@@ -928,7 +928,7 @@ output_handle_done(void *data,
static void
output_handle_scale(void *data,
struct wl_output *wl_output,
- uint32_t factor)
+ int32_t factor)
{
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *)data;
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index f872049d04..a6e68d5f66 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -1237,8 +1237,8 @@ gdk_window_wayland_get_root_coords (GdkWindow *window,
static gboolean
gdk_window_wayland_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
gboolean return_val;
diff --git a/gdk/win32/gdkdevice-virtual.c b/gdk/win32/gdkdevice-virtual.c
index 3a779dc5b2..028a8f5c51 100644
--- a/gdk/win32/gdkdevice-virtual.c
+++ b/gdk/win32/gdkdevice-virtual.c
@@ -47,10 +47,10 @@ static void gdk_device_virtual_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_device_virtual_grab (GdkDevice *device,
GdkWindow *window,
@@ -62,8 +62,8 @@ static GdkGrabStatus gdk_device_virtual_grab (GdkDevice *device,
static void gdk_device_virtual_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_device_virtual_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_device_virtual_select_window_events (GdkDevice *device,
@@ -245,10 +245,10 @@ gdk_device_virtual_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkDeviceVirtual *virtual = GDK_DEVICE_VIRTUAL (device);
@@ -342,8 +342,8 @@ screen_to_client (HWND hwnd, POINT screen_pt, POINT *client_pt)
static GdkWindow *
gdk_device_virtual_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
diff --git a/gdk/win32/gdkdevice-win32.c b/gdk/win32/gdkdevice-win32.c
index 042ef349a2..8be4d1d3c7 100644
--- a/gdk/win32/gdkdevice-win32.c
+++ b/gdk/win32/gdkdevice-win32.c
@@ -47,10 +47,10 @@ static void gdk_device_win32_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_device_win32_grab (GdkDevice *device,
GdkWindow *window,
@@ -62,8 +62,8 @@ static GdkGrabStatus gdk_device_win32_grab (GdkDevice *device,
static void gdk_device_win32_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_device_win32_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_device_win32_select_window_events (GdkDevice *device,
@@ -138,8 +138,8 @@ gdk_device_win32_set_window_cursor (GdkDevice *device,
static void
gdk_device_win32_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
}
@@ -174,10 +174,10 @@ gdk_device_win32_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
POINT point;
@@ -259,8 +259,8 @@ screen_to_client (HWND hwnd, POINT screen_pt, POINT *client_pt)
static GdkWindow *
gdk_device_win32_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
diff --git a/gdk/win32/gdkdevice-wintab.c b/gdk/win32/gdkdevice-wintab.c
index 6af23bad43..369821cb08 100644
--- a/gdk/win32/gdkdevice-wintab.c
+++ b/gdk/win32/gdkdevice-wintab.c
@@ -46,10 +46,10 @@ static void gdk_device_wintab_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_device_wintab_grab (GdkDevice *device,
GdkWindow *window,
@@ -61,8 +61,8 @@ static GdkGrabStatus gdk_device_wintab_grab (GdkDevice *device,
static void gdk_device_wintab_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_device_wintab_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_device_wintab_select_window_events (GdkDevice *device,
@@ -180,10 +180,10 @@ gdk_device_wintab_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkDeviceWintab *device_wintab;
@@ -268,8 +268,8 @@ gdk_device_wintab_ungrab (GdkDevice *device,
static GdkWindow *
gdk_device_wintab_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index 33361743e7..273e53cf7b 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -2128,8 +2128,8 @@ gdk_win32_window_get_frame_extents (GdkWindow *window,
static gboolean
gdk_window_win32_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
GdkWindow *child;
diff --git a/gdk/x11/gdkdevice-core-x11.c b/gdk/x11/gdkdevice-core-x11.c
index e21339dac0..2f87c73c2a 100644
--- a/gdk/x11/gdkdevice-core-x11.c
+++ b/gdk/x11/gdkdevice-core-x11.c
@@ -17,6 +17,7 @@
#include "config.h"
+
#include "gdkx11device-core.h"
#include "gdkdeviceprivate.h"
@@ -25,6 +26,11 @@
#include "gdkprivate-x11.h"
#include "gdkasync.h"
+#include <math.h>
+
+/* for the use of round() */
+#include "fallback-c89.c"
+
struct _GdkX11DeviceCore
{
GdkDevice parent_instance;
@@ -50,16 +56,16 @@ static void gdk_x11_device_core_set_window_cursor (GdkDevice *device,
GdkCursor *cursor);
static void gdk_x11_device_core_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y);
+ gdouble x,
+ gdouble y);
static void gdk_x11_device_core_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_x11_device_core_grab (GdkDevice *device,
GdkWindow *window,
@@ -71,8 +77,8 @@ static GdkGrabStatus gdk_x11_device_core_grab (GdkDevice *device,
static void gdk_x11_device_core_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_x11_device_core_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_x11_device_core_select_window_events (GdkDevice *device,
@@ -196,15 +202,14 @@ gdk_x11_device_core_get_state (GdkDevice *device,
gdouble *axes,
GdkModifierType *mask)
{
- gint x_int, y_int;
+ gdouble x, y;
- /* TODO: This rounds the coords, should use double */
- gdk_window_get_device_position (window, device, &x_int, &y_int, mask);
+ gdk_window_get_device_position_double (window, device, &x, &y, mask);
if (axes)
{
- axes[0] = x_int;
- axes[1] = y_int;
+ axes[0] = x;
+ axes[1] = y;
}
}
@@ -228,8 +233,8 @@ gdk_x11_device_core_set_window_cursor (GdkDevice *device,
static void
gdk_x11_device_core_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
Display *xdisplay;
Window dest;
@@ -238,8 +243,8 @@ gdk_x11_device_core_warp (GdkDevice *device,
dest = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0,
- x * GDK_X11_SCREEN (screen)->window_scale,
- y * GDK_X11_SCREEN (screen)->window_scale);
+ round (x * GDK_X11_SCREEN (screen)->window_scale),
+ round (y * GDK_X11_SCREEN (screen)->window_scale));
}
static void
@@ -247,10 +252,10 @@ gdk_x11_device_core_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
@@ -299,16 +304,16 @@ gdk_x11_device_core_query_state (GdkDevice *device,
*child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
if (root_x)
- *root_x = xroot_x / impl->window_scale;
+ *root_x = (double)xroot_x / impl->window_scale;
if (root_y)
- *root_y = xroot_y / impl->window_scale;
+ *root_y = (double)xroot_y / impl->window_scale;
if (win_x)
- *win_x = xwin_x / impl->window_scale;
+ *win_x = (double)xwin_x / impl->window_scale;
if (win_y)
- *win_y = xwin_y / impl->window_scale;
+ *win_y = (double)xwin_y / impl->window_scale;
if (mask)
*mask = xmask;
@@ -416,8 +421,8 @@ gdk_x11_device_core_ungrab (GdkDevice *device,
static GdkWindow *
gdk_x11_device_core_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
@@ -547,10 +552,10 @@ gdk_x11_device_core_window_at_position (GdkDevice *device,
impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (win_x)
- *win_x = (window) ? xwin_x / impl->window_scale : -1;
+ *win_x = (window) ? (double)xwin_x / impl->window_scale : -1;
if (win_y)
- *win_y = (window) ? xwin_y / impl->window_scale : -1;
+ *win_y = (window) ? (double)xwin_y / impl->window_scale : -1;
if (mask)
*mask = xmask;
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index 4f85ba1703..8245fe4cab 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -29,6 +29,10 @@
#include <X11/Xutil.h>
#include <X11/extensions/XInput2.h>
+#include <math.h>
+
+/* for the use of round() */
+#include "fallback-c89.c"
typedef struct _ScrollValuator ScrollValuator;
@@ -76,16 +80,16 @@ static void gdk_x11_device_xi2_set_window_cursor (GdkDevice *device,
GdkCursor *cursor);
static void gdk_x11_device_xi2_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y);
+ gdouble x,
+ gdouble y);
static void gdk_x11_device_xi2_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_x11_device_xi2_grab (GdkDevice *device,
@@ -99,8 +103,8 @@ static void gdk_x11_device_xi2_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_x11_device_xi2_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_x11_device_xi2_select_window_events (GdkDevice *device,
@@ -292,8 +296,8 @@ gdk_x11_device_xi2_set_window_cursor (GdkDevice *device,
static void
gdk_x11_device_xi2_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
Window dest;
@@ -304,8 +308,8 @@ gdk_x11_device_xi2_warp (GdkDevice *device,
device_xi2->device_id,
None, dest,
0, 0, 0, 0,
- x * GDK_X11_SCREEN(screen)->window_scale,
- y * GDK_X11_SCREEN(screen)->window_scale);
+ round (x * GDK_X11_SCREEN(screen)->window_scale),
+ round (y * GDK_X11_SCREEN(screen)->window_scale));
}
static void
@@ -313,10 +317,10 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
@@ -384,16 +388,16 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
*child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
if (root_x)
- *root_x = (gint) (xroot_x / impl->window_scale);
+ *root_x = xroot_x / impl->window_scale;
if (root_y)
- *root_y = (gint) (xroot_y / impl->window_scale);
+ *root_y = xroot_y / impl->window_scale;
if (win_x)
- *win_x = (gint) (xwin_x / impl->window_scale);
+ *win_x = xwin_x / impl->window_scale;
if (win_y)
- *win_y = (gint) (xwin_y / impl->window_scale);
+ *win_y = xwin_y / impl->window_scale;
if (mask)
*mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
@@ -477,8 +481,8 @@ gdk_x11_device_xi2_ungrab (GdkDevice *device,
static GdkWindow *
gdk_x11_device_xi2_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
@@ -633,10 +637,10 @@ gdk_x11_device_xi2_window_at_position (GdkDevice *device,
impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (win_x)
- *win_x = (window) ? (gint) (xwin_x / impl->window_scale) : -1;
+ *win_x = (window) ? (xwin_x / impl->window_scale) : -1;
if (win_y)
- *win_y = (window) ? (gint) (xwin_y / impl->window_scale) : -1;
+ *win_y = (window) ? (xwin_y / impl->window_scale) : -1;
if (mask)
*mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 49c1361ff8..f9a4335576 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -3242,8 +3242,8 @@ gdk_x11_window_get_frame_extents (GdkWindow *window,
static gboolean
gdk_window_x11_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
GdkWindow *child;