mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
Don't use gdk_{pointer,keyboard}_grab
Instead use gdk_device_grab.
This commit is contained in:
parent
1d41b98cf8
commit
bde1d072e5
52
gtk/gtkhsv.c
52
gtk/gtkhsv.c
@ -669,21 +669,24 @@ compute_v (GtkHSV *hsv,
|
||||
/* Event handlers */
|
||||
|
||||
static void
|
||||
set_cross_grab (GtkHSV *hsv,
|
||||
guint32 time)
|
||||
set_cross_grab (GtkHSV *hsv,
|
||||
GdkDevice *device,
|
||||
guint32 time)
|
||||
{
|
||||
GtkHSVPrivate *priv = hsv->priv;
|
||||
GdkCursor *cursor;
|
||||
|
||||
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (hsv)),
|
||||
GDK_CROSSHAIR);
|
||||
gdk_pointer_grab (priv->window, FALSE,
|
||||
(GDK_POINTER_MOTION_MASK
|
||||
| GDK_POINTER_MOTION_HINT_MASK
|
||||
| GDK_BUTTON_RELEASE_MASK),
|
||||
NULL,
|
||||
cursor,
|
||||
time);
|
||||
gdk_device_grab (device,
|
||||
priv->window,
|
||||
GDK_OWNERSHIP_NONE,
|
||||
FALSE,
|
||||
GDK_POINTER_MOTION_MASK
|
||||
| GDK_POINTER_MOTION_HINT_MASK
|
||||
| GDK_BUTTON_RELEASE_MASK,
|
||||
cursor,
|
||||
time);
|
||||
g_object_unref (cursor);
|
||||
}
|
||||
|
||||
@ -709,15 +712,15 @@ gtk_hsv_button_press (GtkWidget *widget,
|
||||
|
||||
if (priv->mode != DRAG_NONE || event->button != 1)
|
||||
return FALSE;
|
||||
|
||||
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
|
||||
|
||||
if (is_in_ring (hsv, x, y))
|
||||
{
|
||||
priv->mode = DRAG_H;
|
||||
set_cross_grab (hsv, event->time);
|
||||
|
||||
set_cross_grab (hsv, gdk_event_get_device (event), event->time);
|
||||
|
||||
gtk_hsv_set_color (hsv,
|
||||
compute_v (hsv, x, y),
|
||||
priv->s,
|
||||
@ -725,26 +728,26 @@ gtk_hsv_button_press (GtkWidget *widget,
|
||||
|
||||
gtk_widget_grab_focus (widget);
|
||||
priv->focus_on_ring = TRUE;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
if (is_in_triangle (hsv, x, y))
|
||||
{
|
||||
gdouble s, v;
|
||||
|
||||
|
||||
priv->mode = DRAG_SV;
|
||||
set_cross_grab (hsv, event->time);
|
||||
|
||||
set_cross_grab (hsv, gdk_event_get_device (event), event->time);
|
||||
|
||||
compute_sv (hsv, x, y, &s, &v);
|
||||
gtk_hsv_set_color (hsv, priv->h, s, v);
|
||||
|
||||
gtk_widget_grab_focus (widget);
|
||||
priv->focus_on_ring = FALSE;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -759,14 +762,13 @@ gtk_hsv_button_release (GtkWidget *widget,
|
||||
|
||||
if (priv->mode == DRAG_NONE || event->button != 1)
|
||||
return FALSE;
|
||||
|
||||
|
||||
/* Set the drag mode to DRAG_NONE so that signal handlers for "catched"
|
||||
* can see that this is the final color state.
|
||||
*/
|
||||
|
||||
mode = priv->mode;
|
||||
priv->mode = DRAG_NONE;
|
||||
|
||||
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
|
||||
@ -786,8 +788,8 @@ gtk_hsv_button_release (GtkWidget *widget,
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
gdk_display_pointer_ungrab (gdk_window_get_display (event->window),
|
||||
event->time);
|
||||
gdk_device_ungrab (gdk_event_get_device (event), event->time);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -3282,14 +3282,18 @@ gtk_tree_view_button_press (GtkWidget *widget,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (gdk_pointer_grab (_gtk_tree_view_column_get_window (column), FALSE,
|
||||
GDK_POINTER_MOTION_HINT_MASK |
|
||||
GDK_BUTTON1_MOTION_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK,
|
||||
NULL, NULL, event->time))
|
||||
return FALSE;
|
||||
if (gdk_device_grab (gdk_event_get_device ((GdkEvent*)event),
|
||||
_gtk_tree_view_column_get_window (column),
|
||||
GDK_OWNERSHIP_NONE,
|
||||
FALSE,
|
||||
GDK_POINTER_MOTION_HINT_MASK
|
||||
| GDK_BUTTON1_MOTION_MASK
|
||||
| GDK_BUTTON_RELEASE_MASK,
|
||||
NULL,
|
||||
event->time) != GDK_GRAB_SUCCESS)
|
||||
return FALSE;
|
||||
|
||||
gtk_grab_add (widget);
|
||||
gtk_grab_add (widget);
|
||||
tree_view->priv->in_column_resize = TRUE;
|
||||
|
||||
_gtk_tree_view_column_set_resized_width (column, gtk_tree_view_column_get_width (column) -
|
||||
@ -3326,12 +3330,15 @@ gtk_tree_view_button_release_drag_column (GtkWidget *widget,
|
||||
GtkWidget *button;
|
||||
GList *l;
|
||||
gboolean rtl;
|
||||
GdkDevice *device, *other;
|
||||
|
||||
tree_view = GTK_TREE_VIEW (widget);
|
||||
|
||||
rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
|
||||
gdk_display_pointer_ungrab (gtk_widget_get_display (widget), GDK_CURRENT_TIME);
|
||||
gdk_display_keyboard_ungrab (gtk_widget_get_display (widget), GDK_CURRENT_TIME);
|
||||
device = gdk_event_get_device ((GdkEvent*)event);
|
||||
other = gdk_device_get_associated_device (device);
|
||||
gdk_device_ungrab (device, event->time);
|
||||
gdk_device_ungrab (other, event->time);
|
||||
|
||||
/* Move the button back */
|
||||
button = gtk_tree_view_column_get_button (tree_view->priv->drag_column);
|
||||
@ -3406,8 +3413,7 @@ gtk_tree_view_button_release_column_resize (GtkWidget *widget,
|
||||
|
||||
tree_view->priv->in_column_resize = FALSE;
|
||||
gtk_grab_remove (widget);
|
||||
gdk_display_pointer_ungrab (gdk_window_get_display (event->window),
|
||||
event->time);
|
||||
gdk_device_ungrab (gdk_event_get_device ((GdkEvent*)event), event->time);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -9713,6 +9719,7 @@ _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
|
||||
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (tree_view));
|
||||
GdkDisplay *display = gdk_screen_get_display (screen);
|
||||
GtkWidget *button;
|
||||
GdkDevice *pointer, *keyboard;
|
||||
|
||||
g_return_if_fail (tree_view->priv->column_drag_info == NULL);
|
||||
g_return_if_fail (tree_view->priv->cur_reorder == NULL);
|
||||
@ -9801,13 +9808,31 @@ _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
|
||||
gtk_main_iteration ();
|
||||
|
||||
tree_view->priv->in_column_drag = TRUE;
|
||||
gdk_pointer_grab (tree_view->priv->drag_window,
|
||||
FALSE,
|
||||
GDK_POINTER_MOTION_MASK|GDK_BUTTON_RELEASE_MASK,
|
||||
NULL, NULL, GDK_CURRENT_TIME);
|
||||
gdk_keyboard_grab (tree_view->priv->drag_window,
|
||||
FALSE,
|
||||
GDK_CURRENT_TIME);
|
||||
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
||||
{
|
||||
keyboard = device;
|
||||
pointer = gdk_device_get_associated_device (device);
|
||||
}
|
||||
else
|
||||
{
|
||||
pointer = device;
|
||||
keyboard = gdk_device_get_associated_device (device);
|
||||
}
|
||||
|
||||
gdk_device_grab (pointer,
|
||||
tree_view->priv->drag_window,
|
||||
GDK_OWNERSHIP_NONE,
|
||||
FALSE,
|
||||
GDK_POINTER_MOTION_MASK|GDK_BUTTON_RELEASE_MASK,
|
||||
NULL,
|
||||
GDK_CURRENT_TIME);
|
||||
gdk_device_grab (keyboard,
|
||||
tree_view->priv->drag_window,
|
||||
GDK_OWNERSHIP_NONE,
|
||||
FALSE,
|
||||
GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK,
|
||||
NULL,
|
||||
GDK_CURRENT_TIME);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -6935,23 +6935,27 @@ shape_pressed (GtkWidget *widget, GdkEventButton *event)
|
||||
p->y = (int) event->y;
|
||||
|
||||
gtk_grab_add (widget);
|
||||
gdk_pointer_grab (gtk_widget_get_window (widget), TRUE,
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_BUTTON_MOTION_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK,
|
||||
NULL, NULL, 0);
|
||||
gdk_device_grab (gdk_event_get_device ((GdkEvent*)event),
|
||||
gtk_widget_get_window (widget),
|
||||
GDK_OWNERSHIP_NONE,
|
||||
TRUE,
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_BUTTON_MOTION_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK,
|
||||
NULL,
|
||||
event->time);
|
||||
}
|
||||
|
||||
static void
|
||||
shape_released (GtkWidget *widget)
|
||||
shape_released (GtkWidget *widget,
|
||||
GdkEventButton *event)
|
||||
{
|
||||
gtk_grab_remove (widget);
|
||||
gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
|
||||
GDK_CURRENT_TIME);
|
||||
gdk_device_ungrab (gdk_event_get_device ((GdkEvent*)event), event->time);
|
||||
}
|
||||
|
||||
static void
|
||||
shape_motion (GtkWidget *widget,
|
||||
shape_motion (GtkWidget *widget,
|
||||
GdkEventMotion *event)
|
||||
{
|
||||
gint xp, yp;
|
||||
@ -8640,21 +8644,20 @@ destroy_properties (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static gint
|
||||
property_query_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
struct PropertiesData *data)
|
||||
property_query_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
struct PropertiesData *data)
|
||||
{
|
||||
GtkWidget *res_widget = NULL;
|
||||
|
||||
if (!data->in_query)
|
||||
return FALSE;
|
||||
|
||||
|
||||
if (event->type == GDK_BUTTON_RELEASE)
|
||||
{
|
||||
gtk_grab_remove (widget);
|
||||
gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
|
||||
GDK_CURRENT_TIME);
|
||||
|
||||
gdk_device_ungrab (gdk_event_get_device (event), GDK_CURRENT_TIME);
|
||||
|
||||
res_widget = find_widget_at_pointer (gtk_widget_get_display (widget));
|
||||
if (res_widget)
|
||||
{
|
||||
@ -8674,23 +8677,27 @@ query_properties (GtkButton *button,
|
||||
struct PropertiesData *data)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (button);
|
||||
gint failure;
|
||||
GdkDisplay *display;
|
||||
GdkDeviceManager *device_manager;
|
||||
GdkDevice *device;
|
||||
|
||||
g_signal_connect (button, "event",
|
||||
G_CALLBACK (property_query_event), data);
|
||||
|
||||
display = gtk_widget_get_display (widget);
|
||||
|
||||
if (!data->cursor)
|
||||
data->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
|
||||
GDK_TARGET);
|
||||
|
||||
failure = gdk_pointer_grab (gtk_widget_get_window (widget),
|
||||
TRUE,
|
||||
GDK_BUTTON_RELEASE_MASK,
|
||||
NULL,
|
||||
data->cursor,
|
||||
GDK_CURRENT_TIME);
|
||||
data->cursor = gdk_cursor_new_for_display (display, GDK_TARGET);
|
||||
|
||||
device_manager = gdk_display_get_device_manager (display);
|
||||
device = gdk_device_manager_get_client_pointer (device_manager);
|
||||
gdk_device_grab (device,
|
||||
gtk_widget_get_window (widget),
|
||||
GDK_OWNERSHIP_NONE,
|
||||
TRUE,
|
||||
GDK_BUTTON_RELEASE_MASK,
|
||||
data->cursor,
|
||||
GDK_CURRENT_TIME);
|
||||
gtk_grab_add (widget);
|
||||
|
||||
data->in_query = TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user