Merge branch 'wip/carlosg/deprecations' into 'main'

Some deprecations and cleanups

See merge request GNOME/gtk!5465
This commit is contained in:
Matthias Clasen 2023-02-02 14:11:58 +00:00
commit 294b659dc1
10 changed files with 92 additions and 66 deletions

View File

@ -832,6 +832,8 @@ gdk_wayland_display_get_next_serial (GdkDisplay *display)
* if no ID has been defined.
*
* Returns: (nullable): the startup notification ID for @display
*
* Deprecated: 4.10.
*/
const char *
gdk_wayland_display_get_startup_notification_id (GdkDisplay *display)
@ -853,6 +855,8 @@ gdk_wayland_display_get_startup_notification_id (GdkDisplay *display)
* The startup ID is also what is used to signal that the startup is
* complete (for example, when opening a window or when calling
* [method@Gdk.Display.notify_startup_complete]).
*
* Deprecated: 4.10. Use [method@Gdk.Toplevel.set_startup_id]
*/
void
gdk_wayland_display_set_startup_notification_id (GdkDisplay *display,
@ -981,7 +985,9 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
display_class->queue_events = _gdk_wayland_display_queue_events;
display_class->get_app_launch_context = _gdk_wayland_display_get_app_launch_context;
display_class->get_next_serial = gdk_wayland_display_get_next_serial;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
display_class->get_startup_notification_id = gdk_wayland_display_get_startup_notification_id;
G_GNUC_END_IGNORE_DEPRECATIONS
display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete;
display_class->create_surface = _gdk_wayland_display_create_surface;
display_class->get_keymap = _gdk_wayland_display_get_keymap;

View File

@ -53,9 +53,9 @@ GDK_AVAILABLE_IN_ALL
void gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
const char *name,
int size);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
const char * gdk_wayland_display_get_startup_notification_id (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10_FOR(gdk_toplevel_set_startup_id)
void gdk_wayland_display_set_startup_notification_id (GdkDisplay *display,
const char *startup_id);

View File

@ -108,7 +108,9 @@ gtk_application_impl_wayland_before_emit (GtkApplicationImpl *impl,
if (!startup_notification_id)
g_variant_lookup (platform_data, "desktop-startup-id", "&s", &startup_notification_id);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gdk_wayland_display_set_startup_notification_id (gdk_display_get_default (), startup_notification_id);
G_GNUC_END_IGNORE_DEPRECATIONS
}
static guint

View File

@ -69,7 +69,7 @@
*
* Within a widget, gestures can be grouped through [method@Gtk.Gesture.group].
* Grouped gestures synchronize the state of sequences, so calling
* [method@Gtk.Gesture.set_sequence_state] on one will effectively propagate
* [method@Gtk.Gesture.set_state] on one will effectively propagate
* the state throughout the group.
*
* By default, all sequences start out in the %GTK_EVENT_SEQUENCE_NONE state,
@ -99,7 +99,7 @@
* again.
*
* Sequence states can't be changed freely.
* See [method@Gtk.Gesture.set_sequence_state] to know about the possible
* See [method@Gtk.Gesture.set_state] to know about the possible
* lifetimes of a `GdkEventSequence`.
*
* ## Touchpad gestures
@ -519,7 +519,9 @@ _gtk_gesture_update_point (GtkGesture *gesture,
else
state = gtk_gesture_get_group_state (gesture, sequence);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_gesture_set_sequence_state (gesture, sequence, state);
G_GNUC_END_IGNORE_DEPRECATIONS
}
return TRUE;
@ -1017,6 +1019,8 @@ gtk_gesture_get_sequence_state (GtkGesture *gesture,
*
* Returns: %TRUE if @sequence is handled by @gesture,
* and the state is changed successfully
*
* Deprecated: 4.10. Use [method@Gtk.Gesture.set_state]
*/
gboolean
gtk_gesture_set_sequence_state (GtkGesture *gesture,
@ -1069,8 +1073,46 @@ gtk_gesture_set_sequence_state (GtkGesture *gesture,
* Sets the state of all sequences that @gesture is currently
* interacting with.
*
* See [method@Gtk.Gesture.set_sequence_state] for more details
* on sequence states.
* Sequences start in state %GTK_EVENT_SEQUENCE_NONE, and whenever
* they change state, they can never go back to that state. Likewise,
* sequences in state %GTK_EVENT_SEQUENCE_DENIED cannot turn back to
* a not denied state. With these rules, the lifetime of an event
* sequence is constrained to the next four:
*
* * None
* * None Denied
* * None Claimed
* * None Claimed Denied
*
* Note: Due to event handling ordering, it may be unsafe to set the
* state on another gesture within a [signal@Gtk.Gesture::begin] signal
* handler, as the callback might be executed before the other gesture
* knows about the sequence. A safe way to perform this could be:
*
* ```c
* static void
* first_gesture_begin_cb (GtkGesture *first_gesture,
* GdkEventSequence *sequence,
* gpointer user_data)
* {
* gtk_gesture_set_state (first_gesture, GTK_EVENT_SEQUENCE_CLAIMED);
* gtk_gesture_set_state (second_gesture, GTK_EVENT_SEQUENCE_DENIED);
* }
*
* static void
* second_gesture_begin_cb (GtkGesture *second_gesture,
* GdkEventSequence *sequence,
* gpointer user_data)
* {
* if (gtk_gesture_get_sequence_state (first_gesture, sequence) == GTK_EVENT_SEQUENCE_CLAIMED)
* gtk_gesture_set_state (second_gesture, GTK_EVENT_SEQUENCE_DENIED);
* }
* ```
*
* If both gestures are in the same group, just set the state on
* the gesture emitting the event, the sequence will be already
* be initialized to the group's global state when the second
* gesture processes the event.
*
* Returns: %TRUE if the state of at least one sequence
* was changed successfully
@ -1090,8 +1132,10 @@ gtk_gesture_set_state (GtkGesture *gesture,
priv = gtk_gesture_get_instance_private (gesture);
sequences = g_hash_table_get_keys (priv->points);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
for (l = sequences; l; l = l->next)
handled |= gtk_gesture_set_sequence_state (gesture, l->data, state);
G_GNUC_END_IGNORE_DEPRECATIONS
g_list_free (sequences);

View File

@ -51,7 +51,7 @@ GDK_AVAILABLE_IN_ALL
GtkEventSequenceState
gtk_gesture_get_sequence_state (GtkGesture *gesture,
GdkEventSequence *sequence);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
gboolean gtk_gesture_set_sequence_state (GtkGesture *gesture,
GdkEventSequence *sequence,
GtkEventSequenceState state);

View File

@ -1441,13 +1441,10 @@ gesture_pressed (GtkGestureClick *gesture,
double y,
GtkWidget *widget)
{
GdkEventSequence *sequence;
if (gtk_widget_get_focus_on_click (widget) && !gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
gtk_gesture_set_sequence_state (GTK_GESTURE (gesture), sequence, GTK_EVENT_SEQUENCE_CLAIMED);
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
}
static void

View File

@ -273,7 +273,6 @@ typedef struct
double drag_start_y;
guint kinetic_scrolling : 1;
guint in_drag : 1;
guint deceleration_id;
@ -906,7 +905,6 @@ scrolled_window_drag_begin_cb (GtkScrolledWindow *scrolled_window,
GdkEventSequence *sequence;
GtkWidget *event_widget;
priv->in_drag = FALSE;
priv->drag_start_x = priv->unclamped_hadj_value;
priv->drag_start_y = priv->unclamped_vadj_value;
gtk_scrolled_window_cancel_deceleration (scrolled_window);
@ -915,7 +913,7 @@ scrolled_window_drag_begin_cb (GtkScrolledWindow *scrolled_window,
if (event_widget == priv->vscrollbar || event_widget == priv->hscrollbar ||
(!may_hscroll (scrolled_window) && !may_vscroll (scrolled_window)))
gtk_gesture_set_sequence_state (gesture, sequence, GTK_EVENT_SEQUENCE_DENIED);
gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED);
}
static void
@ -977,17 +975,6 @@ scrolled_window_drag_update_cb (GtkScrolledWindow *scrolled_window,
gtk_scrolled_window_invalidate_overshoot (scrolled_window);
}
static void
scrolled_window_drag_end_cb (GtkScrolledWindow *scrolled_window,
GdkEventSequence *sequence,
GtkGesture *gesture)
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
if (!priv->in_drag || !gtk_gesture_handles_sequence (gesture, sequence))
gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED);
}
static void
gtk_scrolled_window_decelerate (GtkScrolledWindow *scrolled_window,
double x_velocity,
@ -1033,18 +1020,13 @@ scrolled_window_long_press_cb (GtkScrolledWindow *scrolled_window,
double y,
GtkGesture *gesture)
{
GdkEventSequence *sequence;
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
gtk_gesture_set_sequence_state (gesture, sequence,
GTK_EVENT_SEQUENCE_DENIED);
gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED);
}
static void
scrolled_window_long_press_cancelled_cb (GtkScrolledWindow *scrolled_window,
GtkGesture *gesture)
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GdkEventSequence *sequence;
GdkEvent *event;
GdkEventType event_type;
@ -1055,11 +1037,7 @@ scrolled_window_long_press_cancelled_cb (GtkScrolledWindow *scrolled_window,
if (event_type == GDK_TOUCH_BEGIN ||
event_type == GDK_BUTTON_PRESS)
gtk_gesture_set_sequence_state (gesture, sequence,
GTK_EVENT_SEQUENCE_DENIED);
else if (event_type != GDK_TOUCH_END &&
event_type != GDK_BUTTON_RELEASE)
priv->in_drag = TRUE;
gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED);
}
static void
@ -2045,9 +2023,6 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
g_signal_connect_swapped (priv->drag_gesture, "drag-update",
G_CALLBACK (scrolled_window_drag_update_cb),
scrolled_window);
g_signal_connect_swapped (priv->drag_gesture, "end",
G_CALLBACK (scrolled_window_drag_end_cb),
scrolled_window);
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (priv->drag_gesture));
priv->pan_gesture = gtk_gesture_pan_new (GTK_ORIENTATION_VERTICAL);

View File

@ -5609,15 +5609,15 @@ gtk_text_view_click_gesture_pressed (GtkGestureClick *gesture,
if (n_press == 1 &&
gdk_event_triggers_context_menu (event))
{
gtk_gesture_set_sequence_state (GTK_GESTURE (gesture), sequence,
GTK_EVENT_SEQUENCE_CLAIMED);
gtk_gesture_set_state (GTK_GESTURE (gesture),
GTK_EVENT_SEQUENCE_CLAIMED);
gtk_text_view_do_popup (text_view, event);
}
else if (button == GDK_BUTTON_MIDDLE &&
get_middle_click_paste (text_view))
{
gtk_gesture_set_sequence_state (GTK_GESTURE (gesture), sequence,
GTK_EVENT_SEQUENCE_CLAIMED);
gtk_gesture_set_state (GTK_GESTURE (gesture),
GTK_EVENT_SEQUENCE_CLAIMED);
get_iter_from_gesture (text_view, GTK_GESTURE (gesture),
&iter, NULL, NULL);
gtk_text_buffer_paste_clipboard (get_buffer (text_view),
@ -5655,8 +5655,8 @@ gtk_text_view_click_gesture_pressed (GtkGestureClick *gesture,
{
if (is_touchscreen)
{
gtk_gesture_set_sequence_state (GTK_GESTURE (gesture), sequence,
GTK_EVENT_SEQUENCE_CLAIMED);
gtk_gesture_set_state (GTK_GESTURE (gesture),
GTK_EVENT_SEQUENCE_CLAIMED);
if (!priv->selection_bubble ||
!gtk_widget_get_visible (priv->selection_bubble))
{

View File

@ -2218,7 +2218,9 @@ _gtk_widget_set_sequence_state_internal (GtkWidget *widget,
gtk_gesture_get_sequence_state (gesture, sequence) != GTK_EVENT_SEQUENCE_CLAIMED)
continue;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
retval = gtk_gesture_set_sequence_state (gesture, seq, gesture_state);
G_GNUC_END_IGNORE_DEPRECATIONS
if (retval || gesture == emitter)
{

View File

@ -256,10 +256,17 @@ do_popup_fallback (GtkWindowHandle *self,
static void
do_popup (GtkWindowHandle *self,
GdkEvent *event)
GtkGestureClick *gesture)
{
GdkSurface *surface =
gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (self)));
GdkEventSequence *sequence;
GdkEvent *event;
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
if (!event)
return;
if (!gdk_toplevel_show_window_menu (GDK_TOPLEVEL (surface), event))
do_popup_fallback (self, event);
@ -267,7 +274,7 @@ do_popup (GtkWindowHandle *self,
static gboolean
perform_titlebar_action_fallback (GtkWindowHandle *self,
GdkEvent *event,
GtkGestureClick *click_gesture,
GdkTitlebarGesture gesture)
{
GtkSettings *settings;
@ -306,7 +313,7 @@ perform_titlebar_action_fallback (GtkWindowHandle *self,
"window.minimize",
NULL);
else if (g_str_equal (action, "menu"))
do_popup (self, event);
do_popup (self, click_gesture);
else
{
g_warning ("Unsupported titlebar action %s", action);
@ -320,7 +327,7 @@ perform_titlebar_action_fallback (GtkWindowHandle *self,
static gboolean
perform_titlebar_action (GtkWindowHandle *self,
GdkEvent *event,
GtkGestureClick *click_gesture,
guint button,
int n_press)
{
@ -349,7 +356,7 @@ perform_titlebar_action (GtkWindowHandle *self,
if (gdk_toplevel_titlebar_gesture (GDK_TOPLEVEL (surface), gesture))
return TRUE;
return perform_titlebar_action_fallback (self, event, gesture);
return perform_titlebar_action_fallback (self, click_gesture, gesture);
}
static void
@ -360,17 +367,10 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
GtkWindowHandle *self)
{
GtkWidget *widget;
GdkEventSequence *sequence;
GdkEvent *event;
guint button;
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);
if (!event)
return;
if (n_press > 1)
gtk_gesture_set_state (self->drag_gesture, GTK_EVENT_SEQUENCE_DENIED);
@ -387,25 +387,25 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
case GDK_BUTTON_PRIMARY:
if (n_press == 2)
{
perform_titlebar_action (self, event, button, n_press);
gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
sequence, GTK_EVENT_SEQUENCE_CLAIMED);
perform_titlebar_action (self, gesture, button, n_press);
gtk_gesture_set_state (GTK_GESTURE (gesture),
GTK_EVENT_SEQUENCE_CLAIMED);
}
break;
case GDK_BUTTON_SECONDARY:
if (perform_titlebar_action (self, event, button, n_press))
gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
sequence, GTK_EVENT_SEQUENCE_CLAIMED);
if (perform_titlebar_action (self, gesture, button, n_press))
gtk_gesture_set_state (GTK_GESTURE (gesture),
GTK_EVENT_SEQUENCE_CLAIMED);
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (self->drag_gesture));
break;
case GDK_BUTTON_MIDDLE:
if (perform_titlebar_action (self, event, button, n_press))
gtk_gesture_set_sequence_state (GTK_GESTURE (gesture),
sequence, GTK_EVENT_SEQUENCE_CLAIMED);
if (perform_titlebar_action (self, gesture, button, n_press))
gtk_gesture_set_state (GTK_GESTURE (gesture),
GTK_EVENT_SEQUENCE_CLAIMED);
break;
default: