From: Lars Ingebrigtsen Date: Fri, 29 Apr 2022 10:42:06 +0000 (+0200) Subject: Add helper function to remove title bar when maximizing frames X-Git-Tag: emacs-29.0.90~1931^2~221 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e313cae71fc38e29849e68b421a16a1014626d04;p=emacs.git Add helper function to remove title bar when maximizing frames * lisp/frame.el (toggle-frame-maximized): Mention it. (frame-hide-title-bar-when-maximized): New function (bug#31968). Adapted from code by Jonathan Kyle Mitchell. * src/window.c (syms_of_window): Mention it. --- diff --git a/lisp/frame.el b/lisp/frame.el index 83e67dac4e5..49eabcf9786 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2960,6 +2960,12 @@ If the frame is in fullscreen state, don't change its state, but set the frame's `fullscreen-restore' parameter to `maximized', so the frame will be maximized after disabling fullscreen state. +If you wish to hide the title bar when the frame is maximized, you +can add something like the following to your init file: + + (add-hook \\='window-size-change-functions + #\\='frame-hide-title-bar-when-maximized) + Note that with some window managers you may have to set `frame-resize-pixelwise' to non-nil in order to make a frame appear truly maximized. In addition, you may have to set @@ -3075,6 +3081,13 @@ Offer NUMBER as default value, if it is a natural number." bidi-display-reordering bidi-inhibit-bpa)) +(defun frame-hide-title-bar-when-maximized (frame) + "Hide the title bar if FRAME is maximized. +If FRAME isn't maximized, show the title bar." + (set-frame-parameter + frame 'undecorated + (eq (alist-get 'fullscreen (frame-parameters frame)) 'maximized))) + (provide 'frame) ;;; frame.el ends here diff --git a/src/window.c b/src/window.c index 48da7839314..ad0f54000c0 100644 --- a/src/window.c +++ b/src/window.c @@ -8341,7 +8341,10 @@ In this case the window is passed as argument. Functions specified by the default value are called for each frame if at least one window on that frame has been added or changed its buffer or its total or body size since the last redisplay. In this case the -frame is passed as argument. */); +frame is passed as argument. + +For instance, to hide the title bar when the frame is maximized, you +can add `frame-hide-title-bar-when-maximized' to this variable. */); Vwindow_size_change_functions = Qnil; DEFVAR_LISP ("window-selection-change-functions", Vwindow_selection_change_functions,