summaryrefslogtreecommitdiff
path: root/gdk/gdktoplevellayout.c
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2020-12-16 11:53:19 +0100
committerJonas Ådahl <jadahl@gmail.com>2020-12-16 14:16:08 +0100
commit142f7862ed0aaa72177286f614430f8a555ad1cb (patch)
tree58d1f0c89b02e75e829ddfaeec0a81bc5518fc1b /gdk/gdktoplevellayout.c
parentb6412adc3288377c795abdb96622a5fac2ec382f (diff)
downloadgtk+-142f7862ed0aaa72177286f614430f8a555ad1cb.tar.gz
gdk/toplevellayout: Change API to be about intent, not full state
When being fullscreen, and wanting to unfullscreen but not caring about whether to go unmaximized or maximized (as this information is lost), if the GdkToplevelLayout represents the full intended state, we won't be able to do the right thing. To avoid this issue, make the GdkToplevelLayout API intend based, where if one e.g. doesn't call gdk_toplevel_set_maximized() with anything, the backend will not attempt to change the maximized state. This means we can also remove the old 'initially_maximized' and 'initially_fullscreen' fields from the private GtkWindow struct, as we only deal with intents now.
Diffstat (limited to 'gdk/gdktoplevellayout.c')
-rw-r--r--gdk/gdktoplevellayout.c49
1 files changed, 39 insertions, 10 deletions
diff --git a/gdk/gdktoplevellayout.c b/gdk/gdktoplevellayout.c
index 577b03be41..0de2720b00 100644
--- a/gdk/gdktoplevellayout.c
+++ b/gdk/gdktoplevellayout.c
@@ -40,7 +40,10 @@ struct _GdkToplevelLayout
grefcount ref_count;
guint resizable : 1;
+
+ guint maximized_valid : 1;
guint maximized : 1;
+ guint fullscreen_valid : 1;
guint fullscreen : 1;
GdkMonitor *fullscreen_monitor;
};
@@ -70,7 +73,9 @@ gdk_toplevel_layout_new (void)
layout = g_new0 (GdkToplevelLayout, 1);
g_ref_count_init (&layout->ref_count);
layout->resizable = TRUE;
+ layout->maximized_valid = FALSE;
layout->maximized = FALSE;
+ layout->fullscreen_valid = FALSE;
layout->fullscreen = FALSE;
layout->fullscreen_monitor = NULL;
@@ -125,7 +130,9 @@ gdk_toplevel_layout_copy (GdkToplevelLayout *layout)
g_ref_count_init (&new_layout->ref_count);
new_layout->resizable = layout->resizable;
+ new_layout->maximized_valid = layout->maximized_valid;
new_layout->maximized = layout->maximized;
+ new_layout->fullscreen_valid = layout->fullscreen_valid;
new_layout->fullscreen = layout->fullscreen;
if (layout->fullscreen_monitor)
new_layout->fullscreen_monitor = g_object_ref (layout->fullscreen_monitor);
@@ -151,7 +158,9 @@ gdk_toplevel_layout_equal (GdkToplevelLayout *layout,
g_return_val_if_fail (other, FALSE);
return layout->resizable == other->resizable &&
+ layout->maximized_valid == other->maximized_valid &&
layout->maximized == other->maximized &&
+ layout->fullscreen_valid == other->fullscreen_valid &&
layout->fullscreen == other->fullscreen &&
layout->fullscreen_monitor == other->fullscreen_monitor;
}
@@ -198,22 +207,32 @@ void
gdk_toplevel_layout_set_maximized (GdkToplevelLayout *layout,
gboolean maximized)
{
+ layout->maximized_valid = TRUE;
layout->maximized = maximized;
}
/**
* gdk_toplevel_layout_get_maximized:
* @layout: a #GdkToplevelLayout
+ * @maximized: (out): set to %TRUE if the toplevel should be maximized
*
- * Returns whether the layout should present the
- * surface as maximized.
+ * If the layout specifies whether to the toplevel should go maximized,
+ * the value pointed to by @maximized is set to %TRUE if it should go
+ * fullscreen, or %FALSE, if it should go unmaximized.
*
- * Returns: %TRUE if the layout is maximized
+ * Returns: whether the @layout specifies the maximized state for the toplevel
*/
gboolean
-gdk_toplevel_layout_get_maximized (GdkToplevelLayout *layout)
+gdk_toplevel_layout_get_maximized (GdkToplevelLayout *layout,
+ gboolean *maximized)
{
- return layout->maximized;
+ if (layout->maximized_valid)
+ {
+ *maximized = layout->maximized;
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
@@ -230,6 +249,7 @@ gdk_toplevel_layout_set_fullscreen (GdkToplevelLayout *layout,
gboolean fullscreen,
GdkMonitor *monitor)
{
+ layout->fullscreen_valid = TRUE;
layout->fullscreen = fullscreen;
if (monitor)
layout->fullscreen_monitor = g_object_ref (monitor);
@@ -238,16 +258,25 @@ gdk_toplevel_layout_set_fullscreen (GdkToplevelLayout *layout,
/**
* gdk_toplevel_layout_get_fullscreen:
* @layout: a #GdkToplevelLayout
+ * @fullscreen: (out): location to store whether the toplevel should be fullscreen
*
- * Returns whether the layout should cause the surface
- * to be fullscreen when presented.
+ * If the layout specifies whether to the toplevel should go fullscreen,
+ * the value pointed to by @fullscreen is set to %TRUE if it should go
+ * fullscreen, or %FALSE, if it should go unfullscreen.
*
- * Returns: %TRUE if @layout is fullscreen
+ * Returns: whether the @layout specifies the fullscreen state for the toplevel
*/
gboolean
-gdk_toplevel_layout_get_fullscreen (GdkToplevelLayout *layout)
+gdk_toplevel_layout_get_fullscreen (GdkToplevelLayout *layout,
+ gboolean *fullscreen)
{
- return layout->fullscreen;
+ if (layout->fullscreen_valid)
+ {
+ *fullscreen = layout->fullscreen;
+ return TRUE;
+ }
+
+ return FALSE;
}
/**