gdksurface-win32.c: Fix Aerosnap computation

Don't get the default display when we compute the Aerosnap region, but instead
get it from the underlying GdkSurface that we are using for the computation.

Also, don't unref the monitors that we obtain from the display in the wrong
place, which was why we had crashes whenever we triggered AeroSnap code (and we
are actually not supposed to do that as they are owned by the GdkDisplay that
is owned by the GdkSurface we are using), and this will eliminate lots of
criticals that are spewed as a result.
This commit is contained in:
Chun-wei Fan
2020-08-03 16:01:40 +08:00
parent e60d6f70bf
commit 06f28af80f

View File

@@ -1979,7 +1979,7 @@ calculate_aerosnap_regions (GdkW32DragMoveResizeContext *context)
int i;
#endif
display = gdk_display_get_default ();
display = gdk_surface_get_display (context->window);
monitors = gdk_display_get_monitors (display);
#define _M_UP 0
@@ -1999,7 +1999,6 @@ calculate_aerosnap_regions (GdkW32DragMoveResizeContext *context)
GdkMonitor *monitor;
monitor = g_list_model_get_item (monitors, monitor_idx);
g_object_unref (monitors);
gdk_win32_monitor_get_workarea (monitor, &wa);
gdk_monitor_get_geometry (monitor, &geometry);
@@ -3428,8 +3427,8 @@ setup_drag_move_resize_context (GdkSurface *window,
GdkSurfaceEdge edge,
GdkDevice *device,
int button,
int x,
int y,
double x,
double y,
guint32 timestamp)
{
RECT rect;