From c835df56026bfdd1d2beea8a46cdcaae457741c0 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 8 Oct 2020 14:13:19 -0400 Subject: [PATCH 1/6] docs: Add more details to the migration guide Add some details about GdkSurface and GtkWindow api changes. Fixes: #3242 --- docs/reference/gtk/migrating-3to4.md | 34 +++++++++++++++++++++------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/docs/reference/gtk/migrating-3to4.md b/docs/reference/gtk/migrating-3to4.md index 3dcb4ab27d..278ec2221d 100644 --- a/docs/reference/gtk/migrating-3to4.md +++ b/docs/reference/gtk/migrating-3to4.md @@ -277,15 +277,22 @@ with surfaces, you may have to change it to call the API in these interfaces, depending on whether the surface you are dealing with is a toplevel or a popup. -As part of this reorganization, X11-only concepts such as sticky or -keep-below have been removed. If you need to use them on your X11 windows, -you will have to set the corresponding X11 properties (as specified in the -EWMH) yourself. Subsurfaces are only supported with the Wayland backend, -using gdk_wayland_surface_new_subsurface(). Native and foreign subwindows -are no longer supported. These concepts were complicating the code and -could not be supported across backends. +As part of this reorganization, X11-only concepts such as sticky, +keep-below, urgency, skip-taskbar or window groups have either been +removed or moved to X11 backend api. If you need to use them on your +X11 windows, you will have to use those backend apis or set the +corresponding X11 properties (as specified in the EWMH) yourself. -gdk_window_reparent() is no longer available. +Subsurfaces are only supported with the Wayland backend, using +gdk_wayland_surface_new_subsurface(). Native and foreign subwindows +are no longer supported. These concepts were complicating the code +and could not be supported across backends. + +A number of GdkWindow APIs are no longer available. This includes +gdk_window_reparent(), gdk_window_set_geometry_hints(), gdk_window_raise(), +gdk_window_restack(), gdk_window_move(), gdk_window_resize(). If +you need to manually control the position or stacking of your X11 +windows, you you will have to use Xlib apis. A number of minor API cleanups have happened in GdkSurface as well. For example, gdk_surface_input_shape_combine_region() @@ -459,6 +466,17 @@ GtkButtonBox has been removed. Use a GtkBox instead. The GtkBox pack-start and -end methods have been replaced by gtk_box_prepend() and gtk_box_append(). You can also reorder box children as necessary. +### Adapt to GtkWindow API changes + +Following the GdkSurface changes, a number of GtkWindow APIs that were +X11-specific have been removed. This includes gtk_window_set_geometry_hints(), +gtk_window_set_gravity(), gtk_window_move(), gtk_window_parse_geometry(), +gtk_window_set_keep_above(), gtk_window_set_keep_below(), +gtk_window_begin_resize_drag(), gtk_window_begin_move_drag(). +Most likely, you should just stop using them. In some cases, you can +fall back to using the underlying #GdkToplevel APIS (for example, +gdk_toplevel_begin_resize()). + ### Adapt to GtkHeaderBar and GtkActionBar API changes The gtk_header_bar_set_show_close_button() function has been renamed to From e7aa10342ba748a8845841c7b284b8ab746fe3d1 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 8 Oct 2020 15:55:22 -0400 Subject: [PATCH 2/6] gtk-demo: Ellipsize columns in the characters demo some of the columns have uneven widths, causing them to bounce around as you scroll. Ellipsize them and give them a fixed with. --- demos/gtk-demo/listview_ucd.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/demos/gtk-demo/listview_ucd.c b/demos/gtk-demo/listview_ucd.c index 4331d646fb..d6711a1aec 100644 --- a/demos/gtk-demo/listview_ucd.c +++ b/demos/gtk-demo/listview_ucd.c @@ -116,6 +116,18 @@ setup_label (GtkSignalListItemFactory *factory, gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label); } +static void +setup_ellipsizing_label (GtkSignalListItemFactory *factory, + GObject *listitem) +{ + GtkWidget *label; + label = gtk_label_new (""); + gtk_label_set_xalign (GTK_LABEL (label), 0); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); + gtk_label_set_width_chars (GTK_LABEL (label), 20); + gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label); +} + static void bind_codepoint (GtkSignalListItemFactory *factory, GObject *listitem) @@ -279,21 +291,21 @@ create_ucd_view (GtkWidget *label) gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column); factory = gtk_signal_list_item_factory_new (); - g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL); + g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL); g_signal_connect (factory, "bind", G_CALLBACK (bind_name), NULL); column = gtk_column_view_column_new ("Name", factory); gtk_column_view_column_set_resizable (column, TRUE); gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column); factory = gtk_signal_list_item_factory_new (); - g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL); + g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL); g_signal_connect (factory, "bind", G_CALLBACK (bind_type), NULL); column = gtk_column_view_column_new ("Type", factory); gtk_column_view_column_set_resizable (column, TRUE); gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column); factory = gtk_signal_list_item_factory_new (); - g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL); + g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL); g_signal_connect (factory, "bind", G_CALLBACK (bind_break_type), NULL); column = gtk_column_view_column_new ("Break Type", factory); gtk_column_view_column_set_resizable (column, TRUE); From eb647299d465599c99fd3845f4d0a5258139b842 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 8 Oct 2020 19:23:23 -0400 Subject: [PATCH 3/6] build: Require sysprof 3.38.0 We use sysprof_collector_request_counters, which was introduced in sysprof 3.38.0. --- meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index ab4e0a1f31..85a605c2c9 100644 --- a/meson.build +++ b/meson.build @@ -34,6 +34,7 @@ graphene_req = '>= 1.9.1' epoxy_req = '>= 1.4' cloudproviders_req = '>= 0.3.1' xkbcommon_req = '>= 0.2.0' +sysprof_req = '>= 3.38.0' gnome = import('gnome') @@ -680,7 +681,7 @@ cdata.set('HAVE_CLOUDPROVIDERS', cloudproviders_dep.found()) # libsysprof-capture support if not get_option('sysprof').disabled() - libsysprof_capture_dep = dependency('sysprof-capture-4', + libsysprof_capture_dep = dependency('sysprof-capture-4', version: sysprof_req, required: get_option('sysprof'), default_options: [ 'enable_examples=false', From 6a0704aeb4edb0d43010270348c8de1d27e4453a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 8 Oct 2020 20:32:39 -0400 Subject: [PATCH 4/6] window: Be more careful when looking for focus When passing focus up to a parent, make sure the newly chosen focus widget actually accepts the focus. --- gtk/gtkwindow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index c5c69e2b33..a6f7f37912 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -5242,8 +5242,8 @@ _gtk_window_unset_focus_and_default (GtkWindow *window, { if (_gtk_widget_get_visible (parent)) { - gtk_window_set_focus (window, parent); - break; + if (gtk_widget_grab_focus (parent)) + break; } parent = gtk_widget_get_parent (parent); From 115ed005e615d5046c50e801f850c2490fe7b339 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 8 Oct 2020 23:06:07 -0400 Subject: [PATCH 5/6] Send focus events to the root We are not propagating focus change events, and that is the only place where we are listening for focus change events. If GtkWindow does not see focus-in events for its popovers, we end up with inadvertendly inactive windows. Fixes: #3240 --- gtk/gtkmain.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 10780b7684..bffb4cfa94 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1648,8 +1648,11 @@ gtk_main_do_event (GdkEvent *event) break; case GDK_FOCUS_CHANGE: - if (!_gtk_widget_captured_event (target_widget, event, target_widget)) - gtk_widget_event (target_widget, event, target_widget); + { + GtkWidget *root = GTK_WIDGET (gtk_widget_get_root (target_widget)); + if (!_gtk_widget_captured_event (root, event, root)) + gtk_widget_event (root, event, root); + } break; case GDK_KEY_PRESS: From 8fcd4ac0f9ffb3513c4a55e9c018a43755bc7f4e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 9 Oct 2020 07:51:57 -0400 Subject: [PATCH 6/6] gtk-demo: Keep undisplayable resources out of view No point in showing an apologetic tab for a blob of binary data. gtk4-demo shows the resources under /DEMONAME/ for each demo, so move the data to /DEMONAME_data/. --- demos/gtk-demo/demo.gresource.xml | 2 +- demos/gtk-demo/listview_ucd.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml index e3f0a034c3..bcb2ebc3b5 100644 --- a/demos/gtk-demo/demo.gresource.xml +++ b/demos/gtk-demo/demo.gresource.xml @@ -184,7 +184,7 @@ listview_settings.ui - + ucdnames.data diff --git a/demos/gtk-demo/listview_ucd.c b/demos/gtk-demo/listview_ucd.c index d6711a1aec..9fe85fcbd1 100644 --- a/demos/gtk-demo/listview_ucd.c +++ b/demos/gtk-demo/listview_ucd.c @@ -74,7 +74,7 @@ ucd_model_new (void) guint u; char *name; - bytes = g_resources_lookup_data ("/listview_ucd/ucdnames.data", 0, NULL); + bytes = g_resources_lookup_data ("/listview_ucd_data/ucdnames.data", 0, NULL); v = g_variant_ref_sink (g_variant_new_from_bytes (G_VARIANT_TYPE ("a(us)"), bytes, TRUE)); iter = g_variant_iter_new (v);