2015-09-04 03:09:59 +02:00
|
|
|
|
;;; exwm-core.el --- Core definitions -*- lexical-binding: t -*-
|
|
|
|
|
|
2024-01-08 01:00:00 +01:00
|
|
|
|
;; Copyright (C) 2015-2024 Free Software Foundation, Inc.
|
2015-09-04 03:09:59 +02:00
|
|
|
|
|
|
|
|
|
;; Author: Chris Feng <chris.w.feng@gmail.com>
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; 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.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; 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
|
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; This module includes core definitions of variables, macros, functions, etc
|
|
|
|
|
;; shared by various other modules.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2016-09-22 13:10:38 +02:00
|
|
|
|
(require 'kmacro)
|
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(require 'xcb)
|
|
|
|
|
(require 'xcb-icccm)
|
|
|
|
|
(require 'xcb-ewmh)
|
2018-09-04 14:00:00 +02:00
|
|
|
|
(require 'xcb-debug)
|
2015-09-04 03:09:59 +02:00
|
|
|
|
|
2024-01-14 00:57:37 +01:00
|
|
|
|
(defgroup exwm-debug nil
|
|
|
|
|
"Debugging."
|
|
|
|
|
:group 'exwm)
|
|
|
|
|
|
2019-09-08 02:00:00 +02:00
|
|
|
|
(defcustom exwm-debug-log-time-function #'exwm-debug-log-uptime
|
|
|
|
|
"Function used for generating timestamps in `exwm-debug' logs.
|
|
|
|
|
|
|
|
|
|
Here are some predefined candidates:
|
|
|
|
|
`exwm-debug-log-uptime': Display the uptime of this Emacs instance.
|
|
|
|
|
`exwm-debug-log-time': Display time of day.
|
|
|
|
|
`nil': Disable timestamp."
|
|
|
|
|
:type `(choice (const :tag "Emacs uptime" ,#'exwm-debug-log-uptime)
|
|
|
|
|
(const :tag "Time of day" ,#'exwm-debug-log-time)
|
|
|
|
|
(const :tag "Off" nil)
|
2019-09-15 02:00:00 +02:00
|
|
|
|
(function :tag "Other"))
|
|
|
|
|
:set (lambda (symbol value)
|
|
|
|
|
(set-default symbol value)
|
|
|
|
|
;; Also change the format for XELB to make logs consistent
|
|
|
|
|
;; (as they share the same buffer).
|
|
|
|
|
(setq xcb-debug:log-time-function value)))
|
|
|
|
|
|
|
|
|
|
(defalias 'exwm-debug-log-uptime 'xcb-debug:log-uptime
|
|
|
|
|
"Add uptime to `exwm-debug' logs.")
|
|
|
|
|
|
|
|
|
|
(defalias 'exwm-debug-log-time 'xcb-debug:log-time
|
|
|
|
|
"Add time of day to `exwm-debug' logs.")
|
2019-09-08 02:00:00 +02:00
|
|
|
|
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(defvar exwm--connection nil "X connection.")
|
|
|
|
|
|
2021-12-09 01:00:00 +01:00
|
|
|
|
(defvar exwm--terminal nil
|
|
|
|
|
"Terminal corresponding to `exwm--connection'.")
|
|
|
|
|
|
2018-03-06 01:00:00 +01:00
|
|
|
|
(defvar exwm--wmsn-window nil
|
|
|
|
|
"An X window owning the WM_S0 selection.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm--wmsn-acquire-timeout 3
|
|
|
|
|
"Number of seconds to wait for other window managers to release the selection.")
|
|
|
|
|
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(defvar exwm--guide-window nil
|
|
|
|
|
"An X window separating workspaces and X windows.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm--id-buffer-alist nil "Alist of (<X window ID> . <Emacs buffer>).")
|
|
|
|
|
|
|
|
|
|
(defvar exwm--root nil "Root window.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-input--global-prefix-keys)
|
2018-02-20 14:57:49 +01:00
|
|
|
|
(defvar exwm-input--simulation-keys)
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(defvar exwm-input-line-mode-passthrough)
|
|
|
|
|
(defvar exwm-input-prefix-keys)
|
2024-03-16 16:53:04 +01:00
|
|
|
|
(defvar exwm-workspace--list)
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(declare-function exwm-input--fake-key "exwm-input.el" (event))
|
|
|
|
|
(declare-function exwm-input--on-KeyPress-line-mode "exwm-input.el"
|
|
|
|
|
(key-press raw-data))
|
|
|
|
|
(declare-function exwm-floating-hide "exwm-floating.el")
|
|
|
|
|
(declare-function exwm-floating-toggle-floating "exwm-floating.el")
|
|
|
|
|
(declare-function exwm-input-release-keyboard "exwm-input.el")
|
|
|
|
|
(declare-function exwm-input-send-next-key "exwm-input.el" (times))
|
|
|
|
|
(declare-function exwm-layout-set-fullscreen "exwm-layout.el" (&optional id))
|
|
|
|
|
(declare-function exwm-layout-toggle-mode-line "exwm-layout.el")
|
|
|
|
|
(declare-function exwm-manage--kill-buffer-query-function "exwm-manage.el")
|
|
|
|
|
(declare-function exwm-workspace-move-window "exwm-workspace.el"
|
|
|
|
|
(frame-or-index &optional id))
|
2024-03-16 17:39:35 +01:00
|
|
|
|
(declare-function exwm-workspace-switch "exwm-workspace.el"
|
|
|
|
|
(frame-or-index &optional force))
|
2018-02-18 17:04:27 +01:00
|
|
|
|
|
2018-09-16 02:00:00 +02:00
|
|
|
|
(define-minor-mode exwm-debug
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Debug-logging enabled if non-nil."
|
|
|
|
|
:global t
|
|
|
|
|
:group 'exwm-debug)
|
2018-09-04 14:00:00 +02:00
|
|
|
|
|
|
|
|
|
(defmacro exwm--debug (&rest forms)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Evaluate FORMS if mode `exwm-debug' is active."
|
2018-09-16 02:00:00 +02:00
|
|
|
|
(when exwm-debug `(progn ,@forms)))
|
2018-09-04 14:00:00 +02:00
|
|
|
|
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(defmacro exwm--log (&optional format-string &rest objects)
|
|
|
|
|
"Emit a message prepending the name of the function being executed.
|
|
|
|
|
|
|
|
|
|
FORMAT-STRING is a string specifying the message to output, as in
|
|
|
|
|
`format'. The OBJECTS arguments specify the substitutions."
|
2018-09-04 14:00:00 +02:00
|
|
|
|
(unless format-string (setq format-string ""))
|
2018-09-16 02:00:00 +02:00
|
|
|
|
`(when exwm-debug
|
2019-09-08 02:00:00 +02:00
|
|
|
|
(xcb-debug:message ,(concat "%s%s:\t" format-string "\n")
|
|
|
|
|
(if exwm-debug-log-time-function
|
|
|
|
|
(funcall exwm-debug-log-time-function)
|
|
|
|
|
"")
|
2018-09-09 02:00:00 +02:00
|
|
|
|
(xcb-debug:compile-time-function-name)
|
2018-09-04 14:00:00 +02:00
|
|
|
|
,@objects)
|
|
|
|
|
nil))
|
2016-02-03 05:12:24 +01:00
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(defsubst exwm--id->buffer (id)
|
|
|
|
|
"X window ID => Emacs buffer."
|
2023-08-18 02:00:00 +02:00
|
|
|
|
(declare (indent defun))
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(cdr (assoc id exwm--id-buffer-alist)))
|
|
|
|
|
|
|
|
|
|
(defsubst exwm--buffer->id (buffer)
|
|
|
|
|
"Emacs buffer BUFFER => X window ID."
|
2023-08-18 02:00:00 +02:00
|
|
|
|
(declare (indent defun))
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(car (rassoc buffer exwm--id-buffer-alist)))
|
|
|
|
|
|
|
|
|
|
(defun exwm--lock (&rest _args)
|
|
|
|
|
"Lock (disable all events)."
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log)
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ChangeWindowAttributes
|
|
|
|
|
:window exwm--root
|
|
|
|
|
:value-mask xcb:CW:EventMask
|
|
|
|
|
:event-mask xcb:EventMask:NoEvent))
|
|
|
|
|
(xcb:flush exwm--connection))
|
|
|
|
|
|
|
|
|
|
(defun exwm--unlock (&rest _args)
|
|
|
|
|
"Unlock (enable all events)."
|
2018-08-13 14:00:00 +02:00
|
|
|
|
(exwm--log)
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ChangeWindowAttributes
|
|
|
|
|
:window exwm--root
|
|
|
|
|
:value-mask xcb:CW:EventMask
|
2015-09-27 13:31:00 +02:00
|
|
|
|
:event-mask (eval-when-compile
|
2018-02-21 17:26:04 +01:00
|
|
|
|
(logior xcb:EventMask:SubstructureRedirect
|
2015-09-27 13:31:00 +02:00
|
|
|
|
xcb:EventMask:StructureNotify))))
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(xcb:flush exwm--connection))
|
|
|
|
|
|
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
|
|
|
|
(defun exwm--set-geometry (xwin x y width height)
|
|
|
|
|
"Set the geometry of X window XWIN to WIDTHxHEIGHT+X+Y.
|
|
|
|
|
|
|
|
|
|
Nil can be passed as placeholder."
|
|
|
|
|
(exwm--log "Setting #x%x to %sx%s+%s+%s" xwin width height x y)
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
|
|
|
|
:window xwin
|
|
|
|
|
:value-mask (logior (if x xcb:ConfigWindow:X 0)
|
|
|
|
|
(if y xcb:ConfigWindow:Y 0)
|
|
|
|
|
(if width xcb:ConfigWindow:Width 0)
|
|
|
|
|
(if height xcb:ConfigWindow:Height 0))
|
|
|
|
|
:x x :y y :width width :height height)))
|
|
|
|
|
|
2022-07-25 18:33:05 +02:00
|
|
|
|
(defun exwm--intern-atom (atom &optional conn)
|
2023-08-18 02:00:00 +02:00
|
|
|
|
"Intern X11 ATOM.
|
|
|
|
|
If CONN is non-nil, use it instead of the value of the variable
|
|
|
|
|
`exwm--connection'."
|
2022-07-25 18:33:05 +02:00
|
|
|
|
(slot-value (xcb:+request-unchecked+reply (or conn exwm--connection)
|
2019-02-06 01:00:00 +01:00
|
|
|
|
(make-instance 'xcb:InternAtom
|
|
|
|
|
:only-if-exists 0
|
|
|
|
|
:name-len (length atom)
|
|
|
|
|
:name atom))
|
|
|
|
|
'atom))
|
|
|
|
|
|
2017-11-19 07:51:45 +01:00
|
|
|
|
(defmacro exwm--defer (secs function &rest args)
|
2017-11-24 15:47:42 +01:00
|
|
|
|
"Defer the execution of FUNCTION.
|
2017-11-19 07:51:45 +01:00
|
|
|
|
|
2017-11-24 15:47:42 +01:00
|
|
|
|
The action is to call FUNCTION with arguments ARGS. If Emacs is not idle,
|
|
|
|
|
defer the action until Emacs is idle. Otherwise, defer the action until at
|
|
|
|
|
least SECS seconds later."
|
2018-03-23 16:57:18 +01:00
|
|
|
|
`(run-with-idle-timer (+ (float-time (or (current-idle-time)
|
2019-09-14 02:00:00 +02:00
|
|
|
|
(seconds-to-time (- ,secs))))
|
|
|
|
|
,secs)
|
2017-11-19 07:51:45 +01:00
|
|
|
|
nil
|
|
|
|
|
,function
|
|
|
|
|
,@args))
|
|
|
|
|
|
2021-12-09 01:00:00 +01:00
|
|
|
|
(defsubst exwm--terminal-p (&optional frame)
|
|
|
|
|
"Return t when FRAME's terminal is EXWM's terminal.
|
|
|
|
|
If FRAME is null, use selected frame."
|
2023-08-18 02:00:00 +02:00
|
|
|
|
(declare (indent defun))
|
2021-12-09 01:00:00 +01:00
|
|
|
|
(eq exwm--terminal (frame-terminal frame)))
|
|
|
|
|
|
2019-03-17 01:00:00 +01:00
|
|
|
|
(defun exwm--get-client-event-mask ()
|
|
|
|
|
"Return event mask set on all managed windows."
|
|
|
|
|
(logior xcb:EventMask:StructureNotify
|
|
|
|
|
xcb:EventMask:PropertyChange
|
|
|
|
|
(if mouse-autoselect-window
|
|
|
|
|
xcb:EventMask:EnterWindow 0)))
|
2015-09-04 03:09:59 +02:00
|
|
|
|
|
2020-02-02 01:00:00 +01:00
|
|
|
|
(defun exwm--color->pixel (color)
|
|
|
|
|
"Convert COLOR to PIXEL (index in TrueColor colormap)."
|
|
|
|
|
(when (and color
|
|
|
|
|
(eq (x-display-visual-class) 'true-color))
|
2024-01-24 00:15:44 +01:00
|
|
|
|
(let ((rgb (color-values color)))
|
2023-08-18 02:00:00 +02:00
|
|
|
|
(logior (ash (ash (pop rgb) -8) 16)
|
|
|
|
|
(ash (ash (pop rgb) -8) 8)
|
|
|
|
|
(ash (pop rgb) -8)))))
|
2020-02-02 01:00:00 +01:00
|
|
|
|
|
2022-03-24 01:00:00 +01:00
|
|
|
|
(defun exwm--get-visual-depth-colormap (conn id)
|
|
|
|
|
"Get visual, depth and colormap from X window ID.
|
2023-08-18 02:00:00 +02:00
|
|
|
|
Return a three element list with the respective results.
|
|
|
|
|
|
|
|
|
|
If CONN is non-nil, use it instead of the value of the variable
|
|
|
|
|
`exwm--connection'."
|
2022-03-24 01:00:00 +01:00
|
|
|
|
(let (ret-visual ret-depth ret-colormap)
|
|
|
|
|
(with-slots (visual colormap)
|
|
|
|
|
(xcb:+request-unchecked+reply conn
|
|
|
|
|
(make-instance 'xcb:GetWindowAttributes :window id))
|
|
|
|
|
(setq ret-visual visual)
|
|
|
|
|
(setq ret-colormap colormap))
|
|
|
|
|
(with-slots (depth)
|
|
|
|
|
(xcb:+request-unchecked+reply conn
|
|
|
|
|
(make-instance 'xcb:GetGeometry :drawable id))
|
|
|
|
|
(setq ret-depth depth))
|
|
|
|
|
(list ret-visual ret-depth ret-colormap)))
|
|
|
|
|
|
2024-03-16 16:53:04 +01:00
|
|
|
|
(defun exwm--mode-name ()
|
|
|
|
|
"Mode name string used in `exwm-mode' buffers."
|
|
|
|
|
(let ((name "EXWM"))
|
|
|
|
|
(if (cl-some (lambda (i) (frame-parameter i 'exwm-urgency))
|
|
|
|
|
exwm-workspace--list)
|
|
|
|
|
(propertize name 'face 'font-lock-warning-face)
|
|
|
|
|
name)))
|
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; Internal variables
|
2016-02-07 03:45:59 +01:00
|
|
|
|
(defvar-local exwm--id nil) ;window ID
|
2018-03-01 17:52:03 +01:00
|
|
|
|
(defvar-local exwm--configurations nil) ;initial configurations.
|
2016-02-07 03:45:59 +01:00
|
|
|
|
(defvar-local exwm--frame nil) ;workspace frame
|
|
|
|
|
(defvar-local exwm--floating-frame nil) ;floating frame
|
|
|
|
|
(defvar-local exwm--mode-line-format nil) ;save mode-line-format
|
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
|
|
|
|
(defvar-local exwm--floating-frame-position nil) ;set when hidden.
|
2016-02-07 03:45:59 +01:00
|
|
|
|
(defvar-local exwm--fixed-size nil) ;fixed size
|
2018-10-21 14:00:00 +02:00
|
|
|
|
(defvar-local exwm--selected-input-mode 'line-mode
|
|
|
|
|
"Input mode as selected by the user.
|
|
|
|
|
One of `line-mode' or `char-mode'.")
|
|
|
|
|
(defvar-local exwm--input-mode 'line-mode
|
|
|
|
|
"Actual input mode, i.e. whether mouse and keyboard are grabbed.")
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; Properties
|
2018-02-19 15:34:03 +01:00
|
|
|
|
(defvar-local exwm--desktop nil "_NET_WM_DESKTOP.")
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(defvar-local exwm-window-type nil "_NET_WM_WINDOW_TYPE.")
|
|
|
|
|
(defvar-local exwm--geometry nil)
|
|
|
|
|
(defvar-local exwm-class-name nil "Class name in WM_CLASS.")
|
|
|
|
|
(defvar-local exwm-instance-name nil "Instance name in WM_CLASS.")
|
2023-08-18 02:00:00 +02:00
|
|
|
|
(defvar-local exwm-title nil "Window title (either _NET_WM_NAME or WM_NAME).")
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(defvar-local exwm--title-is-utf8 nil)
|
|
|
|
|
(defvar-local exwm-transient-for nil "WM_TRANSIENT_FOR.")
|
|
|
|
|
(defvar-local exwm--protocols nil)
|
2016-07-13 12:51:32 +02:00
|
|
|
|
(defvar-local exwm-state xcb:icccm:WM_STATE:NormalState "WM_STATE.")
|
2016-08-12 13:27:26 +02:00
|
|
|
|
(defvar-local exwm--ewmh-state nil "_NET_WM_STATE.")
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; _NET_WM_NORMAL_HINTS
|
|
|
|
|
(defvar-local exwm--normal-hints-x nil)
|
|
|
|
|
(defvar-local exwm--normal-hints-y nil)
|
|
|
|
|
(defvar-local exwm--normal-hints-width nil)
|
|
|
|
|
(defvar-local exwm--normal-hints-height nil)
|
|
|
|
|
(defvar-local exwm--normal-hints-min-width nil)
|
|
|
|
|
(defvar-local exwm--normal-hints-min-height nil)
|
|
|
|
|
(defvar-local exwm--normal-hints-max-width nil)
|
|
|
|
|
(defvar-local exwm--normal-hints-max-height nil)
|
|
|
|
|
;; (defvar-local exwm--normal-hints-win-gravity nil)
|
|
|
|
|
;; WM_HINTS
|
2016-02-19 10:12:43 +01:00
|
|
|
|
(defvar-local exwm--hints-input nil)
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(defvar-local exwm--hints-urgency nil)
|
2015-09-19 10:46:08 +02:00
|
|
|
|
;; _MOTIF_WM_HINTS
|
2016-05-24 06:30:53 +02:00
|
|
|
|
(defvar-local exwm--mwm-hints-decorations t)
|
2015-09-04 03:09:59 +02:00
|
|
|
|
|
|
|
|
|
(defvar exwm-mode-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
2018-09-09 02:00:00 +02:00
|
|
|
|
(define-key map "\C-c\C-d\C-l" #'xcb-debug:clear)
|
|
|
|
|
(define-key map "\C-c\C-d\C-m" #'xcb-debug:mark)
|
2018-09-16 02:00:00 +02:00
|
|
|
|
(define-key map "\C-c\C-d\C-t" #'exwm-debug)
|
2016-02-20 03:02:11 +01:00
|
|
|
|
(define-key map "\C-c\C-f" #'exwm-layout-set-fullscreen)
|
2016-02-25 05:41:35 +01:00
|
|
|
|
(define-key map "\C-c\C-h" #'exwm-floating-hide)
|
2016-02-20 03:02:11 +01:00
|
|
|
|
(define-key map "\C-c\C-k" #'exwm-input-release-keyboard)
|
|
|
|
|
(define-key map "\C-c\C-m" #'exwm-workspace-move-window)
|
|
|
|
|
(define-key map "\C-c\C-q" #'exwm-input-send-next-key)
|
|
|
|
|
(define-key map "\C-c\C-t\C-f" #'exwm-floating-toggle-floating)
|
|
|
|
|
(define-key map "\C-c\C-t\C-m" #'exwm-layout-toggle-mode-line)
|
2015-09-04 03:09:59 +02:00
|
|
|
|
map)
|
|
|
|
|
"Keymap for `exwm-mode'.")
|
|
|
|
|
|
2016-09-22 13:10:38 +02:00
|
|
|
|
(defvar exwm--kmacro-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map [t]
|
|
|
|
|
(lambda ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(cond
|
2017-02-24 16:25:02 +01:00
|
|
|
|
((or exwm-input-line-mode-passthrough
|
2016-09-22 13:10:38 +02:00
|
|
|
|
;; Do not test `exwm-input--during-command'.
|
|
|
|
|
(active-minibuffer-window)
|
|
|
|
|
(memq last-input-event exwm-input--global-prefix-keys)
|
|
|
|
|
(memq last-input-event exwm-input-prefix-keys)
|
2018-03-05 01:00:00 +01:00
|
|
|
|
(lookup-key exwm-mode-map (vector last-input-event))
|
2018-02-20 14:57:49 +01:00
|
|
|
|
(gethash last-input-event exwm-input--simulation-keys))
|
2016-09-22 13:10:38 +02:00
|
|
|
|
(set-transient-map (make-composed-keymap (list exwm-mode-map
|
|
|
|
|
global-map)))
|
|
|
|
|
(push last-input-event unread-command-events))
|
|
|
|
|
(t
|
|
|
|
|
(exwm-input--fake-key last-input-event)))))
|
|
|
|
|
map)
|
|
|
|
|
"Keymap used when executing keyboard macros.")
|
|
|
|
|
|
2016-07-17 06:46:19 +02:00
|
|
|
|
;; This menu mainly acts as an reminder for users. Thus it should be as
|
|
|
|
|
;; detailed as possible, even some entries do not make much sense here.
|
|
|
|
|
;; Also, inactive entries should be disabled rather than hidden.
|
|
|
|
|
(easy-menu-define exwm-mode-menu exwm-mode-map
|
|
|
|
|
"Menu for `exwm-mode'."
|
2024-03-16 16:58:52 +01:00
|
|
|
|
`("EXWM"
|
2016-07-17 06:46:19 +02:00
|
|
|
|
"---"
|
|
|
|
|
"*General*"
|
|
|
|
|
"---"
|
|
|
|
|
["Toggle floating" exwm-floating-toggle-floating]
|
2016-08-24 13:21:17 +02:00
|
|
|
|
["Toggle fullscreen mode" exwm-layout-toggle-fullscreen]
|
2016-07-17 06:46:19 +02:00
|
|
|
|
["Hide window" exwm-floating-hide exwm--floating-frame]
|
2017-02-05 10:51:43 +01:00
|
|
|
|
["Close window" (kill-buffer (current-buffer))]
|
2016-07-17 06:46:19 +02:00
|
|
|
|
|
|
|
|
|
"---"
|
|
|
|
|
"*Resizing*"
|
|
|
|
|
"---"
|
2019-08-05 02:00:00 +02:00
|
|
|
|
["Toggle mode-line" exwm-layout-toggle-mode-line]
|
2016-07-17 06:46:19 +02:00
|
|
|
|
["Enlarge window vertically" exwm-layout-enlarge-window]
|
|
|
|
|
["Enlarge window horizontally" exwm-layout-enlarge-window-horizontally]
|
|
|
|
|
["Shrink window vertically" exwm-layout-shrink-window]
|
|
|
|
|
["Shrink window horizontally" exwm-layout-shrink-window-horizontally]
|
|
|
|
|
|
|
|
|
|
"---"
|
|
|
|
|
"*Keyboard*"
|
|
|
|
|
"---"
|
2016-08-24 13:21:17 +02:00
|
|
|
|
["Toggle keyboard mode" exwm-input-toggle-keyboard]
|
2018-10-08 14:00:00 +02:00
|
|
|
|
["Send key" exwm-input-send-next-key (eq exwm--input-mode 'line-mode)]
|
2016-07-17 06:46:19 +02:00
|
|
|
|
;; This is merely a reference.
|
|
|
|
|
("Send simulation key" :filter
|
2024-03-16 16:58:52 +01:00
|
|
|
|
,(lambda (&rest _args)
|
|
|
|
|
(let (result)
|
|
|
|
|
(maphash
|
|
|
|
|
(lambda (key value)
|
|
|
|
|
(when (sequencep key)
|
|
|
|
|
(setq result (append result
|
2024-03-16 17:39:35 +01:00
|
|
|
|
`([,(format "Send '%s'"
|
2024-03-16 16:58:52 +01:00
|
|
|
|
(key-description value))
|
2024-03-16 17:39:35 +01:00
|
|
|
|
,(lambda ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(mapc #'exwm-input--fake-key value))
|
2024-03-16 16:58:52 +01:00
|
|
|
|
:keys ,(key-description key)])))))
|
|
|
|
|
exwm-input--simulation-keys)
|
|
|
|
|
result)))
|
2016-07-17 06:46:19 +02:00
|
|
|
|
|
|
|
|
|
["Define global binding" exwm-input-set-key]
|
|
|
|
|
|
|
|
|
|
"---"
|
|
|
|
|
"*Workspace*"
|
|
|
|
|
"---"
|
2016-07-19 04:36:14 +02:00
|
|
|
|
["Add workspace" exwm-workspace-add]
|
|
|
|
|
["Delete current workspace" exwm-workspace-delete]
|
|
|
|
|
["Move workspace to" exwm-workspace-move]
|
|
|
|
|
["Swap workspaces" exwm-workspace-swap]
|
2019-08-05 02:00:00 +02:00
|
|
|
|
["Move X window to" exwm-workspace-move-window]
|
2016-07-19 04:36:14 +02:00
|
|
|
|
["Move X window from" exwm-workspace-switch-to-buffer]
|
2016-07-22 06:26:29 +02:00
|
|
|
|
["Toggle minibuffer" exwm-workspace-toggle-minibuffer]
|
2016-07-17 06:46:19 +02:00
|
|
|
|
["Switch workspace" exwm-workspace-switch]
|
|
|
|
|
;; Place this entry at bottom to avoid selecting others by accident.
|
|
|
|
|
("Switch to" :filter
|
2024-03-16 16:58:52 +01:00
|
|
|
|
,(lambda (&rest _args)
|
|
|
|
|
(mapcar (lambda (i)
|
|
|
|
|
`[,(format "Workspace %d" i)
|
2024-03-16 17:39:35 +01:00
|
|
|
|
,(lambda ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(exwm-workspace-switch i))
|
2024-03-16 16:58:52 +01:00
|
|
|
|
(/= ,i exwm-workspace-current-index)])
|
|
|
|
|
(number-sequence 0 (1- (length exwm-workspace--list))))))))
|
2016-07-17 06:46:19 +02:00
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(define-derived-mode exwm-mode nil "EXWM"
|
|
|
|
|
"Major mode for managing X windows.
|
|
|
|
|
|
|
|
|
|
\\{exwm-mode-map}"
|
2024-03-16 14:36:01 +01:00
|
|
|
|
:interactive nil :abbrev-table nil :syntax-table nil
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; Change major-mode is not allowed
|
|
|
|
|
(add-hook 'change-major-mode-hook #'kill-buffer nil t)
|
|
|
|
|
;; Kill buffer -> close window
|
|
|
|
|
(add-hook 'kill-buffer-query-functions
|
2016-02-18 12:56:01 +01:00
|
|
|
|
#'exwm-manage--kill-buffer-query-function nil t)
|
2016-09-22 13:10:38 +02:00
|
|
|
|
;; Redirect events when executing keyboard macros.
|
|
|
|
|
(push `(executing-kbd-macro . ,exwm--kmacro-map)
|
|
|
|
|
minor-mode-overriding-map-alist)
|
2024-03-16 16:53:04 +01:00
|
|
|
|
(setq mode-name '(:eval (exwm--mode-name))
|
|
|
|
|
buffer-read-only t
|
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
|
|
|
|
cursor-type nil
|
2015-09-04 03:09:59 +02:00
|
|
|
|
left-margin-width nil
|
|
|
|
|
right-margin-width nil
|
|
|
|
|
left-fringe-width 0
|
|
|
|
|
right-fringe-width 0
|
|
|
|
|
vertical-scroll-bar nil))
|
|
|
|
|
|
2024-05-29 19:58:45 +02:00
|
|
|
|
(defmacro exwm--define-global-minor-mode (name doc &optional init exit)
|
|
|
|
|
"Define global minor mode named exwm-NAME-mode.
|
|
|
|
|
EXWM's init-hook and exit-hook are modified to call INIT and EXIT functions.
|
|
|
|
|
If an X connection exists, the mode is immediately enabled or disabled."
|
|
|
|
|
(declare (indent 1) (debug t))
|
|
|
|
|
(let ((mode (intern (format "exwm-%s-mode" name)))
|
|
|
|
|
(init (or init (intern (format "exwm-%s--init" name))))
|
|
|
|
|
(exit (or exit (intern (format "exwm-%s--exit" name)))))
|
|
|
|
|
`(define-minor-mode ,mode
|
|
|
|
|
,doc
|
|
|
|
|
:global t
|
|
|
|
|
:group 'exwm
|
|
|
|
|
(exwm--log)
|
|
|
|
|
(cond
|
|
|
|
|
(,mode
|
|
|
|
|
(add-hook 'exwm-init-hook #',init)
|
|
|
|
|
(add-hook 'exwm-exit-hook #',exit)
|
|
|
|
|
(when exwm--connection (,init)))
|
|
|
|
|
(t
|
|
|
|
|
(remove-hook 'exwm-init-hook #',init)
|
|
|
|
|
(remove-hook 'exwm-exit-hook #',exit)
|
|
|
|
|
(when exwm--connection (,exit)))))))
|
2015-09-04 03:09:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(provide 'exwm-core)
|
|
|
|
|
|
|
|
|
|
;;; exwm-core.el ends here
|