[gtk/global-coords: 35/37] Fix the win32 build
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/global-coords: 35/37] Fix the win32 build
- Date: Wed, 29 May 2019 18:06:42 +0000 (UTC)
commit 51396533a1bc937ca233035d457b7a46984ec005
Author: Matthias Clasen <mclasen redhat com>
Date: Wed May 29 17:31:37 2019 +0000
Fix the win32 build
gdk_display_get_monitor_at_point was used
in this backend.
gdk/win32/gdksurface-win32.c | 70 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 69 insertions(+), 1 deletion(-)
---
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index 4336dcbbc7..be14e854a6 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -3328,6 +3328,74 @@ update_fullup_indicator (GdkSurface *window,
ensure_snap_indicator_surface (context, from_or_to.width, from_or_to.height, impl->surface_scale);
}
+static GdkMonitor *
+get_monitor_at_point (GdkDisplay *display,
+ int x,
+ int y)
+{
+ GdkMonitor *nearest = NULL;
+ int nearest_dist = G_MAXINT;
+ int n_monitors, i;
+
+ n_monitors = gdk_display_get_n_monitors (display);
+ for (i = 0; i < n_monitors; i++)
+ {
+ GdkMonitor *monitor;
+ GdkRectangle geometry;
+ int dist_x, dist_y, dist;
+
+ monitor = gdk_display_get_monitor (display, i);
+ gdk_monitor_get_geometry (monitor, &geometry);
+
+ if (x < geometry.x)
+ dist_x = geometry.x - x;
+ else if (geometry.x + geometry.width <= x)
+ dist_x = x - (geometry.x + geometry.width) + 1;
+ else
+ dist_x = 0;
+
+ if (y < geometry.y)
+ dist_y = geometry.y - y;
+ else if (geometry.y + geometry.height <= y)
+ dist_y = y - (geometry.y + geometry.height) + 1;
+ else
+ dist_y = 0;
+
+ dist = dist_x + dist_y;
+ if (dist < nearest_dist)
+ {
+ nearest_dist = dist;
+ nearest = monitor;
+ }
+
+ if (x < geometry.x)
+ dist_x = geometry.x - x;
+ else if (geometry.x + geometry.width <= x)
+ dist_x = x - (geometry.x + geometry.width) + 1;
+ else
+ dist_x = 0;
+
+ if (y < geometry.y)
+ dist_y = geometry.y - y;
+ else if (geometry.y + geometry.height <= y)
+ dist_y = y - (geometry.y + geometry.height) + 1;
+ else
+ dist_y = 0;
+
+ dist = dist_x + dist_y;
+ if (dist < nearest_dist)
+ {
+ nearest_dist = dist;
+ nearest = monitor;
+ }
+
+ if (nearest_dist == 0)
+ break;
+ }
+
+ return nearest;
+}
+
static void
start_indicator (GdkSurface *window,
GdkW32DragMoveResizeContext *context,
@@ -3343,7 +3411,7 @@ start_indicator (GdkSurface *window,
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
display = gdk_surface_get_display (window);
- monitor = gdk_display_get_monitor_at_point (display, x, y);
+ monitor = get_monitor_at_point (display, x, y);
gdk_monitor_get_workarea (monitor, &workarea);
maxysize = GetSystemMetrics (SM_CYVIRTUALSCREEN) / impl->surface_scale;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]