Allow hide/show mode-line on floating frames
* exwm-core.el: new buffer-local variable exwm--floating-mode-line-format for saving mode-line-format when mode-line is hidden * exwm-floating.el (exwm-floating--fit-frame-to-window) (exwm-floating-hide-mode-line, exwm-floating-show-mode-line): new functions for resizing frames, hiding/showing mode-line respectively; (exwm-floating--set-floating): use exwm-floating--fit-frame-to-window to resize frames
This commit is contained in:
parent
637ac15719
commit
eafd031c55
2 changed files with 62 additions and 18 deletions
|
@ -82,6 +82,7 @@
|
||||||
(defvar-local exwm--frame nil) ;workspace frame
|
(defvar-local exwm--frame nil) ;workspace frame
|
||||||
(defvar-local exwm--floating-frame nil) ;floating frame
|
(defvar-local exwm--floating-frame nil) ;floating frame
|
||||||
(defvar-local exwm--floating-edges nil) ;four edges
|
(defvar-local exwm--floating-edges nil) ;four edges
|
||||||
|
(defvar-local exwm--floating-mode-line-format nil) ;save mode-line-format
|
||||||
(defvar-local exwm--fullscreen nil) ;used in fullscreen
|
(defvar-local exwm--fullscreen nil) ;used in fullscreen
|
||||||
(defvar-local exwm--floating-frame-geometry nil) ;in fullscreen
|
(defvar-local exwm--floating-frame-geometry nil) ;in fullscreen
|
||||||
(defvar-local exwm--fixed-size nil) ;fixed size
|
(defvar-local exwm--fixed-size nil) ;fixed size
|
||||||
|
|
|
@ -166,17 +166,7 @@
|
||||||
(+ width exwm-floating-border-width)
|
(+ width exwm-floating-border-width)
|
||||||
(+ height exwm-floating-border-width))))
|
(+ height exwm-floating-border-width))))
|
||||||
;; Fit frame to client
|
;; Fit frame to client
|
||||||
(xcb:+request exwm--connection
|
(exwm-floating--fit-frame-to-window outer-id width height)
|
||||||
(make-instance 'xcb:ConfigureWindow
|
|
||||||
:window outer-id
|
|
||||||
:value-mask (logior xcb:ConfigWindow:Width
|
|
||||||
xcb:ConfigWindow:Height
|
|
||||||
xcb:ConfigWindow:StackMode)
|
|
||||||
:width (+ width (* 2 exwm-floating-border-width))
|
|
||||||
:height (+ height (* 2 exwm-floating-border-width)
|
|
||||||
(window-mode-line-height)
|
|
||||||
(window-header-line-height))
|
|
||||||
:stack-mode xcb:StackMode:Above)) ;top-most
|
|
||||||
;; Reparent window to this frame
|
;; Reparent window to this frame
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:ChangeWindowAttributes
|
(make-instance 'xcb:ChangeWindowAttributes
|
||||||
|
@ -246,6 +236,59 @@
|
||||||
(exwm-floating--unset-floating exwm--id)
|
(exwm-floating--unset-floating exwm--id)
|
||||||
(exwm-floating--set-floating exwm--id))))
|
(exwm-floating--set-floating exwm--id))))
|
||||||
|
|
||||||
|
(defun exwm-floating--fit-frame-to-window (&optional frame-outer-id
|
||||||
|
width height)
|
||||||
|
"Resize a floating frame to make it fit the size of the window.
|
||||||
|
|
||||||
|
Default to resize `exwm--floating-frame' unless FRAME-OUTER-ID is non-nil.
|
||||||
|
This function will issue an `xcb:GetGeometry' request unless WIDTH and HEIGHT
|
||||||
|
are provided. You should call `xcb:flush' and assign `window-size-fixed' a
|
||||||
|
non-nil value afterwards."
|
||||||
|
(setq window-size-fixed nil)
|
||||||
|
(unless (and width height)
|
||||||
|
(let ((geometry (xcb:+request-unchecked+reply exwm--connection
|
||||||
|
(make-instance 'xcb:GetGeometry :drawable exwm--id))))
|
||||||
|
(setq width (slot-value geometry 'width)
|
||||||
|
height (slot-value geometry 'height))))
|
||||||
|
(xcb:+request exwm--connection
|
||||||
|
(make-instance 'xcb:ConfigureWindow
|
||||||
|
:window (or frame-outer-id
|
||||||
|
(frame-parameter exwm--floating-frame
|
||||||
|
'exwm-outer-id))
|
||||||
|
:value-mask (logior xcb:ConfigWindow:Width
|
||||||
|
xcb:ConfigWindow:Height
|
||||||
|
xcb:ConfigWindow:StackMode)
|
||||||
|
:width (+ width (* 2 exwm-floating-border-width))
|
||||||
|
:height (+ height (* 2 exwm-floating-border-width)
|
||||||
|
(window-mode-line-height)
|
||||||
|
(window-header-line-height))
|
||||||
|
:stack-mode xcb:StackMode:Above))) ;top-most
|
||||||
|
|
||||||
|
(defun exwm-floating-hide-mode-line ()
|
||||||
|
"Hide mode-line of a floating frame."
|
||||||
|
(interactive)
|
||||||
|
(unless (eq major-mode 'exwm-mode)
|
||||||
|
(user-error "[EXWM] Please use this command with EXWM buffers"))
|
||||||
|
(when (and exwm--floating-frame mode-line-format)
|
||||||
|
(setq exwm--floating-mode-line-format mode-line-format
|
||||||
|
mode-line-format nil)
|
||||||
|
(exwm-floating--fit-frame-to-window)
|
||||||
|
(xcb:flush exwm--connection)
|
||||||
|
(setq window-size-fixed t)))
|
||||||
|
|
||||||
|
(defun exwm-floating-show-mode-line ()
|
||||||
|
"Show mode-line of a floating frame."
|
||||||
|
(interactive)
|
||||||
|
(unless (eq major-mode 'exwm-mode)
|
||||||
|
(user-error "[EXWM] Please use this command with EXWM buffers"))
|
||||||
|
(when (and exwm--floating-frame (not mode-line-format))
|
||||||
|
(setq mode-line-format exwm--floating-mode-line-format
|
||||||
|
exwm--floating-mode-line-format nil)
|
||||||
|
(exwm-floating--fit-frame-to-window)
|
||||||
|
(exwm-input-grab-keyboard) ;mode-line-format may be outdated
|
||||||
|
(xcb:flush exwm--connection)
|
||||||
|
(setq window-size-fixed t)))
|
||||||
|
|
||||||
(defvar exwm-floating--moveresize-calculate nil
|
(defvar exwm-floating--moveresize-calculate nil
|
||||||
"Calculate move/resize parameters [frame-id event-mask x y width height].")
|
"Calculate move/resize parameters [frame-id event-mask x y width height].")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue