mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 07:04:29 +00:00
Drop device grabs
We were not using this api at all, so lets drop it.
This commit is contained in:
parent
d60097f8fe
commit
0ffb35c9e7
@ -4369,7 +4369,6 @@ gtk_window_group_add_window
|
||||
gtk_window_group_remove_window
|
||||
gtk_window_group_list_windows
|
||||
gtk_window_group_get_current_grab
|
||||
gtk_window_group_get_current_device_grab
|
||||
<SUBSECTION Standard>
|
||||
GTK_IS_WINDOW_GROUP
|
||||
GTK_IS_WINDOW_GROUP_CLASS
|
||||
@ -4395,8 +4394,6 @@ gtk_init_check
|
||||
gtk_grab_add
|
||||
gtk_grab_get_current
|
||||
gtk_grab_remove
|
||||
gtk_device_grab_add
|
||||
gtk_device_grab_remove
|
||||
|
||||
<SUBSECTION>
|
||||
GTK_PRIORITY_RESIZE
|
||||
|
@ -1657,7 +1657,6 @@ gtk_main_do_event (GdkEvent *event)
|
||||
GtkWidget *grab_widget = NULL;
|
||||
GtkWindowGroup *window_group;
|
||||
GdkEvent *rewritten_event = NULL;
|
||||
GdkDevice *device;
|
||||
GList *tmp_list;
|
||||
|
||||
if (gtk_inspector_handle_event (event))
|
||||
@ -1712,14 +1711,9 @@ gtk_main_do_event (GdkEvent *event)
|
||||
goto cleanup;
|
||||
|
||||
window_group = gtk_main_get_window_group (target_widget);
|
||||
device = gdk_event_get_device (event);
|
||||
|
||||
/* check whether there is a (device) grab in effect... */
|
||||
if (device)
|
||||
grab_widget = gtk_window_group_get_current_device_grab (window_group, device);
|
||||
|
||||
if (!grab_widget)
|
||||
grab_widget = gtk_window_group_get_current_grab (window_group);
|
||||
/* check whether there is a grab in effect... */
|
||||
grab_widget = gtk_window_group_get_current_grab (window_group);
|
||||
|
||||
/* If the grab widget is an ancestor of the event widget
|
||||
* then we send the event to the original event widget.
|
||||
@ -1738,13 +1732,6 @@ gtk_main_do_event (GdkEvent *event)
|
||||
if (check_event_in_child_popover (target_widget, grab_widget))
|
||||
grab_widget = target_widget;
|
||||
|
||||
/* If the widget receiving events is actually blocked by another
|
||||
* device GTK grab
|
||||
*/
|
||||
if (device &&
|
||||
_gtk_window_group_widget_is_blocked_for_device (window_group, grab_widget, device))
|
||||
goto cleanup;
|
||||
|
||||
/* Not all events get sent to the grabbing widget.
|
||||
* The delete, destroy, expose, focus change and resize
|
||||
* events still get sent to the event widget because
|
||||
@ -2108,64 +2095,6 @@ gtk_grab_remove (GtkWidget *widget)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_device_grab_add:
|
||||
* @widget: a #GtkWidget
|
||||
* @device: a #GdkDevice to grab on.
|
||||
* @block_others: %TRUE to prevent other devices to interact with @widget.
|
||||
*
|
||||
* Adds a GTK grab on @device, so all the events on @device and its
|
||||
* associated pointer or keyboard (if any) are delivered to @widget.
|
||||
* If the @block_others parameter is %TRUE, any other devices will be
|
||||
* unable to interact with @widget during the grab.
|
||||
*/
|
||||
void
|
||||
gtk_device_grab_add (GtkWidget *widget,
|
||||
GdkDevice *device,
|
||||
gboolean block_others)
|
||||
{
|
||||
GtkWindowGroup *group;
|
||||
GtkWidget *old_grab_widget;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
g_return_if_fail (GDK_IS_DEVICE (device));
|
||||
|
||||
group = gtk_main_get_window_group (widget);
|
||||
old_grab_widget = gtk_window_group_get_current_device_grab (group, device);
|
||||
|
||||
if (old_grab_widget != widget)
|
||||
_gtk_window_group_add_device_grab (group, widget, device, block_others);
|
||||
|
||||
gtk_grab_notify (group, device, old_grab_widget, widget, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_device_grab_remove:
|
||||
* @widget: a #GtkWidget
|
||||
* @device: a #GdkDevice
|
||||
*
|
||||
* Removes a device grab from the given widget.
|
||||
*
|
||||
* You have to pair calls to gtk_device_grab_add() and
|
||||
* gtk_device_grab_remove().
|
||||
*/
|
||||
void
|
||||
gtk_device_grab_remove (GtkWidget *widget,
|
||||
GdkDevice *device)
|
||||
{
|
||||
GtkWindowGroup *group;
|
||||
GtkWidget *new_grab_widget;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
g_return_if_fail (GDK_IS_DEVICE (device));
|
||||
|
||||
group = gtk_main_get_window_group (widget);
|
||||
_gtk_window_group_remove_device_grab (group, widget, device);
|
||||
new_grab_widget = gtk_window_group_get_current_device_grab (group, device);
|
||||
|
||||
gtk_grab_notify (group, device, widget, new_grab_widget, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_get_current_event:
|
||||
*
|
||||
@ -2408,20 +2337,15 @@ gtk_propagate_event (GtkWidget *widget,
|
||||
{
|
||||
GtkWindowGroup *window_group;
|
||||
GtkWidget *event_widget, *topmost = NULL;
|
||||
GdkDevice *device;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||||
g_return_val_if_fail (event != NULL, FALSE);
|
||||
|
||||
event_widget = gtk_get_event_widget (event);
|
||||
window_group = gtk_main_get_window_group (event_widget);
|
||||
device = gdk_event_get_device (event);
|
||||
|
||||
/* check whether there is a (device) grab in effect... */
|
||||
if (device)
|
||||
topmost = gtk_window_group_get_current_device_grab (window_group, device);
|
||||
if (!topmost)
|
||||
topmost = gtk_window_group_get_current_grab (window_group);
|
||||
/* check whether there is a grab in effect... */
|
||||
topmost = gtk_window_group_get_current_grab (window_group);
|
||||
|
||||
return gtk_propagate_event_internal (widget, event, topmost);
|
||||
}
|
||||
|
@ -114,14 +114,6 @@ GtkWidget* gtk_grab_get_current (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_grab_remove (GtkWidget *widget);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_device_grab_add (GtkWidget *widget,
|
||||
GdkDevice *device,
|
||||
gboolean block_others);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_device_grab_remove (GtkWidget *widget,
|
||||
GdkDevice *device);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkEvent * gtk_get_current_event (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -5526,7 +5526,6 @@ gtk_widget_device_is_shadowed (GtkWidget *widget,
|
||||
GtkRoot *root;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
|
||||
|
||||
if (!_gtk_widget_get_realized (widget))
|
||||
return TRUE;
|
||||
@ -5538,14 +5537,6 @@ gtk_widget_device_is_shadowed (GtkWidget *widget,
|
||||
else
|
||||
group = gtk_window_get_group (NULL);
|
||||
|
||||
grab_widget = gtk_window_group_get_current_device_grab (group, device);
|
||||
|
||||
/* Widget not inside the hierarchy of grab_widget */
|
||||
if (grab_widget &&
|
||||
widget != grab_widget &&
|
||||
!gtk_widget_is_ancestor (widget, grab_widget))
|
||||
return TRUE;
|
||||
|
||||
grab_widget = gtk_window_group_get_current_grab (group);
|
||||
if (grab_widget && widget != grab_widget &&
|
||||
!gtk_widget_is_ancestor (widget, grab_widget))
|
||||
|
@ -9494,10 +9494,8 @@ gtk_window_maybe_update_cursor (GtkWindow *window,
|
||||
continue;
|
||||
|
||||
group = gtk_window_get_group (window);
|
||||
grab_widget = gtk_window_group_get_current_device_grab (group,
|
||||
focus->device);
|
||||
if (!grab_widget)
|
||||
grab_widget = gtk_window_group_get_current_grab (group);
|
||||
|
||||
grab_widget = gtk_window_group_get_current_grab (group);
|
||||
if (!grab_widget)
|
||||
grab_widget = gtk_pointer_focus_get_implicit_grab (focus);
|
||||
|
||||
|
@ -62,7 +62,6 @@ struct _GtkDeviceGrabInfo
|
||||
struct _GtkWindowGroupPrivate
|
||||
{
|
||||
GSList *grabs;
|
||||
GSList *device_grabs;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkWindowGroup, gtk_window_group, G_TYPE_OBJECT)
|
||||
@ -98,7 +97,6 @@ window_group_cleanup_grabs (GtkWindowGroup *group,
|
||||
GtkWindow *window)
|
||||
{
|
||||
GtkWindowGroupPrivate *priv;
|
||||
GtkDeviceGrabInfo *info;
|
||||
GSList *tmp_list;
|
||||
GSList *to_remove = NULL;
|
||||
|
||||
@ -118,26 +116,6 @@ window_group_cleanup_grabs (GtkWindowGroup *group,
|
||||
g_object_unref (to_remove->data);
|
||||
to_remove = g_slist_delete_link (to_remove, to_remove);
|
||||
}
|
||||
|
||||
tmp_list = priv->device_grabs;
|
||||
|
||||
while (tmp_list)
|
||||
{
|
||||
info = tmp_list->data;
|
||||
|
||||
if (gtk_widget_get_root (info->widget) == (GtkRoot *) window)
|
||||
to_remove = g_slist_prepend (to_remove, info);
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
while (to_remove)
|
||||
{
|
||||
info = to_remove->data;
|
||||
|
||||
gtk_device_grab_remove (info->widget, info->device);
|
||||
to_remove = g_slist_delete_link (to_remove, to_remove);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -289,133 +267,3 @@ _gtk_window_group_remove_grab (GtkWindowGroup *window_group,
|
||||
priv = window_group->priv;
|
||||
priv->grabs = g_slist_remove (priv->grabs, widget);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
|
||||
GtkWidget *widget,
|
||||
GdkDevice *device,
|
||||
gboolean block_others)
|
||||
{
|
||||
GtkWindowGroupPrivate *priv;
|
||||
GtkDeviceGrabInfo *info;
|
||||
|
||||
priv = window_group->priv;
|
||||
|
||||
info = g_slice_new0 (GtkDeviceGrabInfo);
|
||||
info->widget = widget;
|
||||
info->device = device;
|
||||
info->block_others = block_others;
|
||||
|
||||
priv->device_grabs = g_slist_prepend (priv->device_grabs, info);
|
||||
|
||||
revoke_implicit_grabs (window_group, device, widget);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_window_group_remove_device_grab (GtkWindowGroup *window_group,
|
||||
GtkWidget *widget,
|
||||
GdkDevice *device)
|
||||
{
|
||||
GtkWindowGroupPrivate *priv;
|
||||
GtkDeviceGrabInfo *info;
|
||||
GSList *list, *node = NULL;
|
||||
GdkDevice *other_device;
|
||||
|
||||
priv = window_group->priv;
|
||||
other_device = gdk_device_get_associated_device (device);
|
||||
list = priv->device_grabs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
info = list->data;
|
||||
|
||||
if (info->widget == widget &&
|
||||
(info->device == device ||
|
||||
info->device == other_device))
|
||||
{
|
||||
node = list;
|
||||
break;
|
||||
}
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
if (node)
|
||||
{
|
||||
info = node->data;
|
||||
|
||||
priv->device_grabs = g_slist_delete_link (priv->device_grabs, node);
|
||||
g_slice_free (GtkDeviceGrabInfo, info);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_group_get_current_device_grab:
|
||||
* @window_group: a #GtkWindowGroup
|
||||
* @device: a #GdkDevice
|
||||
*
|
||||
* Returns the current grab widget for @device, or %NULL if none.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): The grab widget, or %NULL
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_window_group_get_current_device_grab (GtkWindowGroup *window_group,
|
||||
GdkDevice *device)
|
||||
{
|
||||
GtkWindowGroupPrivate *priv;
|
||||
GtkDeviceGrabInfo *info;
|
||||
GdkDevice *other_device;
|
||||
GSList *list;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WINDOW_GROUP (window_group), NULL);
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
||||
|
||||
priv = window_group->priv;
|
||||
list = priv->device_grabs;
|
||||
other_device = gdk_device_get_associated_device (device);
|
||||
|
||||
while (list)
|
||||
{
|
||||
info = list->data;
|
||||
list = list->next;
|
||||
|
||||
if (info->device == device ||
|
||||
info->device == other_device)
|
||||
return info->widget;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *window_group,
|
||||
GtkWidget *widget,
|
||||
GdkDevice *device)
|
||||
{
|
||||
GtkWindowGroupPrivate *priv;
|
||||
GtkDeviceGrabInfo *info;
|
||||
GdkDevice *other_device;
|
||||
GSList *list;
|
||||
|
||||
priv = window_group->priv;
|
||||
other_device = gdk_device_get_associated_device (device);
|
||||
list = priv->device_grabs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
info = list->data;
|
||||
list = list->next;
|
||||
|
||||
/* Look for blocking grabs on other device pairs
|
||||
* that have the passed widget within the GTK+ grab.
|
||||
*/
|
||||
if (info->block_others &&
|
||||
info->device != device &&
|
||||
info->device != other_device &&
|
||||
(info->widget == widget ||
|
||||
gtk_widget_is_ancestor (widget, info->widget)))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -78,9 +78,6 @@ GList * gtk_window_group_list_windows (GtkWindowGroup *window_grou
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_window_group_get_current_grab (GtkWindowGroup *window_group);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_window_group_get_current_device_grab (GtkWindowGroup *window_group,
|
||||
GdkDevice *device);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
Loading…
Reference in New Issue
Block a user