From ec21d354b9e4b2a5c2d2068bce815ea02fbe776e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 25 Nov 2020 14:32:23 -0500 Subject: [PATCH 01/13] gsk: doc fixups --- gsk/gskglshader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsk/gskglshader.c b/gsk/gskglshader.c index 9876491d35..181ae32a2d 100644 --- a/gsk/gskglshader.c +++ b/gsk/gskglshader.c @@ -1149,7 +1149,7 @@ gsk_shader_args_builder_to_args (GskShaderArgsBuilder *builder) } /** - * gdk_shader_args_builder_free_to_args: (skip) + * gsk_shader_args_builder_free_to_args: (skip) * @builder: a #GskShaderArgsBuilder * * Creates a new #GBytes args from the current state of the From 6bd9ce7b55d66efa652c9b6c8c1be719b79d198c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 25 Nov 2020 14:49:21 -0500 Subject: [PATCH 02/13] docs: Ignore more generated Wayland protocol headers These inject mysterious words like Airbrush, Lense and Mouse into the list of undocumented apis. No need for that. --- docs/reference/gdk/meson.build | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/reference/gdk/meson.build b/docs/reference/gdk/meson.build index 5713c4ec5e..ed7e4ddb36 100644 --- a/docs/reference/gdk/meson.build +++ b/docs/reference/gdk/meson.build @@ -43,12 +43,17 @@ private_headers = [ 'x11/gdkeventsource.h', 'gtk-primary-selection-client-protocol.h', 'gtk-shell-client-protocol.h', + 'idle-inhibit-unstable-v1-client-protocol.h', 'keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h', 'pointer-gestures-unstable-v1-client-protocol.h', + 'primary-selection-unstable-v1-client-protocol.h', 'server-decoration-client-protocol.h', 'tablet-unstable-v2-client-protocol.h', 'xdg-foreign-unstable-v1-client-protocol.h', 'xdg-shell-unstable-v6-client-protocol.h', + 'xdg-output-unstable-v1-client-protocol.h', + 'xdg-shell-client-protocol.h', + 'xdg-shell-unstable-v6-client-protocol.h', 'win32', 'quartz', 'broadway', From da514187f5215cfb140e4c76c9dba506d178412f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 3 Nov 2020 09:18:37 +0100 Subject: [PATCH 03/13] gl renderer: Make minimal rounded rects more minimal --- gsk/gl/gskglrenderer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c index 1d644da24c..cd93966d5c 100644 --- a/gsk/gl/gskglrenderer.c +++ b/gsk/gl/gskglrenderer.c @@ -306,10 +306,10 @@ color_matrix_modifies_alpha (GskRenderNode *node) static inline void gsk_rounded_rect_shrink_to_minimum (GskRoundedRect *self) { - self->bounds.size.width = ceilf (MAX (MAX (self->corner[0].width, self->corner[1].width), - MAX (self->corner[2].width, self->corner[3].width)) * 2); - self->bounds.size.height = ceilf (MAX (MAX (self->corner[0].height, self->corner[1].height), - MAX (self->corner[2].height, self->corner[3].height)) * 2); + self->bounds.size.width = MAX (self->corner[0].width + self->corner[1].width, + self->corner[3].width + self->corner[2].width); + self->bounds.size.height = MAX (self->corner[0].height + self->corner[3].height, + self->corner[1].height + self->corner[2].height); } static inline gboolean G_GNUC_PURE From 5f4beb711fc4c077ac79c532fb77a349c13661c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 15 Nov 2020 19:14:25 +0100 Subject: [PATCH 04/13] widgetprivate: Remove unused function --- gtk/gtkwidgetprivate.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index 138f0137d9..a79ee938da 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -479,12 +479,6 @@ _gtk_widget_is_sensitive (GtkWidget *widget) return !(widget->priv->state_flags & GTK_STATE_FLAG_INSENSITIVE); } -static inline GskTransform * -gtk_widget_get_transform (GtkWidget *widget) -{ - return widget->priv->transform; -} - G_END_DECLS #endif /* __GTK_WIDGET_PRIVATE_H__ */ From 2d43ecf8ca6c2598875da61b4003b0a0e2f70d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 19 Nov 2020 12:00:40 +0100 Subject: [PATCH 05/13] widget: root child before emitting child observer signals Try to avoid the childen_observer signal handlers screwing up internal state. Fixes #3364 --- gtk/gtkwidget.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 0b663d98dd..239e9ff929 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5776,6 +5776,9 @@ gtk_widget_reposition_after (GtkWidget *widget, _gtk_widget_update_parent_muxer (widget); + if (parent->priv->root && priv->root == NULL) + gtk_widget_root (widget); + if (parent->priv->children_observer) { if (prev_previous) @@ -5784,9 +5787,6 @@ gtk_widget_reposition_after (GtkWidget *widget, gtk_list_list_model_item_added (parent->priv->children_observer, widget); } - if (parent->priv->root && priv->root == NULL) - gtk_widget_root (widget); - if (prev_parent == NULL) g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_PARENT]); From e3ff92bc879c246f3bcbd90fcffacd6b4847adbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 19 Nov 2020 15:27:25 +0100 Subject: [PATCH 06/13] shortcutcontroller: Save signal handler ID gtk_shortcut_controller_finalize() used to take ~13.8% when closing the complex listbox demo in gtk4-demo. Now it takes nothing. --- gtk/gtkshortcutcontroller.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gtk/gtkshortcutcontroller.c b/gtk/gtkshortcutcontroller.c index e30a82ab98..3d63bbfdf3 100644 --- a/gtk/gtkshortcutcontroller.c +++ b/gtk/gtkshortcutcontroller.c @@ -91,6 +91,7 @@ struct _GtkShortcutController GtkShortcutScope scope; GdkModifierType mnemonics_modifiers; + gulong shortcuts_changed_id; guint custom_shortcuts : 1; guint last_activated; @@ -213,7 +214,11 @@ gtk_shortcut_controller_set_property (GObject *object, self->shortcuts = g_object_ref (model); self->custom_shortcuts = FALSE; } - g_signal_connect_swapped (self->shortcuts, "items-changed", G_CALLBACK (g_list_model_items_changed), self); + + self->shortcuts_changed_id = g_signal_connect_swapped (self->shortcuts, + "items-changed", + G_CALLBACK (g_list_model_items_changed), + self); } break; @@ -265,7 +270,7 @@ gtk_shortcut_controller_finalize (GObject *object) { GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (object); - g_signal_handlers_disconnect_by_func (self->shortcuts, g_list_model_items_changed, self); + g_clear_signal_handler (&self->shortcuts_changed_id, self->shortcuts); g_clear_object (&self->shortcuts); G_OBJECT_CLASS (gtk_shortcut_controller_parent_class)->finalize (object); From d663909159de1102b9373870d5294d595c3118ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 19 Nov 2020 15:53:05 +0100 Subject: [PATCH 07/13] shortcutcontroller: Use priv->shortcuts directly in set_widget() Instead of treating the shortcut controller itself as a GListModel, which just passes everything along from priv->shortcuts. --- gtk/gtkshortcutcontroller.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtk/gtkshortcutcontroller.c b/gtk/gtkshortcutcontroller.c index 3d63bbfdf3..2e660ed031 100644 --- a/gtk/gtkshortcutcontroller.c +++ b/gtk/gtkshortcutcontroller.c @@ -486,13 +486,14 @@ gtk_shortcut_controller_set_widget (GtkEventController *controller, GtkWidget *widget) { GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (controller); + GListModel *shortcuts = self->shortcuts; guint i, p; GTK_EVENT_CONTROLLER_CLASS (gtk_shortcut_controller_parent_class)->set_widget (controller, widget); - for (i = 0, p = g_list_model_get_n_items (G_LIST_MODEL (controller)); i < p; i++) + for (i = 0, p = g_list_model_get_n_items (shortcuts); i < p; i++) { - GtkShortcut *shortcut = g_list_model_get_item (G_LIST_MODEL (controller), i); + GtkShortcut *shortcut = g_list_model_get_item (shortcuts, i); if (GTK_IS_SHORTCUT (shortcut)) update_accel (shortcut, widget, TRUE); g_object_unref (shortcut); From 8645773fc668325f9b964dd2c2ce0994e23c415d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 19 Nov 2020 15:57:09 +0100 Subject: [PATCH 08/13] shortcutcontroller: Pass the muxer to update_accel() We only needed the widget to get its action muxer. And this way we don't have to call gtk_widget_get_action_muxer() dozens of times, just once in set_widget(). --- gtk/gtkshortcutcontroller.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/gtk/gtkshortcutcontroller.c b/gtk/gtkshortcutcontroller.c index 2e660ed031..0c7922f5ec 100644 --- a/gtk/gtkshortcutcontroller.c +++ b/gtk/gtkshortcutcontroller.c @@ -447,18 +447,20 @@ gtk_shortcut_controller_handle_event (GtkEventController *controller, } static void -update_accel (GtkShortcut *shortcut, - GtkWidget *widget, - gboolean set) +update_accel (GtkShortcut *shortcut, + GtkActionMuxer *muxer, + gboolean set) { GtkShortcutTrigger *trigger; GtkShortcutAction *action; - GtkActionMuxer *muxer; GVariant *target; const char *action_name; char *action_and_target; char *accel = NULL; + if (!muxer) + return; + trigger = gtk_shortcut_get_trigger (shortcut); action = gtk_shortcut_get_action (shortcut); @@ -466,10 +468,6 @@ update_accel (GtkShortcut *shortcut, !GTK_IS_KEYVAL_TRIGGER (trigger)) return; - muxer = _gtk_widget_get_action_muxer (widget, set); - if (!muxer) - return; - target = gtk_shortcut_get_arguments (shortcut); action_name = gtk_named_action_get_action_name (GTK_NAMED_ACTION (action)); action_and_target = gtk_print_action_and_target (NULL, action_name, target); @@ -487,15 +485,17 @@ gtk_shortcut_controller_set_widget (GtkEventController *controller, { GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (controller); GListModel *shortcuts = self->shortcuts; + GtkActionMuxer *muxer; guint i, p; GTK_EVENT_CONTROLLER_CLASS (gtk_shortcut_controller_parent_class)->set_widget (controller, widget); + muxer = _gtk_widget_get_action_muxer (widget, TRUE); for (i = 0, p = g_list_model_get_n_items (shortcuts); i < p; i++) { GtkShortcut *shortcut = g_list_model_get_item (shortcuts, i); if (GTK_IS_SHORTCUT (shortcut)) - update_accel (shortcut, widget, TRUE); + update_accel (shortcut, muxer, TRUE); g_object_unref (shortcut); } @@ -742,7 +742,11 @@ gtk_shortcut_controller_add_shortcut (GtkShortcutController *self, widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (self)); if (widget) - update_accel (shortcut, widget, TRUE); + { + GtkActionMuxer *muxer = _gtk_widget_get_action_muxer (widget, TRUE); + + update_accel (shortcut, muxer, TRUE); + } g_list_store_append (G_LIST_STORE (self->shortcuts), shortcut); g_object_unref (shortcut); @@ -773,7 +777,11 @@ gtk_shortcut_controller_remove_shortcut (GtkShortcutController *self, widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (self)); if (widget) - update_accel (shortcut, widget, FALSE); + { + GtkActionMuxer *muxer = _gtk_widget_get_action_muxer (widget, FALSE); + + update_accel (shortcut, muxer, FALSE); + } for (i = 0; i < g_list_model_get_n_items (self->shortcuts); i++) { From 1d6c6fc3b8fcdae9d73976687297935273bf0cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 19 Nov 2020 16:27:48 +0100 Subject: [PATCH 09/13] shortcutcontroller: Separate trigger/action early returns We take this early return in update_accel over 36k times when starting the widget factory and always because the action is not a named action. --- gtk/gtkshortcutcontroller.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gtk/gtkshortcutcontroller.c b/gtk/gtkshortcutcontroller.c index 0c7922f5ec..72f777d386 100644 --- a/gtk/gtkshortcutcontroller.c +++ b/gtk/gtkshortcutcontroller.c @@ -461,11 +461,12 @@ update_accel (GtkShortcut *shortcut, if (!muxer) return; - trigger = gtk_shortcut_get_trigger (shortcut); action = gtk_shortcut_get_action (shortcut); + if (!GTK_IS_NAMED_ACTION (action)) + return; - if (!GTK_IS_NAMED_ACTION (action) || - !GTK_IS_KEYVAL_TRIGGER (trigger)) + trigger = gtk_shortcut_get_trigger (shortcut); + if (!GTK_IS_KEYVAL_TRIGGER (trigger)) return; target = gtk_shortcut_get_arguments (shortcut); From aefabcc0560a2116a51edcb6fbc14ad83036a31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 29 Nov 2020 08:41:44 +0100 Subject: [PATCH 10/13] popovermenu: Pull variable declaration in closest scope --- gtk/gtkpopovermenu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gtk/gtkpopovermenu.c b/gtk/gtkpopovermenu.c index d6e5f91887..e0dd9a286c 100644 --- a/gtk/gtkpopovermenu.c +++ b/gtk/gtkpopovermenu.c @@ -275,15 +275,15 @@ focus_out (GtkEventController *controller, } static void -leave_cb (GtkEventController *controller, - gpointer data) +leave_cb (GtkEventController *controller, + gpointer data) { - GtkWidget *target; - - target = gtk_event_controller_get_widget (controller); - if (!gtk_event_controller_motion_contains_pointer (GTK_EVENT_CONTROLLER_MOTION (controller))) - gtk_popover_menu_set_active_item (GTK_POPOVER_MENU (target), NULL); + { + GtkWidget *target = gtk_event_controller_get_widget (controller); + + gtk_popover_menu_set_active_item (GTK_POPOVER_MENU (target), NULL); + } } static void From ff8de0a93f003f9c3bf6c32777a2055f39094ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 29 Nov 2020 09:25:46 +0100 Subject: [PATCH 11/13] eventcontrollermotion: Notify by pspec --- gtk/gtkeventcontrollermotion.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/gtkeventcontrollermotion.c b/gtk/gtkeventcontrollermotion.c index 8a9a623765..86c38c1048 100644 --- a/gtk/gtkeventcontrollermotion.c +++ b/gtk/gtkeventcontrollermotion.c @@ -133,12 +133,12 @@ update_pointer_focus (GtkEventController *controller, if (motion->is_pointer != is_pointer) { motion->is_pointer = is_pointer; - g_object_notify (G_OBJECT (motion), "is-pointer"); + g_object_notify_by_pspec (G_OBJECT (motion), props[PROP_IS_POINTER]); } if (motion->contains_pointer != contains_pointer) { motion->contains_pointer = contains_pointer; - g_object_notify (G_OBJECT (motion), "contains-pointer"); + g_object_notify_by_pspec (G_OBJECT (motion), props[PROP_CONTAINS_POINTER]); } g_object_thaw_notify (G_OBJECT (motion)); From af28237569dea636b39da295f286bb46ca246622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 29 Nov 2020 09:42:18 +0100 Subject: [PATCH 12/13] popovermenu: Connect to right controller signal leave is emitted before the new contains-pointer value is set, so the signal handler wasn't working right. --- gtk/gtkpopovermenu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkpopovermenu.c b/gtk/gtkpopovermenu.c index e0dd9a286c..30b0dd4c53 100644 --- a/gtk/gtkpopovermenu.c +++ b/gtk/gtkpopovermenu.c @@ -309,7 +309,7 @@ gtk_popover_menu_init (GtkPopoverMenu *popover) gtk_widget_add_controller (GTK_WIDGET (popover), controller); controller = gtk_event_controller_motion_new (); - g_signal_connect (controller, "leave", G_CALLBACK (leave_cb), popover); + g_signal_connect (controller, "notify::contains-pointer", G_CALLBACK (leave_cb), popover); gtk_widget_add_controller (GTK_WIDGET (popover), controller); controllers = gtk_widget_list_controllers (GTK_WIDGET (popover), GTK_PHASE_CAPTURE, &n_controllers); From dc13ff97e2bcbb894ef37872c1860d14571b4647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 29 Nov 2020 09:49:08 +0100 Subject: [PATCH 13/13] modelbutton: Reset active menu item on pointer leave We don't want to leave an active menu item behind if the pointer doesn't enter another menu item. This matches the old GtkMenu behavior --- gtk/gtkmodelbutton.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c index 3d2e2519c4..32232909b3 100644 --- a/gtk/gtkmodelbutton.c +++ b/gtk/gtkmodelbutton.c @@ -1387,18 +1387,16 @@ pointer_cb (GObject *object, GParamSpec *pspec, gpointer data) { + GtkWidget *target = GTK_WIDGET (data); + GtkWidget *popover; gboolean contains; contains = gtk_event_controller_motion_contains_pointer (GTK_EVENT_CONTROLLER_MOTION (object)); + popover = gtk_widget_get_ancestor (target, GTK_TYPE_POPOVER_MENU); + if (contains) { - GtkWidget *target; - GtkWidget *popover; - - target = GTK_WIDGET (data); - popover = gtk_widget_get_ancestor (target, GTK_TYPE_POPOVER_MENU); - if (popover) { if (gtk_popover_menu_get_open_submenu (GTK_POPOVER_MENU (popover)) != NULL) @@ -1412,6 +1410,7 @@ pointer_cb (GObject *object, GtkModelButton *button = data; stop_open (button); + gtk_popover_menu_set_active_item (GTK_POPOVER_MENU (popover), NULL); } }