mirror of
https://github.com/emacs-exwm/exwm.git
synced 2024-11-30 16:07:59 +01:00
Use X window borders
; This commit replaces the internal borders of Emacs frames with X ; window borders. This should make the flickering issue of floating X ; windows less serious. * exwm-floating.el (exwm-floating--border-pixel) (exwm-floating--border-colormap): New variables for storing border pixel and its colormap. (exwm-floating--set-floating): Do not set the internal border (and background color) of floating frames; do not take `exwm-floating-border-width' into account when calculating geometries; set the border of floating X window containers. (exwm-floating--unset-floating): No need to restore the position of X windows any more; hide the border of floating X window containers. (exwm-floating--init): Initialize the border pixel. * exwm-layout.el (exwm-layout-set-fullscreen) (exwm-layout-unset-fullscreen): Show/Hide container border respectively. * exwm-manage.el (exwm-manage--manage-window): Set the border pixel and colormap of X window containers. * exwm-workspace.el (exwm-workspace-move-window): Do not set the internal border and background color of floating frames. * exwm.el (exwm--on-ClientMessage): Simplify the code for calculating _NET_REQUEST_FRAME_EXTENTS.
This commit is contained in:
parent
2597f74c7f
commit
6be75083c2
5 changed files with 66 additions and 36 deletions
|
@ -32,6 +32,12 @@
|
||||||
(defvar exwm-floating-border-width 1 "Border width of the floating window.")
|
(defvar exwm-floating-border-width 1 "Border width of the floating window.")
|
||||||
(defvar exwm-floating-border-color "navy"
|
(defvar exwm-floating-border-color "navy"
|
||||||
"Border color of the floating window.")
|
"Border color of the floating window.")
|
||||||
|
(defvar exwm-floating--border-pixel nil
|
||||||
|
"Border pixel drawn around floating X windows.")
|
||||||
|
(defvar exwm-floating--border-colormap nil
|
||||||
|
"Colormap used by the border pixel.
|
||||||
|
|
||||||
|
This is also used by X window containers.")
|
||||||
|
|
||||||
(defvar exwm-floating-setup-hook nil
|
(defvar exwm-floating-setup-hook nil
|
||||||
"Normal hook run when an X window has been made floating, in the
|
"Normal hook run when an X window has been made floating, in the
|
||||||
|
@ -95,8 +101,6 @@ context of the corresponding buffer.")
|
||||||
(get-buffer "*scratch*")))
|
(get-buffer "*scratch*")))
|
||||||
(make-frame
|
(make-frame
|
||||||
`((minibuffer . nil) ;use the default minibuffer.
|
`((minibuffer . nil) ;use the default minibuffer.
|
||||||
(background-color . ,exwm-floating-border-color)
|
|
||||||
(internal-border-width . ,exwm-floating-border-width)
|
|
||||||
(left . 10000)
|
(left . 10000)
|
||||||
(top . 10000)
|
(top . 10000)
|
||||||
(width . ,window-min-width)
|
(width . ,window-min-width)
|
||||||
|
@ -135,8 +139,7 @@ context of the corresponding buffer.")
|
||||||
(window-pixel-height (minibuffer-window
|
(window-pixel-height (minibuffer-window
|
||||||
original-frame)))
|
original-frame)))
|
||||||
(* 2 (window-mode-line-height))
|
(* 2 (window-mode-line-height))
|
||||||
(window-header-line-height window)
|
(window-header-line-height window)))
|
||||||
(* 2 exwm-floating-border-width)))
|
|
||||||
(display-height (* 2 (/ display-height 2)))) ;round to even
|
(display-height (* 2 (/ display-height 2)))) ;round to even
|
||||||
(if (> width display-width)
|
(if (> width display-width)
|
||||||
;; Too wide
|
;; Too wide
|
||||||
|
@ -229,14 +232,17 @@ context of the corresponding buffer.")
|
||||||
(make-instance 'xcb:ReparentWindow
|
(make-instance 'xcb:ReparentWindow
|
||||||
:window outer-id :parent frame-container :x 0 :y 0))
|
:window outer-id :parent frame-container :x 0 :y 0))
|
||||||
;; Place the X window container.
|
;; Place the X window container.
|
||||||
|
;; Also show the floating border.
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:ConfigureWindow
|
(make-instance 'xcb:ConfigureWindow
|
||||||
:window container
|
:window container
|
||||||
:value-mask (eval-when-compile
|
:value-mask (eval-when-compile
|
||||||
(logior xcb:ConfigWindow:X
|
(logior xcb:ConfigWindow:X
|
||||||
xcb:ConfigWindow:Y))
|
xcb:ConfigWindow:Y
|
||||||
:x (- x exwm-floating-border-width)
|
xcb:ConfigWindow:BorderWidth))
|
||||||
:y (- y exwm-floating-border-width)))
|
:x x
|
||||||
|
:y y
|
||||||
|
:border-width exwm-floating-border-width))
|
||||||
(exwm-floating--set-allowed-actions id nil)
|
(exwm-floating--set-allowed-actions id nil)
|
||||||
(xcb:flush exwm--connection)
|
(xcb:flush exwm--connection)
|
||||||
;; Set window/buffer
|
;; Set window/buffer
|
||||||
|
@ -294,14 +300,6 @@ context of the corresponding buffer.")
|
||||||
(make-instance 'xcb:ChangeWindowAttributes
|
(make-instance 'xcb:ChangeWindowAttributes
|
||||||
:window id :value-mask xcb:CW:EventMask
|
:window id :value-mask xcb:CW:EventMask
|
||||||
:event-mask exwm--client-event-mask))
|
:event-mask exwm--client-event-mask))
|
||||||
;; The X window might have been moved due to the floating border.
|
|
||||||
(xcb:+request exwm--connection
|
|
||||||
(make-instance 'xcb:ConfigureWindow
|
|
||||||
:window id
|
|
||||||
:value-mask (logior xcb:ConfigWindow:X
|
|
||||||
xcb:ConfigWindow:Y)
|
|
||||||
:x 0
|
|
||||||
:y 0))
|
|
||||||
;; Reparent the floating frame back to the root window.
|
;; Reparent the floating frame back to the root window.
|
||||||
(let ((frame-id (frame-parameter exwm--floating-frame 'exwm-outer-id))
|
(let ((frame-id (frame-parameter exwm--floating-frame 'exwm-outer-id))
|
||||||
(frame-container (frame-parameter exwm--floating-frame
|
(frame-container (frame-parameter exwm--floating-frame
|
||||||
|
@ -318,11 +316,14 @@ context of the corresponding buffer.")
|
||||||
(make-instance 'xcb:DestroyWindow :window frame-container))))
|
(make-instance 'xcb:DestroyWindow :window frame-container))))
|
||||||
;; Put the X window container just above the Emacs frame container
|
;; Put the X window container just above the Emacs frame container
|
||||||
;; (the stacking order won't change from now on).
|
;; (the stacking order won't change from now on).
|
||||||
|
;; Also hide the possible floating border.
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:ConfigureWindow
|
(make-instance 'xcb:ConfigureWindow
|
||||||
:window exwm--container
|
:window exwm--container
|
||||||
:value-mask (logior xcb:ConfigWindow:Sibling
|
:value-mask (logior xcb:ConfigWindow:BorderWidth
|
||||||
|
xcb:ConfigWindow:Sibling
|
||||||
xcb:ConfigWindow:StackMode)
|
xcb:ConfigWindow:StackMode)
|
||||||
|
:border-width 0
|
||||||
:sibling (frame-parameter exwm-workspace--current
|
:sibling (frame-parameter exwm-workspace--current
|
||||||
'exwm-container)
|
'exwm-container)
|
||||||
:stack-mode xcb:StackMode:Above)))
|
:stack-mode xcb:StackMode:Above)))
|
||||||
|
@ -681,6 +682,29 @@ Both DELTA-X and DELTA-Y default to 1. This command should be bound locally."
|
||||||
|
|
||||||
(defun exwm-floating--init ()
|
(defun exwm-floating--init ()
|
||||||
"Initialize floating module."
|
"Initialize floating module."
|
||||||
|
;; Check border width.
|
||||||
|
(unless (and (integerp exwm-floating-border-width)
|
||||||
|
(> exwm-floating-border-width 0))
|
||||||
|
(setq exwm-floating-border-width 0))
|
||||||
|
;; Initialize border pixel.
|
||||||
|
(when (> exwm-floating-border-width 0)
|
||||||
|
(setq exwm-floating--border-colormap
|
||||||
|
(slot-value (car (slot-value
|
||||||
|
(xcb:get-setup exwm--connection) 'roots))
|
||||||
|
'default-colormap))
|
||||||
|
(unless (stringp exwm-floating-border-color)
|
||||||
|
(setq exwm-floating-border-color ""))
|
||||||
|
(let* ((color (x-color-values exwm-floating-border-color))
|
||||||
|
reply)
|
||||||
|
(when color
|
||||||
|
(setq reply (xcb:+request-unchecked+reply exwm--connection
|
||||||
|
(make-instance 'xcb:AllocColor
|
||||||
|
:cmap exwm-floating--border-colormap
|
||||||
|
:red (pop color)
|
||||||
|
:green (pop color)
|
||||||
|
:blue (pop color))))
|
||||||
|
(when reply
|
||||||
|
(setq exwm-floating--border-pixel (slot-value reply 'pixel))))))
|
||||||
;; Initialize cursors for moving/resizing a window
|
;; Initialize cursors for moving/resizing a window
|
||||||
(xcb:cursor:init exwm--connection)
|
(xcb:cursor:init exwm--connection)
|
||||||
(setq exwm-floating--cursor-move
|
(setq exwm-floating--cursor-move
|
||||||
|
|
|
@ -214,7 +214,9 @@
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:ConfigureWindow
|
(make-instance 'xcb:ConfigureWindow
|
||||||
:window exwm--container
|
:window exwm--container
|
||||||
:value-mask xcb:ConfigWindow:StackMode
|
:value-mask (logior xcb:ConfigWindow:BorderWidth
|
||||||
|
xcb:ConfigWindow:StackMode)
|
||||||
|
:border-width 0
|
||||||
:stack-mode xcb:StackMode:Above))
|
:stack-mode xcb:StackMode:Above))
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:ewmh:set-_NET_WM_STATE
|
(make-instance 'xcb:ewmh:set-_NET_WM_STATE
|
||||||
|
@ -240,9 +242,11 @@
|
||||||
:window exwm--container
|
:window exwm--container
|
||||||
:value-mask (eval-when-compile
|
:value-mask (eval-when-compile
|
||||||
(logior xcb:ConfigWindow:X
|
(logior xcb:ConfigWindow:X
|
||||||
xcb:ConfigWindow:Y))
|
xcb:ConfigWindow:Y
|
||||||
|
xcb:ConfigWindow:BorderWidth))
|
||||||
:x (elt exwm--floating-frame-position 0)
|
:x (elt exwm--floating-frame-position 0)
|
||||||
:y (elt exwm--floating-frame-position 1)))
|
:y (elt exwm--floating-frame-position 1)
|
||||||
|
:border-width exwm-floating-border-width))
|
||||||
;; Put the X window just above the Emacs frame.
|
;; Put the X window just above the Emacs frame.
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:ConfigureWindow
|
(make-instance 'xcb:ConfigureWindow
|
||||||
|
|
|
@ -92,6 +92,8 @@ corresponding buffer.")
|
||||||
:window exwm--root
|
:window exwm--root
|
||||||
:data (vconcat (mapcar #'car exwm--id-buffer-alist)))))
|
:data (vconcat (mapcar #'car exwm--id-buffer-alist)))))
|
||||||
|
|
||||||
|
(defvar exwm-floating--border-colormap)
|
||||||
|
(defvar exwm-floating--border-pixel)
|
||||||
(defvar exwm-workspace--current)
|
(defvar exwm-workspace--current)
|
||||||
(defvar exwm-workspace--switch-history-outdated)
|
(defvar exwm-workspace--switch-history-outdated)
|
||||||
(defvar exwm-workspace-current-index)
|
(defvar exwm-workspace-current-index)
|
||||||
|
@ -243,11 +245,16 @@ corresponding buffer.")
|
||||||
:class xcb:WindowClass:InputOutput
|
:class xcb:WindowClass:InputOutput
|
||||||
:visual 0
|
:visual 0
|
||||||
:value-mask (logior xcb:CW:BackPixmap
|
:value-mask (logior xcb:CW:BackPixmap
|
||||||
|
(if exwm-floating--border-pixel
|
||||||
|
xcb:CW:BorderPixel 0)
|
||||||
xcb:CW:OverrideRedirect
|
xcb:CW:OverrideRedirect
|
||||||
xcb:CW:EventMask)
|
xcb:CW:EventMask
|
||||||
|
xcb:CW:Colormap)
|
||||||
:background-pixmap xcb:BackPixmap:ParentRelative
|
:background-pixmap xcb:BackPixmap:ParentRelative
|
||||||
|
:border-pixel exwm-floating--border-pixel
|
||||||
:override-redirect 1
|
:override-redirect 1
|
||||||
:event-mask xcb:EventMask:SubstructureRedirect))
|
:event-mask xcb:EventMask:SubstructureRedirect
|
||||||
|
:colormap exwm-floating--border-colormap))
|
||||||
(exwm--debug
|
(exwm--debug
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:ewmh:set-_NET_WM_NAME
|
(make-instance 'xcb:ewmh:set-_NET_WM_NAME
|
||||||
|
|
|
@ -636,9 +636,6 @@ INDEX must not exceed the current number of workspaces."
|
||||||
:window id
|
:window id
|
||||||
:data (exwm-workspace--position exwm--frame)))))
|
:data (exwm-workspace--position exwm--frame)))))
|
||||||
|
|
||||||
(defvar exwm-floating-border-width)
|
|
||||||
(defvar exwm-floating-border-color)
|
|
||||||
|
|
||||||
(declare-function exwm-layout--show "exwm-layout.el" (id &optional window))
|
(declare-function exwm-layout--show "exwm-layout.el" (id &optional window))
|
||||||
(declare-function exwm-layout--hide "exwm-layout.el" (id))
|
(declare-function exwm-layout--hide "exwm-layout.el" (id))
|
||||||
(declare-function exwm-layout--refresh "exwm-layout.el")
|
(declare-function exwm-layout--refresh "exwm-layout.el")
|
||||||
|
@ -691,9 +688,6 @@ INDEX must not exceed the current number of workspaces."
|
||||||
(get-buffer "*scratch*")))
|
(get-buffer "*scratch*")))
|
||||||
(make-frame
|
(make-frame
|
||||||
`((minibuffer . ,(minibuffer-window frame))
|
`((minibuffer . ,(minibuffer-window frame))
|
||||||
(background-color . ,exwm-floating-border-color)
|
|
||||||
(internal-border-width
|
|
||||||
. ,exwm-floating-border-width)
|
|
||||||
(left . 10000)
|
(left . 10000)
|
||||||
(top . 10000)
|
(top . 10000)
|
||||||
(width . ,window-min-width)
|
(width . ,window-min-width)
|
||||||
|
|
19
exwm.el
19
exwm.el
|
@ -399,19 +399,20 @@
|
||||||
;; _NET_REQUEST_FRAME_EXTENTS
|
;; _NET_REQUEST_FRAME_EXTENTS
|
||||||
((= type xcb:Atom:_NET_REQUEST_FRAME_EXTENTS)
|
((= type xcb:Atom:_NET_REQUEST_FRAME_EXTENTS)
|
||||||
(let ((buffer (exwm--id->buffer id))
|
(let ((buffer (exwm--id->buffer id))
|
||||||
left right top btm)
|
top btm)
|
||||||
(if (or (not buffer)
|
(if (or (not buffer)
|
||||||
(not (buffer-local-value 'exwm--floating-frame buffer)))
|
(not (buffer-local-value 'exwm--floating-frame buffer)))
|
||||||
(setq left 0 right 0 top 0 btm 0)
|
(setq top 0
|
||||||
(setq left exwm-floating-border-width
|
btm 0)
|
||||||
right exwm-floating-border-width
|
(setq top (window-header-line-height)
|
||||||
top (+ exwm-floating-border-width (window-header-line-height))
|
btm (window-mode-line-height)))
|
||||||
btm (+ exwm-floating-border-width
|
|
||||||
(window-mode-line-height))))
|
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:ewmh:set-_NET_FRAME_EXTENTS
|
(make-instance 'xcb:ewmh:set-_NET_FRAME_EXTENTS
|
||||||
:window id :left left :right right
|
:window id
|
||||||
:top top :bottom btm)))
|
:left 0
|
||||||
|
:right 0
|
||||||
|
:top top
|
||||||
|
:bottom btm)))
|
||||||
(xcb:flush exwm--connection))
|
(xcb:flush exwm--connection))
|
||||||
;; _NET_WM_DESKTOP.
|
;; _NET_WM_DESKTOP.
|
||||||
((= type xcb:Atom:_NET_WM_DESKTOP)
|
((= type xcb:Atom:_NET_WM_DESKTOP)
|
||||||
|
|
Loading…
Reference in a new issue