Commit 1d4eac21 authored by Matthias Clasen's avatar Matthias Clasen

Merge branch 'wip/fix-submenu-size' into 'gtk-3-24'

Fix submenu size

See merge request !565
parents 5b360f21 57300b49
Pipeline #57292 passed with stage
in 8 minutes and 10 seconds
......@@ -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
......@@ -5267,6 +5272,7 @@ gtk_menu_position (GtkMenu *menu,
* the right place to popup the menu.
*/
gtk_widget_realize (priv->toplevel);
gtk_window_move_resize (GTK_WINDOW (priv->toplevel));
if (!gtk_widget_get_visible (priv->toplevel))
gtk_window_set_type_hint (GTK_WINDOW (priv->toplevel), priv->menu_type_hint);
......@@ -5286,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,
......
......@@ -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;
......
......@@ -265,6 +265,7 @@ struct _GtkWindowPrivate
guint unlimited_guessed_size_x : 1;
guint unlimited_guessed_size_y : 1;
guint force_resize : 1;
guint fixate_size : 1;
guint use_subsurface : 1;
......@@ -473,7 +474,6 @@ static GdkScreen *gtk_window_check_screen (GtkWindow *window);
static GtkWindowGeometryInfo* gtk_window_get_geometry_info (GtkWindow *window,
gboolean create);
static void gtk_window_move_resize (GtkWindow *window);
static gboolean gtk_window_compare_hints (GdkGeometry *geometry_a,
guint flags_a,
GdkGeometry *geometry_b,
......@@ -551,6 +551,10 @@ static void gtk_window_style_updated (GtkWidget *widget);
static void gtk_window_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
static void gtk_window_get_remembered_size (GtkWindow *window,
int *width,
int *height);
static GSList *toplevel_list = NULL;
static guint window_signals[LAST_SIGNAL] = { 0 };
static GList *default_icon_list = NULL;
......@@ -6436,6 +6440,8 @@ gtk_window_unmap (GtkWidget *widget)
*/
priv->need_default_position = TRUE;
priv->fixate_size = FALSE;
info = gtk_window_get_geometry_info (window, FALSE);
if (info)
{
......@@ -6477,6 +6483,14 @@ gtk_window_force_resize (GtkWindow *window)
priv->force_resize = TRUE;
}
void
gtk_window_fixate_size (GtkWindow *window)
{
GtkWindowPrivate *priv = window->priv;
priv->fixate_size = TRUE;
}
/* (Note: Replace "size" with "width" or "height". Also, the request
* mode is honoured.)
* For selecting the default window size, the following conditions
......@@ -6508,6 +6522,13 @@ gtk_window_guess_default_size (GtkWindow *window,
display = gtk_widget_get_display (widget);
gdkwindow = _gtk_widget_get_window (widget);
if (window->priv->fixate_size)
{
g_assert (gdkwindow);
gtk_window_get_remembered_size (window, width, height);
return;
}
if (gdkwindow)
monitor = gdk_display_get_monitor_at_window (display, gdkwindow);
else
......@@ -9729,7 +9750,7 @@ gtk_window_constrain_position (GtkWindow *window,
}
}
static void
void
gtk_window_move_resize (GtkWindow *window)
{
/* Overview:
......
......@@ -139,6 +139,8 @@ void gtk_window_set_unlimited_guessed_size (GtkWindow *window,
gboolean x,
gboolean y);
void gtk_window_force_resize (GtkWindow *window);
void gtk_window_fixate_size (GtkWindow *window);
void gtk_window_move_resize (GtkWindow *window);
/* Exported handles */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment