[gtk/gtk-3-24: 4/5] menu: Fixate size calculated by gdk_window_move_to_rect()



commit 57300b49602b856b53f5d30ab3174591c0fb2845
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Feb 6 19:30:54 2019 +0100

    menu: Fixate size calculated by gdk_window_move_to_rect()
    
    When we receive a size from the move-to-rect implementation, force GTK
    to continue using that size until reconfigured by move-to-rect, or
    when remapped.
    
    Fixes: #1651

 gtk/gtkmenu.c        | 25 +++++++++++++++----------
 gtk/gtkmenuprivate.h |  1 +
 2 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 3a9c69ae6d..772e6a9662 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1398,13 +1398,18 @@ moved_to_rect_cb (GdkWindow          *window,
                   gboolean            flipped_y,
                   GtkMenu            *menu)
 {
-  g_signal_emit (menu,
-                 menu_signals[POPPED_UP],
-                 0,
-                 flipped_rect,
-                 final_rect,
-                 flipped_x,
-                 flipped_y);
+  GtkMenuPrivate *priv = menu->priv;
+
+  gtk_window_fixate_size (GTK_WINDOW (priv->toplevel));
+
+  if (!priv->emulated_move_to_rect)
+    g_signal_emit (menu,
+                   menu_signals[POPPED_UP],
+                   0,
+                   flipped_rect,
+                   final_rect,
+                   flipped_x,
+                   flipped_y);
 }
 
 static void
@@ -5287,9 +5292,9 @@ gtk_menu_position (GtkMenu  *menu,
 
   g_signal_handlers_disconnect_by_func (toplevel, moved_to_rect_cb, menu);
 
-  if (!emulated_move_to_rect)
-    g_signal_connect (toplevel, "moved-to-rect", G_CALLBACK (moved_to_rect_cb),
-                      menu);
+  g_signal_connect (toplevel, "moved-to-rect", G_CALLBACK (moved_to_rect_cb),
+                    menu);
+  priv->emulated_move_to_rect = emulated_move_to_rect;
 
   gdk_window_move_to_rect (toplevel,
                            &rect,
diff --git a/gtk/gtkmenuprivate.h b/gtk/gtkmenuprivate.h
index e838d4e0d1..0918d83e7b 100644
--- a/gtk/gtkmenuprivate.h
+++ b/gtk/gtkmenuprivate.h
@@ -62,6 +62,7 @@ struct _GtkMenuPrivate
   gint               rect_anchor_dx;
   gint               rect_anchor_dy;
   GdkWindowTypeHint  menu_type_hint;
+  gboolean           emulated_move_to_rect;
 
   guint toggle_size;
   guint accel_size;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]