[gtk+/wip/otte/gtk4: 16/127] gdk: Require passing screen size to translate_screen_coord()



commit ccbc37c0ddbf18b2fabc5267eaf472debdd14a66
Author: Benjamin Otte <otte redhat com>
Date:   Fri Sep 9 14:48:33 2016 +0200

    gdk: Require passing screen size to translate_screen_coord()

 gdk/gdkdevice.c              |    6 ++++--
 gdk/gdkdeviceprivate.h       |    2 ++
 gdk/win32/gdkdevice-wintab.c |    8 ++++++--
 gdk/x11/gdkdevice-xi2.c      |    4 ++++
 4 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index 92222cc..9f0c6e2 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -1784,6 +1784,8 @@ _gdk_device_translate_screen_coord (GdkDevice *device,
                                     GdkWindow *window,
                                     gdouble    window_root_x,
                                     gdouble    window_root_y,
+                                    gdouble    screen_width,
+                                    gdouble    screen_height,
                                     guint      index_,
                                     gdouble    value,
                                     gdouble   *axis_value)
@@ -1808,7 +1810,7 @@ _gdk_device_translate_screen_coord (GdkDevice *device,
   if (axis_info.use == GDK_AXIS_X)
     {
       if (axis_width > 0)
-        scale = gdk_screen_get_width (gdk_window_get_screen (window)) / axis_width;
+        scale = screen_width / axis_width;
       else
         scale = 1;
 
@@ -1817,7 +1819,7 @@ _gdk_device_translate_screen_coord (GdkDevice *device,
   else
     {
       if (axis_width > 0)
-        scale = gdk_screen_get_height (gdk_window_get_screen (window)) / axis_width;
+        scale = screen_height / axis_width;
       else
         scale = 1;
 
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index 6dbc601..22d5097 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -152,6 +152,8 @@ gboolean   _gdk_device_translate_screen_coord (GdkDevice *device,
                                                GdkWindow *window,
                                                gdouble    window_root_x,
                                                gdouble    window_root_y,
+                                               gdouble    screen_width,
+                                               gdouble    screen_height,
                                                guint      index,
                                                gdouble    value,
                                                gdouble   *axis_value);
diff --git a/gdk/win32/gdkdevice-wintab.c b/gdk/win32/gdkdevice-wintab.c
index fb7f0f2..18279a8 100644
--- a/gdk/win32/gdkdevice-wintab.c
+++ b/gdk/win32/gdkdevice-wintab.c
@@ -219,12 +219,13 @@ _gdk_device_wintab_translate_axes (GdkDeviceWintab *device_wintab,
                                    gdouble         *y)
 {
   GdkDevice *device;
-  GdkWindow *impl_window;
+  GdkWindow *impl_window, *root_window;
   gint root_x, root_y;
   gdouble temp_x, temp_y;
   gint i;
 
   device = GDK_DEVICE (device_wintab);
+  root_window = gdk_screen_get_root_window (gdk_window_get_screen (window));
   impl_window = _gdk_window_get_impl_window (window);
   temp_x = temp_y = 0;
 
@@ -246,7 +247,10 @@ _gdk_device_wintab_translate_axes (GdkDeviceWintab *device_wintab,
                                                 &axes[i]);
           else
             _gdk_device_translate_screen_coord (device, window,
-                                                root_x, root_y, i,
+                                                root_x, root_y,
+                                                gdk_window_get_width (root_window),
+                                                gdk_window_get_height (root_window),
+                                                i,
                                                 device_wintab->last_axis_data[i],
                                                 &axes[i]);
           if (use == GDK_AXIS_X)
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index cd1849c..23816ec 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -243,12 +243,16 @@ gdk_x11_device_xi2_get_state (GdkDevice       *device,
                 _gdk_device_translate_window_coord (device, window, j, value, &axes[j]);
               else
                 {
+                  GdkWindow *root_window;
                   gint root_x, root_y;
 
+                  root_window = gdk_screen_get_root_window (gdk_window_get_screen (window));
                   /* FIXME: Maybe root coords chaching should happen here */
                   gdk_window_get_origin (window, &root_x, &root_y);
                   _gdk_device_translate_screen_coord (device, window,
                                                       root_x, root_y,
+                                                      gdk_window_get_width (root_window),
+                                                      gdk_window_get_height (root_window),
                                                       j, value,
                                                       &axes[j]);
                 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]