From 53622e07ee34b4bbc8cfe90540feefa62642e400 Mon Sep 17 00:00:00 2001 From: wszqkzqk Date: Wed, 8 Mar 2023 11:26:32 +0800 Subject: [PATCH] gtk4: fix combobox popups --- ...01-combobox-Avoid-extra-queue_resize.patch | 58 +++++++++++++++++++ mingw-w64-gtk4/PKGBUILD | 16 ++++- 2 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 mingw-w64-gtk4/0001-combobox-Avoid-extra-queue_resize.patch diff --git a/mingw-w64-gtk4/0001-combobox-Avoid-extra-queue_resize.patch b/mingw-w64-gtk4/0001-combobox-Avoid-extra-queue_resize.patch new file mode 100644 index 0000000000..92b54df16b --- /dev/null +++ b/mingw-w64-gtk4/0001-combobox-Avoid-extra-queue_resize.patch @@ -0,0 +1,58 @@ +From 1fc0fe9ac83104a98b6403eb5ee7dd32cb7c0b51 Mon Sep 17 00:00:00 2001 +From: wszqkzqk +Date: Wed, 8 Mar 2023 11:19:48 +0800 +Subject: [PATCH] combobox: Avoid extra queue_resize() + +width-request already ensures it's above the minimum width, so avoid an +extra queue_resize() when setting size request to (-1, -1). + +This is the same way as GtkDropDown works. This also unbreaks +GtkComboBox after the recent allocation fix in +75a417e33708dab2bdb2f784a8952e085a12bf03. + +Incidentally, this also makes GtkComboBox actually resize its popup as +intended (that was broken before). + +I don't think this is ultimately the final fix, sometimes I still get +allocation warnings. But the proper fix will probably involve changing +some more allocation machinery around popovers. This is good enough for +now. +--- + gtk/deprecated/gtkcombobox.c | 14 ++------------ + 1 file changed, 2 insertions(+), 12 deletions(-) + +diff --git a/gtk/deprecated/gtkcombobox.c b/gtk/deprecated/gtkcombobox.c +index 618f0780b7..1e76b38f41 100644 +--- a/gtk/deprecated/gtkcombobox.c ++++ b/gtk/deprecated/gtkcombobox.c +@@ -366,7 +366,6 @@ gtk_combo_box_size_allocate (GtkWidget *widget, + { + GtkComboBox *combo_box = GTK_COMBO_BOX (widget); + GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box); +- int menu_width; + + gtk_widget_size_allocate (priv->box, + &(GtkAllocation) { +@@ -374,17 +373,8 @@ gtk_combo_box_size_allocate (GtkWidget *widget, + width, height + }, baseline); + +- gtk_widget_set_size_request (priv->popup_widget, -1, -1); +- +- if (priv->popup_fixed_width) +- gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1, +- &menu_width, NULL, NULL, NULL); +- else +- gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1, +- NULL, &menu_width, NULL, NULL); +- +- gtk_widget_set_size_request (priv->popup_widget, +- MAX (width, menu_width), -1); ++ gtk_widget_set_size_request (priv->popup_widget, width, -1); ++ gtk_widget_queue_resize (priv->popup_widget); + + gtk_popover_present (GTK_POPOVER (priv->popup_widget)); + } +-- +2.39.2 + diff --git a/mingw-w64-gtk4/PKGBUILD b/mingw-w64-gtk4/PKGBUILD index 1b62c3f98b..1f08c7d49b 100644 --- a/mingw-w64-gtk4/PKGBUILD +++ b/mingw-w64-gtk4/PKGBUILD @@ -4,7 +4,7 @@ _realname=gtk4 pkgbase=mingw-w64-${_realname} pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" pkgver=4.10.0 -pkgrel=1 +pkgrel=2 pkgdesc="GObject-based multi-platform GUI toolkit (v4) (mingw-w64)" arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32') @@ -29,8 +29,18 @@ depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-gtk-update-icon-cache" "${MINGW_PACKAGE_PREFIX}-gst-plugins-bad-libs" "${MINGW_PACKAGE_PREFIX}-shared-mime-info") -source=("https://download.gnome.org/sources/gtk/${pkgver:0:4}/gtk-${pkgver}.tar.xz") -sha256sums=('8dc1e7c3b3a46772f0fa416a8ca3fd21d0d0b3b03fb307d2e7327ebee69626e4') +source=("https://download.gnome.org/sources/gtk/${pkgver:0:4}/gtk-${pkgver}.tar.xz" + "0001-combobox-Avoid-extra-queue_resize.patch") +sha256sums=('8dc1e7c3b3a46772f0fa416a8ca3fd21d0d0b3b03fb307d2e7327ebee69626e4' + '7016a9aa4247ba28a092bbe983bafa5be6c5fbef9f287cf8a0e4eba250cbc31b') + +prepare() { + cd ${srcdir}/gtk-${pkgver} + # Fix combobox popups + # https://gitlab.gnome.org/GNOME/gtk/-/issues/5644 + # https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5608 + patch -p1 -i "${srcdir}/0001-combobox-Avoid-extra-queue_resize.patch" +} build() { mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}