mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 22:10:08 +00:00
window: Add hide-titlebar-when-maximized property
For maximized windows, titlebars cannot be used to reposition or scale the window, so if an application does not use it to convey useful information (other than the application name), the screen space occupied by titlebars could be put to better use. Add a new window property which requests from the window manager to hide titlebars when windows are maximized to account for this. https://bugzilla.gnome.org/show_bug.cgi?id=665616
This commit is contained in:
parent
cfa0339559
commit
4f8f8fe828
@ -959,6 +959,7 @@ gdk_x11_screen_supports_net_wm_hint
|
||||
gdk_x11_window_foreign_new_for_display
|
||||
gdk_x11_window_lookup_for_display
|
||||
gdk_x11_window_get_xid
|
||||
gdk_x11_window_set_hide_titlebar_when_maximized
|
||||
gdk_x11_window_set_theme_variant
|
||||
gdk_x11_window_set_user_time
|
||||
gdk_x11_window_move_to_current_desktop
|
||||
|
@ -5291,6 +5291,7 @@ gtk_window_get_gravity
|
||||
gtk_window_set_position
|
||||
gtk_window_set_transient_for
|
||||
gtk_window_set_destroy_with_parent
|
||||
gtk_window_set_hide_titlebar_when_maximized
|
||||
gtk_window_set_screen
|
||||
gtk_window_get_screen
|
||||
gtk_window_is_active
|
||||
@ -5336,6 +5337,7 @@ gtk_window_get_default_icon_list
|
||||
gtk_window_get_default_icon_name
|
||||
gtk_window_get_default_size
|
||||
gtk_window_get_destroy_with_parent
|
||||
gtk_window_get_hide_titlebar_when_maximized
|
||||
gtk_window_get_icon
|
||||
gtk_window_get_icon_list
|
||||
gtk_window_get_icon_name
|
||||
|
@ -3130,6 +3130,49 @@ gdk_x11_window_set_theme_variant (GdkWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_x11_window_set_hide_titlebar_when_maximized:
|
||||
* @window: (type GdkX11Window): a #GdkWindow
|
||||
* @hide_titlebar_when_maximized: whether to hide the titlebar when
|
||||
* maximized
|
||||
*
|
||||
* Set a hint for the window manager, requesting that the titlebar
|
||||
* should be hidden when the window is maximized.
|
||||
*
|
||||
* Note that this property is automatically updated by GTK+, so this
|
||||
* function should only be used by applications which do not use GTK+
|
||||
* to create toplevel windows.
|
||||
*
|
||||
* Since: 3.4
|
||||
*/
|
||||
void
|
||||
gdk_x11_window_set_hide_titlebar_when_maximized (GdkWindow *window,
|
||||
gboolean hide_titlebar_when_maximized)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
|
||||
if (!WINDOW_IS_TOPLEVEL (window))
|
||||
return;
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
|
||||
if (hide_titlebar_when_maximized)
|
||||
{
|
||||
guint32 hide = 1;
|
||||
XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
|
||||
GDK_WINDOW_XID (window),
|
||||
gdk_x11_get_xatom_by_name_for_display (display, "_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"),
|
||||
XA_CARDINAL, 32,
|
||||
PropModeReplace, (guchar *)&hide, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
|
||||
GDK_WINDOW_XID (window),
|
||||
gdk_x11_get_xatom_by_name_for_display (display, "_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"));
|
||||
}
|
||||
}
|
||||
|
||||
#define GDK_SELECTION_MAX_SIZE(display) \
|
||||
MIN(262144, \
|
||||
XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \
|
||||
|
@ -59,6 +59,8 @@ void gdk_x11_window_set_user_time (GdkWindow *window,
|
||||
guint32 timestamp);
|
||||
void gdk_x11_window_set_theme_variant (GdkWindow *window,
|
||||
char *variant);
|
||||
void gdk_x11_window_set_hide_titlebar_when_maximized (GdkWindow *window,
|
||||
gboolean hide_titlebar_when_maximized);
|
||||
void gdk_x11_window_move_to_current_desktop (GdkWindow *window);
|
||||
|
||||
/**
|
||||
|
@ -152,6 +152,7 @@ struct _GtkWindowPrivate
|
||||
guint has_focus : 1;
|
||||
guint has_user_ref_count : 1;
|
||||
guint has_toplevel_focus : 1;
|
||||
guint hide_titlebar_when_maximized : 1;
|
||||
guint iconify_initially : 1; /* gtk_window_iconify() called before realization */
|
||||
guint is_active : 1;
|
||||
guint maximize_initially : 1;
|
||||
@ -206,6 +207,7 @@ enum {
|
||||
PROP_DEFAULT_WIDTH,
|
||||
PROP_DEFAULT_HEIGHT,
|
||||
PROP_DESTROY_WITH_PARENT,
|
||||
PROP_HIDE_TITLEBAR_WHEN_MAXIMIZED,
|
||||
PROP_ICON,
|
||||
PROP_ICON_NAME,
|
||||
PROP_SCREEN,
|
||||
@ -699,6 +701,21 @@ gtk_window_class_init (GtkWindowClass *klass)
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkWindow:hide-titlebar-when-maximized:
|
||||
*
|
||||
* Whether the titlebar should be hidden during maximization.
|
||||
*
|
||||
* Since: 3.4
|
||||
*/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_HIDE_TITLEBAR_WHEN_MAXIMIZED,
|
||||
g_param_spec_boolean ("hide-titlebar-when-maximized",
|
||||
P_("Hide the titlebar during maximization"),
|
||||
P_("If this window's titlebar should be hidden when the window is maximized"),
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ICON,
|
||||
g_param_spec_object ("icon",
|
||||
@ -1209,6 +1226,9 @@ gtk_window_set_property (GObject *object,
|
||||
case PROP_DESTROY_WITH_PARENT:
|
||||
gtk_window_set_destroy_with_parent (window, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_HIDE_TITLEBAR_WHEN_MAXIMIZED:
|
||||
gtk_window_set_hide_titlebar_when_maximized (window, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_ICON:
|
||||
gtk_window_set_icon (window,
|
||||
g_value_get_object (value));
|
||||
@ -1323,6 +1343,9 @@ gtk_window_get_property (GObject *object,
|
||||
case PROP_DESTROY_WITH_PARENT:
|
||||
g_value_set_boolean (value, priv->destroy_with_parent);
|
||||
break;
|
||||
case PROP_HIDE_TITLEBAR_WHEN_MAXIMIZED:
|
||||
g_value_set_boolean (value, priv->hide_titlebar_when_maximized);
|
||||
break;
|
||||
case PROP_ICON:
|
||||
g_value_set_object (value, gtk_window_get_icon (window));
|
||||
break;
|
||||
@ -3039,6 +3062,61 @@ gtk_window_get_destroy_with_parent (GtkWindow *window)
|
||||
return window->priv->destroy_with_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_set_hide_titlebar_when_maximized:
|
||||
* @window: a #GtkWindow
|
||||
* @setting: whether to hide the titlebar when @window is maximized
|
||||
*
|
||||
* If @setting is %TRUE, then @window will request that it's titlebar
|
||||
* should be hidden when maximized.
|
||||
* This is useful for windows that don't convey any information other
|
||||
* than the application name in the titlebar, to put the available
|
||||
* screen space to better use. If the underlying window system does not
|
||||
* support the request, the setting will not have any effect.
|
||||
*
|
||||
* Since: 3.4
|
||||
**/
|
||||
void
|
||||
gtk_window_set_hide_titlebar_when_maximized (GtkWindow *window,
|
||||
gboolean setting)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
{
|
||||
GdkWindow *gdk_window;
|
||||
|
||||
gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
|
||||
|
||||
if (GDK_IS_X11_WINDOW (gdk_window))
|
||||
gdk_x11_window_set_hide_titlebar_when_maximized (gdk_window, setting);
|
||||
}
|
||||
#endif
|
||||
|
||||
window->priv->hide_titlebar_when_maximized = setting;
|
||||
g_object_notify (G_OBJECT (window), "hide-titlebar-when-maximized");
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_get_hide_titlebar_when_maximized:
|
||||
* @window: a #GtkWindow
|
||||
*
|
||||
* Returns whether the window has requested to have its titlebar hidden
|
||||
* when maximized. See gtk_window_set_hide_titlebar_when_maximized ().
|
||||
*
|
||||
* Return value: %TRUE if the window has requested to have its titlebar
|
||||
* hidden when maximized
|
||||
*
|
||||
* Since: 3.4
|
||||
**/
|
||||
gboolean
|
||||
gtk_window_get_hide_titlebar_when_maximized (GtkWindow *window)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
|
||||
|
||||
return window->priv->hide_titlebar_when_maximized;
|
||||
}
|
||||
|
||||
static GtkWindowGeometryInfo*
|
||||
gtk_window_get_geometry_info (GtkWindow *window,
|
||||
gboolean create)
|
||||
@ -4760,7 +4838,11 @@ gtk_window_map (GtkWidget *widget)
|
||||
gdk_window_set_keep_below (gdk_window, priv->below_initially);
|
||||
|
||||
if (priv->type == GTK_WINDOW_TOPLEVEL)
|
||||
gtk_window_set_theme_variant (window);
|
||||
{
|
||||
gtk_window_set_theme_variant (window);
|
||||
gtk_window_set_hide_titlebar_when_maximized (window,
|
||||
priv->hide_titlebar_when_maximized);
|
||||
}
|
||||
|
||||
/* No longer use the default settings */
|
||||
priv->need_default_size = FALSE;
|
||||
|
@ -159,6 +159,9 @@ gboolean gtk_window_get_focus_on_map (GtkWindow *window);
|
||||
void gtk_window_set_destroy_with_parent (GtkWindow *window,
|
||||
gboolean setting);
|
||||
gboolean gtk_window_get_destroy_with_parent (GtkWindow *window);
|
||||
void gtk_window_set_hide_titlebar_when_maximized (GtkWindow *window,
|
||||
gboolean setting);
|
||||
gboolean gtk_window_get_hide_titlebar_when_maximized (GtkWindow *window);
|
||||
void gtk_window_set_mnemonics_visible (GtkWindow *window,
|
||||
gboolean setting);
|
||||
gboolean gtk_window_get_mnemonics_visible (GtkWindow *window);
|
||||
|
Loading…
Reference in New Issue
Block a user