2015-07-17 13:16:08 +02:00
|
|
|
|
;;; exwm-manage.el --- Window Management Module for -*- lexical-binding: t -*-
|
|
|
|
|
;;; EXWM
|
|
|
|
|
|
2024-01-08 01:00:00 +01:00
|
|
|
|
;; Copyright (C) 2015-2024 Free Software Foundation, Inc.
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
|
|
|
|
;; Author: Chris Feng <chris.w.feng@gmail.com>
|
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; This file is part of GNU Emacs.
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; This is the fundamental module of EXWM that deals with window management.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(require 'exwm-core)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(defgroup exwm-manage nil
|
|
|
|
|
"Manage."
|
|
|
|
|
:group 'exwm)
|
|
|
|
|
|
|
|
|
|
(defcustom exwm-manage-finish-hook nil
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Normal hook run after a window is just managed.
|
|
|
|
|
This hook runs in the context of the corresponding `exwm-mode' buffer."
|
2018-02-18 17:04:27 +01:00
|
|
|
|
:type 'hook)
|
|
|
|
|
|
|
|
|
|
(defcustom exwm-manage-force-tiling nil
|
2016-07-26 15:39:39 +02:00
|
|
|
|
"Non-nil to force managing all X windows in tiling layout.
|
2018-02-18 17:04:27 +01:00
|
|
|
|
You can still make the X windows floating afterwards."
|
|
|
|
|
:type 'boolean)
|
2016-07-26 15:39:39 +02:00
|
|
|
|
|
2018-02-25 17:25:11 +01:00
|
|
|
|
(defcustom exwm-manage-ping-timeout 3
|
|
|
|
|
"Seconds to wait before killing a client."
|
|
|
|
|
:type 'integer)
|
|
|
|
|
|
2018-03-01 17:52:03 +01:00
|
|
|
|
(defcustom exwm-manage-configurations nil
|
2019-04-14 02:00:00 +02:00
|
|
|
|
"Per-application configurations.
|
|
|
|
|
|
|
|
|
|
Configuration options allow to override various default behaviors of EXWM
|
|
|
|
|
and only take effect when they are present. Note for certain options
|
|
|
|
|
specifying nil is not exactly the same as leaving them out. Currently
|
|
|
|
|
possible choices:
|
|
|
|
|
* floating: Force floating (non-nil) or tiling (nil) on startup.
|
|
|
|
|
* x/y/width/height: Override the initial geometry (floating X window only).
|
|
|
|
|
* border-width: Override the border width (only visible when floating).
|
|
|
|
|
* fullscreen: Force full screen (non-nil) on startup.
|
|
|
|
|
* floating-mode-line: `mode-line-format' used when floating.
|
|
|
|
|
* tiling-mode-line: `mode-line-format' used when tiling.
|
|
|
|
|
* floating-header-line: `header-line-format' used when floating.
|
|
|
|
|
* tiling-header-line: `header-line-format' used when tiling.
|
|
|
|
|
* char-mode: Force char-mode (non-nil) on startup.
|
|
|
|
|
* prefix-keys: `exwm-input-prefix-keys' local to this X window.
|
|
|
|
|
* simulation-keys: `exwm-input-simulation-keys' local to this X window.
|
|
|
|
|
* workspace: The initial workspace.
|
|
|
|
|
* managed: Force to manage (non-nil) or not manage (nil) the X window.
|
|
|
|
|
|
|
|
|
|
For each X window managed for the first time, matching criteria (sexps) are
|
|
|
|
|
evaluated sequentially and the first configuration with a non-nil matching
|
2019-09-08 02:00:00 +02:00
|
|
|
|
criterion would be applied. Apart from generic forms, one would typically
|
|
|
|
|
want to match against EXWM internal variables such as `exwm-title',
|
|
|
|
|
`exwm-class-name' and `exwm-instance-name'."
|
2018-03-01 17:52:03 +01:00
|
|
|
|
:type '(alist :key-type (sexp :tag "Matching criterion" nil)
|
|
|
|
|
:value-type
|
|
|
|
|
(plist :tag "Configurations"
|
2019-08-11 02:00:00 +02:00
|
|
|
|
:options
|
|
|
|
|
(((const :tag "Floating" floating) boolean)
|
|
|
|
|
((const :tag "X" x) number)
|
|
|
|
|
((const :tag "Y" y) number)
|
|
|
|
|
((const :tag "Width" width) number)
|
|
|
|
|
((const :tag "Height" height) number)
|
|
|
|
|
((const :tag "Border width" border-width) integer)
|
|
|
|
|
((const :tag "Fullscreen" fullscreen) boolean)
|
|
|
|
|
((const :tag "Floating mode-line" floating-mode-line)
|
|
|
|
|
sexp)
|
|
|
|
|
((const :tag "Tiling mode-line" tiling-mode-line) sexp)
|
|
|
|
|
((const :tag "Floating header-line"
|
|
|
|
|
floating-header-line)
|
|
|
|
|
sexp)
|
|
|
|
|
((const :tag "Tiling header-line" tiling-header-line)
|
|
|
|
|
sexp)
|
|
|
|
|
((const :tag "Char-mode" char-mode) boolean)
|
|
|
|
|
((const :tag "Prefix keys" prefix-keys)
|
|
|
|
|
(repeat key-sequence))
|
|
|
|
|
((const :tag "Simulation keys" simulation-keys)
|
|
|
|
|
(alist :key-type (key-sequence :tag "From")
|
|
|
|
|
:value-type (key-sequence :tag "To")))
|
|
|
|
|
((const :tag "Workspace" workspace) integer)
|
|
|
|
|
((const :tag "Managed" managed) boolean)
|
2018-03-01 17:52:03 +01:00
|
|
|
|
;; For forward compatibility.
|
2019-08-11 02:00:00 +02:00
|
|
|
|
((other) sexp))))
|
|
|
|
|
;; TODO: This is admittedly ugly. We'd be better off with an event type.
|
|
|
|
|
:get (lambda (symbol)
|
|
|
|
|
(mapcar (lambda (pair)
|
|
|
|
|
(let* ((match (car pair))
|
|
|
|
|
(config (cdr pair))
|
|
|
|
|
(prefix-keys (plist-get config 'prefix-keys)))
|
|
|
|
|
(when prefix-keys
|
|
|
|
|
(setq config (copy-tree config)
|
|
|
|
|
config (plist-put config 'prefix-keys
|
|
|
|
|
(mapcar (lambda (i)
|
|
|
|
|
(if (sequencep i)
|
|
|
|
|
i
|
|
|
|
|
(vector i)))
|
|
|
|
|
prefix-keys))))
|
|
|
|
|
(cons match config)))
|
|
|
|
|
(default-value symbol)))
|
|
|
|
|
:set (lambda (symbol value)
|
|
|
|
|
(set symbol
|
|
|
|
|
(mapcar (lambda (pair)
|
|
|
|
|
(let* ((match (car pair))
|
|
|
|
|
(config (cdr pair))
|
|
|
|
|
(prefix-keys (plist-get config 'prefix-keys)))
|
|
|
|
|
(when prefix-keys
|
|
|
|
|
(setq config (copy-tree config)
|
|
|
|
|
config (plist-put config 'prefix-keys
|
|
|
|
|
(mapcar (lambda (i)
|
|
|
|
|
(if (sequencep i)
|
|
|
|
|
(aref i 0)
|
|
|
|
|
i))
|
|
|
|
|
prefix-keys))))
|
|
|
|
|
(cons match config)))
|
|
|
|
|
value))))
|
2018-03-01 17:52:03 +01:00
|
|
|
|
|
2018-02-18 17:04:27 +01:00
|
|
|
|
;; FIXME: Make the following values as small as possible.
|
|
|
|
|
(defconst exwm-manage--height-delta-min 5)
|
|
|
|
|
(defconst exwm-manage--width-delta-min 5)
|
2016-07-26 15:39:39 +02:00
|
|
|
|
|
2018-02-18 17:04:27 +01:00
|
|
|
|
;; The _MOTIF_WM_HINTS atom (see <Xm/MwmUtil.h> for more details)
|
|
|
|
|
;; It's currently only used in 'exwm-manage' module
|
|
|
|
|
(defvar exwm-manage--_MOTIF_WM_HINTS nil "_MOTIF_WM_HINTS atom.")
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2016-08-12 13:22:18 +02:00
|
|
|
|
(defvar exwm-manage--desktop nil "The desktop X window.")
|
|
|
|
|
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(defvar exwm-manage--frame-outer-id-list nil
|
|
|
|
|
"List of window-outer-id's of all frames.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-manage--ping-lock nil
|
|
|
|
|
"Non-nil indicates EXWM is pinging a window.")
|
|
|
|
|
|
2018-12-16 01:00:00 +01:00
|
|
|
|
(defvar exwm-input--skip-buffer-list-update)
|
2018-03-02 18:00:28 +01:00
|
|
|
|
(defvar exwm-input-prefix-keys)
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(defvar exwm-workspace--current)
|
|
|
|
|
(defvar exwm-workspace--id-struts-alist)
|
|
|
|
|
(defvar exwm-workspace--list)
|
|
|
|
|
(defvar exwm-workspace--switch-history-outdated)
|
|
|
|
|
(defvar exwm-workspace-current-index)
|
|
|
|
|
(declare-function exwm--update-class "exwm.el" (id &optional force))
|
|
|
|
|
(declare-function exwm--update-hints "exwm.el" (id &optional force))
|
|
|
|
|
(declare-function exwm--update-normal-hints "exwm.el" (id &optional force))
|
|
|
|
|
(declare-function exwm--update-protocols "exwm.el" (id &optional force))
|
|
|
|
|
(declare-function exwm--update-struts "exwm.el" (id))
|
|
|
|
|
(declare-function exwm--update-title "exwm.el" (id))
|
|
|
|
|
(declare-function exwm--update-transient-for "exwm.el" (id &optional force))
|
2018-02-19 15:34:03 +01:00
|
|
|
|
(declare-function exwm--update-desktop "exwm.el" (id &optional force))
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(declare-function exwm--update-window-type "exwm.el" (id &optional force))
|
|
|
|
|
(declare-function exwm-floating--set-floating "exwm-floating.el" (id))
|
|
|
|
|
(declare-function exwm-floating--unset-floating "exwm-floating.el" (id))
|
2023-08-18 02:00:00 +02:00
|
|
|
|
(declare-function exwm-input-grab-keyboard "exwm-input.el" (&optional id))
|
|
|
|
|
(declare-function exwm-input-release-keyboard "exwm-input.el" (&optional id))
|
2018-03-02 18:00:28 +01:00
|
|
|
|
(declare-function exwm-input-set-local-simulation-keys "exwm-input.el")
|
2018-03-04 05:23:37 +01:00
|
|
|
|
(declare-function exwm-layout--fullscreen-p "exwm-layout.el" ())
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(declare-function exwm-layout--iconic-state-p "exwm-layout.el" (&optional id))
|
2023-08-18 02:00:00 +02:00
|
|
|
|
(declare-function exwm-layout-set-fullscreen "exwm-layout.el" (&optional id))
|
|
|
|
|
(declare-function exwm-workspace--get-geometry "exwm-workspace.el" (frame))
|
2018-02-19 15:40:27 +01:00
|
|
|
|
(declare-function exwm-workspace--position "exwm-workspace.el" (frame))
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(declare-function exwm-workspace--set-fullscreen "exwm-workspace.el" (frame))
|
|
|
|
|
(declare-function exwm-workspace--update-struts "exwm-workspace.el" ())
|
|
|
|
|
(declare-function exwm-workspace--update-workareas "exwm-workspace.el" ())
|
2023-06-09 02:00:00 +02:00
|
|
|
|
(declare-function exwm-workspace--workarea "exwm-workspace.el" (frame))
|
2018-02-18 17:04:27 +01:00
|
|
|
|
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(defun exwm-manage--update-geometry (id &optional force)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Update geometry of X window ID.
|
|
|
|
|
Override current geometry if FORCE is non-nil."
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log "id=#x%x" id)
|
2015-08-10 08:23:37 +02:00
|
|
|
|
(with-current-buffer (exwm--id->buffer id)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(unless (and exwm--geometry (not force))
|
|
|
|
|
(let ((reply (xcb:+request-unchecked+reply exwm--connection
|
|
|
|
|
(make-instance 'xcb:GetGeometry :drawable id))))
|
2018-05-20 10:14:01 +02:00
|
|
|
|
(setq exwm--geometry
|
|
|
|
|
(or reply
|
|
|
|
|
;; Provide a reasonable fallback value.
|
|
|
|
|
(make-instance 'xcb:RECTANGLE
|
|
|
|
|
:x 0
|
|
|
|
|
:y 0
|
|
|
|
|
:width (/ (x-display-pixel-width) 2)
|
|
|
|
|
:height (/ (x-display-pixel-height) 2))))))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2016-08-12 13:27:26 +02:00
|
|
|
|
(defun exwm-manage--update-ewmh-state (id)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Update _NET_WM_STATE of X window ID."
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log "id=#x%x" id)
|
2016-08-12 13:27:26 +02:00
|
|
|
|
(with-current-buffer (exwm--id->buffer id)
|
|
|
|
|
(unless exwm--ewmh-state
|
|
|
|
|
(let ((reply (xcb:+request-unchecked+reply exwm--connection
|
|
|
|
|
(make-instance 'xcb:ewmh:get-_NET_WM_STATE
|
|
|
|
|
:window id))))
|
|
|
|
|
(when reply
|
|
|
|
|
(setq exwm--ewmh-state (append (slot-value reply 'value) nil)))))))
|
|
|
|
|
|
2015-09-19 10:46:08 +02:00
|
|
|
|
(defun exwm-manage--update-mwm-hints (id &optional force)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Update _MOTIF_WM_HINTS of X window ID.
|
|
|
|
|
Override current hinds if FORCE is non-nil."
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log "id=#x%x" id)
|
2015-09-19 10:46:08 +02:00
|
|
|
|
(with-current-buffer (exwm--id->buffer id)
|
2016-05-24 06:30:53 +02:00
|
|
|
|
(unless (and (not exwm--mwm-hints-decorations) (not force))
|
2015-09-19 10:46:08 +02:00
|
|
|
|
(let ((reply (xcb:+request-unchecked+reply exwm--connection
|
|
|
|
|
(make-instance 'xcb:icccm:-GetProperty
|
|
|
|
|
:window id
|
|
|
|
|
:property exwm-manage--_MOTIF_WM_HINTS
|
|
|
|
|
:type exwm-manage--_MOTIF_WM_HINTS
|
|
|
|
|
:long-length 5))))
|
|
|
|
|
(when reply
|
2016-05-24 06:30:53 +02:00
|
|
|
|
;; Check MotifWmHints.decorations.
|
|
|
|
|
(with-slots (value) reply
|
|
|
|
|
(setq value (append value nil))
|
|
|
|
|
(when (and value
|
|
|
|
|
;; See <Xm/MwmUtil.h> for fields definitions.
|
|
|
|
|
(/= 0 (logand
|
|
|
|
|
(elt value 0) ;MotifWmHints.flags
|
|
|
|
|
2)) ;MWM_HINTS_DECORATIONS
|
|
|
|
|
(= 0
|
|
|
|
|
(elt value 2))) ;MotifWmHints.decorations
|
|
|
|
|
(setq exwm--mwm-hints-decorations nil))))))))
|
2015-09-19 10:46:08 +02:00
|
|
|
|
|
2024-02-04 21:57:58 +01:00
|
|
|
|
(defun exwm-manage--update-default-directory (id)
|
|
|
|
|
"Update the `default-directory' of X window ID.
|
|
|
|
|
Sets the `default-directory' of the EXWM buffer associated with X window to
|
|
|
|
|
match its current working directory.
|
|
|
|
|
|
|
|
|
|
This only works when procfs is mounted, which may not be the case on some BSDs."
|
|
|
|
|
(with-current-buffer (exwm--id->buffer id)
|
|
|
|
|
(if-let* ((response (xcb:+request-unchecked+reply exwm--connection
|
|
|
|
|
(make-instance 'xcb:ewmh:get-_NET_WM_PID
|
|
|
|
|
:window id)))
|
|
|
|
|
(pid (slot-value response 'value))
|
|
|
|
|
(cwd (file-symlink-p (format "/proc/%d/cwd" pid)))
|
|
|
|
|
((file-accessible-directory-p cwd)))
|
2024-02-04 22:39:06 +01:00
|
|
|
|
(setq default-directory (file-name-as-directory cwd))
|
2024-02-04 21:57:58 +01:00
|
|
|
|
(setq default-directory (expand-file-name "~/")))))
|
|
|
|
|
|
|
|
|
|
|
2016-07-13 12:51:32 +02:00
|
|
|
|
(defun exwm-manage--set-client-list ()
|
|
|
|
|
"Set _NET_CLIENT_LIST."
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log)
|
2016-07-13 12:51:32 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ewmh:set-_NET_CLIENT_LIST
|
|
|
|
|
:window exwm--root
|
|
|
|
|
:data (vconcat (mapcar #'car exwm--id-buffer-alist)))))
|
|
|
|
|
|
2018-03-01 17:52:03 +01:00
|
|
|
|
(cl-defun exwm-manage--get-configurations ()
|
|
|
|
|
"Retrieve configurations for this buffer."
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log)
|
2018-03-01 17:52:03 +01:00
|
|
|
|
(when (derived-mode-p 'exwm-mode)
|
|
|
|
|
(dolist (i exwm-manage-configurations)
|
|
|
|
|
(save-current-buffer
|
2019-09-08 02:00:00 +02:00
|
|
|
|
(when (with-demoted-errors "Problematic configuration: %S"
|
|
|
|
|
(eval (car i) t))
|
2018-03-01 17:52:03 +01:00
|
|
|
|
(cl-return-from exwm-manage--get-configurations (cdr i)))))))
|
|
|
|
|
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(defun exwm-manage--manage-window (id)
|
|
|
|
|
"Manage window ID."
|
2015-08-07 15:52:34 +02:00
|
|
|
|
(exwm--log "Try to manage #x%x" id)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(catch 'return
|
|
|
|
|
;; Ensure it's alive
|
|
|
|
|
(when (xcb:+request-checked+request-check exwm--connection
|
|
|
|
|
(make-instance 'xcb:ChangeWindowAttributes
|
|
|
|
|
:window id :value-mask xcb:CW:EventMask
|
2019-03-17 01:00:00 +01:00
|
|
|
|
:event-mask (exwm--get-client-event-mask)))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(throw 'return 'dead))
|
2016-07-30 13:01:33 +02:00
|
|
|
|
;; Add this X window to save-set.
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ChangeSaveSet
|
|
|
|
|
:mode xcb:SetMode:Insert
|
|
|
|
|
:window id))
|
2018-12-16 01:00:00 +01:00
|
|
|
|
(with-current-buffer (let ((exwm-input--skip-buffer-list-update t))
|
|
|
|
|
(generate-new-buffer "*EXWM*"))
|
2016-07-13 12:51:32 +02:00
|
|
|
|
;; Keep the oldest X window first.
|
|
|
|
|
(setq exwm--id-buffer-alist
|
|
|
|
|
(nconc exwm--id-buffer-alist `((,id . ,(current-buffer)))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(exwm-mode)
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
(setq exwm--id id
|
|
|
|
|
exwm--frame exwm-workspace--current)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(exwm--update-window-type id)
|
|
|
|
|
(exwm--update-class id)
|
2015-09-19 11:52:04 +02:00
|
|
|
|
(exwm--update-transient-for id)
|
|
|
|
|
(exwm--update-normal-hints id)
|
2016-05-24 06:30:53 +02:00
|
|
|
|
(exwm--update-hints id)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(exwm-manage--update-geometry id)
|
2015-09-19 10:46:08 +02:00
|
|
|
|
(exwm-manage--update-mwm-hints id)
|
2019-02-01 01:00:00 +01:00
|
|
|
|
(exwm--update-title id)
|
|
|
|
|
(exwm--update-protocols id)
|
2018-11-18 01:00:00 +01:00
|
|
|
|
(setq exwm--configurations (exwm-manage--get-configurations))
|
|
|
|
|
;; OverrideRedirect is not checked here.
|
|
|
|
|
(when (and
|
|
|
|
|
;; The user has specified to manage it.
|
|
|
|
|
(not (plist-get exwm--configurations 'managed))
|
|
|
|
|
(or
|
|
|
|
|
;; The user has specified not to manage it.
|
|
|
|
|
(plist-member exwm--configurations 'managed)
|
|
|
|
|
;; This is not a type of X window we can manage.
|
|
|
|
|
(and exwm-window-type
|
|
|
|
|
(not (cl-intersection
|
|
|
|
|
exwm-window-type
|
|
|
|
|
(list xcb:Atom:_NET_WM_WINDOW_TYPE_UTILITY
|
|
|
|
|
xcb:Atom:_NET_WM_WINDOW_TYPE_DIALOG
|
|
|
|
|
xcb:Atom:_NET_WM_WINDOW_TYPE_NORMAL))))
|
|
|
|
|
;; Check the _MOTIF_WM_HINTS property to not manage floating X
|
|
|
|
|
;; windows without decoration.
|
|
|
|
|
(and (not exwm--mwm-hints-decorations)
|
|
|
|
|
(not exwm--hints-input)
|
|
|
|
|
;; Floating windows only
|
|
|
|
|
(or exwm-transient-for exwm--fixed-size
|
|
|
|
|
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_UTILITY
|
|
|
|
|
exwm-window-type)
|
|
|
|
|
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_DIALOG
|
|
|
|
|
exwm-window-type)))))
|
2015-08-07 15:52:34 +02:00
|
|
|
|
(exwm--log "No need to manage #x%x" id)
|
2016-07-12 12:35:51 +02:00
|
|
|
|
;; Update struts.
|
|
|
|
|
(when (memq xcb:Atom:_NET_WM_WINDOW_TYPE_DOCK exwm-window-type)
|
2016-07-15 14:04:56 +02:00
|
|
|
|
(exwm--update-struts id))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;; Remove all events
|
2016-02-18 12:56:01 +01:00
|
|
|
|
(xcb:+request exwm--connection
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(make-instance 'xcb:ChangeWindowAttributes
|
|
|
|
|
:window id :value-mask xcb:CW:EventMask
|
2016-07-12 12:35:51 +02:00
|
|
|
|
:event-mask
|
|
|
|
|
(if (memq xcb:Atom:_NET_WM_WINDOW_TYPE_DOCK
|
|
|
|
|
exwm-window-type)
|
2016-07-15 14:04:56 +02:00
|
|
|
|
;; Listen for PropertyChange (struts) and
|
|
|
|
|
;; UnmapNotify/DestroyNotify event of the dock.
|
2019-03-17 01:00:00 +01:00
|
|
|
|
(exwm--get-client-event-mask)
|
2016-07-12 12:35:51 +02:00
|
|
|
|
xcb:EventMask:NoEvent)))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;; The window needs to be mapped
|
|
|
|
|
(xcb:+request exwm--connection
|
2015-08-28 20:14:04 +02:00
|
|
|
|
(make-instance 'xcb:MapWindow :window id))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(with-slots (x y width height) exwm--geometry
|
|
|
|
|
;; Center window of type _NET_WM_WINDOW_TYPE_SPLASH
|
|
|
|
|
(when (memq xcb:Atom:_NET_WM_WINDOW_TYPE_SPLASH exwm-window-type)
|
2023-06-09 02:00:00 +02:00
|
|
|
|
(with-slots ((x* x) (y* y) (width* width) (height* height))
|
|
|
|
|
(exwm-workspace--workarea exwm--frame)
|
2018-02-19 15:40:27 +01:00
|
|
|
|
(exwm--set-geometry id
|
|
|
|
|
(+ x* (/ (- width* width) 2))
|
|
|
|
|
(+ y* (/ (- height* height) 2))
|
|
|
|
|
nil
|
|
|
|
|
nil))))
|
2016-08-12 13:22:18 +02:00
|
|
|
|
;; Check for desktop.
|
|
|
|
|
(when (memq xcb:Atom:_NET_WM_WINDOW_TYPE_DESKTOP exwm-window-type)
|
|
|
|
|
;; There should be only one desktop X window.
|
|
|
|
|
(setq exwm-manage--desktop id)
|
|
|
|
|
;; Put it at bottom.
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
|
|
|
|
:window id
|
|
|
|
|
:value-mask xcb:ConfigWindow:StackMode
|
|
|
|
|
:stack-mode xcb:StackMode:Below)))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(xcb:flush exwm--connection)
|
|
|
|
|
(setq exwm--id-buffer-alist (assq-delete-all id exwm--id-buffer-alist))
|
2018-12-16 01:00:00 +01:00
|
|
|
|
(let ((kill-buffer-query-functions nil)
|
|
|
|
|
(exwm-input--skip-buffer-list-update t))
|
2015-10-28 07:04:41 +01:00
|
|
|
|
(kill-buffer (current-buffer)))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(throw 'return 'ignored))
|
2018-03-23 16:49:39 +01:00
|
|
|
|
(let ((index (plist-get exwm--configurations 'workspace)))
|
|
|
|
|
(when (and index (< index (length exwm-workspace--list)))
|
|
|
|
|
(setq exwm--frame (elt exwm-workspace--list index))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;; Manage the window
|
2015-08-07 15:52:34 +02:00
|
|
|
|
(exwm--log "Manage #x%x" id)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(xcb:+request exwm--connection ;remove border
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
|
|
|
|
:window id :value-mask xcb:ConfigWindow:BorderWidth
|
|
|
|
|
:border-width 0))
|
2015-09-20 04:51:58 +02:00
|
|
|
|
(dolist (button ;grab buttons to set focus / move / resize
|
|
|
|
|
(list xcb:ButtonIndex:1 xcb:ButtonIndex:2 xcb:ButtonIndex:3))
|
2016-02-18 12:56:01 +01:00
|
|
|
|
(xcb:+request exwm--connection
|
2015-09-20 04:51:58 +02:00
|
|
|
|
(make-instance 'xcb:GrabButton
|
|
|
|
|
:owner-events 0 :grab-window id
|
|
|
|
|
:event-mask xcb:EventMask:ButtonPress
|
|
|
|
|
:pointer-mode xcb:GrabMode:Sync
|
|
|
|
|
:keyboard-mode xcb:GrabMode:Async
|
|
|
|
|
:confine-to xcb:Window:None :cursor xcb:Cursor:None
|
|
|
|
|
:button button :modifiers xcb:ModMask:Any)))
|
2016-07-13 12:51:32 +02:00
|
|
|
|
(exwm-manage--set-client-list)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(xcb:flush exwm--connection)
|
2018-03-01 17:52:03 +01:00
|
|
|
|
(if (plist-member exwm--configurations 'floating)
|
|
|
|
|
;; User has specified whether it should be floating.
|
|
|
|
|
(if (plist-get exwm--configurations 'floating)
|
|
|
|
|
(exwm-floating--set-floating id)
|
2018-03-23 16:49:39 +01:00
|
|
|
|
(with-selected-window (frame-selected-window exwm--frame)
|
|
|
|
|
(exwm-floating--unset-floating id)))
|
2018-03-01 17:52:03 +01:00
|
|
|
|
;; Try to determine if it should be floating.
|
|
|
|
|
(if (and (not exwm-manage-force-tiling)
|
|
|
|
|
(or exwm-transient-for exwm--fixed-size
|
|
|
|
|
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_UTILITY
|
|
|
|
|
exwm-window-type)
|
|
|
|
|
(memq xcb:Atom:_NET_WM_WINDOW_TYPE_DIALOG
|
|
|
|
|
exwm-window-type)))
|
|
|
|
|
(exwm-floating--set-floating id)
|
2018-03-23 16:49:39 +01:00
|
|
|
|
(with-selected-window (frame-selected-window exwm--frame)
|
|
|
|
|
(exwm-floating--unset-floating id))))
|
2018-03-02 18:00:28 +01:00
|
|
|
|
(if (plist-get exwm--configurations 'char-mode)
|
|
|
|
|
(exwm-input-release-keyboard id)
|
|
|
|
|
(exwm-input-grab-keyboard id))
|
2024-02-04 21:49:33 +01:00
|
|
|
|
(when-let ((simulation-keys (plist-get exwm--configurations 'simulation-keys)))
|
|
|
|
|
(exwm-input-set-local-simulation-keys simulation-keys))
|
|
|
|
|
(when-let ((prefix-keys (plist-get exwm--configurations 'prefix-keys)))
|
|
|
|
|
(setq-local exwm-input-prefix-keys prefix-keys))
|
2015-09-17 13:48:50 +02:00
|
|
|
|
(setq exwm-workspace--switch-history-outdated t)
|
2018-02-19 15:34:03 +01:00
|
|
|
|
(exwm--update-desktop id)
|
2016-08-12 13:27:26 +02:00
|
|
|
|
(exwm-manage--update-ewmh-state id)
|
2024-02-04 21:57:58 +01:00
|
|
|
|
(exwm-manage--update-default-directory id)
|
2024-02-04 21:49:33 +01:00
|
|
|
|
(when (or (plist-get exwm--configurations 'fullscreen)
|
|
|
|
|
(exwm-layout--fullscreen-p))
|
|
|
|
|
(setq exwm--ewmh-state (delq xcb:Atom:_NET_WM_STATE_FULLSCREEN
|
|
|
|
|
exwm--ewmh-state))
|
|
|
|
|
(exwm-layout-set-fullscreen id))
|
|
|
|
|
(run-hooks 'exwm-manage-finish-hook))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
|
|
|
|
(defun exwm-manage--unmanage-window (id &optional withdraw-only)
|
2016-07-14 16:08:27 +02:00
|
|
|
|
"Unmanage window ID.
|
|
|
|
|
|
|
|
|
|
If WITHDRAW-ONLY is non-nil, the X window will be properly placed back to the
|
2023-08-18 02:00:00 +02:00
|
|
|
|
root window. Set WITHDRAW-ONLY to `quit' if this functions is used when window
|
2016-07-14 16:08:27 +02:00
|
|
|
|
manager is shutting down."
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(let ((buffer (exwm--id->buffer id)))
|
2016-02-20 07:52:53 +01:00
|
|
|
|
(exwm--log "Unmanage #x%x (buffer: %s, widthdraw: %s)"
|
|
|
|
|
id buffer withdraw-only)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(setq exwm--id-buffer-alist (assq-delete-all id exwm--id-buffer-alist))
|
2016-07-15 14:04:56 +02:00
|
|
|
|
;; Update workspaces when a dock is destroyed.
|
2016-08-12 13:25:14 +02:00
|
|
|
|
(when (and (null withdraw-only)
|
|
|
|
|
(assq id exwm-workspace--id-struts-alist))
|
2016-07-15 14:04:56 +02:00
|
|
|
|
(setq exwm-workspace--id-struts-alist
|
|
|
|
|
(assq-delete-all id exwm-workspace--id-struts-alist))
|
|
|
|
|
(exwm-workspace--update-struts)
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(exwm-workspace--update-workareas)
|
2016-07-15 14:04:56 +02:00
|
|
|
|
(dolist (f exwm-workspace--list)
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(exwm-workspace--set-fullscreen f)))
|
2023-06-09 02:00:00 +02:00
|
|
|
|
(when (and (buffer-live-p buffer)
|
|
|
|
|
;; Invoked from `exwm-manage--exit' upon disconnection.
|
|
|
|
|
(slot-value exwm--connection 'connected))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(with-current-buffer buffer
|
2016-02-20 14:52:07 +01:00
|
|
|
|
;; Unmap the X window.
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:UnmapWindow :window id))
|
2016-02-20 07:52:53 +01:00
|
|
|
|
;;
|
2015-09-17 13:48:50 +02:00
|
|
|
|
(setq exwm-workspace--switch-history-outdated t)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;;
|
|
|
|
|
(when withdraw-only
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ChangeWindowAttributes
|
|
|
|
|
:window id :value-mask xcb:CW:EventMask
|
|
|
|
|
:event-mask xcb:EventMask:NoEvent))
|
|
|
|
|
;; Delete WM_STATE property
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:DeleteProperty
|
2016-07-14 16:08:27 +02:00
|
|
|
|
:window id :property xcb:Atom:WM_STATE))
|
2018-03-06 01:00:00 +01:00
|
|
|
|
(cond
|
|
|
|
|
((eq withdraw-only 'quit)
|
|
|
|
|
;; Remap the window when exiting.
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:MapWindow :window id)))
|
|
|
|
|
(t
|
2016-07-14 16:08:27 +02:00
|
|
|
|
;; Remove _NET_WM_DESKTOP.
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:DeleteProperty
|
|
|
|
|
:window id
|
2018-03-06 01:00:00 +01:00
|
|
|
|
:property xcb:Atom:_NET_WM_DESKTOP)))))
|
2016-02-18 12:56:01 +01:00
|
|
|
|
(when exwm--floating-frame
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
;; Unmap the floating frame before destroying its container.
|
|
|
|
|
(let ((window (frame-parameter exwm--floating-frame 'exwm-outer-id))
|
|
|
|
|
(container (frame-parameter exwm--floating-frame
|
|
|
|
|
'exwm-container)))
|
2016-02-20 07:52:53 +01:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:UnmapWindow :window window))
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ReparentWindow
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
:window window :parent exwm--root :x 0 :y 0))
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:DestroyWindow :window container))))
|
2018-07-29 02:00:00 +02:00
|
|
|
|
(when (exwm-layout--fullscreen-p)
|
|
|
|
|
(let ((window (get-buffer-window)))
|
|
|
|
|
(when window
|
|
|
|
|
(set-window-dedicated-p window nil))))
|
2016-07-30 04:12:31 +02:00
|
|
|
|
(exwm-manage--set-client-list)
|
|
|
|
|
(xcb:flush exwm--connection))
|
|
|
|
|
(let ((kill-buffer-func
|
|
|
|
|
(lambda (buffer)
|
2017-11-24 15:43:16 +01:00
|
|
|
|
(when (buffer-local-value 'exwm--floating-frame buffer)
|
|
|
|
|
(select-window
|
|
|
|
|
(frame-selected-window exwm-workspace--current)))
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(let ((kill-buffer-query-functions nil))
|
|
|
|
|
(kill-buffer buffer))))))
|
2017-11-19 07:51:45 +01:00
|
|
|
|
(exwm--defer 0 kill-buffer-func buffer)
|
2017-10-26 05:50:25 +02:00
|
|
|
|
(when (active-minibuffer-window)
|
2016-07-30 04:12:31 +02:00
|
|
|
|
(exit-minibuffer))))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
|
|
|
|
(defun exwm-manage--scan ()
|
|
|
|
|
"Search for existing windows and try to manage them."
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(let* ((tree (xcb:+request-unchecked+reply exwm--connection
|
2016-08-12 13:19:58 +02:00
|
|
|
|
(make-instance 'xcb:QueryTree
|
|
|
|
|
:window exwm--root)))
|
|
|
|
|
reply)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(dolist (i (slot-value tree 'children))
|
2016-08-12 13:19:58 +02:00
|
|
|
|
(setq reply (xcb:+request-unchecked+reply exwm--connection
|
|
|
|
|
(make-instance 'xcb:GetWindowAttributes
|
|
|
|
|
:window i)))
|
|
|
|
|
;; It's possible the X window has been destroyed.
|
|
|
|
|
(when reply
|
|
|
|
|
(with-slots (override-redirect map-state) reply
|
|
|
|
|
(when (and (= 0 override-redirect)
|
|
|
|
|
(= xcb:MapState:Viewable map-state))
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:UnmapWindow
|
|
|
|
|
:window i))
|
|
|
|
|
(xcb:flush exwm--connection)
|
|
|
|
|
(exwm-manage--manage-window i)))))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2016-02-18 12:56:01 +01:00
|
|
|
|
(defun exwm-manage--kill-buffer-query-function ()
|
|
|
|
|
"Run in `kill-buffer-query-functions'."
|
2023-06-09 02:00:00 +02:00
|
|
|
|
(exwm--log "id=#x%x; buffer=%s" (or exwm--id 0) (current-buffer))
|
2016-02-18 12:56:01 +01:00
|
|
|
|
(catch 'return
|
2023-06-09 02:00:00 +02:00
|
|
|
|
(when (or (not exwm--connection)
|
|
|
|
|
(not (slot-value exwm--connection 'connected)))
|
|
|
|
|
(throw 'return t))
|
2016-09-25 13:54:13 +02:00
|
|
|
|
(when (or (not exwm--id)
|
|
|
|
|
(xcb:+request-checked+request-check exwm--connection
|
2019-08-25 02:00:00 +02:00
|
|
|
|
(make-instance 'xcb:ChangeWindowAttributes
|
|
|
|
|
:window exwm--id
|
|
|
|
|
:value-mask xcb:CW:EventMask
|
|
|
|
|
:event-mask (exwm--get-client-event-mask))))
|
2016-02-18 12:56:01 +01:00
|
|
|
|
;; The X window is no longer alive so just close the buffer.
|
|
|
|
|
(when exwm--floating-frame
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
(let ((window (frame-parameter exwm--floating-frame 'exwm-outer-id))
|
|
|
|
|
(container (frame-parameter exwm--floating-frame
|
|
|
|
|
'exwm-container)))
|
2016-02-20 14:52:07 +01:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:UnmapWindow :window window))
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ReparentWindow
|
|
|
|
|
:window window
|
|
|
|
|
:parent exwm--root
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
:x 0 :y 0))
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:DestroyWindow
|
|
|
|
|
:window container))))
|
2015-10-29 11:31:16 +01:00
|
|
|
|
(xcb:flush exwm--connection)
|
2016-02-18 12:56:01 +01:00
|
|
|
|
(throw 'return t))
|
|
|
|
|
(unless (memq xcb:Atom:WM_DELETE_WINDOW exwm--protocols)
|
|
|
|
|
;; The X window does not support WM_DELETE_WINDOW; destroy it.
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:DestroyWindow :window exwm--id))
|
|
|
|
|
(xcb:flush exwm--connection)
|
|
|
|
|
;; Wait for DestroyNotify event.
|
|
|
|
|
(throw 'return nil))
|
2016-03-03 12:34:17 +01:00
|
|
|
|
(let ((id exwm--id))
|
|
|
|
|
;; Try to close the X window with WM_DELETE_WINDOW client message.
|
2016-02-20 07:52:53 +01:00
|
|
|
|
(xcb:+request exwm--connection
|
2016-03-06 06:45:13 +01:00
|
|
|
|
(make-instance 'xcb:icccm:SendEvent
|
|
|
|
|
:destination id
|
|
|
|
|
:event (xcb:marshal
|
|
|
|
|
(make-instance 'xcb:icccm:WM_DELETE_WINDOW
|
|
|
|
|
:window id)
|
|
|
|
|
exwm--connection)))
|
2016-02-20 07:52:53 +01:00
|
|
|
|
(xcb:flush exwm--connection)
|
2016-03-03 12:34:17 +01:00
|
|
|
|
;;
|
|
|
|
|
(unless (memq xcb:Atom:_NET_WM_PING exwm--protocols)
|
2016-09-25 13:54:13 +02:00
|
|
|
|
;; For X windows without _NET_WM_PING support, we'd better just
|
|
|
|
|
;; wait for DestroyNotify events.
|
2016-03-06 06:45:13 +01:00
|
|
|
|
(throw 'return nil))
|
2016-03-03 12:34:17 +01:00
|
|
|
|
;; Try to determine if the X window is dead with _NET_WM_PING.
|
|
|
|
|
(setq exwm-manage--ping-lock t)
|
|
|
|
|
(xcb:+request exwm--connection
|
2016-03-06 06:45:13 +01:00
|
|
|
|
(make-instance 'xcb:SendEvent
|
|
|
|
|
:propagate 0
|
|
|
|
|
:destination id
|
|
|
|
|
:event-mask xcb:EventMask:NoEvent
|
|
|
|
|
:event (xcb:marshal
|
|
|
|
|
(make-instance 'xcb:ewmh:_NET_WM_PING
|
|
|
|
|
:window id
|
|
|
|
|
:timestamp 0
|
|
|
|
|
:client-window id)
|
|
|
|
|
exwm--connection)))
|
2016-03-03 12:34:17 +01:00
|
|
|
|
(xcb:flush exwm--connection)
|
|
|
|
|
(with-timeout (exwm-manage-ping-timeout
|
2016-09-25 13:54:13 +02:00
|
|
|
|
(if (y-or-n-p (format "'%s' is not responding. \
|
2016-02-18 12:56:01 +01:00
|
|
|
|
Would you like to kill it? "
|
2016-03-06 06:45:13 +01:00
|
|
|
|
(buffer-name)))
|
|
|
|
|
(progn (exwm-manage--kill-client id)
|
|
|
|
|
;; Kill the unresponsive X window and
|
|
|
|
|
;; wait for DestroyNotify event.
|
|
|
|
|
(throw 'return nil))
|
|
|
|
|
;; Give up.
|
|
|
|
|
(throw 'return nil)))
|
|
|
|
|
(while (and exwm-manage--ping-lock
|
|
|
|
|
(exwm--id->buffer id)) ;may have been destroyed.
|
|
|
|
|
(accept-process-output nil 0.1))
|
|
|
|
|
;; Give up.
|
|
|
|
|
(throw 'return nil)))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
|
|
|
|
(defun exwm-manage--kill-client (&optional id)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Kill X client ID.
|
|
|
|
|
If ID is nil, kill X window corresponding to current buffer."
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(unless id (setq id (exwm--buffer->id (current-buffer))))
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log "id=#x%x" id)
|
2015-08-16 20:53:04 +02:00
|
|
|
|
(let* ((response (xcb:+request-unchecked+reply exwm--connection
|
|
|
|
|
(make-instance 'xcb:ewmh:get-_NET_WM_PID :window id)))
|
2015-10-29 11:31:16 +01:00
|
|
|
|
(pid (and response (slot-value response 'value)))
|
|
|
|
|
(request (make-instance 'xcb:KillClient :resource id)))
|
|
|
|
|
(if (not pid)
|
|
|
|
|
(xcb:+request exwm--connection request)
|
|
|
|
|
;; What if the PID is fake/wrong?
|
|
|
|
|
(signal-process pid 'SIGKILL)
|
|
|
|
|
;; Ensure it's dead
|
|
|
|
|
(run-with-timer exwm-manage-ping-timeout nil
|
2019-03-24 01:00:00 +01:00
|
|
|
|
(lambda ()
|
|
|
|
|
(xcb:+request exwm--connection request))))
|
2015-10-29 11:31:16 +01:00
|
|
|
|
(xcb:flush exwm--connection)))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2016-09-25 13:58:16 +02:00
|
|
|
|
(defun exwm-manage--add-frame (frame)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Run in `after-make-frame-functions'.
|
|
|
|
|
FRAME is the newly created frame."
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log "frame=%s" frame)
|
2017-04-09 18:30:43 +02:00
|
|
|
|
(when (display-graphic-p frame)
|
|
|
|
|
(push (string-to-number (frame-parameter frame 'outer-window-id))
|
|
|
|
|
exwm-manage--frame-outer-id-list)))
|
2016-09-25 13:58:16 +02:00
|
|
|
|
|
|
|
|
|
(defun exwm-manage--remove-frame (frame)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Run in `delete-frame-functions'.
|
|
|
|
|
FRAME is the frame to be deleted."
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log "frame=%s" frame)
|
2017-04-09 18:30:43 +02:00
|
|
|
|
(when (display-graphic-p frame)
|
|
|
|
|
(setq exwm-manage--frame-outer-id-list
|
|
|
|
|
(delq (string-to-number (frame-parameter frame 'outer-window-id))
|
|
|
|
|
exwm-manage--frame-outer-id-list))))
|
2016-09-25 13:58:16 +02:00
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(defun exwm-manage--on-ConfigureRequest (data _synthetic)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Handle ConfigureRequest event.
|
|
|
|
|
DATA contains unmarshalled ConfigureRequest event data."
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(let ((obj (make-instance 'xcb:ConfigureRequest))
|
2016-03-11 07:12:01 +01:00
|
|
|
|
buffer edges width-delta height-delta)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(xcb:unmarshal obj data)
|
2016-02-20 14:52:07 +01:00
|
|
|
|
(with-slots (window x y width height
|
|
|
|
|
border-width sibling stack-mode value-mask)
|
2015-08-14 11:46:43 +02:00
|
|
|
|
obj
|
2018-12-02 01:00:00 +01:00
|
|
|
|
(exwm--log "#x%x (#x%x) @%dx%d%+d%+d; \
|
2016-02-20 14:52:07 +01:00
|
|
|
|
border-width: %d; sibling: #x%x; stack-mode: %d"
|
|
|
|
|
window value-mask width height x y
|
|
|
|
|
border-width sibling stack-mode)
|
2016-03-06 07:28:42 +01:00
|
|
|
|
(if (and (setq buffer (exwm--id->buffer window))
|
|
|
|
|
(with-current-buffer buffer
|
2018-03-04 05:23:37 +01:00
|
|
|
|
(or (exwm-layout--fullscreen-p)
|
2016-03-11 07:12:01 +01:00
|
|
|
|
;; Make sure it's a floating X window wanting to resize
|
|
|
|
|
;; itself.
|
|
|
|
|
(or (not exwm--floating-frame)
|
|
|
|
|
(progn
|
|
|
|
|
(setq edges
|
|
|
|
|
(window-inside-pixel-edges
|
|
|
|
|
(get-buffer-window buffer t))
|
|
|
|
|
width-delta (- width (- (elt edges 2)
|
|
|
|
|
(elt edges 0)))
|
|
|
|
|
height-delta (- height (- (elt edges 3)
|
|
|
|
|
(elt edges 1))))
|
|
|
|
|
;; We cannot do resizing precisely for now.
|
|
|
|
|
(and (if (= 0 (logand value-mask
|
|
|
|
|
xcb:ConfigWindow:Width))
|
|
|
|
|
t
|
|
|
|
|
(< (abs width-delta)
|
|
|
|
|
exwm-manage--width-delta-min))
|
|
|
|
|
(if (= 0 (logand value-mask
|
2016-07-19 04:24:23 +02:00
|
|
|
|
xcb:ConfigWindow:Height))
|
2016-03-11 07:12:01 +01:00
|
|
|
|
t
|
|
|
|
|
(< (abs height-delta)
|
|
|
|
|
exwm-manage--height-delta-min))))))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;; Send client message for managed windows
|
2015-08-06 06:32:14 +02:00
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(setq edges
|
2018-03-04 05:23:37 +01:00
|
|
|
|
(if (exwm-layout--fullscreen-p)
|
2018-02-19 15:40:27 +01:00
|
|
|
|
(with-slots (x y width height)
|
|
|
|
|
(exwm-workspace--get-geometry exwm--frame)
|
|
|
|
|
(list x y width height))
|
2016-02-03 05:12:24 +01:00
|
|
|
|
(window-inside-absolute-pixel-edges
|
|
|
|
|
(get-buffer-window buffer t))))
|
2015-08-11 09:06:11 +02:00
|
|
|
|
(exwm--log "Reply with ConfigureNotify (edges): %s" edges)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:SendEvent
|
|
|
|
|
:propagate 0 :destination window
|
|
|
|
|
:event-mask xcb:EventMask:StructureNotify
|
|
|
|
|
:event (xcb:marshal
|
|
|
|
|
(make-instance
|
|
|
|
|
'xcb:ConfigureNotify
|
|
|
|
|
:event window :window window
|
|
|
|
|
:above-sibling xcb:Window:None
|
|
|
|
|
:x (elt edges 0) :y (elt edges 1)
|
|
|
|
|
:width (- (elt edges 2) (elt edges 0))
|
|
|
|
|
:height (- (elt edges 3) (elt edges 1))
|
|
|
|
|
:border-width 0 :override-redirect 0)
|
|
|
|
|
exwm--connection))))
|
2016-03-06 07:28:42 +01:00
|
|
|
|
(if buffer
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(exwm--log "ConfigureWindow (resize floating X window)")
|
2018-07-14 18:00:00 +02:00
|
|
|
|
(exwm--set-geometry (frame-parameter exwm--floating-frame
|
|
|
|
|
'exwm-outer-id)
|
|
|
|
|
nil
|
|
|
|
|
nil
|
|
|
|
|
(+ (frame-pixel-width exwm--floating-frame)
|
|
|
|
|
width-delta)
|
2016-03-11 07:12:01 +01:00
|
|
|
|
(+ (frame-pixel-height exwm--floating-frame)
|
2018-07-14 18:00:00 +02:00
|
|
|
|
height-delta)))
|
2016-03-06 07:28:42 +01:00
|
|
|
|
(exwm--log "ConfigureWindow (preserve geometry)")
|
|
|
|
|
;; Configure the unmanaged window.
|
2016-09-25 13:58:16 +02:00
|
|
|
|
;; But Emacs frames should be excluded. Generally we don't
|
|
|
|
|
;; receive ConfigureRequest events from Emacs frames since we
|
|
|
|
|
;; have set OverrideRedirect on them, but this is not true for
|
|
|
|
|
;; Lucid build (as of 25.1).
|
|
|
|
|
(unless (memq window exwm-manage--frame-outer-id-list)
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
|
|
|
|
:window window
|
|
|
|
|
:value-mask value-mask
|
|
|
|
|
:x x :y y :width width :height height
|
|
|
|
|
:border-width border-width
|
|
|
|
|
:sibling sibling
|
|
|
|
|
:stack-mode stack-mode)))))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(xcb:flush exwm--connection))
|
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(defun exwm-manage--on-MapRequest (data _synthetic)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Handle MapRequest event.
|
|
|
|
|
DATA contains unmarshalled MapRequest event data."
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(let ((obj (make-instance 'xcb:MapRequest)))
|
|
|
|
|
(xcb:unmarshal obj data)
|
2015-08-24 13:01:14 +02:00
|
|
|
|
(with-slots (parent window) obj
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log "id=#x%x parent=#x%x" window parent)
|
2015-10-29 05:22:00 +01:00
|
|
|
|
(if (assoc window exwm--id-buffer-alist)
|
2016-07-13 12:51:32 +02:00
|
|
|
|
(with-current-buffer (exwm--id->buffer window)
|
|
|
|
|
(if (exwm-layout--iconic-state-p)
|
|
|
|
|
;; State change: iconic => normal.
|
|
|
|
|
(when (eq exwm--frame exwm-workspace--current)
|
2017-08-30 18:58:39 +02:00
|
|
|
|
(pop-to-buffer-same-window (current-buffer)))
|
2016-07-13 12:51:32 +02:00
|
|
|
|
(exwm--log "#x%x is already managed" window)))
|
2015-10-29 05:22:00 +01:00
|
|
|
|
(if (/= exwm--root parent)
|
|
|
|
|
(progn (xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:MapWindow :window window))
|
|
|
|
|
(xcb:flush exwm--connection))
|
2018-12-02 01:00:00 +01:00
|
|
|
|
(exwm--log "#x%x" window)
|
2015-10-29 05:22:00 +01:00
|
|
|
|
(exwm-manage--manage-window window))))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2016-02-09 06:26:48 +01:00
|
|
|
|
(defun exwm-manage--on-UnmapNotify (data _synthetic)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Handle UnmapNotify event.
|
|
|
|
|
DATA contains unmarshalled UnmapNotify event data."
|
2016-02-09 06:26:48 +01:00
|
|
|
|
(let ((obj (make-instance 'xcb:UnmapNotify)))
|
|
|
|
|
(xcb:unmarshal obj data)
|
|
|
|
|
(with-slots (window) obj
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log "id=#x%x" window)
|
2016-02-09 06:26:48 +01:00
|
|
|
|
(exwm-manage--unmanage-window window t))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2018-09-04 14:00:00 +02:00
|
|
|
|
(defun exwm-manage--on-MapNotify (data _synthetic)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Handle MapNotify event.
|
|
|
|
|
DATA contains unmarshalled MapNotify event data."
|
2018-09-04 14:00:00 +02:00
|
|
|
|
(let ((obj (make-instance 'xcb:MapNotify)))
|
|
|
|
|
(xcb:unmarshal obj data)
|
|
|
|
|
(with-slots (window) obj
|
|
|
|
|
(when (assoc window exwm--id-buffer-alist)
|
|
|
|
|
(exwm--log "id=#x%x" window)
|
|
|
|
|
;; With this we ensure that a "window hierarchy change" happens after
|
|
|
|
|
;; mapping the window, as some servers (XQuartz) do not generate it.
|
2018-11-11 01:00:00 +01:00
|
|
|
|
(with-current-buffer (exwm--id->buffer window)
|
|
|
|
|
(if exwm--floating-frame
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
|
|
|
|
:window window
|
|
|
|
|
:value-mask xcb:ConfigWindow:StackMode
|
|
|
|
|
:stack-mode xcb:StackMode:Above))
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
|
|
|
|
:window window
|
|
|
|
|
:value-mask (logior xcb:ConfigWindow:Sibling
|
|
|
|
|
xcb:ConfigWindow:StackMode)
|
|
|
|
|
:sibling exwm--guide-window
|
|
|
|
|
:stack-mode xcb:StackMode:Above))))
|
2018-09-04 14:00:00 +02:00
|
|
|
|
(xcb:flush exwm--connection)))))
|
|
|
|
|
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(defun exwm-manage--on-DestroyNotify (data synthetic)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Handle DestroyNotify event.
|
|
|
|
|
DATA contains unmarshalled DestroyNotify event data.
|
|
|
|
|
SYNTHETIC indicates whether the event is a synthetic event."
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(unless synthetic
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(let ((obj (make-instance 'xcb:DestroyNotify)))
|
|
|
|
|
(xcb:unmarshal obj data)
|
2018-12-02 01:00:00 +01:00
|
|
|
|
(exwm--log "#x%x" (slot-value obj 'window))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(exwm-manage--unmanage-window (slot-value obj 'window)))))
|
|
|
|
|
|
|
|
|
|
(defun exwm-manage--init ()
|
|
|
|
|
"Initialize manage module."
|
2015-09-19 10:46:08 +02:00
|
|
|
|
;; Intern _MOTIF_WM_HINTS
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log)
|
2019-02-06 01:00:00 +01:00
|
|
|
|
(setq exwm-manage--_MOTIF_WM_HINTS (exwm--intern-atom "_MOTIF_WM_HINTS"))
|
2016-09-25 13:58:16 +02:00
|
|
|
|
(add-hook 'after-make-frame-functions #'exwm-manage--add-frame)
|
|
|
|
|
(add-hook 'delete-frame-functions #'exwm-manage--remove-frame)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(xcb:+event exwm--connection 'xcb:ConfigureRequest
|
2015-09-04 03:09:59 +02:00
|
|
|
|
#'exwm-manage--on-ConfigureRequest)
|
|
|
|
|
(xcb:+event exwm--connection 'xcb:MapRequest #'exwm-manage--on-MapRequest)
|
|
|
|
|
(xcb:+event exwm--connection 'xcb:UnmapNotify #'exwm-manage--on-UnmapNotify)
|
2018-09-04 14:00:00 +02:00
|
|
|
|
(xcb:+event exwm--connection 'xcb:MapNotify #'exwm-manage--on-MapNotify)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(xcb:+event exwm--connection 'xcb:DestroyNotify
|
2015-09-04 03:09:59 +02:00
|
|
|
|
#'exwm-manage--on-DestroyNotify))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2016-05-23 13:13:42 +02:00
|
|
|
|
(defun exwm-manage--exit ()
|
|
|
|
|
"Exit the manage module."
|
2018-12-02 01:00:00 +01:00
|
|
|
|
(exwm--log)
|
2018-03-06 01:00:00 +01:00
|
|
|
|
(dolist (pair exwm--id-buffer-alist)
|
|
|
|
|
(exwm-manage--unmanage-window (car pair) 'quit))
|
|
|
|
|
(remove-hook 'after-make-frame-functions #'exwm-manage--add-frame)
|
|
|
|
|
(remove-hook 'delete-frame-functions #'exwm-manage--remove-frame)
|
2016-05-23 13:13:42 +02:00
|
|
|
|
(setq exwm-manage--_MOTIF_WM_HINTS nil))
|
|
|
|
|
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(provide 'exwm-manage)
|
|
|
|
|
|
|
|
|
|
;;; exwm-manage.el ends here
|