Fix the win32 build

gdk_display_get_monitor_at_point was used
in this backend.
This commit is contained in:
Matthias Clasen 2019-05-29 17:31:37 +00:00
parent b867cbe0d8
commit 51396533a1

View File

@ -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;