From 0b23607ca3d0dc7f9f1d14ff0f78fc009e03888c Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Fri, 29 Dec 2023 14:04:15 +0100 Subject: Remove exwm-cm The exwm-cm feature has been obsoleted over five years ago in 7823eb98. Stop distributing it. * exwm-cm.el: Remove file. --- exwm-cm.el | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 exwm-cm.el diff --git a/exwm-cm.el b/exwm-cm.el deleted file mode 100644 index d2d04cbf92..0000000000 --- a/exwm-cm.el +++ /dev/null @@ -1,50 +0,0 @@ -;;; exwm-cm.el --- Compositing Manager for EXWM -*- lexical-binding: t -*- - -;; Copyright (C) 2016-2023 Free Software Foundation, Inc. - -;; Author: Chris Feng - -;; 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 . - -;;; Commentary: - -;; This module is obsolete since EXWM now supports third-party compositors. - -;;; Code: - -(make-obsolete-variable 'exwm-cm-opacity - "This variable should no longer be used." "26") - -(defun exwm-cm-set-opacity (&rest _args) - (declare (obsolete nil "26"))) - -(defun exwm-cm-enable () - (declare (obsolete nil "26"))) - -(defun exwm-cm-start () - (declare (obsolete nil "26"))) - -(defun exwm-cm-stop () - (declare (obsolete nil "26"))) - -(defun exwm-cm-toggle () - (declare (obsolete nil "26"))) - - - -(provide 'exwm-cm) - -;;; exwm-cm.el ends here -- cgit 1.4.1 From 50681727e3310d6f23e9f06dab83be5eb1f99763 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Fri, 29 Dec 2023 15:38:33 +0100 Subject: Add message-box and message-or-box to exwm-blocking-subrs (fix #874) * exwm.el (exwm-blocking-subrs): Add `message-box' and `message-or-box' to the list of blocking subrs. --- exwm.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exwm.el b/exwm.el index 5745533720..b8b9c2e8da 100644 --- a/exwm.el +++ b/exwm.el @@ -97,7 +97,9 @@ "Normal hook run when window title is updated." :type 'hook) -(defcustom exwm-blocking-subrs '(x-file-dialog x-popup-dialog x-select-font) +(defcustom exwm-blocking-subrs + (list #'x-file-dialog #'x-popup-dialog #'x-select-font + #'message-box #'message-or-box) "Subrs (primitives) that would normally block EXWM." :type '(repeat function)) -- cgit 1.4.1 From 8ea607ba8548e193157c5627ca30e3e57431ba5f Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 29 Dec 2023 14:07:08 -0800 Subject: Passthrough input when explicitly reading events and keys When any of these functions are called, Emacs expects to receive all input events until they return. Unfortunately, there doesn't appear to be a reliable way to detect that these functions are currently running other than advising them. * exwm-input.el (exwm-input--init): Advise low-level input reading functions to bind 'exwm-input-line-mode-passthrough' to t when called. (exwm-input--exit): Unadvise. (exwm-input--call-with-passthrough): The advice. (exwm-input--passthrough-functions): The functions we now advise. --- exwm-input.el | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/exwm-input.el b/exwm-input.el index 05b021093c..7ffd80f38a 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -102,6 +102,13 @@ defined in `exwm-mode-map' here." (defconst exwm-input--update-focus-interval 0.01 "Time interval (in seconds) for accumulating input focus update requests.") +(defconst exwm-input--passthrough-functions '(read-char + read-char-exclusive + read-key-sequence-vector + read-key-sequence + read-event) + "Low-level functions that read events and need to be exempted from EXWM's input handling.") + (defvar exwm-input--during-command nil "Indicate whether between `pre-command-hook' and `post-command-hook'.") @@ -1158,6 +1165,11 @@ One use is to access the keymap bound to KEYS (as prefix keys) in `char-mode'." (exwm--log) (exwm-input--on-minibuffer-exit))) +(defun exwm-input--call-with-passthrough (function &rest args) + "Bind `exwm-input-line-mode-passthrough' and call the specified FUNCTION with ARGS." + (let ((exwm-input-line-mode-passthrough t)) + (apply function args))) + (defun exwm-input--init () "Initialize the keyboard module." (exwm--log) @@ -1213,7 +1225,10 @@ One use is to access the keymap bound to KEYS (as prefix keys) in `char-mode'." (run-with-idle-timer 0 t #'exwm-input--on-echo-area-dirty)) (add-hook 'echo-area-clear-hook #'exwm-input--on-echo-area-clear) ;; Update focus when buffer list updates - (add-hook 'buffer-list-update-hook #'exwm-input--on-buffer-list-update)) + (add-hook 'buffer-list-update-hook #'exwm-input--on-buffer-list-update) + + (dolist (fun exwm-input--passthrough-functions) + (advice-add fun :around #'exwm-input--call-with-passthrough))) (defun exwm-input--post-init () "The second stage in the initialization of the input module." @@ -1223,6 +1238,8 @@ One use is to access the keymap bound to KEYS (as prefix keys) in `char-mode'." (defun exwm-input--exit () "Exit the input module." (exwm--log) + (dolist (fun exwm-input--passthrough-functions) + (advice-remove fun #'exwm-input--call-with-passthrough)) (exwm-input--unset-simulation-keys) (remove-hook 'pre-command-hook #'exwm-input--on-pre-command) (remove-hook 'post-command-hook #'exwm-input--on-post-command) -- cgit 1.4.1 From 6eaa0301f17898449827c778d52456800f776e65 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 29 Dec 2023 16:55:25 -0800 Subject: Correctly stop the subordinate Emacs daemon This patch starts Emacs as a foreground daemon (so it can accurately be killed) and terminates it by sending a signal (because 'server-force-delete' stops the local server, not the named server). * exwm.el (exwm--server-timeout): The time to politely wait for the subordinate server to exit before killing it. (exwm--server-stop): Send SIGTERM to the subordinate process instead of using 'server-force-delete'. (exwm--server-eval-at): Prevent Emacs from forking so we can manage it as a subprocess. --- exwm.el | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/exwm.el b/exwm.el index 5745533720..5e8489fee6 100644 --- a/exwm.el +++ b/exwm.el @@ -5,7 +5,7 @@ ;; Author: Chris Feng ;; Maintainer: Adrián Medraño Calvo ;; Version: 0.28 -;; Package-Requires: ((xelb "0.18")) +;; Package-Requires: ((emacs "26.1") (xelb "0.18")) ;; Keywords: unix ;; URL: https://github.com/ch11ng/exwm @@ -110,6 +110,9 @@ (defconst exwm--server-name "server-exwm" "Name of the subordinate Emacs server.") +(defvar exwm--server-timeout 1 + "Number of seconds to wait for the subordinate Emacs server to exit before killing it.") + (defvar exwm--server-process nil "Process of the subordinate Emacs server.") (defun exwm-reset () @@ -999,8 +1002,13 @@ FRAME, if given, indicates the X display EXWM should manage." (defun exwm--server-stop () "Stop the subordinate Emacs server." (exwm--log) - (server-force-delete exwm--server-name) (when exwm--server-process + (when (process-live-p exwm--server-process) + (cl-loop + initially (signal-process exwm--server-process 'TERM) + while (process-live-p exwm--server-process) + repeat (* 10 exwm--server-timeout) + do (sit-for 0.1))) (delete-process exwm--server-process) (setq exwm--server-process nil))) @@ -1017,7 +1025,7 @@ FUNCTION is the function to be evaluated, ARGS are the arguments." (car command-line-args) ;The executable file "-d" (frame-parameter nil 'display) "-Q" - (concat "--daemon=" exwm--server-name) + (concat "--fg-daemon=" exwm--server-name) "--eval" ;; Create an invisible frame "(make-frame '((window-system . x) (visibility)))")) -- cgit 1.4.1 From 92fbafee6c44885fcf2b67c7787480922aa1c305 Mon Sep 17 00:00:00 2001 From: Adrián Medraño Calvo Date: Mon, 8 Jan 2024 00:00:00 +0000 Subject: Update copyright year to 2024 --- exwm-background.el | 2 +- exwm-cm.el | 2 +- exwm-config.el | 2 +- exwm-core.el | 2 +- exwm-floating.el | 2 +- exwm-input.el | 2 +- exwm-layout.el | 2 +- exwm-manage.el | 2 +- exwm-randr.el | 2 +- exwm-systemtray.el | 2 +- exwm-workspace.el | 2 +- exwm-xim.el | 2 +- exwm.el | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/exwm-background.el b/exwm-background.el index 9c9bc5e352..44fa5d0377 100644 --- a/exwm-background.el +++ b/exwm-background.el @@ -1,6 +1,6 @@ ;;; exwm-background.el --- X Background Module for EXWM -*- lexical-binding: t -*- -;; Copyright (C) 2022-2023 Free Software Foundation, Inc. +;; Copyright (C) 2022-2024 Free Software Foundation, Inc. ;; Author: Steven Allen diff --git a/exwm-cm.el b/exwm-cm.el index d2d04cbf92..ed3c0fe84b 100644 --- a/exwm-cm.el +++ b/exwm-cm.el @@ -1,6 +1,6 @@ ;;; exwm-cm.el --- Compositing Manager for EXWM -*- lexical-binding: t -*- -;; Copyright (C) 2016-2023 Free Software Foundation, Inc. +;; Copyright (C) 2016-2024 Free Software Foundation, Inc. ;; Author: Chris Feng diff --git a/exwm-config.el b/exwm-config.el index f3357807b5..a9f21e9c8c 100644 --- a/exwm-config.el +++ b/exwm-config.el @@ -1,6 +1,6 @@ ;;; exwm-config.el --- Predefined configurations -*- lexical-binding: t -*- -;; Copyright (C) 2015-2023 Free Software Foundation, Inc. +;; Copyright (C) 2015-2024 Free Software Foundation, Inc. ;; Author: Chris Feng diff --git a/exwm-core.el b/exwm-core.el index 4df57e7381..6683c77120 100644 --- a/exwm-core.el +++ b/exwm-core.el @@ -1,6 +1,6 @@ ;;; exwm-core.el --- Core definitions -*- lexical-binding: t -*- -;; Copyright (C) 2015-2023 Free Software Foundation, Inc. +;; Copyright (C) 2015-2024 Free Software Foundation, Inc. ;; Author: Chris Feng diff --git a/exwm-floating.el b/exwm-floating.el index def7f43e53..ebf39c4a5c 100644 --- a/exwm-floating.el +++ b/exwm-floating.el @@ -1,6 +1,6 @@ ;;; exwm-floating.el --- Floating Module for EXWM -*- lexical-binding: t -*- -;; Copyright (C) 2015-2023 Free Software Foundation, Inc. +;; Copyright (C) 2015-2024 Free Software Foundation, Inc. ;; Author: Chris Feng diff --git a/exwm-input.el b/exwm-input.el index 05b021093c..e24a66cfd0 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -1,6 +1,6 @@ ;;; exwm-input.el --- Input Module for EXWM -*- lexical-binding: t -*- -;; Copyright (C) 2015-2023 Free Software Foundation, Inc. +;; Copyright (C) 2015-2024 Free Software Foundation, Inc. ;; Author: Chris Feng diff --git a/exwm-layout.el b/exwm-layout.el index e47620de3b..91764ad1c3 100644 --- a/exwm-layout.el +++ b/exwm-layout.el @@ -1,6 +1,6 @@ ;;; exwm-layout.el --- Layout Module for EXWM -*- lexical-binding: t -*- -;; Copyright (C) 2015-2023 Free Software Foundation, Inc. +;; Copyright (C) 2015-2024 Free Software Foundation, Inc. ;; Author: Chris Feng diff --git a/exwm-manage.el b/exwm-manage.el index 4771c3c088..7c7ad3901e 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -1,7 +1,7 @@ ;;; exwm-manage.el --- Window Management Module for -*- lexical-binding: t -*- ;;; EXWM -;; Copyright (C) 2015-2023 Free Software Foundation, Inc. +;; Copyright (C) 2015-2024 Free Software Foundation, Inc. ;; Author: Chris Feng diff --git a/exwm-randr.el b/exwm-randr.el index 8d1824babb..abfa84fe81 100644 --- a/exwm-randr.el +++ b/exwm-randr.el @@ -1,6 +1,6 @@ ;;; exwm-randr.el --- RandR Module for EXWM -*- lexical-binding: t -*- -;; Copyright (C) 2015-2023 Free Software Foundation, Inc. +;; Copyright (C) 2015-2024 Free Software Foundation, Inc. ;; Author: Chris Feng diff --git a/exwm-systemtray.el b/exwm-systemtray.el index 7f2b268df9..441da956e3 100644 --- a/exwm-systemtray.el +++ b/exwm-systemtray.el @@ -1,7 +1,7 @@ ;;; exwm-systemtray.el --- System Tray Module for -*- lexical-binding: t -*- ;;; EXWM -;; Copyright (C) 2016-2023 Free Software Foundation, Inc. +;; Copyright (C) 2016-2024 Free Software Foundation, Inc. ;; Author: Chris Feng diff --git a/exwm-workspace.el b/exwm-workspace.el index 61e2f69d28..472b2c2d74 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -1,6 +1,6 @@ ;;; exwm-workspace.el --- Workspace Module for EXWM -*- lexical-binding: t -*- -;; Copyright (C) 1015-2023 Free Software Foundation, Inc. +;; Copyright (C) 1015-2024 Free Software Foundation, Inc. ;; Author: Chris Feng diff --git a/exwm-xim.el b/exwm-xim.el index aea0eb53fb..1f0c9c460b 100644 --- a/exwm-xim.el +++ b/exwm-xim.el @@ -1,6 +1,6 @@ ;;; exwm-xim.el --- XIM Module for EXWM -*- lexical-binding: t -*- -;; Copyright (C) 2019-2023 Free Software Foundation, Inc. +;; Copyright (C) 2019-2024 Free Software Foundation, Inc. ;; Author: Chris Feng diff --git a/exwm.el b/exwm.el index 5745533720..3ec11905c5 100644 --- a/exwm.el +++ b/exwm.el @@ -1,6 +1,6 @@ ;;; exwm.el --- Emacs X Window Manager -*- lexical-binding: t -*- -;; Copyright (C) 2015-2023 Free Software Foundation, Inc. +;; Copyright (C) 2015-2024 Free Software Foundation, Inc. ;; Author: Chris Feng ;; Maintainer: Adrián Medraño Calvo -- cgit 1.4.1 From 798dc60a9b926e3fb3e48198ac507c8f9cc7299c Mon Sep 17 00:00:00 2001 From: Adrián Medraño Calvo Date: Mon, 8 Jan 2024 00:00:00 +0000 Subject: ; Shorten docstrings --- exwm-input.el | 5 +++-- exwm.el | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/exwm-input.el b/exwm-input.el index a37f416807..366fd624d9 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -107,7 +107,8 @@ defined in `exwm-mode-map' here." read-key-sequence-vector read-key-sequence read-event) - "Low-level functions that read events and need to be exempted from EXWM's input handling.") + "Low-level functions that read events and need to be exempted from +EXWM's input handling.") (defvar exwm-input--during-command nil "Indicate whether between `pre-command-hook' and `post-command-hook'.") @@ -1166,7 +1167,7 @@ One use is to access the keymap bound to KEYS (as prefix keys) in `char-mode'." (exwm-input--on-minibuffer-exit))) (defun exwm-input--call-with-passthrough (function &rest args) - "Bind `exwm-input-line-mode-passthrough' and call the specified FUNCTION with ARGS." + "Bind `exwm-input-line-mode-passthrough' and call FUNCTION with ARGS." (let ((exwm-input-line-mode-passthrough t)) (apply function args))) diff --git a/exwm.el b/exwm.el index f3cc7bd70f..d2a0a625a6 100644 --- a/exwm.el +++ b/exwm.el @@ -113,7 +113,8 @@ "Name of the subordinate Emacs server.") (defvar exwm--server-timeout 1 - "Number of seconds to wait for the subordinate Emacs server to exit before killing it.") + "Number of seconds to wait for the subordinate Emacs server to exit before +killing it.") (defvar exwm--server-process nil "Process of the subordinate Emacs server.") -- cgit 1.4.1 From 262aa0485576912626f77ce4c08f149e5e87c24a Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 9 Jan 2024 09:43:07 +0100 Subject: ; README and commentary: Mention background and xim features --- README.md | 1 + exwm.el | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 6d7e0dd1ff..b17db2fece 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ It features: + (Optional) RandR (multi-monitor) support + (Optional) Builtin system tray + (Optional) Builtin input method ++ (Optional) Background setting support Please check out the [screenshots](https://github.com/ch11ng/exwm/wiki/Screenshots) diff --git a/exwm.el b/exwm.el index d2a0a625a6..1929b7a60c 100644 --- a/exwm.el +++ b/exwm.el @@ -37,6 +37,8 @@ ;; + ICCCM/EWMH compliance ;; + (Optional) RandR (multi-monitor) support ;; + (Optional) Built-in system tray +;; + (Optional) Builtin input method +;; + (Optional) Background setting support ;; Installation & configuration ;; ---------------------------- -- cgit 1.4.1 From b51389ce8f8650766a2fdee95c4d3d4ffa72ad88 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 9 Jan 2024 09:43:40 +0100 Subject: ; exwm-background: Wrap docstrings to avoid compiler warnings --- exwm-background.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exwm-background.el b/exwm-background.el index 44fa5d0377..701e577d83 100644 --- a/exwm-background.el +++ b/exwm-background.el @@ -47,13 +47,13 @@ (defconst exwm-background--properties '("_XROOTPMAP_ID" "_XSETROOT_ID" "ESETROOT_PMAP_ID") "The background properties to set. -We can't need to set these so that compositing window managers can correctly display the background -color.") +We can't need to set these so that compositing window managers +can correctly display the background color.") (defvar exwm-background--connection nil "The X connection used for setting the background. -We use a separate connection as other background-setting tools may kill this connection when they -replace it.") +We use a separate connection as other background-setting tools +may kill this connection when they replace it.") (defvar exwm-background--pixmap nil "Cached background pixmap.") -- cgit 1.4.1 From 22aa38b0cda9b58865ec2d59dc89bc32884ffc76 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 9 Jan 2024 19:52:51 +0100 Subject: ; Use two spaces after sentence I follow this convention in Elisp files only. --- exwm-background.el | 2 +- exwm-input.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exwm-background.el b/exwm-background.el index 701e577d83..fa663d8fe6 100644 --- a/exwm-background.el +++ b/exwm-background.el @@ -27,7 +27,7 @@ ;; (require 'exwm-background) ;; (exwm-background-enable) ;; -;; By default, this will apply the theme's background color. However, that +;; By default, this will apply the theme's background color. However, that ;; color can be customized via the `exwm-background-color' setting. ;;; Code: diff --git a/exwm-input.el b/exwm-input.el index 366fd624d9..147638be72 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -762,7 +762,7 @@ Current buffer must be an `exwm-mode' buffer." (defun exwm-input--on-ButtonPress-line-mode (buffer button-event) "Handle button events in line mode. BUFFER is the `exwm-mode' buffer the event was generated -on. BUTTON-EVENT is the X event converted into an Emacs event. +on. BUTTON-EVENT is the X event converted into an Emacs event. The return value is used as event_mode to release the original button event." -- cgit 1.4.1 From 2e79830e3942f1c3c71c43d973b248b7bbbcd686 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 9 Jan 2024 19:46:50 +0100 Subject: ; First line of docstring should be a full sentence --- exwm-floating.el | 8 ++++---- exwm-input.el | 3 +-- exwm.el | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/exwm-floating.el b/exwm-floating.el index ebf39c4a5c..c4e29dece4 100644 --- a/exwm-floating.el +++ b/exwm-floating.el @@ -35,13 +35,13 @@ :group 'exwm) (defcustom exwm-floating-setup-hook nil - "Normal hook run when an X window has been made floating, in the -context of the corresponding buffer." + "Normal hook run when an X window has been made floating. +This hook runs in the context of the corresponding buffer." :type 'hook) (defcustom exwm-floating-exit-hook nil - "Normal hook run when an X window has exited floating state, in the -context of the corresponding buffer." + "Normal hook run when an X window has exited floating state. +This hook runs in the context of the corresponding buffer." :type 'hook) (defcustom exwm-floating-border-color "navy" diff --git a/exwm-input.el b/exwm-input.el index 147638be72..bb97adc623 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -107,8 +107,7 @@ defined in `exwm-mode-map' here." read-key-sequence-vector read-key-sequence read-event) - "Low-level functions that read events and need to be exempted from -EXWM's input handling.") + "Low-level read functions that must be exempted from EXWM input handling.") (defvar exwm-input--during-command nil "Indicate whether between `pre-command-hook' and `post-command-hook'.") diff --git a/exwm.el b/exwm.el index 1929b7a60c..a9deb5cd8d 100644 --- a/exwm.el +++ b/exwm.el @@ -115,8 +115,8 @@ "Name of the subordinate Emacs server.") (defvar exwm--server-timeout 1 - "Number of seconds to wait for the subordinate Emacs server to exit before -killing it.") + "Number of seconds to wait for the subordinate Emacs server to exit. +After this time, the server will be killed.") (defvar exwm--server-process nil "Process of the subordinate Emacs server.") -- cgit 1.4.1 From c069e8195dfdd81f458e4a0dac4d9589077321e3 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 9 Jan 2024 09:51:28 +0100 Subject: exwm-blocking-subrs: x-* functions may be missing on some Emacs builds Avoid compiler warnings. Follow-up of https://github.com/ch11ng/exwm/pull/937. --- exwm.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exwm.el b/exwm.el index a9deb5cd8d..3561cf27ac 100644 --- a/exwm.el +++ b/exwm.el @@ -100,8 +100,9 @@ :type 'hook) (defcustom exwm-blocking-subrs - (list #'x-file-dialog #'x-popup-dialog #'x-select-font - #'message-box #'message-or-box) + ;; `x-file-dialog' and `x-select-font' are missing on some Emacs builds, for + ;; example on the X11 Lucid build. + '(x-file-dialog x-popup-dialog x-select-font message-box message-or-box) "Subrs (primitives) that would normally block EXWM." :type '(repeat function)) -- cgit 1.4.1 From dc26c38af7fc65fc2cb59c5083cd14e0ef7cc7b0 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 9 Jan 2024 19:41:37 +0100 Subject: Remove obsolete functions and variables These functions and variables have been marked as obsolete over five years ago. * exwm-input.el (exwm-input-set-simulation-keys): Remove obsolete function. * exwm-randr.el (exwm-randr--refresh, exwm-randr-workspace-output-plist): Remove obsolete aliases. --- exwm-input.el | 5 ----- exwm-randr.el | 7 ------- 2 files changed, 12 deletions(-) diff --git a/exwm-input.el b/exwm-input.el index bb97adc623..5767f13978 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -984,11 +984,6 @@ multiple keys. If END-KEY is non-nil, stop sending keys if it's pressed." #'exwm-input-send-simulation-key)))) exwm-input--simulation-keys)) -(defun exwm-input-set-simulation-keys (simulation-keys) - "Please customize or set `exwm-input-simulation-keys' instead." - (declare (obsolete nil "26")) - (exwm-input--set-simulation-keys simulation-keys)) - (defcustom exwm-input-simulation-keys nil "Simulation keys. diff --git a/exwm-randr.el b/exwm-randr.el index abfa84fe81..e98074fecb 100644 --- a/exwm-randr.el +++ b/exwm-randr.el @@ -91,10 +91,6 @@ corresponding monitors whenever the monitors are active. \\='(1 \"HDMI-1\" 3 \"DP-1\")" :type '(plist :key-type integer :value-type string)) -(with-no-warnings - (define-obsolete-variable-alias 'exwm-randr-workspace-output-plist - 'exwm-randr-workspace-monitor-plist "27.1")) - (defvar exwm-randr--last-timestamp 0 "Used for debouncing events.") (defvar exwm-randr--prev-screen-change-seqnum nil @@ -269,9 +265,6 @@ In a mirroring setup some monitors overlap and should be treated as one." (xcb:flush exwm--connection) (run-hooks 'exwm-randr-refresh-hook)))) -(define-obsolete-function-alias 'exwm-randr--refresh #'exwm-randr-refresh - "27.1") - (defun exwm-randr--on-ScreenChangeNotify (data _synthetic) "Handle `ScreenChangeNotify' event. -- cgit 1.4.1 From 2c5dcadfabd70a16913d9dfcab7733c0f8811b1a Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Fri, 12 Jan 2024 10:28:23 +0100 Subject: ; Update repository URLs --- README.md | 8 ++++---- exwm.el | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b17db2fece..404f3228fc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Emacs X Window Manager EXWM (Emacs X Window Manager) is a full-featured tiling X window manager -for Emacs built on top of [XELB](https://github.com/ch11ng/xelb). +for Emacs built on top of [XELB](https://github.com/emacs-exwm/xelb). It features: + Fully keyboard-driven operations + Hybrid layout modes (tiling & stacking) @@ -13,9 +13,9 @@ It features: + (Optional) Background setting support Please check out the -[screenshots](https://github.com/ch11ng/exwm/wiki/Screenshots) -to get an overview of what EXWM is capable of, -and the [user guide](https://github.com/ch11ng/exwm/wiki) +[screenshots](https://github.com/emacs-exwm/exwm/wiki/Screenshots) +to get an overview of what EXWM is capable of, and the +[user guide](https://github.com/emacs-exwm/exwm/wiki) for a detailed explanation of its usage. **Note**: If you install EXWM from source, it's recommended to install diff --git a/exwm.el b/exwm.el index 3561cf27ac..d421a22ef5 100644 --- a/exwm.el +++ b/exwm.el @@ -7,7 +7,7 @@ ;; Version: 0.28 ;; Package-Requires: ((emacs "26.1") (xelb "0.18")) ;; Keywords: unix -;; URL: https://github.com/ch11ng/exwm +;; URL: https://github.com/emacs-exwm/exwm ;; This file is part of GNU Emacs. @@ -29,7 +29,7 @@ ;; Overview ;; -------- ;; EXWM (Emacs X Window Manager) is a full-featured tiling X window manager -;; for Emacs built on top of [XELB](https://github.com/ch11ng/xelb). +;; for Emacs built on top of [XELB](https://github.com/emacs-exwm/xelb). ;; It features: ;; + Fully keyboard-driven operations ;; + Hybrid layout modes (tiling & stacking) @@ -56,7 +56,7 @@ ;; xinit -- vt01 ;; ;; You should additionally hide the menu-bar, tool-bar, etc to increase the -;; usable space. Please check the wiki (https://github.com/ch11ng/exwm/wiki) +;; usable space. Please check the wiki (https://github.com/emacs-exwm/exwm/wiki) ;; for more detailed instructions on installation, configuration, usage, etc. ;; References: -- cgit 1.4.1 From 588cfc77908de8db4a7acb0ccff55c04eabc68a7 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Fri, 12 Jan 2024 11:10:48 +0100 Subject: Add new maintainers: Steven Allen (@stebalien) and Daniel Mendler (@minad) --- exwm.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exwm.el b/exwm.el index d421a22ef5..319168a91c 100644 --- a/exwm.el +++ b/exwm.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2015-2024 Free Software Foundation, Inc. ;; Author: Chris Feng -;; Maintainer: Adrián Medraño Calvo +;; Maintainer: Adrián Medraño Calvo , Steven Allen , Daniel Mendler ;; Version: 0.28 ;; Package-Requires: ((emacs "26.1") (xelb "0.18")) ;; Keywords: unix -- cgit 1.4.1 From 4a3feec76f94a2688e885e4742b600a76b6fa8af Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Fri, 12 Jan 2024 15:01:18 +0100 Subject: ; Add LICENSE to .elpaignore --- .elpaignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.elpaignore b/.elpaignore index b43bf86b50..f0f644ee08 100644 --- a/.elpaignore +++ b/.elpaignore @@ -1 +1,2 @@ +LICENSE README.md -- cgit 1.4.1 From 96a9de8c19bdf4f6ef4a05a2be81f5f4cacc6b95 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 9 Jan 2024 19:38:01 +0100 Subject: Depend on Emacs 27.1 Emacs 27.1 is widely available on all major Linux distributions, including the ones with long time support. --- exwm-input.el | 18 ++++-------------- exwm.el | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/exwm-input.el b/exwm-input.el index 5767f13978..b4d6d28b21 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -587,20 +587,10 @@ instead." (when (called-interactively-p 'any) (exwm-input--update-global-prefix-keys))) -;; Putting (t . EVENT) into `unread-command-events' does not really work -;; as documented for Emacs < 26.2. -(eval-and-compile - (if (or (< emacs-major-version 26) - (and (= emacs-major-version 26) - (< emacs-minor-version 2))) - (defsubst exwm-input--unread-event (event) - (declare (indent defun)) - (setq unread-command-events - (append unread-command-events (list event)))) - (defsubst exwm-input--unread-event (event) - (declare (indent defun)) - (setq unread-command-events - (append unread-command-events `((t . ,event))))))) +(defsubst exwm-input--unread-event (event) + (declare (indent defun)) + (setq unread-command-events + (append unread-command-events `((t . ,event))))) (defun exwm-input--mimic-read-event (event) "Process EVENT as if it were returned by `read-event'." diff --git a/exwm.el b/exwm.el index 319168a91c..92591d4c20 100644 --- a/exwm.el +++ b/exwm.el @@ -5,7 +5,7 @@ ;; Author: Chris Feng ;; Maintainer: Adrián Medraño Calvo , Steven Allen , Daniel Mendler ;; Version: 0.28 -;; Package-Requires: ((emacs "26.1") (xelb "0.18")) +;; Package-Requires: ((emacs "27.1") (xelb "0.18")) ;; Keywords: unix ;; URL: https://github.com/emacs-exwm/exwm -- cgit 1.4.1 From c573ff143a95dd5838467b67687f16e0225b777d Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 9 Jan 2024 19:43:17 +0100 Subject: Drop :version keywords from defgroup These may refer to an Emacs version and may have been added by mistake. --- exwm-floating.el | 1 - exwm-input.el | 1 - exwm-layout.el | 1 - exwm-manage.el | 1 - exwm-randr.el | 1 - exwm-systemtray.el | 1 - exwm-workspace.el | 1 - exwm.el | 1 - 8 files changed, 8 deletions(-) diff --git a/exwm-floating.el b/exwm-floating.el index c4e29dece4..34d06a30db 100644 --- a/exwm-floating.el +++ b/exwm-floating.el @@ -31,7 +31,6 @@ (defgroup exwm-floating nil "Floating." - :version "25.3" :group 'exwm) (defcustom exwm-floating-setup-hook nil diff --git a/exwm-input.el b/exwm-input.el index b4d6d28b21..835705ff9d 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -40,7 +40,6 @@ (defgroup exwm-input nil "Input." - :version "25.3" :group 'exwm) (defcustom exwm-input-prefix-keys diff --git a/exwm-layout.el b/exwm-layout.el index 91764ad1c3..47ccf5c519 100644 --- a/exwm-layout.el +++ b/exwm-layout.el @@ -29,7 +29,6 @@ (defgroup exwm-layout nil "Layout." - :version "25.3" :group 'exwm) (defcustom exwm-layout-auto-iconify t diff --git a/exwm-manage.el b/exwm-manage.el index 7c7ad3901e..fa73a8f380 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -30,7 +30,6 @@ (defgroup exwm-manage nil "Manage." - :version "25.3" :group 'exwm) (defcustom exwm-manage-finish-hook nil diff --git a/exwm-randr.el b/exwm-randr.el index e98074fecb..7f0e50559b 100644 --- a/exwm-randr.el +++ b/exwm-randr.el @@ -56,7 +56,6 @@ (defgroup exwm-randr nil "RandR." - :version "25.3" :group 'exwm) (defcustom exwm-randr-refresh-hook nil diff --git a/exwm-systemtray.el b/exwm-systemtray.el index 441da956e3..9e57dae4eb 100644 --- a/exwm-systemtray.el +++ b/exwm-systemtray.el @@ -57,7 +57,6 @@ (defgroup exwm-systemtray nil "System tray." - :version "25.3" :group 'exwm) (defcustom exwm-systemtray-height nil diff --git a/exwm-workspace.el b/exwm-workspace.el index 472b2c2d74..89be697159 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -31,7 +31,6 @@ (defgroup exwm-workspace nil "Workspace." - :version "25.3" :group 'exwm) (defcustom exwm-workspace-switch-hook nil diff --git a/exwm.el b/exwm.el index 92591d4c20..a80232dc17 100644 --- a/exwm.el +++ b/exwm.el @@ -79,7 +79,6 @@ (defgroup exwm nil "Emacs X Window Manager." :tag "EXWM" - :version "25.3" :group 'applications :prefix "exwm-") -- cgit 1.4.1 From ff4edaab89311281fd78725b98a751e15b6a2ec1 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 26 Jul 2022 16:51:02 -0700 Subject: Implement the XSETTINGS protocol Users can use this to configure system-wide themes, icons, fonts, etc. * exwm-xsettings.el: Implement the XSETTINGS protocol (fixes https://github.com/ch11ng/exwm/issues/876) --- exwm-xsettings.el | 400 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 400 insertions(+) create mode 100644 exwm-xsettings.el diff --git a/exwm-xsettings.el b/exwm-xsettings.el new file mode 100644 index 0000000000..4eac557b9a --- /dev/null +++ b/exwm-xsettings.el @@ -0,0 +1,400 @@ +;;; exwm-xsettings.el --- XSETTINGS Module for EXWM -*- lexical-binding: t -*- + +;; Copyright (C) 2022-2024 Free Software Foundation, Inc. + +;; Author: Steven Allen + +;; 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 . + +;;; Commentary: + +;; Implements the XSETTINGS protocol, allowing Emacs to manage the system theme, +;; fonts, icons, etc. +;; +;; This package can be configured as follows: +;; +;; (require 'exwm-xsettings) +;; (setq exwm-xsettings-theme '("Adwaita" . "Adwaita-dark") ;; light/dark +;; exwm-xsettings `(("Xft/HintStyle" . "hintslight") +;; ("Xft/RGBA" . "rgb") +;; ("Xft/lcdfilter" . "lcddefault") +;; ("Xft/Antialias" . 1) +;; ;; DPI is in 1024ths of an inch, so this is a DPI of +;; ;; 144, equivalent to ;; a scaling factor of 1.5 +;; ;; (144 = 1.5 * 96). +;; ("Xft/DPI" . ,(* 144 1024)) +;; ("Xft/Hinting" . 1))) +;; (exwm-xsettings-enable) +;; +;; To modify these settings at runtime, customize them with +;; `custom-set-variables' or `setopt' (Emacs 29+). E.g., the following will +;; immediately change the icon theme to "Papirus" at runtime, even in running +;; applications: +;; +;; (setopt exwm-xsettings-icon-theme "Papirus") + +;;; Code: + +(require 'xcb-ewmh) +(require 'xcb-icccm) + +(require 'exwm-core) + +(defvar exwm-xsettings--connection nil) +(defvar exwm-xsettings--XSETTINGS_SETTINGS-atom nil) +(defvar exwm-xsettings--XSETTINGS_S0-atom nil) +(defvar exwm-xsettings--selection-owner-window nil) + +(defun exwm-xsettings--rgba-match (_widget value) + "Return t if VALUE is a valid RGBA color." + (and (numberp value) (<= 0 value 1))) + +(defun exwm-xsettings--custom-set (symbol value) + "Setter used by `exwm-xsettings' customization options. + +SYMBOL is the setting being updated and VALUE is the new value." + (set-default-toplevel-value symbol value) + (exwm-xsettings--update-settings)) + +(defcustom exwm-xsettings nil + "Custom XSETTINGS. +These settings take precedence over `exwm-xsettings-theme' and +`exwm-xsettings-icon-theme'." + :group 'exwm + :type '(alist :key-type (string :tag "Name") + :value-type (choice :tag "Value" + (string :tag "String") + (integer :tag "Integer") + (list :tag "Color" + (number :tag "Red" + :type-error + "This field should contain a number between 0 and 1." + :match exwm-xsettings--rgba-match) + (number :tag "Green" + :type-error + "This field should contain a number between 0 and 1." + :match exwm-xsettings--rgba-match) + (number :tag "Blue" + :type-error + "This field should contain a number between 0 and 1." + :match exwm-xsettings--rgba-match) + (number :tag "Alpha" + :type-error + "This field should contain a number between 0 and 1." + :match exwm-xsettings--rgba-match + :value 1.0)))) + :initialize #'custom-initialize-default + :set #'exwm-xsettings--custom-set) + +(defcustom exwm-xsettings-theme nil + "The system-wide theme." + :group 'exwm + :type '(choice (string :tag "Theme") + (cons (string :tag "Light Theme") + (string :tag "Dark Theme"))) + :initialize #'custom-initialize-default + :set #'exwm-xsettings--custom-set) + +(defcustom exwm-xsettings-icon-theme nil + "The system-wide icon theme." + :group 'exwm + :type '(choice (string :tag "Icon Theme") + (cons (string :tag "Light Icon Theme") + (string :tag "Dark Icon Theme"))) + :initialize #'custom-initialize-default + :set #'exwm-xsettings--custom-set) + +(defvar exwm-xsettings--serial 0) + +(defconst xcb:xsettings:-Type:Integer 0) +(defconst xcb:xsettings:-Type:String 1) +(defconst xcb:xsettings:-Type:Color 2) + +(defclass xcb:xsettings:-Settings + (xcb:-struct) + ((byte-order :initarg :byte-order :type xcb:CARD8) + (pad~0 :initform 3 :type xcb:-pad) + (serial :initarg :serial :type xcb:CARD32) + (settings-len :initarg :settings-len :type xcb:CARD32) + (settings~ :initform + '(name settings type xcb:xsettings:-SETTING size + (xcb:-fieldref 'settings-len)) + :type xcb:-list) + (settings :initarg :settings :type xcb:-ignore))) + +(defclass xcb:xsettings:-SETTING + (xcb:-struct) + ((type :initarg :type :type xcb:CARD8) + (pad~0 :initform 1 :type xcb:-pad) + (name-len :initarg :name-len :type xcb:CARD16) + (name~ :initform + '(name name type xcb:char size + (xcb:-fieldref 'name-len)) + :type xcb:-list) + (name :initarg :name :type xcb:-ignore) + (pad~1 :initform 4 :type xcb:-pad-align) + (last-change-serial :initarg :last-change-serial :type xcb:CARD32))) + +(defclass xcb:xsettings:-SETTING_INTEGER + (xcb:xsettings:-SETTING) + ((type :initform 'xcb:xsettings:-Type:Integer) + (value :initarg :value :type xcb:INT32))) + +(defclass xcb:xsettings:-SETTING_STRING + (xcb:xsettings:-SETTING) + ((type :initform 'xcb:xsettings:-Type:String) + (value-len :initarg :value-len :type xcb:CARD32) + (value~ :initform + '(name value type xcb:char size + (xcb:-fieldref 'value-len)) + :type xcb:-list) + (value :initarg :value :type xcb:-ignore) + (pad~2 :initform 4 :type xcb:-pad-align))) + +(defclass xcb:xsettings:-SETTING_COLOR + (xcb:xsettings:-SETTING) + ((type :initform 'xcb:xsettings:-Type:Color) + (red :initarg :red :type xcb:CARD16) + (green :initarg :green :type xcb:CARD16) + (blue :initarg :blue :type xcb:CARD16) + (alpha :initarg :alpha :initform #xffff :type xcb:CARD16))) + +(defclass xcb:xsettings:-ClientMessage + (xcb:icccm:--ClientMessage xcb:ClientMessage) + ((format :initform 32) + (type :initform 'xcb:Atom:MANAGER) + (time :initarg :time :type xcb:TIMESTAMP) ;new slot + (selection :initarg :selection :type xcb:ATOM) ;new slot + (owner :initarg :owner :type xcb:WINDOW)) ;new slot + :documentation "An XSETTINGS client message.") + +(defalias 'exwm-xsettings--color-dark-p + (if (eval-when-compile (< emacs-major-version 29)) + ;; Borrowed from Emacs 29. + (lambda (rgb) + "Whether RGB is more readable against white than black." + (unless (<= 0 (apply #'min rgb) (apply #'max rgb) 1) + (error "RGB components %S not in [0,1]" rgb)) + (let* ((r (expt (nth 0 rgb) 2.2)) + (g (expt (nth 1 rgb) 2.2)) + (b (expt (nth 2 rgb) 2.2)) + (y (+ (* r 0.2126) (* g 0.7152) (* b 0.0722)))) + (< y 0.325))) + 'color-dark-p)) + +(defun exwm-xsettings--pick-theme (theme) + "Pick a light or dark theme from the given THEME. +If THEME is a string, it's returned directly. +If THEME is a cons of (LIGHT . DARK), the appropriate theme is picked based on +the default face's background color." + (pcase theme + ((cl-type string) theme) + (`(,(cl-type string) . ,(cl-type string)) + (if (exwm-xsettings--color-dark-p (color-name-to-rgb (face-background 'default))) + (cdr theme) (car theme))) + (_ (error "Expected theme to be a string or a pair of strings")))) + +(defun exwm-xsettings--get-settings () + "Get the current settings. +Combines `exwm-xsettings', `exwm-xsettings-theme' (if set), and +`exwm-xsettings-icon-theme' (if set)." + (cl-remove-duplicates + (append + exwm-xsettings + (when exwm-xsettings-theme + (list (cons "Net/ThemeName" (exwm-xsettings--pick-theme exwm-xsettings-theme)))) + (when exwm-xsettings-icon-theme + (list (cons "Net/IconThemeName" (exwm-xsettings--pick-theme exwm-xsettings-icon-theme))))) + :key 'car + :test 'string=)) + +(defun exwm-xsettings--make-settings (settings serial) + "Construct a new settings object. +SETTINGS is an alist of key/value pairs. +SERIAL is a sequence number." + (make-instance 'xcb:xsettings:-Settings + :byte-order (if xcb:lsb 0 1) + :serial serial + :settings-len (length settings) + :settings + (mapcar + (lambda (prop) + (let* ((name (car prop)) + (value (cdr prop)) + (common (list :name name + :name-len (length name) + :last-change-serial serial))) + (pcase value + ((cl-type string) + (apply #'make-instance 'xcb:xsettings:-SETTING_STRING + :value-len (length value) + :value value + common)) + ((cl-type integer) + (apply #'make-instance 'xcb:xsettings:-SETTING_INTEGER + :value value common)) + ((and (cl-type list) (app length (or 3 4))) + ;; Convert from RGB(A) to 16bit integers. + (setq value (mapcar (lambda (x) (round (* x #xffff))) value)) + (apply #'make-instance 'xcb:xsettings:-SETTING_COLOR + :red (pop value) + :green (pop value) + :blue (pop value) + :alpha (or (pop value) #xffff))) + (_ (error "Setting value must be a string, integer, or length 3-4 list"))))) + settings))) + +(defun exwm-xsettings--update-settings () + "Update the xsettings." + (when exwm-xsettings--connection + (setq exwm-xsettings--serial (1+ exwm-xsettings--serial)) + (let* ((settings (exwm-xsettings--get-settings)) + (bytes (xcb:marshal (exwm-xsettings--make-settings settings exwm-xsettings--serial)))) + (xcb:+request exwm-xsettings--connection + (make-instance 'xcb:ChangeProperty + :mode xcb:PropMode:Replace + :window exwm-xsettings--selection-owner-window + :property exwm-xsettings--XSETTINGS_SETTINGS-atom + :type exwm-xsettings--XSETTINGS_SETTINGS-atom + :format 8 + :data-len (length bytes) + :data bytes))) + (xcb:flush exwm-xsettings--connection))) + +(defun exwm-xsettings--on-theme-change (&rest _) + "Called when the Emacs theme is changed." + ;; We only bother updating the xsettings if changing the theme could effect + ;; the settings. + (when (or (consp exwm-xsettings-theme) (consp exwm-xsettings-icon-theme)) + (exwm-xsettings--update-settings))) + +(defun exwm-xsettings--on-SelectionClear (_data _synthetic) + "Called when another xsettings daemon takes over." + (exwm--log "XSETTINGS manager has been replaced.") + (exwm-xsettings--exit)) + +(cl-defun exwm-xsettings--init () + "Initialize the XSETTINGS module." + (exwm--log) + + (cl-assert (not exwm-xsettings--connection)) + + ;; Connect + (setq exwm-xsettings--connection (xcb:connect)) + (set-process-query-on-exit-flag (slot-value exwm-xsettings--connection + 'process) + nil) + + ;; Intern the atoms. + (setq exwm-xsettings--XSETTINGS_SETTINGS-atom + (exwm--intern-atom "_XSETTINGS_SETTINGS" exwm-xsettings--connection) + + exwm-xsettings--XSETTINGS_S0-atom + (exwm--intern-atom "_XSETTINGS_S0" exwm-xsettings--connection)) + + ;; Detect running XSETTINGS managers. + (with-slots (owner) + (xcb:+request-unchecked+reply exwm-xsettings--connection + (make-instance 'xcb:GetSelectionOwner + :selection exwm-xsettings--XSETTINGS_S0-atom)) + (when (/= owner xcb:Window:None) + (xcb:disconnect exwm-xsettings--connection) + (setq exwm-xsettings--connection nil) + (warn "[EXWM] Other XSETTINGS manager detected") + (cl-return-from exwm-xsettings--init))) + + + (let ((id(xcb:generate-id exwm-xsettings--connection))) + (setq exwm-xsettings--selection-owner-window id) + + ;; Create a settings window. + (xcb:+request exwm-xsettings--connection + (make-instance 'xcb:CreateWindow + :wid id + :parent exwm--root + :class xcb:WindowClass:InputOnly + :x 0 + :y 0 + :width 1 + :height 1 + :border-width 0 + :depth 0 + :visual 0 + :value-mask xcb:CW:OverrideRedirect + :override-redirect 1)) + + ;; Set _NET_WM_NAME. + (xcb:+request exwm-xsettings--connection + (make-instance 'xcb:ewmh:set-_NET_WM_NAME + :window id + :data "EXWM: exwm-xsettings--selection-owner-window")) + + ;; Apply the XSETTINGS properties. + (exwm-xsettings--update-settings) + + ;; Take ownership and notify. + (xcb:+request exwm-xsettings--connection + (make-instance 'xcb:SetSelectionOwner + :owner id + :selection exwm-xsettings--XSETTINGS_S0-atom + :time xcb:Time:CurrentTime)) + (xcb:+request exwm-xsettings--connection + (make-instance 'xcb:SendEvent + :propagate 0 + :destination exwm--root + :event-mask xcb:EventMask:StructureNotify + :event (xcb:marshal + (make-instance 'xcb:xsettings:-ClientMessage + :window exwm--root + :time xcb:Time:CurrentTime + :selection exwm-xsettings--XSETTINGS_S0-atom + :owner id) + exwm-xsettings--connection))) + + ;; Detect loss of XSETTINGS ownership. + (xcb:+event exwm-xsettings--connection 'xcb:SelectionClear + #'exwm-xsettings--on-SelectionClear) + + (xcb:flush exwm-xsettings--connection)) + + ;; Update the xsettings if/when the theme changes. + (add-hook 'enable-theme-functions #'exwm-xsettings--on-theme-change) + (add-hook 'disable-theme-functions #'exwm-xsettings--on-theme-change)) + +(defun exwm-xsettings--exit () + "Exit the XSETTINGS module." + (exwm--log) + + (when exwm-xsettings--connection + (remove-hook 'enable-theme-functions #'exwm-xsettings--on-theme-change) + (remove-hook 'disable-theme-functions #'exwm-xsettings--on-theme-change) + + (xcb:disconnect exwm-xsettings--connection) + + (setq exwm-xsettings--connection nil + exwm-xsettings--XSETTINGS_SETTINGS-atom nil + exwm-xsettings--XSETTINGS_S0-atom nil + exwm-xsettings--selection-owner-window nil))) + +(defun exwm-xsettings-enable () + "Enable xsettings support for EXWM." + (exwm--log) + (add-hook 'exwm-init-hook #'exwm-xsettings--init) + (add-hook 'exwm-exit-hook #'exwm-xsettings--exit)) + +(provide 'exwm-xsettings) + +;;; exwm-xsettings.el ends here -- cgit 1.4.1 From 8980c03a6b1617fd8fed635884a58de81dfec119 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 13 Jan 2024 20:38:09 +0100 Subject: ; Commentary: Update list of features --- README.md | 10 ++++++---- exwm.el | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 404f3228fc..8ab93561e2 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,12 @@ It features: + Hybrid layout modes (tiling & stacking) + Dynamic workspace support + ICCCM/EWMH compliance -+ (Optional) RandR (multi-monitor) support -+ (Optional) Builtin system tray -+ (Optional) Builtin input method -+ (Optional) Background setting support +Optional features: ++ RandR (multi-monitor) support ++ System tray ++ Input method ++ Background setting support ++ XSETTINGS server Please check out the [screenshots](https://github.com/emacs-exwm/exwm/wiki/Screenshots) diff --git a/exwm.el b/exwm.el index a80232dc17..bf074b6f9f 100644 --- a/exwm.el +++ b/exwm.el @@ -35,10 +35,12 @@ ;; + Hybrid layout modes (tiling & stacking) ;; + Dynamic workspace support ;; + ICCCM/EWMH compliance -;; + (Optional) RandR (multi-monitor) support -;; + (Optional) Built-in system tray -;; + (Optional) Builtin input method -;; + (Optional) Background setting support +;; Optional features: +;; + RandR (multi-monitor) support +;; + System tray +;; + Input method +;; + Background setting support +;; + XSETTINGS server ;; Installation & configuration ;; ---------------------------- -- cgit 1.4.1 From f3c03ebbc3bb57906209e3c396ac50177e8c577c Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 13 Jan 2024 20:43:00 +0100 Subject: ; README: Fix feature list formatting --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8ab93561e2..84a14896bd 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,13 @@ EXWM (Emacs X Window Manager) is a full-featured tiling X window manager for Emacs built on top of [XELB](https://github.com/emacs-exwm/xelb). + It features: + Fully keyboard-driven operations + Hybrid layout modes (tiling & stacking) + Dynamic workspace support + ICCCM/EWMH compliance + Optional features: + RandR (multi-monitor) support + System tray -- cgit 1.4.1 From c033fc00f34f5b638cf8971a0661de61391786ef Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sun, 14 Jan 2024 00:57:37 +0100 Subject: New customization group exwm-debug The group was already used, but the docstring was missing. * exwm-core.el (exwm-debug): New customization group. --- exwm-core.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exwm-core.el b/exwm-core.el index 6683c77120..d159592fc5 100644 --- a/exwm-core.el +++ b/exwm-core.el @@ -33,6 +33,10 @@ (require 'xcb-ewmh) (require 'xcb-debug) +(defgroup exwm-debug nil + "Debugging." + :group 'exwm) + (defcustom exwm-debug-log-time-function #'exwm-debug-log-uptime "Function used for generating timestamps in `exwm-debug' logs. @@ -40,7 +44,6 @@ 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." - :group 'exwm-debug :type `(choice (const :tag "Emacs uptime" ,#'exwm-debug-log-uptime) (const :tag "Time of day" ,#'exwm-debug-log-time) (const :tag "Off" nil) -- cgit 1.4.1 From 5acb8bea8a4c1e01e05c29eedbd85360a0e27309 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sun, 14 Jan 2024 01:05:36 +0100 Subject: New customization group exwm-xsettings * exwm-xsettings.el (exwm-xsettings): New customization group. --- exwm-xsettings.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/exwm-xsettings.el b/exwm-xsettings.el index 4eac557b9a..42b781ad84 100644 --- a/exwm-xsettings.el +++ b/exwm-xsettings.el @@ -40,7 +40,7 @@ ;; (exwm-xsettings-enable) ;; ;; To modify these settings at runtime, customize them with -;; `custom-set-variables' or `setopt' (Emacs 29+). E.g., the following will +;; `custom-set-variables' or `setopt' (Emacs 29+). E.g., the following will ;; immediately change the icon theme to "Papirus" at runtime, even in running ;; applications: ;; @@ -69,11 +69,14 @@ SYMBOL is the setting being updated and VALUE is the new value." (set-default-toplevel-value symbol value) (exwm-xsettings--update-settings)) +(defgroup exwm-xsettings nil + "XSETTINGS." + :group 'exwm) + (defcustom exwm-xsettings nil - "Custom XSETTINGS. + "Alist of custom XSETTINGS. These settings take precedence over `exwm-xsettings-theme' and `exwm-xsettings-icon-theme'." - :group 'exwm :type '(alist :key-type (string :tag "Name") :value-type (choice :tag "Value" (string :tag "String") @@ -101,7 +104,6 @@ These settings take precedence over `exwm-xsettings-theme' and (defcustom exwm-xsettings-theme nil "The system-wide theme." - :group 'exwm :type '(choice (string :tag "Theme") (cons (string :tag "Light Theme") (string :tag "Dark Theme"))) @@ -110,7 +112,6 @@ These settings take precedence over `exwm-xsettings-theme' and (defcustom exwm-xsettings-icon-theme nil "The system-wide icon theme." - :group 'exwm :type '(choice (string :tag "Icon Theme") (cons (string :tag "Light Icon Theme") (string :tag "Dark Icon Theme"))) -- cgit 1.4.1 From eb28ebf165123c6731db90ef2558939003feb8c5 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sun, 14 Jan 2024 12:32:02 +0100 Subject: ; README: Refer to the user guide for installation instructions --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 84a14896bd..58585cdce9 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,4 @@ Please check out the [screenshots](https://github.com/emacs-exwm/exwm/wiki/Screenshots) to get an overview of what EXWM is capable of, and the [user guide](https://github.com/emacs-exwm/exwm/wiki) -for a detailed explanation of its usage. - -**Note**: If you install EXWM from source, it's recommended to install -XELB also from source (otherwise install both from GNU ELPA). +for installation instructions and a detailed explanation of its usage. -- cgit 1.4.1 From 089e0c86830c28d754ec8a812f833b2ab248c6ce Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Mon, 15 Jan 2024 08:33:00 +0100 Subject: Move xsettings classes to xelb --- exwm-xsettings.el | 69 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 67 deletions(-) diff --git a/exwm-xsettings.el b/exwm-xsettings.el index 42b781ad84..99d6b9c4ac 100644 --- a/exwm-xsettings.el +++ b/exwm-xsettings.el @@ -49,14 +49,14 @@ ;;; Code: (require 'xcb-ewmh) -(require 'xcb-icccm) - +(require 'xcb-xsettings) (require 'exwm-core) (defvar exwm-xsettings--connection nil) (defvar exwm-xsettings--XSETTINGS_SETTINGS-atom nil) (defvar exwm-xsettings--XSETTINGS_S0-atom nil) (defvar exwm-xsettings--selection-owner-window nil) +(defvar exwm-xsettings--serial 0) (defun exwm-xsettings--rgba-match (_widget value) "Return t if VALUE is a valid RGBA color." @@ -118,70 +118,6 @@ These settings take precedence over `exwm-xsettings-theme' and :initialize #'custom-initialize-default :set #'exwm-xsettings--custom-set) -(defvar exwm-xsettings--serial 0) - -(defconst xcb:xsettings:-Type:Integer 0) -(defconst xcb:xsettings:-Type:String 1) -(defconst xcb:xsettings:-Type:Color 2) - -(defclass xcb:xsettings:-Settings - (xcb:-struct) - ((byte-order :initarg :byte-order :type xcb:CARD8) - (pad~0 :initform 3 :type xcb:-pad) - (serial :initarg :serial :type xcb:CARD32) - (settings-len :initarg :settings-len :type xcb:CARD32) - (settings~ :initform - '(name settings type xcb:xsettings:-SETTING size - (xcb:-fieldref 'settings-len)) - :type xcb:-list) - (settings :initarg :settings :type xcb:-ignore))) - -(defclass xcb:xsettings:-SETTING - (xcb:-struct) - ((type :initarg :type :type xcb:CARD8) - (pad~0 :initform 1 :type xcb:-pad) - (name-len :initarg :name-len :type xcb:CARD16) - (name~ :initform - '(name name type xcb:char size - (xcb:-fieldref 'name-len)) - :type xcb:-list) - (name :initarg :name :type xcb:-ignore) - (pad~1 :initform 4 :type xcb:-pad-align) - (last-change-serial :initarg :last-change-serial :type xcb:CARD32))) - -(defclass xcb:xsettings:-SETTING_INTEGER - (xcb:xsettings:-SETTING) - ((type :initform 'xcb:xsettings:-Type:Integer) - (value :initarg :value :type xcb:INT32))) - -(defclass xcb:xsettings:-SETTING_STRING - (xcb:xsettings:-SETTING) - ((type :initform 'xcb:xsettings:-Type:String) - (value-len :initarg :value-len :type xcb:CARD32) - (value~ :initform - '(name value type xcb:char size - (xcb:-fieldref 'value-len)) - :type xcb:-list) - (value :initarg :value :type xcb:-ignore) - (pad~2 :initform 4 :type xcb:-pad-align))) - -(defclass xcb:xsettings:-SETTING_COLOR - (xcb:xsettings:-SETTING) - ((type :initform 'xcb:xsettings:-Type:Color) - (red :initarg :red :type xcb:CARD16) - (green :initarg :green :type xcb:CARD16) - (blue :initarg :blue :type xcb:CARD16) - (alpha :initarg :alpha :initform #xffff :type xcb:CARD16))) - -(defclass xcb:xsettings:-ClientMessage - (xcb:icccm:--ClientMessage xcb:ClientMessage) - ((format :initform 32) - (type :initform 'xcb:Atom:MANAGER) - (time :initarg :time :type xcb:TIMESTAMP) ;new slot - (selection :initarg :selection :type xcb:ATOM) ;new slot - (owner :initarg :owner :type xcb:WINDOW)) ;new slot - :documentation "An XSETTINGS client message.") - (defalias 'exwm-xsettings--color-dark-p (if (eval-when-compile (< emacs-major-version 29)) ;; Borrowed from Emacs 29. @@ -317,7 +253,6 @@ SERIAL is a sequence number." (warn "[EXWM] Other XSETTINGS manager detected") (cl-return-from exwm-xsettings--init))) - (let ((id(xcb:generate-id exwm-xsettings--connection))) (setq exwm-xsettings--selection-owner-window id) -- cgit 1.4.1 From 0e365a00587b961b83de54206a5dc058adadfddf Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 23 Jan 2024 15:15:44 -0800 Subject: Use color-values instead of x-color-values * exwm-core.el (exwm--color->pixel): Use `color-values` (introduced in Emacs 21) instead of `x-color-values` (deprecated in Emacs 30). --- exwm-core.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exwm-core.el b/exwm-core.el index d159592fc5..e0d644d941 100644 --- a/exwm-core.el +++ b/exwm-core.el @@ -206,7 +206,7 @@ If FRAME is null, use selected frame." "Convert COLOR to PIXEL (index in TrueColor colormap)." (when (and color (eq (x-display-visual-class) 'true-color)) - (let ((rgb (x-color-values color))) + (let ((rgb (color-values color))) (logior (ash (ash (pop rgb) -8) 16) (ash (ash (pop rgb) -8) 8) (ash (pop rgb) -8))))) -- cgit 1.4.1 From 2bb9a5787ea5b15c8fe4e7c461eb99b412363a16 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 23 Jan 2024 14:41:12 -0800 Subject: Use '=' instead of 'eq' to compare numbers. * exwm.el (exwm--update-desktop): * exwm-layout.el (exwm-layout--hide): Use `=` instead of `eq` for numeric comparison. --- exwm-layout.el | 3 ++- exwm.el | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/exwm-layout.el b/exwm-layout.el index 47ccf5c519..8649c11ffd 100644 --- a/exwm-layout.el +++ b/exwm-layout.el @@ -156,7 +156,8 @@ See variable `exwm-layout-auto-iconify'." (with-current-buffer (exwm--id->buffer id) (unless (or (exwm-layout--iconic-state-p) (and exwm--floating-frame - (eq 4294967295. exwm--desktop))) + exwm--desktop + (= 4294967295. exwm--desktop))) (exwm--log "Hide #x%x" id) (when exwm--floating-frame (let* ((container (frame-parameter exwm--floating-frame diff --git a/exwm.el b/exwm.el index bf074b6f9f..c4900eab48 100644 --- a/exwm.el +++ b/exwm.el @@ -176,7 +176,7 @@ Argument XWIN contains the X window of the `exwm-mode' buffer." (when reply (setq desktop (slot-value reply 'value)) (cond - ((eq desktop 4294967295.) + ((and desktop (= desktop 4294967295.)) (unless (or (not exwm--floating-frame) (eq exwm--frame exwm-workspace--current) (and exwm--desktop -- cgit 1.4.1 From c2856d15e8b76e6faec5e2f44a9c80865a39f55a Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 4 Feb 2024 12:49:33 -0800 Subject: Remove redundant with-current-buffer in manage-window (#13) All this logic runs in the context of the EXWM buffer. If there are concerns about the X windows associating with a different buffer while we're still trying to manage it, we probably have bigger problems. * exwm-manage.el (exwm-manage--manage-window): assume that the current buffer doesn't change. --- exwm-manage.el | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/exwm-manage.el b/exwm-manage.el index fa73a8f380..c344c4cfb1 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -393,23 +393,19 @@ Override current hinds if FORCE is non-nil." (if (plist-get exwm--configurations 'char-mode) (exwm-input-release-keyboard id) (exwm-input-grab-keyboard id)) - (let ((simulation-keys (plist-get exwm--configurations 'simulation-keys)) - (prefix-keys (plist-get exwm--configurations 'prefix-keys))) - (with-current-buffer (exwm--id->buffer id) - (when simulation-keys - (exwm-input-set-local-simulation-keys simulation-keys)) - (when prefix-keys - (setq-local exwm-input-prefix-keys prefix-keys)))) + (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)) (setq exwm-workspace--switch-history-outdated t) (exwm--update-desktop id) (exwm-manage--update-ewmh-state id) - (with-current-buffer (exwm--id->buffer id) - (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))))) + (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)))) (defun exwm-manage--unmanage-window (id &optional withdraw-only) "Unmanage window ID. -- cgit 1.4.1 From fbc1e81ed65a2a7caeb6e73aab88fe8769e0f952 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 4 Feb 2024 12:57:58 -0800 Subject: Set the EXWM buffer's default directory to match the process's CWD (#14) * exwm-manage.el (exwm-manage--update-default-directory): define a function to update the default-directory of an X window based on it's CID. (exwm-manage--manage-window): call `exwm-manage--update-update-default-directory` on manage (fixes #12). --- exwm-manage.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/exwm-manage.el b/exwm-manage.el index c344c4cfb1..d1eeaa7c87 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -234,6 +234,23 @@ Override current hinds if FORCE is non-nil." (elt value 2))) ;MotifWmHints.decorations (setq exwm--mwm-hints-decorations nil)))))))) +(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))) + (setq default-directory cwd) + (setq default-directory (expand-file-name "~/"))))) + + (defun exwm-manage--set-client-list () "Set _NET_CLIENT_LIST." (exwm--log) @@ -400,6 +417,7 @@ Override current hinds if FORCE is non-nil." (setq exwm-workspace--switch-history-outdated t) (exwm--update-desktop id) (exwm-manage--update-ewmh-state id) + (exwm-manage--update-default-directory id) (when (or (plist-get exwm--configurations 'fullscreen) (exwm-layout--fullscreen-p)) (setq exwm--ewmh-state (delq xcb:Atom:_NET_WM_STATE_FULLSCREEN -- cgit 1.4.1 From 44e74bcc07f6ab2f985bcce12d68dccb943475cf Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sun, 4 Feb 2024 22:39:06 +0100 Subject: Ensure that default-directory is a directory name in EXWM buffers. Otherwise `default-directory' could be /home/user instead of /home/user/ as is expected by Emacs. * exwm-manage.el (exwm-manage--update-default-directory): Use `file-name-as-directory'. --- exwm-manage.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exwm-manage.el b/exwm-manage.el index d1eeaa7c87..ab66e298ac 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -247,7 +247,7 @@ This only works when procfs is mounted, which may not be the case on some BSDs." (pid (slot-value response 'value)) (cwd (file-symlink-p (format "/proc/%d/cwd" pid))) ((file-accessible-directory-p cwd))) - (setq default-directory cwd) + (setq default-directory (file-name-as-directory cwd)) (setq default-directory (expand-file-name "~/"))))) -- cgit 1.4.1 From a6e66f5e339473105d83dd4e7e3f3db9b1aa9f0f Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 5 Feb 2024 07:32:51 -0800 Subject: Simplify and improve focus handling (#10) Combine both focus update timers into one and ignore windows in "no focus" frames. * exwm-input.el (exwm-input--on-buffer-list-update): Avoid focusing windows in frames with the `no-accept-focus` frame property. (exwm-input--update-focus-defer-timer): Remove the duplicate timer. (exwm-input--update-focus-defer): Use a single `exwm-input--update-focus-timer`. (exwm-input--update-focus-commit): Read `exwm-input--update-focus-window` instead of taking a window as a parameter (this is what lets us combine the timers). (exwm-input--update-focus-commit): Use a let-bind instead of unwind-protect. (exwm-input--exit): Remove references to `exwm-input--update-focus-defer-timer`. --- exwm-input.el | 52 +++++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/exwm-input.el b/exwm-input.el index 835705ff9d..f1f035c91a 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -135,14 +135,12 @@ defined in `exwm-mode-map' here." (defvar exwm-input--timestamp-window nil) -(defvar exwm-input--update-focus-defer-timer nil "Timer for polling the lock.") +(defvar exwm-input--update-focus-timer nil + "Timer for deferring the update of input focus.") (defvar exwm-input--update-focus-lock nil "Lock for solving input focus update contention.") -(defvar exwm-input--update-focus-timer nil - "Timer for deferring the update of input focus.") - (defvar exwm-input--update-focus-window nil "The (Emacs) window to be focused. This value should always be overwritten.") @@ -302,7 +300,8 @@ ARGS are additional arguments to CALLBACK." "Run in `buffer-list-update-hook' to track input focus." (when (and ; this hook is called incesantly; place cheap tests on top (not exwm-input--skip-buffer-list-update) - (exwm--terminal-p)) ; skip other terminals, e.g. TTY client frames + (exwm--terminal-p) ; skip other terminals, e.g. TTY client frames + (not (frame-parameter nil 'no-accept-focus))) (exwm--log "current-buffer=%S selected-window=%S" (current-buffer) (selected-window)) (redirect-frame-focus (selected-frame) nil) @@ -310,31 +309,28 @@ ARGS are additional arguments to CALLBACK." (exwm-input--update-focus-defer))) (defun exwm-input--update-focus-defer () - "Defer updating input focus." - (when exwm-input--update-focus-defer-timer - (cancel-timer exwm-input--update-focus-defer-timer)) + "Schedule a deferred update to input focus. +Instead of immediately focusing the current window, it defers the focus change +until the selected window stops changing (debouncing input focus updates)." + (when exwm-input--update-focus-timer + (cancel-timer exwm-input--update-focus-timer)) + (setq exwm-input--update-focus-timer + ;; Attempt to accumulate successive events close enough. + (run-with-timer exwm-input--update-focus-interval + nil + #'exwm-input--update-focus-commit))) + +(defun exwm-input--update-focus-commit () + "Attempt to update the window focus. +If we're currently updating the window focus, re-schedule a focus update +attempt later." (if exwm-input--update-focus-lock - (setq exwm-input--update-focus-defer-timer - (exwm--defer 0 #'exwm-input--update-focus-defer)) - (setq exwm-input--update-focus-defer-timer nil) - (when exwm-input--update-focus-timer - (cancel-timer exwm-input--update-focus-timer)) - (setq exwm-input--update-focus-timer - ;; Attempt to accumulate successive events close enough. - (run-with-timer exwm-input--update-focus-interval - nil - #'exwm-input--update-focus-commit - exwm-input--update-focus-window)))) - -(defun exwm-input--update-focus-commit (window) - "Commit updating input focus." - (setq exwm-input--update-focus-lock t) - (unwind-protect - (exwm-input--update-focus window) - (setq exwm-input--update-focus-lock nil))) + (exwm-input--update-focus-defer) + (let ((exwm-input--update-focus-lock t)) + (exwm-input--update-focus exwm-input--update-focus-window)))) (defun exwm-input--update-focus (window) - "Update input focus." + "Update input focus to WINDOW." (when (window-live-p window) (exwm--log "focus-window=%s focus-buffer=%s" window (window-buffer window)) (with-current-buffer (window-buffer window) @@ -1234,8 +1230,6 @@ One use is to access the keymap bound to KEYS (as prefix keys) in `char-mode'." (setq exwm-input--echo-area-timer nil)) (remove-hook 'echo-area-clear-hook #'exwm-input--on-echo-area-clear) (remove-hook 'buffer-list-update-hook #'exwm-input--on-buffer-list-update) - (when exwm-input--update-focus-defer-timer - (cancel-timer exwm-input--update-focus-defer-timer)) (when exwm-input--update-focus-timer (cancel-timer exwm-input--update-focus-timer)) ;; Make input focus working even without a WM. -- cgit 1.4.1