Merge branch 'wip/carlosg/input-cleanups' into 'master'

Some input cleanups

Closes #2851

See merge request GNOME/gtk!2147
This commit is contained in:
Matthias Clasen 2020-06-24 21:32:30 +00:00
commit db82eaec0a
40 changed files with 307 additions and 879 deletions

View File

@ -207,8 +207,6 @@ GdkModifierType
GDK_MODIFIER_MASK
<SUBSECTION>
gdk_surface_get_support_multidevice
gdk_surface_set_support_multidevice
gdk_surface_get_device_cursor
gdk_surface_set_device_cursor
@ -381,7 +379,6 @@ gdk_device_get_surface_at_position
GdkTimeCoord
gdk_device_get_axis
gdk_device_get_axis_names
gdk_device_get_last_event_surface
<SUBSECTION>
gdk_device_tool_get_serial
@ -443,7 +440,6 @@ gdk_seat_get_capabilities
gdk_seat_get_pointer
gdk_seat_get_keyboard
gdk_seat_get_physical_devices
gdk_seat_get_logical_pointers
<SUBSECTION Standard>
GDK_SEAT

View File

@ -4501,11 +4501,8 @@ gtk_widget_has_visible_focus
gtk_widget_is_drawable
gtk_widget_set_receives_default
gtk_widget_get_receives_default
gtk_widget_set_support_multidevice
gtk_widget_get_support_multidevice
gtk_widget_get_realized
gtk_widget_get_mapped
gtk_widget_device_is_shadowed
gtk_widget_get_opacity
gtk_widget_set_opacity
gtk_widget_get_overflow

View File

@ -1107,13 +1107,12 @@ create_moveresize_surface (MoveResizeData *mv_resize,
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
status = gdk_device_grab (pointer,
mv_resize->moveresize_emulation_surface,
GDK_OWNERSHIP_APPLICATION,
FALSE,
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK,
NULL,
timestamp);
mv_resize->moveresize_emulation_surface,
FALSE,
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK,
NULL,
timestamp);
G_GNUC_END_IGNORE_DEPRECATIONS;
if (status != GDK_GRAB_SUCCESS)

View File

