GdkDevice *pointer = NULL;
GdkDeviceTool *tool = NULL;
double *axes = NULL;
+ cairo_region_t *input_region;
g_assert (GDK_IS_MACOS_DISPLAY (display));
g_assert (GDK_IS_MACOS_SURFACE (surface));
seat = gdk_display_get_default_seat (GDK_DISPLAY (display));
state = get_keyboard_modifiers_from_ns_event (nsevent) |
_gdk_macos_display_get_current_mouse_modifiers (display);
+ input_region = GDK_SURFACE (surface)->input_region;
switch ((int)[nsevent type])
{
*/
if (type == GDK_BUTTON_PRESS &&
(x < 0 || x > GDK_SURFACE (surface)->width ||
- y < 0 || y > GDK_SURFACE (surface)->height))
+ y < 0 || y > GDK_SURFACE (surface)->height ||
+ (input_region && !cairo_region_contains_point (input_region, x, y))))
return NULL;
if (([nsevent subtype] == NSEventSubtypeTabletPoint) &&
GdkDeviceGrabInfo *grab;
GdkSeat *seat;
- surface = get_surface_from_ns_event (self, nsevent, &point, x, y);
+ /* Even if we had a surface window, it might be for something outside
+ * the input region (shadow) which we might want to ignore. This is
+ * handled for us deeper in the event unwrapping.
+ */
+ if (!(surface = get_surface_from_ns_event (self, nsevent, &point, x, y)))
+ return NULL;
+
display = gdk_surface_get_display (surface);
seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
pointer = gdk_seat_get_pointer (seat);
g_assert (x != NULL);
g_assert (y != NULL);
- if (!(surface = get_surface_from_ns_event (self, nsevent, &point, x, y)))
- return NULL;
-
- view = (GdkMacosBaseView *)[GDK_MACOS_SURFACE (surface)->window contentView];
-
_gdk_macos_display_from_display_coords (self, point.x, point.y, &x_tmp, &y_tmp);
switch ((int)[nsevent type])
/* Only handle our own entered/exited events, not the ones for the
* titlebar buttons.
*/
- if ([nsevent trackingArea] == [view trackingArea])
+ if ((surface = get_surface_from_ns_event (self, nsevent, &point, x, y)) &&
+ (view = (GdkMacosBaseView *)[GDK_MACOS_SURFACE (surface)->window contentView]) &&
+ ([nsevent trackingArea] == [view trackingArea]))
return GDK_MACOS_SURFACE (surface);
else
return NULL;
*surface_x = x - GDK_MACOS_SURFACE (surface)->root_x;
*surface_y = y - GDK_MACOS_SURFACE (surface)->root_y;
+ /* One last check to make sure that the x,y is within the input
+ * region of the window. Otherwise we might send the event to the
+ * wrong window because of window shadow.
+ */
+ if (surface->input_region != NULL &&
+ !cairo_region_contains_point (surface->input_region, *surface_x, *surface_y))
+ continue;
+
return GDK_MACOS_SURFACE (surface);
}
}