From beda50f6316fc14bb2687b3e7f0fac61d8db32a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sat, 16 Oct 2021 08:51:32 +0200 Subject: [PATCH 1/5] cssparser: Make a signed expression unsigned --- gtk/css/gtkcssparser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/css/gtkcssparser.c b/gtk/css/gtkcssparser.c index aa2e171aa1..3026fb1c78 100644 --- a/gtk/css/gtkcssparser.c +++ b/gtk/css/gtkcssparser.c @@ -1083,7 +1083,7 @@ gtk_css_parser_consume_any (GtkCssParser *parser, g_return_val_if_fail (n_options < sizeof (gsize) * 8 - 1, 0); result = 0; - while (result != (1 << n_options) - 1) + while (result != (1u << n_options) - 1u) { for (i = 0; i < n_options; i++) { From a61999170e94a972a245822de58595f07de26aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sat, 16 Oct 2021 15:44:58 +0200 Subject: [PATCH 2/5] fontrendering: Protect against NULL hints --- demos/gtk-demo/fontrendering.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/demos/gtk-demo/fontrendering.c b/demos/gtk-demo/fontrendering.c index c349e54b26..283523f481 100644 --- a/demos/gtk-demo/fontrendering.c +++ b/demos/gtk-demo/fontrendering.c @@ -59,16 +59,18 @@ update_image (void) fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context)); hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting)); - if (strcmp (hint, "none") == 0) - hintstyle = CAIRO_HINT_STYLE_NONE; - else if (strcmp (hint, "slight") == 0) - hintstyle = CAIRO_HINT_STYLE_SLIGHT; - else if (strcmp (hint, "medium") == 0) - hintstyle = CAIRO_HINT_STYLE_MEDIUM; - else if (strcmp (hint, "full") == 0) - hintstyle = CAIRO_HINT_STYLE_FULL; - else - hintstyle = CAIRO_HINT_STYLE_DEFAULT; + hintstyle = CAIRO_HINT_STYLE_DEFAULT; + if (hint) + { + if (strcmp (hint, "none") == 0) + hintstyle = CAIRO_HINT_STYLE_NONE; + else if (strcmp (hint, "slight") == 0) + hintstyle = CAIRO_HINT_STYLE_SLIGHT; + else if (strcmp (hint, "medium") == 0) + hintstyle = CAIRO_HINT_STYLE_MEDIUM; + else if (strcmp (hint, "full") == 0) + hintstyle = CAIRO_HINT_STYLE_FULL; + } cairo_font_options_set_hint_style (fopt, hintstyle); if (gtk_check_button_get_active (GTK_CHECK_BUTTON (hint_metrics))) From 03d4ac1863abf846eeb270954f49d8b417a32d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sat, 16 Oct 2021 15:56:46 +0200 Subject: [PATCH 3/5] theme: enable tabular numbers in GtkCalendar It aligns numbers a lot so this makes sense. --- gtk/theme/Default/_common.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/theme/Default/_common.scss b/gtk/theme/Default/_common.scss index e3129bd4d5..ebef2a800c 100644 --- a/gtk/theme/Default/_common.scss +++ b/gtk/theme/Default/_common.scss @@ -3443,6 +3443,7 @@ expander-widget { calendar { color: $text_color; border: 1px solid $borders_color; + font-feature-settings: "tnum"; > header { border-bottom: 1px solid $borders_color; From e7ac8275eaa9d85e1c37f0b96d1acc87f744c8b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 17 Oct 2021 11:21:00 +0200 Subject: [PATCH 4/5] main: Flip set_widget_active_state() logic The function used to take a boolean, just to set the active state of the widget to the exact opposite of that boolean. Fix that. --- gtk/gtkmain.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 830c074b2b..f6d56febf9 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1290,19 +1290,15 @@ is_key_event (GdkEvent *event) } static inline void -set_widget_active_state (GtkWidget *target, - const gboolean release) +set_widget_active_state (GtkWidget *target, + const gboolean is_active) { GtkWidget *w; w = target; while (w) { - if (release) - gtk_widget_set_active_state (w, FALSE); - else - gtk_widget_set_active_state (w, TRUE); - + gtk_widget_set_active_state (w, is_active); w = _gtk_widget_get_parent (w); } } @@ -1353,7 +1349,7 @@ handle_pointing_event (GdkEvent *event) case GDK_TOUCH_CANCEL: old_target = update_pointer_focus_state (toplevel, event, NULL); if (type == GDK_TOUCH_END || type == GDK_TOUCH_CANCEL) - set_widget_active_state (old_target, TRUE); + set_widget_active_state (old_target, FALSE); else if (type == GDK_LEAVE_NOTIFY) gtk_synthesize_crossing_events (GTK_ROOT (toplevel), GTK_CROSSING_POINTER, old_target, NULL, event, gdk_crossing_event_get_mode (event), NULL); @@ -1408,7 +1404,7 @@ handle_pointing_event (GdkEvent *event) else if (type == GDK_TOUCH_BEGIN) { gtk_window_set_pointer_focus_grab (toplevel, device, sequence, target); - set_widget_active_state (target, FALSE); + set_widget_active_state (target, TRUE); } /* Let it take the effective pointer focus anyway, as it may change due @@ -1453,9 +1449,9 @@ handle_pointing_event (GdkEvent *event) } if (type == GDK_BUTTON_PRESS) - set_widget_active_state (target, FALSE); - else if (has_implicit) set_widget_active_state (target, TRUE); + else if (has_implicit) + set_widget_active_state (target, FALSE); break; case GDK_SCROLL: @@ -1468,7 +1464,7 @@ handle_pointing_event (GdkEvent *event) target = gtk_window_lookup_effective_pointer_focus_widget (toplevel, device, sequence); - set_widget_active_state (target, TRUE); + set_widget_active_state (target, FALSE); } break; default: From 085f0171c16547858ae250eb1ff3f3425d3a3e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 17 Oct 2021 12:15:34 +0200 Subject: [PATCH 5/5] Ensure blur nodes have a positive blur radius --- gsk/gskrendernodeimpl.c | 3 ++- gtk/gtksnapshot.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index 28cb14ae64..d318fe9eec 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -4858,7 +4858,7 @@ gsk_blur_node_diff (GskRenderNode *node1, /** * gsk_blur_node_new: * @child: the child node to blur - * @radius: the blur radius + * @radius: the blur radius. Must be positive * * Creates a render node that blurs the child. * @@ -4873,6 +4873,7 @@ gsk_blur_node_new (GskRenderNode *child, float clip_radius; g_return_val_if_fail (GSK_IS_RENDER_NODE (child), NULL); + g_return_val_if_fail (radius >= 0, NULL); self = gsk_render_node_alloc (GSK_BLUR_NODE); node = (GskRenderNode *) self; diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 8b8627fb92..114c06fa84 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -520,6 +520,9 @@ gtk_snapshot_collect_blur (GtkSnapshot *snapshot, if (radius == 0.0) return node; + if (radius < 0) + return node; + blur_node = gsk_blur_node_new (node, radius); gsk_render_node_unref (node); @@ -530,7 +533,7 @@ gtk_snapshot_collect_blur (GtkSnapshot *snapshot, /** * gtk_snapshot_push_blur: * @snapshot: a `GtkSnapshot` - * @radius: the blur radius to use + * @radius: the blur radius to use. Must be positive * * Blurs an image. *