@ -924,7 +924,6 @@ get_native_grab_event_mask (GdkEventMask grab_mask)
GdkGrabStatus
gdk_device_grab (GdkDevice *device,
GdkSurface *surface,
GdkGrabOwnership grab_ownership,
gboolean owner_events,
GdkEventMask event_mask,
GdkCursor *cursor,
@ -958,7 +957,6 @@ gdk_device_grab (GdkDevice *device,
_gdk_display_add_device_grab (display,
device,
surface,
grab_ownership,
owner_events,
event_mask,
serial,
@ -1284,33 +1282,6 @@ _gdk_device_surface_at_position (GdkDevice *device,
mask);
}
/**
* gdk_device_get_last_event_surface:
* @device: a #GdkDevice, with a source other than %GDK_SOURCE_KEYBOARD
*
* Gets information about which surface the given pointer device is in, based on events
* that have been received so far from the display server. If another application
* has a pointer grab, or this application has a grab with owner_events = %FALSE,
* %NULL may be returned even if the pointer is physically over one of this
* application's surfaces.
*
* Returns: (transfer none) (allow-none): the last surface the device
*/
GdkSurface *
gdk_device_get_last_event_surface (GdkDevice *device)
{
GdkDisplay *display;
GdkPointerSurfaceInfo *info;
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
g_return_val_if_fail (device->source != GDK_SOURCE_KEYBOARD, NULL);
display = gdk_device_get_display (device);
info = _gdk_display_get_pointer_info (display, device);
return info->surface_under_pointer;
}
/**
* gdk_device_get_vendor_id:
* @device: a physical #GdkDevice

View File

@ -40,8 +40,6 @@ typedef struct _GdkTimeCoord GdkTimeCoord;
* @GDK_SOURCE_MOUSE: the device is a mouse. (This will be reported for the core
* pointer, even if it is something else, such as a trackball.)
* @GDK_SOURCE_PEN: the device is a stylus of a graphics tablet or similar device.
* @GDK_SOURCE_ERASER: the device is an eraser. Typically, this would be the other end
* of a stylus on a graphics tablet.
* @GDK_SOURCE_CURSOR: the device is a graphics tablet puck or similar device.
* @GDK_SOURCE_KEYBOARD: the device is a keyboard.
* @GDK_SOURCE_TOUCHSCREEN: the device is a direct-input touch device, such
@ -60,7 +58,6 @@ typedef enum
{
GDK_SOURCE_MOUSE,
GDK_SOURCE_PEN,
GDK_SOURCE_ERASER,
GDK_SOURCE_CURSOR,
GDK_SOURCE_KEYBOARD,
GDK_SOURCE_TOUCHSCREEN,
@ -146,9 +143,6 @@ GList * gdk_device_list_physical_devices (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
GdkDeviceType gdk_device_get_device_type (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
GdkSurface *gdk_device_get_last_event_surface (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
const gchar *gdk_device_get_vendor_id (GdkDevice *device);
GDK_AVAILABLE_IN_ALL

View File

@ -521,7 +521,6 @@ GdkDeviceGrabInfo *
_gdk_display_add_device_grab (GdkDisplay *display,
GdkDevice *device,
GdkSurface *surface,
GdkGrabOwnership grab_ownership,
gboolean owner_events,
GdkEventMask event_mask,
unsigned long serial_start,
@ -540,7 +539,6 @@ _gdk_display_add_device_grab (GdkDisplay *display,
info->event_mask = event_mask;
info->time = time;
info->implicit = implicit;
info->ownership = grab_ownership;
grabs = g_hash_table_lookup (display->device_grabs, device);
@ -816,61 +814,6 @@ _gdk_display_end_device_grab (GdkDisplay *display,
return FALSE;
}
/* Returns TRUE if device events are not blocked by any grab */
gboolean
_gdk_display_check_grab_ownership (GdkDisplay *display,
GdkDevice *device,
gulong serial)
{
GHashTableIter iter;
gpointer key, value;
GdkGrabOwnership higher_ownership, device_ownership;
gboolean device_is_keyboard;
g_hash_table_iter_init (&iter, display->device_grabs);
higher_ownership = device_ownership = GDK_OWNERSHIP_NONE;
device_is_keyboard = (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD);
while (g_hash_table_iter_next (&iter, &key, &value))
{
GdkDeviceGrabInfo *grab;
GdkDevice *dev;
GList *grabs;
dev = key;
grabs = value;
grabs = grab_list_find (grabs, serial);
if (!grabs)
continue;
/* Discard device if it's not of the same type */
if ((device_is_keyboard && gdk_device_get_source (dev) != GDK_SOURCE_KEYBOARD) ||
(!device_is_keyboard && gdk_device_get_source (dev) == GDK_SOURCE_KEYBOARD))
continue;
grab = grabs->data;
if (dev == device)
device_ownership = grab->ownership;
else
{
if (grab->ownership > higher_ownership)
higher_ownership = grab->ownership;
}
}
if (higher_ownership > device_ownership)
{
/* There's a higher priority ownership
* going on for other device(s)
*/
return FALSE;
}
return TRUE;
}
GdkPointerSurfaceInfo *
_gdk_display_get_pointer_info (GdkDisplay *display,
GdkDevice *device)

View File

@ -45,7 +45,6 @@ typedef struct
gulong serial_end; /* exclusive, i.e. not active on serial_end */
guint event_mask;
guint32 time;
GdkGrabOwnership ownership;
guint activated : 1;
guint implicit_ungrab : 1;
@ -187,7 +186,6 @@ GdkDeviceGrabInfo * _gdk_display_get_last_device_grab (GdkDisplay *display,
GdkDeviceGrabInfo * _gdk_display_add_device_grab (GdkDisplay *display,
GdkDevice *device,
GdkSurface *surface,
GdkGrabOwnership grab_ownership,
gboolean owner_events,
GdkEventMask event_mask,
gulong serial_start,
@ -201,9 +199,6 @@ gboolean _gdk_display_end_device_grab (GdkDisplay *display
gulong serial,
GdkSurface *if_child,
gboolean implicit);
gboolean _gdk_display_check_grab_ownership (GdkDisplay *display,
GdkDevice *device,
gulong serial);
GdkPointerSurfaceInfo * _gdk_display_get_pointer_info (GdkDisplay *display,
GdkDevice *device);
void _gdk_display_pointer_info_foreach (GdkDisplay *display,

View File

@ -1185,6 +1185,22 @@ gdk_event_get_surface (GdkEvent *event)
return event->surface;
}
/**
* gdk_event_get_seat:
* @event: a #GdkEvent.
*
* Returns the seat that originated the event.
*
* Returns: (nullable) (transfer none): a #GdkSeat.
*/
GdkSeat *
gdk_event_get_seat (GdkEvent *event)
{
g_return_val_if_fail (GDK_IS_EVENT (event), NULL);
return event->device ? gdk_device_get_seat (event->device) : NULL;
}
/**
* gdk_event_get_device:
* @event: a #GdkEvent.

View File

@ -344,6 +344,9 @@ GdkEventType gdk_event_get_event_type (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GdkSurface * gdk_event_get_surface (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GdkSeat * gdk_event_get_seat (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GdkDevice * gdk_event_get_device (GdkEvent *event);

View File

@ -229,21 +229,6 @@ typedef enum
GDK_GRAB_FAILED = 5
} GdkGrabStatus;
/**
* GdkGrabOwnership:
* @GDK_OWNERSHIP_NONE: All other devices events are allowed.
* @GDK_OWNERSHIP_SURFACE: Other devices events are blocked for the grab surface.
* @GDK_OWNERSHIP_APPLICATION: Other devices events are blocked for the whole application.
*
* Defines how device grabs interact with other devices.
*/
typedef enum
{
GDK_OWNERSHIP_NONE,
GDK_OWNERSHIP_SURFACE,
GDK_OWNERSHIP_APPLICATION
} GdkGrabOwnership;
typedef enum
{
GDK_EXPOSURE_MASK = 1 << 1,
@ -274,7 +259,6 @@ typedef enum
GdkGrabStatus gdk_device_grab (GdkDevice *device,
GdkSurface *surface,
GdkGrabOwnership grab_ownership,
gboolean owner_events,
GdkEventMask event_mask,
GdkCursor *cursor,

View File

@ -446,31 +446,3 @@ gdk_seat_get_tool (GdkSeat *seat,
seat_class = GDK_SEAT_GET_CLASS (seat);
return seat_class->get_tool (seat, serial, hw_id);
}
/**
* gdk_seat_get_logical_pointers:
* @seat: The #GdkSeat
* @capabilities: Queried capabilities
*
* Returns all logical pointers with the given capabilities driven by
* this @seat.
*
* On most windowing system backends this function will return a list
* with a single element (meaning that all input devices drive the same
* on-screen cursor).
*
* In other windowing systems where there can possibly be multiple
* foci (e.g. Wayland), this function will return all logical #GdkDevices
* that represent these.
*
* Returns: (transfer container) (element-type GdkDevice): A list
* of logical pointing devices
*/
GList *
gdk_seat_get_logical_pointers (GdkSeat *seat,
GdkSeatCapabilities capabilities)
{
g_return_val_if_fail (GDK_IS_SEAT (seat), NULL);
return GDK_SEAT_GET_CLASS (seat)->get_logical_pointers (seat, capabilities);
}

View File

@ -83,10 +83,6 @@ GdkDevice * gdk_seat_get_pointer (GdkSeat *seat);
GDK_AVAILABLE_IN_ALL
GdkDevice * gdk_seat_get_keyboard (GdkSeat *seat);
GDK_AVAILABLE_IN_ALL
GList * gdk_seat_get_logical_pointers (GdkSeat *seat,
GdkSeatCapabilities capabilities);
G_END_DECLS
#endif /* __GDK_SEAT_H__ */

View File

@ -149,7 +149,7 @@ gdk_seat_default_grab (GdkSeat *seat,
pointer_evmask |= TOUCH_EVENTS;
status = gdk_device_grab (priv->logical_pointer, surface,
GDK_OWNERSHIP_NONE, owner_events,
owner_events,
pointer_evmask, cursor,
evtime);
}
@ -158,7 +158,7 @@ gdk_seat_default_grab (GdkSeat *seat,
capabilities & GDK_SEAT_CAPABILITY_KEYBOARD)
{
status = gdk_device_grab (priv->logical_keyboard, surface,
GDK_OWNERSHIP_NONE, owner_events,
owner_events,
KEYBOARD_EVENTS, cursor,
evtime);
@ -228,7 +228,6 @@ device_get_capability (GdkDevice *device)
case GDK_SOURCE_TOUCHSCREEN:
return GDK_SEAT_CAPABILITY_TOUCH;
case GDK_SOURCE_PEN:
case GDK_SOURCE_ERASER:
case GDK_SOURCE_CURSOR:
return GDK_SEAT_CAPABILITY_TABLET_STYLUS;
case GDK_SOURCE_TABLET_PAD:
@ -306,18 +305,6 @@ gdk_seat_default_get_tool (GdkSeat *seat,
return NULL;
}
static GList *
gdk_seat_default_get_logical_pointers (GdkSeat *seat,
GdkSeatCapabilities capabilities)
{
GList *pointers = NULL;
if (capabilities & GDK_SEAT_CAPABILITY_ALL_POINTING)
pointers = g_list_prepend (pointers, gdk_seat_get_pointer (seat));
return pointers;
}
static void
gdk_seat_default_class_init (GdkSeatDefaultClass *klass)
{
@ -333,7 +320,6 @@ gdk_seat_default_class_init (GdkSeatDefaultClass *klass)
seat_class->get_logical_device = gdk_seat_default_get_logical_device;
seat_class->get_physical_devices = gdk_seat_default_get_physical_devices;
seat_class->get_logical_pointers = gdk_seat_default_get_logical_pointers;
seat_class->get_tool = gdk_seat_default_get_tool;
}

View File

@ -60,8 +60,6 @@ struct _GdkSeatClass
GdkDeviceTool * (* get_tool) (GdkSeat *seat,
guint64 serial,
guint64 tool_id);
GList * (* get_logical_pointers) (GdkSeat *seat,
GdkSeatCapabilities capabilities);
};
void gdk_seat_device_added (GdkSeat *seat,

View File

@ -2186,53 +2186,6 @@ gdk_surface_beep (GdkSurface *surface)
gdk_display_beep (surface->display);
}
/**
* gdk_surface_set_support_multidevice:
* @surface: a #GdkSurface.
* @support_multidevice: %TRUE to enable multidevice support in @surface.
*
* This function will enable multidevice features in @surface.
*
* Multidevice aware surfaces will need to handle properly multiple,
* per device enter/leave events, device grabs and grab ownerships.
**/
void
gdk_surface_set_support_multidevice (GdkSurface *surface,
gboolean support_multidevice)
{
g_return_if_fail (GDK_IS_SURFACE (surface));
if (GDK_SURFACE_DESTROYED (surface))
return;
if (surface->support_multidevice == support_multidevice)
return;
surface->support_multidevice = support_multidevice;
/* FIXME: What to do if called when some pointers are inside the surface ? */
}
/**
* gdk_surface_get_support_multidevice:
* @surface: a #GdkSurface.
*
* Returns %TRUE if the surface is aware of the existence of multiple
* devices.
*
* Returns: %TRUE if the surface handles multidevice features.
**/
gboolean
gdk_surface_get_support_multidevice (GdkSurface *surface)
{
g_return_val_if_fail (GDK_IS_SURFACE (surface), FALSE);
if (GDK_SURFACE_DESTROYED (surface))
return FALSE;
return surface->support_multidevice;
}
void
_gdk_display_set_surface_under_pointer (GdkDisplay *display,
GdkDevice *device,
@ -2292,13 +2245,6 @@ _gdk_windowing_got_event (GdkDisplay *display,
}
_gdk_display_device_grab_update (display, device, source_device, serial);
if (!_gdk_display_check_grab_ownership (display, device, serial))
{
/* Device events are blocked by another device grab */
unlink_event = TRUE;
goto out;
}
}
event_surface = gdk_event_get_surface (event);
@ -2321,7 +2267,6 @@ _gdk_windowing_got_event (GdkDisplay *display,
_gdk_display_add_device_grab (display,
device,
event_surface,
GDK_OWNERSHIP_NONE,
FALSE,
GDK_ALL_EVENTS_MASK,
serial,
@ -3002,11 +2947,9 @@ gdk_surface_get_seat_from_event (GdkSurface *surface,
{
if (event)
{
GdkDevice *device = gdk_event_get_device (event);
GdkSeat *seat = NULL;
if (device)
seat = gdk_device_get_seat (device);
seat = gdk_event_get_seat (event);
if (seat)
return seat;

View File

@ -213,12 +213,6 @@ void gdk_surface_freeze_updates (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_thaw_updates (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_support_multidevice (GdkSurface *surface,
gboolean support_multidevice);
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_get_support_multidevice (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GdkFrameClock* gdk_surface_get_frame_clock (GdkSurface *surface);

View File

@ -70,7 +70,6 @@ struct _GdkSurface
guint destroyed : 2;
guint support_multidevice : 1;
guint in_update : 1;
guint frame_clock_events_paused : 1;
guint autohide : 1;

View File

@ -178,8 +178,6 @@ struct _GdkWaylandTabletData
GdkDevice *logical_device;
GdkDevice *stylus_device;
GdkDevice *eraser_device;
GdkDevice *current_device;
GdkSeat *seat;
GdkWaylandPointerData pointer_info;
@ -350,8 +348,7 @@ gdk_wayland_seat_find_tablet (GdkWaylandSeat *seat,
GdkWaylandTabletData *tablet = l->data;
if (tablet->logical_device == device ||
tablet->stylus_device == device ||
tablet->eraser_device == device)
tablet->stylus_device == device)
return tablet;
}
@ -2738,20 +2735,6 @@ gesture_pinch_end (void *data,
0, 0, 1, 0);
}
static GdkDevice *
tablet_select_device_for_tool (GdkWaylandTabletData *tablet,
GdkDeviceTool *tool)
{
GdkDevice *device;
if (gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER)
device = tablet->eraser_device;
else
device = tablet->stylus_device;
return device;
}
static void
_gdk_wayland_seat_remove_tool (GdkWaylandSeat *seat,
GdkWaylandTabletToolData *tool)
@ -2772,7 +2755,6 @@ _gdk_wayland_seat_remove_tablet (GdkWaylandSeat *seat,
seat->tablets = g_list_remove (seat->tablets, tablet);
gdk_seat_device_removed (GDK_SEAT (seat), tablet->stylus_device);
gdk_seat_device_removed (GDK_SEAT (seat), tablet->eraser_device);
gdk_seat_device_removed (GDK_SEAT (seat), tablet->logical_device);
while (tablet->pads)
@ -2787,7 +2769,6 @@ _gdk_wayland_seat_remove_tablet (GdkWaylandSeat *seat,
_gdk_device_set_associated_device (tablet->logical_device, NULL);
_gdk_device_set_associated_device (tablet->stylus_device, NULL);
_gdk_device_set_associated_device (tablet->eraser_device, NULL);
if (tablet->pointer_info.focus)
g_object_unref (tablet->pointer_info.focus);
@ -2798,7 +2779,6 @@ _gdk_wayland_seat_remove_tablet (GdkWaylandSeat *seat,
wl_surface_destroy (tablet->pointer_info.pointer_surface);
g_object_unref (tablet->logical_device);
g_object_unref (tablet->stylus_device);
g_object_unref (tablet->eraser_device);
g_free (tablet);
}
@ -2872,8 +2852,8 @@ tablet_handle_done (void *data,
GdkWaylandTabletData *tablet = data;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
GdkDisplay *display = gdk_seat_get_display (GDK_SEAT (seat));
GdkDevice *logical_device, *stylus_device, *eraser_device;
gchar *logical_name, *eraser_name;
GdkDevice *logical_device, *stylus_device;
gchar *logical_name;
gchar *vid, *pid;
vid = g_strdup_printf ("%.4x", tablet->vid);
@ -2890,8 +2870,6 @@ tablet_handle_done (void *data,
NULL);
GDK_WAYLAND_DEVICE (logical_device)->pointer = &tablet->pointer_info;
eraser_name = g_strconcat (tablet->name, " (Eraser)", NULL);
stylus_device = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
"name", tablet->name,
"type", GDK_DEVICE_TYPE_PHYSICAL,
@ -2903,32 +2881,17 @@ tablet_handle_done (void *data,
"product-id", pid,
NULL);
eraser_device = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
"name", eraser_name,
"type", GDK_DEVICE_TYPE_PHYSICAL,
"source", GDK_SOURCE_ERASER,
"has-cursor", FALSE,
"display", display,
"seat", seat,
"vendor-id", vid,
"product-id", pid,
NULL);
tablet->logical_device = logical_device;
init_pointer_data (&tablet->pointer_info, display, tablet->logical_device);
tablet->stylus_device = stylus_device;
tablet->eraser_device = eraser_device;
_gdk_device_set_associated_device (logical_device, seat->logical_keyboard);
_gdk_device_set_associated_device (stylus_device, logical_device);
_gdk_device_set_associated_device (eraser_device, logical_device);
gdk_seat_device_added (GDK_SEAT (seat), logical_device);
gdk_seat_device_added (GDK_SEAT (seat), stylus_device);
gdk_seat_device_added (GDK_SEAT (seat), eraser_device);
g_free (eraser_name);
g_free (logical_name);
g_free (vid);
g_free (pid);
@ -3383,45 +3346,45 @@ gdk_wayland_device_tablet_clone_tool_axes (GdkWaylandTabletData *tablet,
{
gint axis_pos;
g_object_freeze_notify (G_OBJECT (tablet->current_device));
_gdk_device_reset_axes (tablet->current_device);
g_object_freeze_notify (G_OBJECT (tablet->stylus_device));
_gdk_device_reset_axes (tablet->stylus_device);
_gdk_device_add_axis (tablet->current_device, GDK_AXIS_X, 0, 0, 0);
_gdk_device_add_axis (tablet->current_device, GDK_AXIS_Y, 0, 0, 0);
_gdk_device_add_axis (tablet->stylus_device, GDK_AXIS_X, 0, 0, 0);
_gdk_device_add_axis (tablet->stylus_device, GDK_AXIS_Y, 0, 0, 0);
if (tool->tool_axes & (GDK_AXIS_FLAG_XTILT | GDK_AXIS_FLAG_YTILT))
{
axis_pos = _gdk_device_add_axis (tablet->current_device,
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
GDK_AXIS_XTILT, -90, 90, 0);
tablet->axis_indices[GDK_AXIS_XTILT] = axis_pos;
axis_pos = _gdk_device_add_axis (tablet->current_device,
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
GDK_AXIS_YTILT, -90, 90, 0);
tablet->axis_indices[GDK_AXIS_YTILT] = axis_pos;
}
if (tool->tool_axes & GDK_AXIS_FLAG_DISTANCE)
{
axis_pos = _gdk_device_add_axis (tablet->current_device,
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
GDK_AXIS_DISTANCE, 0, 65535, 0);
tablet->axis_indices[GDK_AXIS_DISTANCE] = axis_pos;
}
if (tool->tool_axes & GDK_AXIS_FLAG_PRESSURE)
{
axis_pos = _gdk_device_add_axis (tablet->current_device,
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
GDK_AXIS_PRESSURE, 0, 65535, 0);
tablet->axis_indices[GDK_AXIS_PRESSURE] = axis_pos;
}
if (tool->tool_axes & GDK_AXIS_FLAG_ROTATION)
{
axis_pos = _gdk_device_add_axis (tablet->current_device,
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
GDK_AXIS_ROTATION, 0, 360, 0);
tablet->axis_indices[GDK_AXIS_ROTATION] = axis_pos;
}
if (tool->tool_axes & GDK_AXIS_FLAG_SLIDER)
{
axis_pos = _gdk_device_add_axis (tablet->current_device,
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
GDK_AXIS_SLIDER, -65535, 65535, 0);
tablet->axis_indices[GDK_AXIS_SLIDER] = axis_pos;
}
@ -3430,9 +3393,9 @@ gdk_wayland_device_tablet_clone_tool_axes (GdkWaylandTabletData *tablet,
g_free (tablet->axes);
tablet->axes =
g_new0 (gdouble, gdk_device_get_n_axes (tablet->current_device));
g_new0 (gdouble, gdk_device_get_n_axes (tablet->stylus_device));
g_object_thaw_notify (G_OBJECT (tablet->current_device));
g_object_thaw_notify (G_OBJECT (tablet->stylus_device));
}
static void
@ -3485,16 +3448,15 @@ tablet_tool_handle_proximity_in (void *data,
tablet->pointer_info.enter_serial = serial;
tablet->pointer_info.focus = g_object_ref (surface);
tablet->current_device = tablet_select_device_for_tool (tablet, tool->tool);
gdk_device_update_tool (tablet->current_device, tool->tool);
gdk_device_update_tool (tablet->stylus_device, tool->tool);
gdk_wayland_device_tablet_clone_tool_axes (tablet, tool->tool);
gdk_wayland_mimic_device_axes (tablet->logical_device, tablet->current_device);
gdk_wayland_mimic_device_axes (tablet->logical_device, tablet->stylus_device);
event = gdk_proximity_event_new (GDK_PROXIMITY_IN,
tablet->pointer_info.focus,
tablet->logical_device,
tablet->current_device,
tablet->stylus_device,
tool->tool,
tablet->pointer_info.time);
gdk_wayland_tablet_set_frame_event (tablet, event);
@ -3525,7 +3487,7 @@ tablet_tool_handle_proximity_out (void *data,
event = gdk_proximity_event_new (GDK_PROXIMITY_OUT,
tablet->pointer_info.focus,
tablet->logical_device,
tablet->current_device,
tablet->stylus_device,
tool->tool,
tablet->pointer_info.time);
gdk_wayland_tablet_set_frame_event (tablet, event);
@ -3540,7 +3502,7 @@ tablet_tool_handle_proximity_out (void *data,
g_object_unref (tablet->pointer_info.focus);
tablet->pointer_info.focus = NULL;
gdk_device_update_tool (tablet->current_device, NULL);
gdk_device_update_tool (tablet->stylus_device, NULL);
g_clear_object (&tablet->pointer_info.cursor);
}
@ -3548,7 +3510,7 @@ static double *
tablet_copy_axes (GdkWaylandTabletData *tablet)
{
return g_memdup (tablet->axes,
sizeof (gdouble) * gdk_device_get_n_axes (tablet->current_device));
sizeof (gdouble) * gdk_device_get_n_axes (tablet->stylus_device));
}
static void
@ -3562,7 +3524,7 @@ tablet_create_button_event_frame (GdkWaylandTabletData *tablet,
event = gdk_button_event_new (evtype,
tablet->pointer_info.focus,
tablet->logical_device,
tablet->current_device,
tablet->stylus_device,
tablet->current_tool->tool,
tablet->pointer_info.time,
device_get_modifiers (seat->logical_pointer),
@ -3627,7 +3589,7 @@ tablet_tool_handle_motion (void *data,
event = gdk_motion_event_new (tablet->pointer_info.focus,
tablet->logical_device,
tablet->current_device,
tablet->stylus_device,
tool->tool,
tablet->pointer_info.time,
device_get_modifiers (tablet->logical_device),
@ -3647,7 +3609,7 @@ tablet_tool_handle_pressure (void *data,
GdkWaylandTabletData *tablet = tool->current_tablet;
gint axis_index = tablet->axis_indices[GDK_AXIS_PRESSURE];
_gdk_device_translate_axis (tablet->current_device, axis_index,
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
pressure, &tablet->axes[axis_index]);
GDK_SEAT_NOTE (tool->seat, EVENTS,
@ -3664,7 +3626,7 @@ tablet_tool_handle_distance (void *data,
GdkWaylandTabletData *tablet = tool->current_tablet;
gint axis_index = tablet->axis_indices[GDK_AXIS_DISTANCE];
_gdk_device_translate_axis (tablet->current_device, axis_index,
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
distance, &tablet->axes[axis_index]);
GDK_SEAT_NOTE (tool->seat, EVENTS,
@ -3683,10 +3645,10 @@ tablet_tool_handle_tilt (void *data,
gint xtilt_axis_index = tablet->axis_indices[GDK_AXIS_XTILT];
gint ytilt_axis_index = tablet->axis_indices[GDK_AXIS_YTILT];
_gdk_device_translate_axis (tablet->current_device, xtilt_axis_index,
_gdk_device_translate_axis (tablet->stylus_device, xtilt_axis_index,
wl_fixed_to_double (xtilt),
&tablet->axes[xtilt_axis_index]);
_gdk_device_translate_axis (tablet->current_device, ytilt_axis_index,
_gdk_device_translate_axis (tablet->stylus_device, ytilt_axis_index,
wl_fixed_to_double (ytilt),
&tablet->axes[ytilt_axis_index]);
@ -3741,7 +3703,7 @@ tablet_tool_handle_rotation (void *data,
GdkWaylandTabletData *tablet = tool->current_tablet;
gint axis_index = tablet->axis_indices[GDK_AXIS_ROTATION];
_gdk_device_translate_axis (tablet->current_device, axis_index,
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
wl_fixed_to_double (degrees),
&tablet->axes[axis_index]);
@ -3760,7 +3722,7 @@ tablet_tool_handle_slider (void *data,
GdkWaylandTabletData *tablet = tool->current_tablet;
gint axis_index = tablet->axis_indices[GDK_AXIS_SLIDER];
_gdk_device_translate_axis (tablet->current_device, axis_index,
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
position, &tablet->axes[axis_index]);
GDK_SEAT_NOTE (tool->seat, EVENTS,
@ -3789,7 +3751,7 @@ tablet_tool_handle_wheel (void *data,
/* Send smooth event */
event = gdk_scroll_event_new (tablet->pointer_info.focus,
tablet->logical_device,
tablet->current_device,
tablet->stylus_device,
tablet->current_tool->tool,
tablet->pointer_info.time,
device_get_modifiers (tablet->logical_device),
@ -3801,7 +3763,7 @@ tablet_tool_handle_wheel (void *data,
/* Send discrete event */
event = gdk_scroll_event_new_discrete (tablet->pointer_info.focus,
tablet->logical_device,
tablet->current_device,
tablet->stylus_device,
tablet->current_tool->tool,
tablet->pointer_info.time,
device_get_modifiers (tablet->logical_device),
@ -4620,7 +4582,6 @@ gdk_wayland_seat_grab (GdkSeat *seat,
_gdk_display_add_device_grab (display,
wayland_seat->logical_pointer,
surface,
GDK_OWNERSHIP_NONE,
owner_events,
GDK_ALL_EVENTS_MASK,
_gdk_display_get_next_serial (display),
@ -4641,7 +4602,6 @@ gdk_wayland_seat_grab (GdkSeat *seat,
_gdk_display_add_device_grab (display,
wayland_seat->logical_touch,
surface,
GDK_OWNERSHIP_NONE,
owner_events,
GDK_ALL_EVENTS_MASK,
_gdk_display_get_next_serial (display),
@ -4658,7 +4618,6 @@ gdk_wayland_seat_grab (GdkSeat *seat,
_gdk_display_add_device_grab (display,
wayland_seat->logical_keyboard,
surface,
GDK_OWNERSHIP_NONE,
owner_events,
GDK_ALL_EVENTS_MASK,
_gdk_display_get_next_serial (display),
@ -4684,7 +4643,6 @@ gdk_wayland_seat_grab (GdkSeat *seat,
_gdk_display_add_device_grab (display,
tablet->logical_device,
surface,
GDK_OWNERSHIP_NONE,
owner_events,
GDK_ALL_EVENTS_MASK,
_gdk_display_get_next_serial (display),
@ -4792,7 +4750,6 @@ gdk_wayland_seat_get_physical_devices (GdkSeat *seat,
GdkWaylandTabletData *tablet = l->data;
physical_devices = g_list_prepend (physical_devices, tablet->stylus_device);
physical_devices = g_list_prepend (physical_devices, tablet->eraser_device);
}
}
@ -4810,32 +4767,6 @@ gdk_wayland_seat_get_physical_devices (GdkSeat *seat,
return physical_devices;
}
static GList *
gdk_wayland_seat_get_logical_pointers (GdkSeat *seat,
GdkSeatCapabilities capabilities)
{
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
GList *logical_devices = NULL;
if (capabilities & GDK_SEAT_CAPABILITY_POINTER)
logical_devices = g_list_prepend (logical_devices, wayland_seat->logical_pointer);
if (capabilities & GDK_SEAT_CAPABILITY_TOUCH)
logical_devices = g_list_prepend (logical_devices, wayland_seat->logical_touch);
if (capabilities & GDK_SEAT_CAPABILITY_TABLET_STYLUS)
{
GList *l;
for (l = wayland_seat->tablets; l; l = l->next)
{
GdkWaylandTabletData *tablet = l->data;
logical_devices = g_list_prepend (logical_devices, tablet->logical_device);
}
}
return logical_devices;
}
static void
gdk_wayland_seat_class_init (GdkWaylandSeatClass *klass)
{
@ -4849,7 +4780,6 @@ gdk_wayland_seat_class_init (GdkWaylandSeatClass *klass)
seat_class->ungrab = gdk_wayland_seat_ungrab;
seat_class->get_logical_device = gdk_wayland_seat_get_logical_device;
seat_class->get_physical_devices = gdk_wayland_seat_get_physical_devices;
seat_class->get_logical_pointers = gdk_wayland_seat_get_logical_pointers;
}
static void
@ -4956,10 +4886,9 @@ _gdk_wayland_display_remove_seat (GdkWaylandDisplay *display_wayland,
}
uint32_t
_gdk_wayland_device_get_implicit_grab_serial (GdkWaylandDevice *device,
GdkEvent *event)
_gdk_wayland_seat_get_implicit_grab_serial (GdkSeat *seat,
GdkEvent *event)
{
GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (device));
GdkEventSequence *sequence = NULL;
GdkWaylandTouchData *touch = NULL;
@ -4983,7 +4912,7 @@ _gdk_wayland_device_get_implicit_grab_serial (GdkWaylandDevice *device,
{
GdkWaylandTabletData *tablet = l->data;
if (tablet->current_device == source)
if (tablet->stylus_device == source)
return tablet->pointer_info.press_serial;
}
}
@ -5144,7 +5073,7 @@ gdk_wayland_seat_get_wl_seat (GdkSeat *seat)
* will return %NULL.
*
* This is most notably implemented for devices of type
* %GDK_SOURCE_PEN, %GDK_SOURCE_ERASER and %GDK_SOURCE_TABLET_PAD.
* %GDK_SOURCE_PEN, %GDK_SOURCE_TABLET_PAD.
*
* Returns: the /dev/input/event* path of this device
**/

View File

@ -134,8 +134,8 @@ void _gdk_wayland_display_remove_seat (GdkWaylandDisplay *displa
guint32 id);
GdkKeymap *_gdk_wayland_device_get_keymap (GdkDevice *device);
uint32_t _gdk_wayland_device_get_implicit_grab_serial(GdkWaylandDevice *device,
GdkEvent *event);
uint32_t _gdk_wayland_seat_get_implicit_grab_serial(GdkSeat *seat,
GdkEvent *event);
uint32_t _gdk_wayland_seat_get_last_implicit_grab_serial (GdkWaylandSeat *seat,
GdkEventSequence **seqence);
struct wl_data_device * gdk_wayland_device_get_data_device (GdkDevice *gdk_device);

View File

@ -3830,8 +3830,8 @@ gdk_wayland_surface_show_window_menu (GdkSurface *surface,
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GdkWaylandDisplay *display_wayland =
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
struct wl_seat *seat;
GdkWaylandDevice *device;
GdkSeat *seat;
struct wl_seat *wl_seat;
double x, y;
uint32_t serial;
@ -3850,21 +3850,21 @@ gdk_wayland_surface_show_window_menu (GdkSurface *surface,
if (!is_realized_toplevel (surface))
return FALSE;
device = GDK_WAYLAND_DEVICE (gdk_event_get_device (event));
seat = gdk_wayland_device_get_wl_seat (GDK_DEVICE (device));
seat = gdk_event_get_seat (event);
wl_seat = gdk_wayland_seat_get_wl_seat (seat);
gdk_event_get_position (event, &x, &y);
serial = _gdk_wayland_device_get_implicit_grab_serial (device, event);
serial = _gdk_wayland_seat_get_implicit_grab_serial (seat, event);
switch (display_wayland->shell_variant)
{
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
xdg_toplevel_show_window_menu (impl->display_server.xdg_toplevel,
seat, serial, x, y);
wl_seat, serial, x, y);
break;
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
zxdg_toplevel_v6_show_window_menu (impl->display_server.zxdg_toplevel_v6,
seat, serial, x, y);
wl_seat, serial, x, y);
break;
default:
g_assert_not_reached ();

View File

@ -2048,7 +2048,7 @@ gdk_win32_drag_set_cursor (GdkDrag *drag,
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gdk_device_grab (gdk_seat_get_pointer (drag_win32->grab_seat),
drag_win32->grab_surface,
GDK_OWNERSHIP_APPLICATION, FALSE,
FALSE,
GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
cursor, GDK_CURRENT_TIME);
G_GNUC_END_IGNORE_DEPRECATIONS;

View File

@ -3762,7 +3762,7 @@ setup_drag_move_resize_context (GdkSurface *window,
* This is why we first do the grab, *then* set the op.
*/
gdk_device_grab (device, pointer_window,
GDK_OWNERSHIP_NONE, FALSE,
FALSE,
GDK_ALL_EVENTS_MASK,
context->cursor,
timestamp);

View File

@ -489,14 +489,13 @@ create_device (GdkX11DeviceManagerXI2 *device_manager,
tmp_name = g_ascii_strdown (dev->name, -1);
if (strstr (tmp_name, "eraser"))
input_source = GDK_SOURCE_ERASER;
else if (strstr (tmp_name, "cursor"))
if (strstr (tmp_name, "cursor"))
input_source = GDK_SOURCE_CURSOR;
else if (strstr (tmp_name, " pad"))
input_source = GDK_SOURCE_TABLET_PAD;
else if (strstr (tmp_name, "wacom") ||
strstr (tmp_name, "pen"))
strstr (tmp_name, "pen") ||
strstr (tmp_name, "eraser"))
input_source = GDK_SOURCE_PEN;
else if (!strstr (tmp_name, "mouse") &&
!strstr (tmp_name, "pointer") &&

View File

@ -2077,7 +2077,7 @@ gdk_x11_drag_set_cursor (GdkDrag *drag,
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gdk_device_grab (gdk_seat_get_pointer (x11_drag->grab_seat),
x11_drag->ipc_surface,
GDK_OWNERSHIP_APPLICATION, FALSE,
FALSE,
GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
cursor, GDK_CURRENT_TIME);
G_GNUC_END_IGNORE_DEPRECATIONS;

View File

@ -152,9 +152,8 @@ static void
handle_touch_synthetic_crossing (GdkEvent *event)
{
GdkEventType evtype = gdk_event_get_event_type (event);
GdkDevice *device = gdk_event_get_device (event);
GdkEvent *crossing = NULL;
GdkSeat *seat = gdk_device_get_seat (device);
GdkSeat *seat = gdk_event_get_seat (event);
gboolean needs_enter, set_needs_enter = FALSE;
if (quark_needs_enter == 0)
@ -208,7 +207,7 @@ handle_touch_synthetic_crossing (GdkEvent *event)
if (crossing)
{
gdk_display_put_event (gdk_device_get_display (device), crossing);
gdk_display_put_event (gdk_seat_get_display (seat), crossing);
gdk_event_unref (crossing);
}
}

View File

@ -140,8 +140,6 @@ static void gtk_button_finish_activate (GtkButton *button,
static void gtk_button_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
static void gtk_button_grab_notify (GtkWidget *widget,
gboolean was_grabbed);
static void gtk_button_do_release (GtkButton *button,
gboolean emit_clicked);
static void gtk_button_set_child_type (GtkButton *button, guint child_type);
@ -212,7 +210,6 @@ gtk_button_class_init (GtkButtonClass *klass)
widget_class->unrealize = gtk_button_unrealize;
widget_class->state_flags_changed = gtk_button_state_flags_changed;
widget_class->grab_notify = gtk_button_grab_notify;
widget_class->unmap = gtk_button_unmap;
widget_class->compute_expand = gtk_button_compute_expand;
widget_class->get_request_mode = gtk_button_get_request_mode;
@ -369,6 +366,11 @@ click_gesture_cancel_cb (GtkGesture *gesture,
GdkEventSequence *sequence,
GtkButton *button)
{
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
if (priv->activate_timeout)
gtk_button_finish_activate (button, FALSE);
gtk_button_do_release (button, FALSE);
}
@ -935,22 +937,6 @@ gtk_button_state_flags_changed (GtkWidget *widget,
gtk_button_do_release (button, FALSE);
}
static void
gtk_button_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
{
GtkButton *button = GTK_BUTTON (widget);
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
GTK_WIDGET_CLASS (gtk_button_parent_class)->grab_notify (widget, was_grabbed);
if (was_grabbed && priv->activate_timeout)
gtk_button_finish_activate (button, FALSE);
if (!was_grabbed)
gtk_button_do_release (button, FALSE);
}
/**
* gtk_button_set_icon_name:
* @button: A #GtkButton

View File

@ -1663,6 +1663,25 @@ handle_key_event (GdkEvent *event)
return focus_widget ? focus_widget : event_widget;
}
static gboolean
is_transient_for (GtkWindow *child,
GtkWindow *parent)
{
GtkWindow *transient_for;
transient_for = gtk_window_get_transient_for (child);
while (transient_for)
{
if (transient_for == parent)
return TRUE;
transient_for = gtk_window_get_transient_for (transient_for);
}
return FALSE;
}
void
gtk_main_do_event (GdkEvent *event)
{
@ -1726,11 +1745,16 @@ gtk_main_do_event (GdkEvent *event)
/* If the grab widget is an ancestor of the event widget
* then we send the event to the original event widget.
* This is the key to implementing modality.
* This is the key to implementing modality. This also applies
* across windows that are directly or indirectly transient-for
* the modal one.
*/
if (!grab_widget ||
((gtk_widget_is_sensitive (target_widget) || gdk_event_get_event_type (event) == GDK_SCROLL) &&
gtk_widget_is_ancestor (target_widget, grab_widget)))
gtk_widget_is_ancestor (target_widget, grab_widget)) ||
(GTK_IS_WINDOW (grab_widget) &&
grab_widget != event_widget &&
is_transient_for (GTK_WINDOW (event_widget), GTK_WINDOW (grab_widget))))
grab_widget = target_widget;
g_object_ref (target_widget);
@ -1835,165 +1859,17 @@ gtk_main_get_window_group (GtkWidget *widget)
return gtk_window_get_group (NULL);
}
typedef struct
{
GtkWidget *old_grab_widget;
GtkWidget *new_grab_widget;
gboolean was_grabbed;
gboolean is_grabbed;
gboolean from_grab;
GList *notified_surfaces;
GdkDevice *device;
} GrabNotifyInfo;
static void
synth_crossing_for_grab_notify (GtkWidget *from,
GtkWidget *to,
GrabNotifyInfo *info,
GdkDevice **devices,
guint n_devices,
GdkCrossingMode mode)
{
guint i;
for (i = 0; i < n_devices; i++)
{
GdkDevice *device = devices[i];
GdkSurface *from_surface, *to_surface;
/* Do not propagate events more than once to
* the same surfaces if non-multidevice aware.
*/
if (!from)
from_surface = NULL;
else
{
from_surface = _gtk_widget_get_device_surface (from, device);
if (from_surface &&
!gdk_surface_get_support_multidevice (from_surface) &&
g_list_find (info->notified_surfaces, from_surface))
from_surface = NULL;
}
if (!to)
to_surface = NULL;
else
{
to_surface = _gtk_widget_get_device_surface (to, device);
if (to_surface &&
!gdk_surface_get_support_multidevice (to_surface) &&
g_list_find (info->notified_surfaces, to_surface))
to_surface = NULL;
}
if (from_surface || to_surface)
{
_gtk_widget_synthesize_crossing ((from_surface) ? from : NULL,
(to_surface) ? to : NULL,
device, mode);
if (from_surface)
info->notified_surfaces = g_list_prepend (info->notified_surfaces, from_surface);
if (to_surface)
info->notified_surfaces = g_list_prepend (info->notified_surfaces, to_surface);
}
}
}
static void
gtk_grab_notify_foreach (GtkWidget *child,
gpointer data)
{
GrabNotifyInfo *info = data;
gboolean was_grabbed, is_grabbed, was_shadowed, is_shadowed;
GdkDevice **devices;
guint n_devices;
was_grabbed = info->was_grabbed;
is_grabbed = info->is_grabbed;
info->was_grabbed = info->was_grabbed || (child == info->old_grab_widget);
info->is_grabbed = info->is_grabbed || (child == info->new_grab_widget);
was_shadowed = info->old_grab_widget && !info->was_grabbed;
is_shadowed = info->new_grab_widget && !info->is_grabbed;
g_object_ref (child);
if (was_shadowed || is_shadowed)
{
GtkWidget *p;
for (p = _gtk_widget_get_first_child (child);
p != NULL;
p = _gtk_widget_get_next_sibling (p))
{
gtk_grab_notify_foreach (p, info);
}
}
if (info->device &&
_gtk_widget_get_device_surface (child, info->device))
{
/* Device specified and is on widget */
devices = g_new (GdkDevice *, 1);
devices[0] = info->device;
n_devices = 1;
}
else
devices = _gtk_widget_list_devices (child, &n_devices);
if (is_shadowed)
{
_gtk_widget_set_shadowed (child, TRUE);
if (!was_shadowed && devices &&
gtk_widget_is_sensitive (child))
synth_crossing_for_grab_notify (child, info->new_grab_widget,
info, devices, n_devices,
GDK_CROSSING_GTK_GRAB);
}
else
{
_gtk_widget_set_shadowed (child, FALSE);
if (was_shadowed && devices &&
gtk_widget_is_sensitive (child))
synth_crossing_for_grab_notify (info->old_grab_widget, child,
info, devices, n_devices,
info->from_grab ? GDK_CROSSING_GTK_GRAB :
GDK_CROSSING_GTK_UNGRAB);
}
if (was_shadowed != is_shadowed)
_gtk_widget_grab_notify (child, was_shadowed);
g_object_unref (child);
g_free (devices);
info->was_grabbed = was_grabbed;
info->is_grabbed = is_grabbed;
}
static void
gtk_grab_notify (GtkWindowGroup *group,
GdkDevice *device,
GtkWidget *old_grab_widget,
GtkWidget *new_grab_widget,
gboolean from_grab)
{
GList *toplevels;
GrabNotifyInfo info = { 0 };
if (old_grab_widget == new_grab_widget)
return;
info.old_grab_widget = old_grab_widget;
info.new_grab_widget = new_grab_widget;
info.from_grab = from_grab;
info.device = device;
g_object_ref (group);
toplevels = gtk_window_list_toplevels ();
@ -2004,15 +1880,13 @@ gtk_grab_notify (GtkWindowGroup *group,
GtkWindow *toplevel = toplevels->data;
toplevels = g_list_delete_link (toplevels, toplevels);
info.was_grabbed = FALSE;
info.is_grabbed = FALSE;
if (group == gtk_window_get_group (toplevel))
gtk_grab_notify_foreach (GTK_WIDGET (toplevel), &info);
gtk_window_grab_notify (toplevel,
old_grab_widget,
new_grab_widget,
from_grab);
g_object_unref (toplevel);
}
g_list_free (info.notified_surfaces);
g_object_unref (group);
}
@ -2048,7 +1922,7 @@ gtk_grab_add (GtkWidget *widget)
g_object_ref (widget);
_gtk_window_group_add_grab (group, widget);
gtk_grab_notify (group, NULL, old_grab_widget, widget, TRUE);
gtk_grab_notify (group, old_grab_widget, widget, TRUE);
}
}
@ -2078,7 +1952,7 @@ gtk_grab_remove (GtkWidget *widget)
_gtk_window_group_remove_grab (group, widget);
new_grab_widget = gtk_window_group_get_current_grab (group);
gtk_grab_notify (group, NULL, widget, new_grab_widget, FALSE);
gtk_grab_notify (group, widget, new_grab_widget, FALSE);
g_object_unref (widget);
}

View File

@ -771,8 +771,6 @@ static void gtk_notebook_motion (GtkEventController *controller,
double x,
double y,
gpointer user_data);
static void gtk_notebook_grab_notify (GtkWidget *widget,
gboolean was_grabbed);
static void gtk_notebook_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
static void gtk_notebook_direction_changed (GtkWidget *widget,
@ -911,7 +909,9 @@ static void gtk_notebook_gesture_released (GtkGestureClick *gesture,
double x,
double y,
gpointer user_data);
static void gtk_notebook_gesture_cancel (GtkGestureClick *gesture,
GdkEventSequence *sequence,
GtkNotebook *notebook);
static guint notebook_signals[LAST_SIGNAL] = { 0 };
@ -1029,7 +1029,6 @@ gtk_notebook_class_init (GtkNotebookClass *class)
gobject_class->dispose = gtk_notebook_dispose;
widget_class->unmap = gtk_notebook_unmap;
widget_class->grab_notify = gtk_notebook_grab_notify;
widget_class->state_flags_changed = gtk_notebook_state_flags_changed;
widget_class->direction_changed = gtk_notebook_direction_changed;
widget_class->focus = gtk_notebook_focus;
@ -1435,6 +1434,7 @@ gtk_notebook_init (GtkNotebook *notebook)
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_CAPTURE);
g_signal_connect (gesture, "pressed", G_CALLBACK (gtk_notebook_gesture_pressed), notebook);
g_signal_connect (gesture, "released", G_CALLBACK (gtk_notebook_gesture_released), notebook);
g_signal_connect (gesture, "cancel", G_CALLBACK (gtk_notebook_gesture_cancel), notebook);
gtk_widget_add_controller (GTK_WIDGET (notebook), GTK_EVENT_CONTROLLER (gesture));
controller = gtk_event_controller_motion_new ();
@ -2752,6 +2752,15 @@ gtk_notebook_gesture_released (GtkGestureClick *gesture,
stop_scrolling (notebook);
}
static void
gtk_notebook_gesture_cancel (GtkGestureClick *gesture,
GdkEventSequence *sequence,
GtkNotebook *notebook)
{
gtk_notebook_stop_reorder (notebook);
stop_scrolling (notebook);
}
static GtkNotebookPointerPosition
get_pointer_position (GtkNotebook *notebook)
{
@ -2954,21 +2963,6 @@ gtk_notebook_motion (GtkEventController *controller,
gtk_widget_queue_allocate (notebook->tabs_widget);
}
static void
gtk_notebook_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GTK_WIDGET_CLASS (gtk_notebook_parent_class)->grab_notify (widget, was_grabbed);
if (!was_grabbed)
{
gtk_notebook_stop_reorder (notebook);
stop_scrolling (notebook);
}
}
static void
update_arrow_state (GtkNotebook *notebook)
{

View File

@ -1395,15 +1395,6 @@ print_callback_new (void)
return &callback->iPrintDialogCallback;
}
static void
plug_grab_notify (GtkWidget *widget,
gboolean was_grabbed,
GtkPrintOperation *op)
{
EnableWindow (GetAncestor (GDK_SURFACE_HWND (gtk_native_get_surface (gtk_widget_get_native (widget))), GA_ROOT),
was_grabbed);
}
static INT_PTR CALLBACK
pageDlgProc (HWND wnd, UINT message, WPARAM wparam, LPARAM lparam)
{
@ -1429,9 +1420,6 @@ pageDlgProc (HWND wnd, UINT message, WPARAM wparam, LPARAM lparam)
/* This dialog is modal, so we grab the embed widget */
gtk_grab_add (plug);
/* When we lose the grab we need to disable the print dialog */
g_signal_connect (plug, "grab-notify", G_CALLBACK (plug_grab_notify), op);
return FALSE;
}
else if (message == WM_DESTROY)

View File

@ -1269,7 +1269,6 @@ captured_motion (GtkEventController *controller,
indicator_set_over (&priv->vindicator, FALSE);
}
else if (input_source == GDK_SOURCE_PEN ||
input_source == GDK_SOURCE_ERASER ||
input_source == GDK_SOURCE_TRACKPOINT)
{
indicator_set_over (&priv->hindicator, TRUE);

View File

@ -273,8 +273,6 @@ static void gtk_spin_button_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gtk_spin_button_realize (GtkWidget *widget);
static void gtk_spin_button_grab_notify (GtkWidget *widget,
gboolean was_grabbed);
static void gtk_spin_button_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
static gboolean gtk_spin_button_timer (GtkSpinButton *spin_button);
@ -350,7 +348,6 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
gobject_class->get_property = gtk_spin_button_get_property;
widget_class->realize = gtk_spin_button_realize;
widget_class->grab_notify = gtk_spin_button_grab_notify;
widget_class->state_flags_changed = gtk_spin_button_state_flags_changed;
widget_class->mnemonic_activate = gtk_spin_button_mnemonic_activate;
widget_class->grab_focus = gtk_spin_button_grab_focus;
@ -1190,18 +1187,6 @@ gtk_spin_button_update_width_chars (GtkSpinButton *spin_button)
gtk_editable_set_width_chars (GTK_EDITABLE (spin_button->entry), width_chars);
}
static void
gtk_spin_button_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
{
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->grab_notify (widget, was_grabbed);
if (!was_grabbed)
gtk_spin_button_stop_spinning (spin);
}
static void
gtk_spin_button_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state)

View File

@ -3773,9 +3773,6 @@ gtk_text_view_dispose (GObject *object)
g_object_set_data (object, "gtk-emoji-chooser", NULL);
}
while ((child = gtk_widget_get_first_child (GTK_WIDGET (text_view))))
gtk_text_view_remove (text_view, child);
gtk_text_view_remove_validate_idles (text_view);
gtk_text_view_set_buffer (text_view, NULL);
gtk_text_view_destroy_layout (text_view);
@ -3801,6 +3798,9 @@ gtk_text_view_dispose (GObject *object)
g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent);
g_clear_pointer (&priv->magnifier_popover, gtk_widget_unparent);
while ((child = gtk_widget_get_first_child (GTK_WIDGET (text_view))))
gtk_text_view_remove (text_view, child);
G_OBJECT_CLASS (gtk_text_view_parent_class)->dispose (object);
}

View File

@ -2691,8 +2691,7 @@ grab_focus_and_unset_draw_keyfocus (GtkTreeView *tree_view)
GtkWidget *widget = GTK_WIDGET (tree_view);
if (gtk_widget_get_focusable (widget) &&
!gtk_widget_has_focus (widget) &&
!_gtk_widget_get_shadowed (widget))
!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
tree_view->draw_keyfocus = 0;

View File

@ -171,14 +171,14 @@ gtk_video_unmap (GtkWidget *widget)
}
static void
gtk_video_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
gtk_video_set_focus_child (GtkWidget *widget,
GtkWidget *child)
{
GtkVideo *self = GTK_VIDEO (widget);
self->grabbed = !was_grabbed;
self->grabbed = child != NULL;
GTK_WIDGET_CLASS (gtk_video_parent_class)->grab_notify (widget, was_grabbed);
GTK_WIDGET_CLASS (gtk_video_parent_class)->set_focus_child (widget, child);
}
static void
@ -268,7 +268,7 @@ gtk_video_class_init (GtkVideoClass *klass)
widget_class->unrealize = gtk_video_unrealize;
widget_class->map = gtk_video_map;
widget_class->unmap = gtk_video_unmap;
widget_class->grab_notify = gtk_video_grab_notify;
widget_class->set_focus_child = gtk_video_set_focus_child;
gobject_class->dispose = gtk_video_dispose;
gobject_class->get_property = gtk_video_get_property;

View File

@ -492,7 +492,6 @@ enum {
UNREALIZE,
STATE_FLAGS_CHANGED,
DIRECTION_CHANGED,
GRAB_NOTIFY,
MNEMONIC_ACTIVATE,
MOVE_FOCUS,
KEYNAV_FAILED,
@ -808,26 +807,28 @@ gtk_widget_real_contains (GtkWidget *widget,
&GRAPHENE_POINT_INIT (x, y));
}
static void
gtk_widget_real_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
/**
* _gtk_widget_grab_notify:
* @widget: a #GtkWidget
* @was_grabbed: whether a grab is now in effect
*
* Emits the #GtkWidget::grab-notify signal on @widget.
**/
void
_gtk_widget_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
int i;
if (!priv->controllers)
return;
if (was_grabbed)
return;
for (i = (int)priv->controllers->len - 1; i >= 0; i--)
{
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
GdkDevice *device = NULL;
if (GTK_IS_GESTURE (controller))
device = gtk_gesture_get_device (GTK_GESTURE (controller));
if (!device || !gtk_widget_device_is_shadowed (widget, device))
continue;
gtk_event_controller_reset (controller);
}
@ -923,7 +924,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->measure = gtk_widget_real_measure;
klass->state_flags_changed = gtk_widget_real_state_flags_changed;
klass->direction_changed = gtk_widget_real_direction_changed;
klass->grab_notify = gtk_widget_real_grab_notify;
klass->snapshot = gtk_widget_real_snapshot;
klass->mnemonic_activate = gtk_widget_real_mnemonic_activate;
klass->grab_focus = gtk_widget_grab_focus_self;
@ -1527,31 +1527,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
G_TYPE_NONE, 1,
GTK_TYPE_TEXT_DIRECTION);
/**
* GtkWidget::grab-notify:
* @widget: the object which received the signal
* @was_grabbed: %FALSE if the widget becomes shadowed, %TRUE
* if it becomes unshadowed
*
* The ::grab-notify signal is emitted when a widget becomes
* shadowed by a GTK+ grab (not a pointer or keyboard grab) on
* another widget, or when it becomes unshadowed due to a grab
* being removed.
*
* A widget is shadowed by a gtk_grab_add() when the topmost
* grab widget in the grab stack of its window group is not
* its ancestor.
*/
widget_signals[GRAB_NOTIFY] =
g_signal_new (I_("grab-notify"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, grab_notify),
NULL, NULL,
NULL,
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
/**
* GtkWidget::mnemonic-activate:
* @widget: the object which received the signal.
@ -2178,8 +2153,7 @@ _gtk_widget_set_sequence_state_internal (GtkWidget *widget,
/* If a group is provided, ensure only gestures pertaining to the group
* get a "claimed" state, all other claiming gestures must deny the sequence.
*/
if (gesture_state == GTK_EVENT_SEQUENCE_CLAIMED &&
gtk_gesture_get_sequence_state (gesture, sequence) == GTK_EVENT_SEQUENCE_CLAIMED)
if (state == GTK_EVENT_SEQUENCE_CLAIMED)
gesture_state = GTK_EVENT_SEQUENCE_DENIED;
else
continue;
@ -3356,13 +3330,6 @@ gtk_widget_realize (GtkWidget *widget)
g_signal_emit (widget, widget_signals[REALIZE], 0);
if (priv->multidevice)
{
GdkSurface *surface = gtk_widget_get_surface (widget);
gdk_surface_set_support_multidevice (surface, TRUE);
}
if (priv->context)
gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
else
@ -4601,20 +4568,6 @@ gtk_widget_activate (GtkWidget *widget)
return FALSE;
}
/**
* _gtk_widget_grab_notify:
* @widget: a #GtkWidget
* @was_grabbed: whether a grab is now in effect
*
* Emits the #GtkWidget::grab-notify signal on @widget.
**/
void
_gtk_widget_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
{
g_signal_emit (widget, widget_signals[GRAB_NOTIFY], 0, was_grabbed);
}
/**
* gtk_widget_grab_focus:
* @widget: a #GtkWidget
@ -5265,48 +5218,6 @@ _gtk_widget_set_has_grab (GtkWidget *widget,
priv->has_grab = has_grab;
}
/**
* gtk_widget_device_is_shadowed:
* @widget: a #GtkWidget
* @device: a #GdkDevice
*
* Returns %TRUE if @device has been shadowed by a GTK+
* device grab on another widget, so it would stop sending
* events to @widget. This may be used in the
* #GtkWidget::grab-notify signal to check for specific
* devices. See gtk_device_grab_add().
*
* Returns: %TRUE if there is an ongoing grab on @device
* by another #GtkWidget than @widget.
**/
gboolean
gtk_widget_device_is_shadowed (GtkWidget *widget,
GdkDevice *device)
{
GtkWindowGroup *group;
GtkWidget *grab_widget;
GtkRoot *root;
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
if (!_gtk_widget_get_realized (widget))
return TRUE;
root = _gtk_widget_get_root (widget);
if (GTK_IS_WINDOW (root))
group = gtk_window_get_group (GTK_WINDOW (root));
else
group = gtk_window_get_group (NULL);
grab_widget = gtk_window_group_get_current_grab (group);
if (grab_widget && widget != grab_widget &&
!gtk_widget_is_ancestor (widget, grab_widget))
return TRUE;
return FALSE;
}
/**
* gtk_widget_set_name:
* @widget: a #GtkWidget
@ -7556,48 +7467,12 @@ gtk_widget_adjust_baseline_request (GtkWidget *widget,
}
}
static gboolean
is_my_surface (GtkWidget *widget,
GdkSurface *surface)
{
if (!surface)
return FALSE;
return gdk_surface_get_widget (surface) == widget;
}
/*
* _gtk_widget_get_device_surface:
* @widget: a #GtkWidget
* @device: a #GdkDevice
*
* Returns: (nullable): the surface of @widget that @device is in, or %NULL
*/
GdkSurface *
_gtk_widget_get_device_surface (GtkWidget *widget,
GdkDevice *device)
{
GdkSurface *surface;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
return NULL;
surface = gdk_device_get_last_event_surface (device);
if (surface && is_my_surface (widget, surface))
return surface;
else
return NULL;
}
/*
* _gtk_widget_list_devices:
* @widget: a #GtkWidget
*
* Returns the list of pointer #GdkDevices that are currently
* on top of any surface belonging to @widget. Free the list
* on top of @widget. Free the list
* with g_free(), the elements are owned by GTK+ and must
* not be freed.
*/
@ -7605,11 +7480,7 @@ GdkDevice **
_gtk_widget_list_devices (GtkWidget *widget,
guint *out_n_devices)
{
GPtrArray *result;
GdkSeat *seat;
GList *devices;
GList *l;
GdkDevice *device;
GtkRoot *root;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
g_assert (out_n_devices);
@ -7620,29 +7491,15 @@ _gtk_widget_list_devices (GtkWidget *widget,
return NULL;
}
seat = gdk_display_get_default_seat (_gtk_widget_get_display (widget));
if (!seat)
root = gtk_widget_get_root (widget);
if (!root)
{
*out_n_devices = 0;
return NULL;
}
device = gdk_seat_get_pointer (seat);
result = g_ptr_array_new ();
if (is_my_surface (widget, gdk_device_get_last_event_surface (device)))
g_ptr_array_add (result, device);
devices = gdk_seat_get_physical_devices (seat, GDK_SEAT_CAPABILITY_ALL_POINTING);
for (l = devices; l; l = l->next)
{
device = l->data;
if (is_my_surface (widget, gdk_device_get_last_event_surface (device)))
g_ptr_array_add (result, device);
}
g_list_free (devices);
*out_n_devices = result->len;
return (GdkDevice **)g_ptr_array_free (result, FALSE);
return gtk_window_get_foci_on_widget (GTK_WINDOW (root),
widget, out_n_devices);
}
/*
@ -7674,19 +7531,14 @@ _gtk_widget_synthesize_crossing (GtkWidget *from,
{
crossing.direction = GTK_CROSSING_OUT;
from_surface = _gtk_widget_get_device_surface (from, device);
if (!from_surface)
from_surface = gtk_widget_get_surface (from);
from_surface = gtk_widget_get_surface (from);
gdk_surface_get_device_position (from_surface, device, &x, &y, NULL);
gtk_widget_handle_crossing (from, &crossing, x, y);
}
if (to)
{
to_surface = _gtk_widget_get_device_surface (to, device);
if (!to_surface)
to_surface = gtk_widget_get_surface (to);
to_surface = gtk_widget_get_surface (to);
crossing.direction = GTK_CROSSING_IN;
gdk_surface_get_device_position (to_surface, device, &x, &y, NULL);
@ -7721,8 +7573,18 @@ gtk_widget_propagate_state (GtkWidget *widget,
if (old_flags != new_flags)
{
GtkWindowGroup *window_group;
GtkRoot *root;
GtkWidget *grab;
gboolean shadowed;
g_object_ref (widget);
root = gtk_widget_get_root (widget);
window_group = gtk_window_get_group (GTK_WINDOW (root));
grab = gtk_window_group_get_current_grab (window_group);
shadowed = grab && grab != widget && !gtk_widget_is_ancestor (widget, grab);
if (!gtk_widget_is_sensitive (widget) && gtk_widget_has_grab (widget))
gtk_grab_remove (widget);
@ -7730,29 +7592,19 @@ gtk_widget_propagate_state (GtkWidget *widget,
g_signal_emit (widget, widget_signals[STATE_FLAGS_CHANGED], 0, old_flags);
if (!priv->shadowed &&
if (!shadowed &&
(new_flags & GTK_STATE_FLAG_INSENSITIVE) != (old_flags & GTK_STATE_FLAG_INSENSITIVE))
{
guint i, n_devices;
GdkDevice **devices;
GList *event_surfaces = NULL;
devices = _gtk_widget_list_devices (widget, &n_devices);
for (i = 0; i < n_devices; i++)
{
GdkSurface *surface;
GdkDevice *device;
device = devices[i];
surface = _gtk_widget_get_device_surface (widget, device);
/* Do not propagate more than once to the
* same surface if non-multidevice aware.
*/
if (!gdk_surface_get_support_multidevice (surface) &&
g_list_find (event_surfaces, surface))
continue;
if (!gtk_widget_is_sensitive (widget))
_gtk_widget_synthesize_crossing (widget, NULL, device,
@ -7760,11 +7612,8 @@ gtk_widget_propagate_state (GtkWidget *widget,
else
_gtk_widget_synthesize_crossing (NULL, widget, device,
GDK_CROSSING_STATE_CHANGED);
event_surfaces = g_list_prepend (event_surfaces, surface);
}
g_list_free (event_surfaces);
g_free (devices);
}
@ -10221,54 +10070,6 @@ gtk_widget_get_allocated_baseline (GtkWidget *widget)
return priv->baseline - margin.top - border.top - padding.top;
}
/**
* gtk_widget_get_support_multidevice:
* @widget: a #GtkWidget
*
* Returns %TRUE if @widget is multiple pointer aware. See
* gtk_widget_set_support_multidevice() for more information.
*
* Returns: %TRUE if @widget is multidevice aware.
**/
gboolean
gtk_widget_get_support_multidevice (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
return priv->multidevice;
}
/**
* gtk_widget_set_support_multidevice:
* @widget: a #GtkWidget
* @support_multidevice: %TRUE to support input from multiple devices.
*
* Enables or disables multiple pointer awareness. If this setting is %TRUE,
* @widget will start receiving multiple, per device enter/leave events. Note
* that if custom #GdkSurfaces are created in #GtkWidget::realize,
* gdk_surface_set_support_multidevice() will have to be called manually on them.
**/
void
gtk_widget_set_support_multidevice (GtkWidget *widget,
gboolean support_multidevice)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
g_return_if_fail (GTK_IS_WIDGET (widget));
priv->multidevice = (support_multidevice == TRUE);
if (_gtk_widget_get_realized (widget))
{
GdkSurface *surface = gtk_widget_get_surface (widget);
if (surface)
gdk_surface_set_support_multidevice (surface, support_multidevice);
}
}
/**
* gtk_widget_set_opacity:
* @widget: a #GtkWidget
@ -10414,23 +10215,6 @@ gtk_widget_in_destruction (GtkWidget *widget)
return priv->in_destruction;
}
gboolean
_gtk_widget_get_shadowed (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
return priv->shadowed;
}
void
_gtk_widget_set_shadowed (GtkWidget *widget,
gboolean shadowed)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
priv->shadowed = shadowed;
}
gboolean
_gtk_widget_get_alloc_needed (GtkWidget *widget)
{

View File

@ -158,9 +158,6 @@ struct _GtkWidget
* see gtk_widget_get_state_flags().
* @direction_changed: Signal emitted when the text direction of a
* widget changes.
* @grab_notify: Signal emitted when a widget becomes shadowed by a
* GTK+ grab (not a pointer or keyboard grab) on another widget, or
* when it becomes unshadowed due to a grab being removed.
* @get_request_mode: This allows a widget to tell its parent container whether
* it prefers to be allocated in %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or
* %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
@ -226,8 +223,6 @@ struct _GtkWidgetClass
GtkStateFlags previous_state_flags);
void (* direction_changed) (GtkWidget *widget,
GtkTextDirection previous_direction);
void (* grab_notify) (GtkWidget *widget,
gboolean was_grabbed);
/* size requests */
GtkSizeRequestMode (* get_request_mode) (GtkWidget *widget);
@ -432,10 +427,6 @@ void gtk_widget_set_receives_default (GtkWidget *widget,
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_get_receives_default (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_device_is_shadowed (GtkWidget *widget,
GdkDevice *device);
GDK_AVAILABLE_IN_ALL
void gtk_widget_set_name (GtkWidget *widget,
@ -596,14 +587,6 @@ GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_compute_expand (GtkWidget *widget,
GtkOrientation orientation);
/* Multidevice support */
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_get_support_multidevice (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_widget_set_support_multidevice (GtkWidget *widget,
gboolean support_multidevice);
/* Accessibility support */
GDK_AVAILABLE_IN_ALL
void gtk_widget_class_set_accessible_type (GtkWidgetClass *widget_class,

View File

@ -82,9 +82,7 @@ struct _GtkWidgetPrivate
guint has_default : 1;
guint receives_default : 1;
guint has_grab : 1;
guint shadowed : 1;
guint child_visible : 1;
guint multidevice : 1;
guint can_target : 1;
/* Queue-resize related flags */
@ -222,9 +220,6 @@ void gtk_widget_unroot (GtkWidget *widget);
GtkCssNode * gtk_widget_get_css_node (GtkWidget *widget);
void _gtk_widget_set_visible_flag (GtkWidget *widget,
gboolean visible);
gboolean _gtk_widget_get_shadowed (GtkWidget *widget);
void _gtk_widget_set_shadowed (GtkWidget *widget,
gboolean shadowed);
gboolean _gtk_widget_get_alloc_needed (GtkWidget *widget);
gboolean gtk_widget_needs_allocate (GtkWidget *widget);
void gtk_widget_ensure_resize (GtkWidget *widget);
@ -258,8 +253,6 @@ void _gtk_widget_propagate_display_changed (GtkWidget *widget,
void _gtk_widget_set_device_surface (GtkWidget *widget,
GdkDevice *device,
GdkSurface *pointer_window);
GdkSurface * _gtk_widget_get_device_surface (GtkWidget *widget,
GdkDevice *device);
GdkDevice ** _gtk_widget_list_devices (GtkWidget *widget,
guint *out_n_devices);

View File

@ -7195,3 +7195,130 @@ gtk_window_destroy (GtkWindow *window)
g_object_unref (window);
}
GdkDevice**
gtk_window_get_foci_on_widget (GtkWindow *window,
GtkWidget *widget,
guint *n_devices)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GPtrArray *array = g_ptr_array_new ();
GList *l;
for (l = priv->foci; l; l = l->next)
{
GtkPointerFocus *focus = l->data;
GtkWidget *target;
target = gtk_pointer_focus_get_effective_target (focus);
if (target == widget || gtk_widget_is_ancestor (target, widget))
g_ptr_array_add (array, focus->device);
}
if (n_devices)
*n_devices = array->len;
return (GdkDevice**) g_ptr_array_free (array, FALSE);
}
static void
gtk_grab_notify_foreach (GtkWidget *child,
GdkDevice *device,
GtkWidget *new_grab_widget,
GtkWidget *old_grab_widget,
gboolean from_grab,
gboolean was_shadowed,
gboolean is_shadowed)
{
g_object_ref (child);
if (is_shadowed)
{
if (!was_shadowed &&
gtk_widget_is_sensitive (child))
_gtk_widget_synthesize_crossing (child,
new_grab_widget,
device,
GDK_CROSSING_GTK_GRAB);
}
else
{
if (was_shadowed &&
gtk_widget_is_sensitive (child))
_gtk_widget_synthesize_crossing (old_grab_widget, child,
device,
from_grab ? GDK_CROSSING_GTK_GRAB :
GDK_CROSSING_GTK_UNGRAB);
}
_gtk_widget_grab_notify (child, was_shadowed);
g_object_unref (child);
}
static void
gtk_window_propagate_grab_notify (GtkWindow *window,
GtkWidget *target,
GdkDevice *device,
GtkWidget *old_grab_widget,
GtkWidget *new_grab_widget,
gboolean from_grab)
{
GList *l, *widgets = NULL;
gboolean was_grabbed = FALSE, is_grabbed = FALSE;
while (target)
{
widgets = g_list_prepend (widgets, g_object_ref (target));
target = gtk_widget_get_parent (target);
}
widgets = g_list_reverse (widgets);
for (l = widgets; l; l = l->next)
{
gboolean was_shadowed, is_shadowed;
was_grabbed |= (l->data == old_grab_widget);
is_grabbed |= (l->data == new_grab_widget);
was_shadowed = old_grab_widget && !was_grabbed;
is_shadowed = new_grab_widget && is_grabbed;
if (was_shadowed == is_shadowed)
break;
gtk_grab_notify_foreach (l->data,
device,
old_grab_widget,
new_grab_widget,
from_grab,
was_shadowed,
is_shadowed);
}
g_list_free_full (widgets, g_object_unref);
}
void
gtk_window_grab_notify (GtkWindow *window,
GtkWidget *old_grab_widget,
GtkWidget *new_grab_widget,
gboolean from_grab)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GList *l;
for (l = priv->foci; l; l = l->next)
{
GtkPointerFocus *focus = l->data;
gtk_window_propagate_grab_notify (window,
gtk_pointer_focus_get_effective_target (focus),
focus->device,
old_grab_widget,
new_grab_widget,
from_grab);
}
}

View File

@ -328,13 +328,11 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
GdkEventSequence *sequence;
GdkEvent *event;
guint button;
GtkRoot *root;
widget = GTK_WIDGET (self);
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
root = gtk_widget_get_root (widget);
if (!event)
return;
@ -355,9 +353,8 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
if (n_press == 2)
perform_titlebar_action (self, event, button, n_press);
if (gtk_widget_has_grab (GTK_WIDGET (root)))
gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
sequence, GTK_EVENT_SEQUENCE_CLAIMED);
gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
sequence, GTK_EVENT_SEQUENCE_CLAIMED);
break;
case GDK_BUTTON_SECONDARY:
@ -420,7 +417,6 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
* widget from doing anything.
*/
if (event_widget != GTK_WIDGET (self) &&
!gtk_widget_has_grab (event_widget) &&
gtk_widget_consumes_motion (event_widget, GTK_WIDGET (self), sequence))
{
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);

View File

@ -124,6 +124,13 @@ GtkWidget * gtk_window_pick_popover (GtkWindow *window,
double x,
double y,
GtkPickFlags flags);
GdkDevice** gtk_window_get_foci_on_widget (GtkWindow *window,
GtkWidget *widget,
guint *n_devices);
void gtk_window_grab_notify (GtkWindow *window,
GtkWidget *old_grab_widget,
GtkWidget *new_grab_widget,
gboolean from_grab);
G_END_DECLS