[gtk/gtk-3-24: 3/5] menu: Force resize when remapping
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24: 3/5] menu: Force resize when remapping
- Date: Fri, 18 Jan 2019 22:42:37 +0000 (UTC)
commit 3e586a82e6cc563a84f7f16341c63743b0c62762
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Thu Jan 17 19:23:21 2019 +0100
menu: Force resize when remapping
A menu will be clamped to the work area as a side effect of the
move_to_rect() logic if the resize anchor flags was set. For it to work
a second time, the initial size needs to be the actual menu size before
being clamped again. Achieve this by forcing a size recalculation before
showing the menu.
gtk/gtkmenu.c | 1 +
gtk/gtkwindow.c | 20 +++++++++++++++++---
gtk/gtkwindowprivate.h | 1 +
3 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index ec74a5a006..5b84eab3fa 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1985,6 +1985,7 @@ gtk_menu_popup_internal (GtkMenu *menu,
gtk_menu_shell_select_first (menu_shell, TRUE);
/* Once everything is set up correctly, map the toplevel */
+ gtk_window_force_resize (GTK_WINDOW (priv->toplevel));
gtk_widget_show (priv->toplevel);
if (xgrab_shell == widget)
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 4806504a78..699a70286c 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -264,6 +264,7 @@ struct _GtkWindowPrivate
guint tiled : 1;
guint unlimited_guessed_size_x : 1;
guint unlimited_guessed_size_y : 1;
+ guint force_resize : 1;
guint use_subsurface : 1;
@@ -6468,6 +6469,14 @@ gtk_window_set_unlimited_guessed_size (GtkWindow *window,
priv->unlimited_guessed_size_y = y;
}
+void
+gtk_window_force_resize (GtkWindow *window)
+{
+ GtkWindowPrivate *priv = window->priv;
+
+ priv->force_resize = TRUE;
+}
+
/* (Note: Replace "size" with "width" or "height". Also, the request
* mode is honoured.)
* For selecting the default window size, the following conditions
@@ -9384,7 +9393,8 @@ gtk_window_compute_configure_request_size (GtkWindow *window,
info = gtk_window_get_geometry_info (window, FALSE);
- if (priv->need_default_size)
+ if (priv->need_default_size ||
+ priv->force_resize)
{
gtk_window_guess_default_size (window, width, height);
gtk_window_get_remembered_size (window, &w, &h);
@@ -9789,9 +9799,13 @@ gtk_window_move_resize (GtkWindow *window)
info->last.configure_request.y != new_request.y)
configure_request_pos_changed = TRUE;
- if ((info->last.configure_request.width != new_request.width ||
+ if (priv->force_resize ||
+ (info->last.configure_request.width != new_request.width ||
info->last.configure_request.height != new_request.height))
- configure_request_size_changed = TRUE;
+ {
+ priv->force_resize = FALSE;
+ configure_request_size_changed = TRUE;
+ }
hints_changed = FALSE;
diff --git a/gtk/gtkwindowprivate.h b/gtk/gtkwindowprivate.h
index 0f4c631b77..9c12233c95 100644
--- a/gtk/gtkwindowprivate.h
+++ b/gtk/gtkwindowprivate.h
@@ -138,6 +138,7 @@ GdkScreen *_gtk_window_get_screen (GtkWindow *window);
void gtk_window_set_unlimited_guessed_size (GtkWindow *window,
gboolean x,
gboolean y);
+void gtk_window_force_resize (GtkWindow *window);
/* Exported handles */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]