2015-07-17 13:16:08 +02:00
|
|
|
|
;;; exwm-workspace.el --- Workspace Module for EXWM -*- lexical-binding: t -*-
|
|
|
|
|
|
2017-12-31 13:49:37 +01:00
|
|
|
|
;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
|
|
|
|
;; Author: Chris Feng <chris.w.feng@gmail.com>
|
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; This file is part of GNU Emacs.
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; This module adds workspace support for EXWM.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2016-08-01 13:49:43 +02:00
|
|
|
|
(require 'server)
|
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(require 'exwm-core)
|
|
|
|
|
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(defgroup exwm-workspace nil
|
|
|
|
|
"Workspace."
|
|
|
|
|
:version "25.3"
|
|
|
|
|
:group 'exwm)
|
2016-08-12 13:22:18 +02:00
|
|
|
|
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(defcustom exwm-workspace-switch-hook nil
|
|
|
|
|
"Normal hook run after switching workspace."
|
|
|
|
|
:type 'hook)
|
|
|
|
|
|
|
|
|
|
(defcustom exwm-workspace-list-change-hook nil
|
|
|
|
|
"Normal hook run when the workspace list is changed (workspace added,
|
|
|
|
|
deleted, moved, etc)."
|
|
|
|
|
:type 'hook)
|
|
|
|
|
|
|
|
|
|
(defcustom exwm-workspace-show-all-buffers nil
|
|
|
|
|
"Non-nil to show buffers on other workspaces."
|
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
|
|
|
|
(defcustom exwm-workspace-number 1
|
|
|
|
|
"Initial number of workspaces."
|
|
|
|
|
:type 'integer)
|
|
|
|
|
|
|
|
|
|
(defcustom exwm-workspace-index-map #'number-to-string
|
2017-07-16 11:08:24 +02:00
|
|
|
|
"Function for mapping a workspace index to a string for display.
|
|
|
|
|
|
2018-02-18 17:04:27 +01:00
|
|
|
|
By default `number-to-string' is applied which yields 0 1 2 ... ."
|
|
|
|
|
:type 'function)
|
|
|
|
|
|
|
|
|
|
(defcustom exwm-workspace-minibuffer-position nil
|
|
|
|
|
"Position of the minibuffer frame."
|
|
|
|
|
:type '(choice (const :tag "Bottom (fixed)" nil)
|
|
|
|
|
(const :tag "Bottom (auto-hide)" bottom)
|
|
|
|
|
(const :tag "Top (auto-hide)" top)))
|
|
|
|
|
|
|
|
|
|
(defcustom exwm-workspace-display-echo-area-timeout 1
|
|
|
|
|
"Timeout for displaying echo area."
|
|
|
|
|
:type 'integer)
|
|
|
|
|
|
|
|
|
|
(defcustom exwm-workspace-switch-create-limit 10
|
|
|
|
|
"Number of workspaces `exwm-workspace-switch-create' allowed to create
|
|
|
|
|
each time."
|
|
|
|
|
:type 'integer)
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace-current-index 0 "Index of current active workspace.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--attached-minibuffer-height 0
|
|
|
|
|
"Height (in pixel) of the attached minibuffer.
|
|
|
|
|
|
|
|
|
|
If the minibuffer is detached, this value is 0.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--client nil
|
|
|
|
|
"The 'client' frame parameter of emacsclient frames.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--create-silently nil
|
|
|
|
|
"When non-nil workspaces are created in the background (not switched to).
|
|
|
|
|
|
|
|
|
|
Please manually run the hook `exwm-workspace-list-change-hook' afterwards.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--current nil "Current active workspace.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--display-echo-area-timer nil
|
|
|
|
|
"Timer for auto-hiding echo area.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--id-struts-alist nil "Alist of X window and struts.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--fullscreen-frame-count 0
|
|
|
|
|
"Count the fullscreen workspace frames.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--list nil "List of all workspaces (Emacs frames).")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--minibuffer nil
|
|
|
|
|
"The minibuffer frame shared among all frames.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--prompt-add-allowed nil
|
|
|
|
|
"Non-nil to allow adding workspace from the prompt.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--prompt-delete-allowed nil
|
|
|
|
|
"Non-nil to allow deleting workspace from the prompt.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--struts nil "Areas occupied by struts.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--switch-history nil
|
|
|
|
|
"History for `read-from-minibuffer' to interactively switch workspace.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--switch-history-outdated nil
|
|
|
|
|
"Non-nil to indicate `exwm-workspace--switch-history' is outdated.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--timer nil "Timer used to track echo area changes.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--update-workareas-hook nil
|
|
|
|
|
"Normal hook run when workareas get updated.")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-workspace--workareas nil "Workareas (struts excluded).")
|
|
|
|
|
|
|
|
|
|
(defvar exwm-input--during-command)
|
|
|
|
|
(defvar exwm-layout-show-all-buffers)
|
|
|
|
|
(defvar exwm-manage--desktop)
|
|
|
|
|
(declare-function exwm--exit "exwm.el")
|
|
|
|
|
(declare-function exwm-input--on-buffer-list-update "exwm-input.el" ())
|
|
|
|
|
(declare-function exwm-layout--hide "exwm-layout.el" (id))
|
|
|
|
|
(declare-function exwm-layout--other-buffer-predicate "exwm-layout.el"
|
|
|
|
|
(buffer))
|
|
|
|
|
(declare-function exwm-layout--refresh "exwm-layout.el")
|
|
|
|
|
(declare-function exwm-layout--show "exwm-layout.el" (id &optional window))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
|
|
|
|
|
(defsubst exwm-workspace--position (frame)
|
|
|
|
|
"Retrieve index of given FRAME in workspace list.
|
|
|
|
|
|
|
|
|
|
NIL if FRAME is not a workspace"
|
|
|
|
|
(cl-position frame exwm-workspace--list))
|
|
|
|
|
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(defsubst exwm-workspace--count ()
|
|
|
|
|
"Retrieve total number of workspaces."
|
|
|
|
|
(length exwm-workspace--list))
|
|
|
|
|
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(defsubst exwm-workspace--workspace-p (frame)
|
|
|
|
|
"Return t if FRAME is a workspace."
|
|
|
|
|
(memq frame exwm-workspace--list))
|
|
|
|
|
|
2016-08-01 13:53:04 +02:00
|
|
|
|
(defsubst exwm-workspace--client-p (&optional frame)
|
|
|
|
|
"Return non-nil if FRAME is an emacsclient frame."
|
|
|
|
|
(frame-parameter frame 'client))
|
|
|
|
|
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(defvar exwm-workspace--switch-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map [t] (lambda () (interactive)))
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(define-key map "+" #'exwm-workspace--prompt-add)
|
|
|
|
|
(define-key map "-" #'exwm-workspace--prompt-delete)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(dotimes (i 10)
|
|
|
|
|
(define-key map (int-to-string i)
|
2016-07-19 04:24:23 +02:00
|
|
|
|
#'exwm-workspace--switch-map-nth-prefix))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(define-key map "\C-a" (lambda () (interactive) (goto-history-element 1)))
|
|
|
|
|
(define-key map "\C-e" (lambda ()
|
|
|
|
|
(interactive)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(goto-history-element (exwm-workspace--count))))
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(define-key map "\C-g" #'abort-recursive-edit)
|
|
|
|
|
(define-key map "\C-]" #'abort-recursive-edit)
|
|
|
|
|
(define-key map "\C-j" #'exit-minibuffer)
|
|
|
|
|
;; (define-key map "\C-m" #'exit-minibuffer) ;not working
|
|
|
|
|
(define-key map [return] #'exit-minibuffer)
|
|
|
|
|
(define-key map " " #'exit-minibuffer)
|
|
|
|
|
(define-key map "\C-f" #'previous-history-element)
|
|
|
|
|
(define-key map "\C-b" #'next-history-element)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;; Alternative keys
|
2015-09-04 03:09:59 +02:00
|
|
|
|
(define-key map [right] #'previous-history-element)
|
|
|
|
|
(define-key map [left] #'next-history-element)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
map)
|
|
|
|
|
"Keymap used for interactively switch workspace.")
|
|
|
|
|
|
2018-02-18 17:04:27 +01:00
|
|
|
|
(defun exwm-workspace--workspace-from-frame-or-index (frame-or-index)
|
|
|
|
|
"Retrieve the workspace frame from FRAME-OR-INDEX."
|
|
|
|
|
(cond
|
|
|
|
|
((framep frame-or-index)
|
|
|
|
|
(unless (exwm-workspace--position frame-or-index)
|
|
|
|
|
(user-error "[EXWM] Frame is not a workspace %S" frame-or-index))
|
|
|
|
|
frame-or-index)
|
|
|
|
|
((integerp frame-or-index)
|
|
|
|
|
(unless (and (<= 0 frame-or-index)
|
|
|
|
|
(< frame-or-index (exwm-workspace--count)))
|
|
|
|
|
(user-error "[EXWM] Workspace index out of range: %d" frame-or-index))
|
|
|
|
|
(elt exwm-workspace--list frame-or-index))
|
|
|
|
|
(t (user-error "[EXWM] Invalid workspace: %s" frame-or-index))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2016-07-19 04:30:21 +02:00
|
|
|
|
(defun exwm-workspace--prompt-for-workspace (&optional prompt)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
"Prompt for a workspace, returning the workspace frame."
|
|
|
|
|
(exwm-workspace--update-switch-history)
|
|
|
|
|
(let* ((current-idx (exwm-workspace--position exwm-workspace--current))
|
|
|
|
|
(history-add-new-input nil) ;prevent modifying history
|
|
|
|
|
(history-idx (read-from-minibuffer
|
2016-07-19 04:30:21 +02:00
|
|
|
|
(or prompt "Workspace: ")
|
|
|
|
|
(elt exwm-workspace--switch-history current-idx)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
exwm-workspace--switch-map nil
|
|
|
|
|
`(exwm-workspace--switch-history . ,(1+ current-idx))))
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(workspace-idx (cl-position history-idx exwm-workspace--switch-history
|
|
|
|
|
:test #'equal)))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(elt exwm-workspace--list workspace-idx)))
|
|
|
|
|
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(defun exwm-workspace--prompt-add ()
|
|
|
|
|
"Add workspace from the prompt."
|
|
|
|
|
(interactive)
|
|
|
|
|
(when exwm-workspace--prompt-add-allowed
|
|
|
|
|
(let ((exwm-workspace--create-silently t))
|
2016-07-21 07:02:07 +02:00
|
|
|
|
(make-frame)
|
|
|
|
|
(run-hooks 'exwm-workspace-list-change-hook))
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(exwm-workspace--update-switch-history)
|
|
|
|
|
(goto-history-element minibuffer-history-position)))
|
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--prompt-delete ()
|
|
|
|
|
"Delete workspace from the prompt."
|
|
|
|
|
(interactive)
|
|
|
|
|
(when (and exwm-workspace--prompt-delete-allowed
|
|
|
|
|
(< 1 (exwm-workspace--count)))
|
|
|
|
|
(let ((frame (elt exwm-workspace--list (1- minibuffer-history-position))))
|
|
|
|
|
(if (eq frame exwm-workspace--current)
|
|
|
|
|
;; Abort the recursive minibuffer if deleting the current workspace.
|
|
|
|
|
(progn
|
2017-11-19 07:51:45 +01:00
|
|
|
|
(exwm--defer 0 #'delete-frame frame)
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(abort-recursive-edit))
|
|
|
|
|
(delete-frame frame)
|
|
|
|
|
(exwm-workspace--update-switch-history)
|
|
|
|
|
(goto-history-element (min minibuffer-history-position
|
|
|
|
|
(exwm-workspace--count)))))))
|
|
|
|
|
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(defun exwm-workspace--update-switch-history ()
|
|
|
|
|
"Update the history for switching workspace to reflect the latest status."
|
2015-09-17 13:48:50 +02:00
|
|
|
|
(when exwm-workspace--switch-history-outdated
|
|
|
|
|
(setq exwm-workspace--switch-history-outdated nil)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(let* ((num (exwm-workspace--count))
|
|
|
|
|
(sequence (number-sequence 0 (1- num)))
|
|
|
|
|
(not-empty (make-vector num nil)))
|
2015-09-17 13:48:50 +02:00
|
|
|
|
(dolist (i exwm--id-buffer-alist)
|
|
|
|
|
(with-current-buffer (cdr i)
|
|
|
|
|
(when exwm--frame
|
|
|
|
|
(setf (aref not-empty
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(exwm-workspace--position exwm--frame))
|
2015-09-17 13:48:50 +02:00
|
|
|
|
t))))
|
|
|
|
|
(setq exwm-workspace--switch-history
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (i)
|
|
|
|
|
(mapconcat
|
|
|
|
|
(lambda (j)
|
|
|
|
|
(format (if (= i j) "[%s]" " %s ")
|
|
|
|
|
(propertize
|
2017-07-16 11:08:24 +02:00
|
|
|
|
(apply exwm-workspace-index-map (list j))
|
2015-09-17 13:48:50 +02:00
|
|
|
|
'face
|
|
|
|
|
(cond ((frame-parameter (elt exwm-workspace--list j)
|
2016-07-21 06:41:51 +02:00
|
|
|
|
'exwm-urgency)
|
2015-09-17 13:48:50 +02:00
|
|
|
|
'(:foreground "orange"))
|
|
|
|
|
((aref not-empty j) '(:foreground "green"))
|
|
|
|
|
(t nil)))))
|
|
|
|
|
sequence ""))
|
|
|
|
|
sequence)))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2016-07-16 08:34:57 +02:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun exwm-workspace--get-geometry (frame)
|
|
|
|
|
"Return the geometry of frame FRAME."
|
|
|
|
|
(or (frame-parameter frame 'exwm-geometry)
|
|
|
|
|
(make-instance 'xcb:RECTANGLE
|
|
|
|
|
:x 0
|
|
|
|
|
:y 0
|
|
|
|
|
:width (x-display-pixel-width)
|
|
|
|
|
:height (x-display-pixel-height))))
|
|
|
|
|
|
2016-02-19 10:12:43 +01:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun exwm-workspace--current-height ()
|
|
|
|
|
"Return the height of current workspace."
|
|
|
|
|
(let ((geometry (frame-parameter exwm-workspace--current 'exwm-geometry)))
|
|
|
|
|
(if geometry
|
|
|
|
|
(slot-value geometry 'height)
|
|
|
|
|
(x-display-pixel-height))))
|
|
|
|
|
|
2016-02-07 04:40:14 +01:00
|
|
|
|
;;;###autoload
|
2016-02-06 22:43:32 +01:00
|
|
|
|
(defun exwm-workspace--minibuffer-own-frame-p ()
|
|
|
|
|
"Reports whether the minibuffer is displayed in its own frame."
|
|
|
|
|
(memq exwm-workspace-minibuffer-position '(top bottom)))
|
|
|
|
|
|
2016-07-15 14:04:56 +02:00
|
|
|
|
(defun exwm-workspace--update-struts ()
|
|
|
|
|
"Update `exwm-workspace--struts'."
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(setq exwm-workspace--struts nil)
|
|
|
|
|
(let (struts struts*)
|
2016-07-15 14:04:56 +02:00
|
|
|
|
(dolist (pair exwm-workspace--id-struts-alist)
|
|
|
|
|
(setq struts (cdr pair))
|
2016-08-12 14:28:05 +02:00
|
|
|
|
(when struts
|
|
|
|
|
(dotimes (i 4)
|
|
|
|
|
(when (/= 0 (aref struts i))
|
|
|
|
|
(setq struts*
|
|
|
|
|
(vector (aref [left right top bottom] i)
|
|
|
|
|
(aref struts i)
|
|
|
|
|
(when (= 12 (length struts))
|
|
|
|
|
(substring struts (+ 4 (* i 2)) (+ 6 (* i 2))))))
|
|
|
|
|
(if (= 0 (mod i 2))
|
|
|
|
|
;; Make left/top processed first.
|
|
|
|
|
(push struts* exwm-workspace--struts)
|
|
|
|
|
(setq exwm-workspace--struts
|
|
|
|
|
(append exwm-workspace--struts (list struts*))))))))))
|
2016-07-16 08:34:57 +02:00
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--update-workareas ()
|
2016-08-15 12:42:35 +02:00
|
|
|
|
"Update `exwm-workspace--workareas'."
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(let ((root-width (x-display-pixel-width))
|
|
|
|
|
(root-height (x-display-pixel-height))
|
|
|
|
|
workareas
|
|
|
|
|
edge width position
|
|
|
|
|
delta)
|
|
|
|
|
;; Calculate workareas with no struts.
|
|
|
|
|
(if (frame-parameter (car exwm-workspace--list) 'exwm-geometry)
|
|
|
|
|
;; Use the 'exwm-geometry' frame parameter if possible.
|
|
|
|
|
(dolist (f exwm-workspace--list)
|
|
|
|
|
(with-slots (x y width height) (frame-parameter f 'exwm-geometry)
|
|
|
|
|
(setq workareas (append workareas
|
|
|
|
|
(list (vector x y width height))))))
|
|
|
|
|
;; Fall back to use the screen size.
|
|
|
|
|
(let ((workarea (vector 0 0 root-width root-height)))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(setq workareas (make-list (exwm-workspace--count) workarea))))
|
2016-07-16 08:34:57 +02:00
|
|
|
|
;; Exclude areas occupied by struts.
|
|
|
|
|
(dolist (struts exwm-workspace--struts)
|
|
|
|
|
(setq edge (aref struts 0)
|
|
|
|
|
width (aref struts 1)
|
|
|
|
|
position (aref struts 2))
|
|
|
|
|
(dolist (w workareas)
|
|
|
|
|
(pcase edge
|
|
|
|
|
;; Left and top are always processed first.
|
|
|
|
|
(`left
|
|
|
|
|
(setq delta (- (aref w 0) width))
|
|
|
|
|
(when (and (< delta 0)
|
2016-07-18 06:55:27 +02:00
|
|
|
|
(or (not position)
|
|
|
|
|
(< (max (aref position 0) (aref w 1))
|
|
|
|
|
(min (aref position 1)
|
|
|
|
|
(+ (aref w 1) (aref w 3))))))
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(cl-incf (aref w 2) delta)
|
|
|
|
|
(setf (aref w 0) width)))
|
|
|
|
|
(`right
|
|
|
|
|
(setq delta (- root-width (aref w 0) (aref w 2) width))
|
|
|
|
|
(when (and (< delta 0)
|
2016-07-18 06:55:27 +02:00
|
|
|
|
(or (not position)
|
|
|
|
|
(< (max (aref position 0) (aref w 1))
|
|
|
|
|
(min (aref position 1)
|
|
|
|
|
(+ (aref w 1) (aref w 3))))))
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(cl-incf (aref w 2) delta)))
|
|
|
|
|
(`top
|
|
|
|
|
(setq delta (- (aref w 1) width))
|
|
|
|
|
(when (and (< delta 0)
|
2016-07-18 06:55:27 +02:00
|
|
|
|
(or (not position)
|
|
|
|
|
(< (max (aref position 0) (aref w 0))
|
|
|
|
|
(min (aref position 1)
|
|
|
|
|
(+ (aref w 0) (aref w 2))))))
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(cl-incf (aref w 3) delta)
|
|
|
|
|
(setf (aref w 1) width)))
|
|
|
|
|
(`bottom
|
|
|
|
|
(setq delta (- root-height (aref w 1) (aref w 3) width))
|
|
|
|
|
(when (and (< delta 0)
|
2016-07-18 06:55:27 +02:00
|
|
|
|
(or (not position)
|
|
|
|
|
(< (max (aref position 0) (aref w 0))
|
|
|
|
|
(min (aref position 1)
|
|
|
|
|
(+ (aref w 0) (aref w 2))))))
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(cl-incf (aref w 3) delta))))))
|
|
|
|
|
;; Save the result.
|
|
|
|
|
(setq exwm-workspace--workareas workareas)
|
2017-02-24 16:05:43 +01:00
|
|
|
|
(xcb:flush exwm--connection))
|
|
|
|
|
(run-hooks 'exwm-workspace--update-workareas-hook))
|
2016-07-12 12:35:51 +02:00
|
|
|
|
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(defun exwm-workspace--set-active (frame active)
|
|
|
|
|
"Make frame FRAME active on its output."
|
|
|
|
|
(set-frame-parameter frame 'exwm-active active)
|
|
|
|
|
(if active
|
|
|
|
|
(exwm-workspace--set-fullscreen frame)
|
|
|
|
|
(exwm--set-geometry (frame-parameter frame 'exwm-container) nil nil 1 1)
|
|
|
|
|
(xcb:flush exwm--connection)))
|
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--active-p (frame)
|
|
|
|
|
"Return non-nil if FRAME is active"
|
|
|
|
|
(frame-parameter frame 'exwm-active))
|
|
|
|
|
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(defun exwm-workspace--set-fullscreen (frame)
|
|
|
|
|
"Make frame FRAME fullscreen according to `exwm-workspace--workareas'."
|
|
|
|
|
(let ((workarea (elt exwm-workspace--workareas
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(exwm-workspace--position frame)))
|
2016-07-12 12:35:51 +02:00
|
|
|
|
(id (frame-parameter frame 'exwm-outer-id))
|
|
|
|
|
(container (frame-parameter frame 'exwm-container))
|
2016-07-16 08:34:57 +02:00
|
|
|
|
x y width height)
|
|
|
|
|
(setq x (aref workarea 0)
|
|
|
|
|
y (aref workarea 1)
|
|
|
|
|
width (aref workarea 2)
|
|
|
|
|
height (aref workarea 3))
|
|
|
|
|
(when (and (eq frame exwm-workspace--current)
|
|
|
|
|
(exwm-workspace--minibuffer-own-frame-p))
|
|
|
|
|
(exwm-workspace--resize-minibuffer-frame))
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(if (exwm-workspace--active-p frame)
|
|
|
|
|
(exwm--set-geometry container x y width height)
|
|
|
|
|
(exwm--set-geometry container x y 1 1))
|
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
|
|
|
|
(exwm--set-geometry id nil nil width height)
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(xcb:flush exwm--connection))
|
|
|
|
|
;; This is only used for workspace initialization.
|
|
|
|
|
(when exwm-workspace--fullscreen-frame-count
|
2016-07-15 14:04:56 +02:00
|
|
|
|
(cl-incf exwm-workspace--fullscreen-frame-count)))
|
2016-07-12 12:35:51 +02:00
|
|
|
|
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(defun exwm-workspace--resize-minibuffer-frame ()
|
|
|
|
|
"Resize minibuffer (and its container) to fit the size of workspace."
|
2016-02-06 22:43:32 +01:00
|
|
|
|
(cl-assert (exwm-workspace--minibuffer-own-frame-p))
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(let ((workarea (elt exwm-workspace--workareas exwm-workspace-current-index))
|
2016-02-06 13:33:56 +01:00
|
|
|
|
(container (frame-parameter exwm-workspace--minibuffer
|
2016-07-16 08:34:57 +02:00
|
|
|
|
'exwm-container))
|
|
|
|
|
y width)
|
|
|
|
|
(setq y (if (eq exwm-workspace-minibuffer-position 'top)
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(- (aref workarea 1)
|
|
|
|
|
exwm-workspace--attached-minibuffer-height)
|
|
|
|
|
;; Reset the frame size.
|
|
|
|
|
(set-frame-height exwm-workspace--minibuffer 1)
|
|
|
|
|
(redisplay) ;FIXME.
|
|
|
|
|
(+ (aref workarea 1) (aref workarea 3)
|
|
|
|
|
(- (frame-pixel-height exwm-workspace--minibuffer))
|
|
|
|
|
exwm-workspace--attached-minibuffer-height))
|
2016-07-16 08:34:57 +02:00
|
|
|
|
width (aref workarea 2))
|
2016-02-06 13:33:56 +01:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
|
|
|
|
:window container
|
2016-07-19 13:23:37 +02:00
|
|
|
|
:value-mask (logior xcb:ConfigWindow:X
|
|
|
|
|
xcb:ConfigWindow:Y
|
2016-02-06 13:33:56 +01:00
|
|
|
|
xcb:ConfigWindow:Width
|
2016-08-12 13:22:18 +02:00
|
|
|
|
(if exwm-manage--desktop
|
|
|
|
|
xcb:ConfigWindow:Sibling
|
|
|
|
|
0)
|
2016-02-06 13:33:56 +01:00
|
|
|
|
xcb:ConfigWindow:StackMode)
|
2016-07-19 13:23:37 +02:00
|
|
|
|
:x (aref workarea 0)
|
2016-02-06 13:33:56 +01:00
|
|
|
|
:y y
|
|
|
|
|
:width width
|
2016-08-12 13:22:18 +02:00
|
|
|
|
:sibling exwm-manage--desktop
|
|
|
|
|
:stack-mode (if exwm-manage--desktop
|
|
|
|
|
xcb:StackMode:Above
|
|
|
|
|
xcb:StackMode:Below)))
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
|
|
|
|
:window (frame-parameter exwm-workspace--minibuffer
|
|
|
|
|
'exwm-outer-id)
|
|
|
|
|
:value-mask xcb:ConfigWindow:Width
|
|
|
|
|
:width width))))
|
2016-02-06 13:33:56 +01:00
|
|
|
|
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(defun exwm-workspace--switch-map-nth-prefix (&optional prefix-digits)
|
|
|
|
|
"Allow selecting a workspace by number.
|
|
|
|
|
|
|
|
|
|
PREFIX-DIGITS is a list of the digits introduced so far."
|
|
|
|
|
(interactive)
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(let* ((k (aref (substring (this-command-keys-vector) -1) 0))
|
|
|
|
|
(d (- k ?0))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;; Convert prefix-digits to number. For example, '(2 1) to 120.
|
|
|
|
|
(o 1)
|
|
|
|
|
(pn (apply #'+ (mapcar (lambda (x)
|
|
|
|
|
(setq o (* 10 o))
|
|
|
|
|
(* o x))
|
|
|
|
|
prefix-digits)))
|
|
|
|
|
(n (+ pn d))
|
2016-07-19 13:16:19 +02:00
|
|
|
|
prefix-length index-max index-length)
|
|
|
|
|
(if (or (= n 0)
|
|
|
|
|
(> n
|
|
|
|
|
(setq index-max (1- (exwm-workspace--count))))
|
|
|
|
|
(>= (setq prefix-length (length prefix-digits))
|
|
|
|
|
(setq index-length (floor (log index-max 10))))
|
|
|
|
|
;; Check if it's still possible to do a match.
|
|
|
|
|
(> (* n (expt 10 (- index-length prefix-length)))
|
|
|
|
|
index-max))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(exwm-workspace--switch-map-select-nth n)
|
2016-07-19 13:16:19 +02:00
|
|
|
|
;; Go ahead if there are enough digits to select any workspace.
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(set-transient-map
|
|
|
|
|
(let ((map (make-sparse-keymap))
|
|
|
|
|
(cmd `(lambda ()
|
|
|
|
|
(interactive)
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(exwm-workspace--switch-map-nth-prefix
|
|
|
|
|
',(cons d prefix-digits)))))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(dotimes (i 10)
|
|
|
|
|
(define-key map (int-to-string i) cmd))
|
|
|
|
|
;; Accept
|
|
|
|
|
(define-key map [return]
|
|
|
|
|
`(lambda ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(exwm-workspace--switch-map-select-nth ,n)))
|
|
|
|
|
map)))))
|
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--switch-map-select-nth (n)
|
|
|
|
|
"Select Nth workspace."
|
|
|
|
|
(interactive)
|
|
|
|
|
(goto-history-element (1+ n))
|
|
|
|
|
(exit-minibuffer))
|
|
|
|
|
|
2015-09-21 07:31:57 +02:00
|
|
|
|
;;;###autoload
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(defun exwm-workspace-switch (frame-or-index &optional force)
|
2018-02-18 17:04:27 +01:00
|
|
|
|
"Switch to workspace INDEX (0-based).
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2018-02-18 17:04:27 +01:00
|
|
|
|
Query for the index if not specified when called interactively. Passing a
|
|
|
|
|
workspace frame as the first option or making use of the rest options are
|
|
|
|
|
for internal use only."
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(interactive
|
|
|
|
|
(list
|
2018-03-03 18:36:36 +01:00
|
|
|
|
(cond
|
|
|
|
|
((null current-prefix-arg)
|
|
|
|
|
(unless (and (eq major-mode 'exwm-mode)
|
|
|
|
|
;; The prompt is invisible in fullscreen mode.
|
|
|
|
|
(memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state))
|
|
|
|
|
(let ((exwm-workspace--prompt-add-allowed t)
|
|
|
|
|
(exwm-workspace--prompt-delete-allowed t))
|
|
|
|
|
(exwm-workspace--prompt-for-workspace "Switch to [+/-]: "))))
|
|
|
|
|
((and (integerp current-prefix-arg)
|
|
|
|
|
(<= 0 current-prefix-arg (exwm-workspace--count)))
|
|
|
|
|
current-prefix-arg)
|
|
|
|
|
(t 0))))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(let* ((frame (exwm-workspace--workspace-from-frame-or-index frame-or-index))
|
2017-03-04 18:10:43 +01:00
|
|
|
|
(old-frame exwm-workspace--current)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(index (exwm-workspace--position frame))
|
|
|
|
|
(window (frame-parameter frame 'exwm-selected-window)))
|
|
|
|
|
(when (or force (not (eq frame exwm-workspace--current)))
|
|
|
|
|
(unless (window-live-p window)
|
|
|
|
|
(setq window (frame-selected-window frame)))
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
;; Raise this frame.
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
:window (frame-parameter frame 'exwm-container)
|
|
|
|
|
:value-mask (logior xcb:ConfigWindow:Sibling
|
|
|
|
|
xcb:ConfigWindow:StackMode)
|
|
|
|
|
:sibling exwm--guide-window
|
|
|
|
|
:stack-mode xcb:StackMode:Below))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(setq exwm-workspace--current frame
|
|
|
|
|
exwm-workspace-current-index index)
|
|
|
|
|
(unless (exwm-workspace--workspace-p (selected-frame))
|
|
|
|
|
;; Save the floating frame window selected on the previous workspace.
|
2016-07-21 06:41:51 +02:00
|
|
|
|
(set-frame-parameter (buffer-local-value 'exwm--frame (window-buffer))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
'exwm-selected-window (selected-window)))
|
2018-02-21 17:31:57 +01:00
|
|
|
|
;; Show/Hide X windows.
|
|
|
|
|
(let ((output-old (frame-parameter old-frame 'exwm-randr-output))
|
|
|
|
|
(output-new (frame-parameter frame 'exwm-randr-output))
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(active-old (exwm-workspace--active-p old-frame))
|
|
|
|
|
(active-new (exwm-workspace--active-p frame))
|
2018-02-21 17:31:57 +01:00
|
|
|
|
workspaces-to-hide)
|
|
|
|
|
(cond
|
|
|
|
|
((not active-old)
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(exwm-workspace--set-active frame t))
|
2018-03-02 17:55:36 +01:00
|
|
|
|
((equal output-old output-new)
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(exwm-workspace--set-active old-frame nil)
|
|
|
|
|
(exwm-workspace--set-active frame t)
|
2018-02-21 17:31:57 +01:00
|
|
|
|
(setq workspaces-to-hide (list old-frame)))
|
|
|
|
|
(active-new)
|
|
|
|
|
(t
|
|
|
|
|
(dolist (w exwm-workspace--list)
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(when (and (exwm-workspace--active-p w)
|
2018-03-02 17:55:36 +01:00
|
|
|
|
(equal output-new
|
|
|
|
|
(frame-parameter w 'exwm-randr-output)))
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(exwm-workspace--set-active w nil)
|
2018-02-21 17:31:57 +01:00
|
|
|
|
(setq workspaces-to-hide (append workspaces-to-hide (list w)))))
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(exwm-workspace--set-active frame t)))
|
2018-02-21 17:31:57 +01:00
|
|
|
|
(dolist (i exwm--id-buffer-alist)
|
|
|
|
|
(with-current-buffer (cdr i)
|
|
|
|
|
(if (memq exwm--frame workspaces-to-hide)
|
|
|
|
|
(exwm-layout--hide exwm--id)
|
|
|
|
|
(when (eq frame exwm--frame)
|
|
|
|
|
(let ((window (get-buffer-window nil t)))
|
|
|
|
|
(when window
|
|
|
|
|
(exwm-layout--show exwm--id window))))))))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(select-window window)
|
2016-07-30 12:57:27 +02:00
|
|
|
|
(x-focus-frame (window-frame window)) ;The real input focus.
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(set-frame-parameter frame 'exwm-selected-window nil)
|
|
|
|
|
;; Close the (possible) active minibuffer
|
|
|
|
|
(when (active-minibuffer-window)
|
2017-11-19 07:51:45 +01:00
|
|
|
|
(exwm--defer 0 (lambda ()
|
|
|
|
|
;; Might be aborted by then.
|
|
|
|
|
(when (active-minibuffer-window)
|
|
|
|
|
(abort-recursive-edit)))))
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(if (exwm-workspace--minibuffer-own-frame-p)
|
|
|
|
|
;; Resize the minibuffer frame.
|
|
|
|
|
(exwm-workspace--resize-minibuffer-frame)
|
|
|
|
|
;; Set a default minibuffer frame.
|
|
|
|
|
(setq default-minibuffer-frame frame))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;; Hide windows in other workspaces by preprending a space
|
|
|
|
|
(unless exwm-workspace-show-all-buffers
|
|
|
|
|
(dolist (i exwm--id-buffer-alist)
|
|
|
|
|
(with-current-buffer (cdr i)
|
|
|
|
|
(let ((name (replace-regexp-in-string "^\\s-*" ""
|
|
|
|
|
(buffer-name))))
|
|
|
|
|
(exwm-workspace-rename-buffer (if (eq frame exwm--frame)
|
|
|
|
|
name
|
|
|
|
|
(concat " " name)))))))
|
|
|
|
|
;; Update demands attention flag
|
2016-07-21 06:41:51 +02:00
|
|
|
|
(set-frame-parameter frame 'exwm-urgency nil)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;; Update switch workspace history
|
|
|
|
|
(setq exwm-workspace--switch-history-outdated t)
|
|
|
|
|
;; Set _NET_CURRENT_DESKTOP
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ewmh:set-_NET_CURRENT_DESKTOP
|
|
|
|
|
:window exwm--root :data index))
|
|
|
|
|
(xcb:flush exwm--connection))
|
2017-03-04 18:10:43 +01:00
|
|
|
|
(when (frame-live-p old-frame)
|
|
|
|
|
(with-selected-frame old-frame
|
|
|
|
|
(run-hooks 'focus-out-hook)))
|
|
|
|
|
(run-hooks 'focus-in-hook)
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(run-hooks 'exwm-workspace-switch-hook)))
|
|
|
|
|
|
2016-07-22 06:26:29 +02:00
|
|
|
|
;;;###autoload
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(defun exwm-workspace-switch-create (frame-or-index)
|
2018-02-18 17:04:27 +01:00
|
|
|
|
"Switch to workspace INDEX or creating it first if it does not exist yet.
|
|
|
|
|
|
|
|
|
|
Passing a workspace frame as the first option is for internal use only."
|
2018-03-03 18:36:36 +01:00
|
|
|
|
(interactive
|
|
|
|
|
(list
|
|
|
|
|
(cond
|
|
|
|
|
((integerp current-prefix-arg)
|
|
|
|
|
current-prefix-arg)
|
|
|
|
|
(t 0))))
|
|
|
|
|
(unless frame-or-index
|
|
|
|
|
(setq frame-or-index 0))
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(if (or (framep frame-or-index)
|
|
|
|
|
(< frame-or-index (exwm-workspace--count)))
|
|
|
|
|
(exwm-workspace-switch frame-or-index)
|
|
|
|
|
(let ((exwm-workspace--create-silently t))
|
|
|
|
|
(dotimes (_ (min exwm-workspace-switch-create-limit
|
|
|
|
|
(1+ (- frame-or-index
|
|
|
|
|
(exwm-workspace--count)))))
|
2016-07-21 07:02:07 +02:00
|
|
|
|
(make-frame))
|
|
|
|
|
(run-hooks 'exwm-workspace-list-change-hook))
|
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
|
|
|
|
(exwm-workspace-switch frame-or-index)))
|
2016-07-21 06:48:12 +02:00
|
|
|
|
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;;;###autoload
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(defun exwm-workspace-swap (workspace1 workspace2)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
"Interchange position of WORKSPACE1 with that of WORKSPACE2."
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(interactive
|
2016-08-12 13:27:26 +02:00
|
|
|
|
(unless (and (eq major-mode 'exwm-mode)
|
|
|
|
|
;; The prompt is invisible in fullscreen mode.
|
|
|
|
|
(memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state))
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(let (w1 w2)
|
|
|
|
|
(let ((exwm-workspace--prompt-add-allowed t)
|
|
|
|
|
(exwm-workspace--prompt-delete-allowed t))
|
|
|
|
|
(setq w1 (exwm-workspace--prompt-for-workspace
|
|
|
|
|
"Pick a workspace [+/-]: ")))
|
|
|
|
|
(setq w2 (exwm-workspace--prompt-for-workspace
|
2016-07-19 04:30:21 +02:00
|
|
|
|
(format "Swap workspace %d with: "
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(exwm-workspace--position w1))))
|
2016-07-19 04:30:21 +02:00
|
|
|
|
(list w1 w2))))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(let ((pos1 (exwm-workspace--position workspace1))
|
|
|
|
|
(pos2 (exwm-workspace--position workspace2)))
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(if (or (not pos1) (not pos2) (= pos1 pos2))
|
|
|
|
|
(user-error "[EXWM] Cannot swap %s and %s" workspace1 workspace2)
|
|
|
|
|
(setf (elt exwm-workspace--list pos1) workspace2)
|
|
|
|
|
(setf (elt exwm-workspace--list pos2) workspace1)
|
|
|
|
|
;; Update the _NET_WM_DESKTOP property of each X window affected.
|
|
|
|
|
(dolist (pair exwm--id-buffer-alist)
|
|
|
|
|
(when (memq (buffer-local-value 'exwm--frame (cdr pair))
|
|
|
|
|
(list workspace1 workspace2))
|
|
|
|
|
(exwm-workspace--set-desktop (car pair))))
|
|
|
|
|
(xcb:flush exwm--connection)
|
|
|
|
|
(when (memq exwm-workspace--current (list workspace1 workspace2))
|
|
|
|
|
;; With the current workspace involved, lots of stuffs need refresh.
|
|
|
|
|
(set-frame-parameter exwm-workspace--current 'exwm-selected-window
|
|
|
|
|
(selected-window))
|
2016-07-19 04:34:38 +02:00
|
|
|
|
(exwm-workspace-switch exwm-workspace--current t))
|
|
|
|
|
(run-hooks 'exwm-workspace-list-change-hook))))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;;;###autoload
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(defun exwm-workspace-move (workspace nth)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
"Move WORKSPACE to the NTH position.
|
2018-02-18 17:04:27 +01:00
|
|
|
|
|
2016-07-17 14:00:00 +02:00
|
|
|
|
When called interactively, prompt for a workspace and move current one just
|
|
|
|
|
before it."
|
|
|
|
|
(interactive
|
2018-03-03 18:36:36 +01:00
|
|
|
|
(cond
|
|
|
|
|
((null current-prefix-arg)
|
|
|
|
|
(unless (and (eq major-mode 'exwm-mode)
|
|
|
|
|
;; The prompt is invisible in fullscreen mode.
|
|
|
|
|
(memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state))
|
|
|
|
|
(list exwm-workspace--current
|
|
|
|
|
(exwm-workspace--position
|
|
|
|
|
(exwm-workspace--prompt-for-workspace "Move workspace to: ")))))
|
|
|
|
|
((and (integerp current-prefix-arg)
|
|
|
|
|
(<= 0 current-prefix-arg (exwm-workspace--count)))
|
|
|
|
|
(list exwm-workspace--current current-prefix-arg))
|
|
|
|
|
(t (list exwm-workspace--current 0))))
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(let ((pos (exwm-workspace--position workspace))
|
|
|
|
|
flag start end index)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(if (= nth pos)
|
|
|
|
|
(user-error "[EXWM] Cannot move to same position")
|
2016-07-19 04:24:23 +02:00
|
|
|
|
;; Set if the current workspace is involved.
|
|
|
|
|
(setq flag (or (eq workspace exwm-workspace--current)
|
|
|
|
|
(eq (elt exwm-workspace--list nth)
|
|
|
|
|
exwm-workspace--current)))
|
|
|
|
|
;; Do the move.
|
2016-07-31 07:16:51 +02:00
|
|
|
|
(with-no-warnings ;For Emacs 24.
|
|
|
|
|
(pop (nthcdr pos exwm-workspace--list)))
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(push workspace (nthcdr nth exwm-workspace--list))
|
|
|
|
|
;; Update the _NET_WM_DESKTOP property of each X window affected.
|
|
|
|
|
(setq start (min pos nth)
|
|
|
|
|
end (max pos nth))
|
|
|
|
|
(dolist (pair exwm--id-buffer-alist)
|
|
|
|
|
(setq index (exwm-workspace--position
|
|
|
|
|
(buffer-local-value 'exwm--frame (cdr pair))))
|
|
|
|
|
(unless (or (< index start) (> index end))
|
|
|
|
|
(exwm-workspace--set-desktop (car pair))))
|
|
|
|
|
(when flag
|
|
|
|
|
;; With the current workspace involved, lots of stuffs need refresh.
|
|
|
|
|
(set-frame-parameter exwm-workspace--current 'exwm-selected-window
|
|
|
|
|
(selected-window))
|
2016-07-19 04:34:38 +02:00
|
|
|
|
(exwm-workspace-switch exwm-workspace--current t))
|
|
|
|
|
(run-hooks 'exwm-workspace-list-change-hook))))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
|
2016-07-19 04:30:21 +02:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun exwm-workspace-add (&optional index)
|
|
|
|
|
"Add a workspace as the INDEX-th workspace, or the last one if INDEX is nil.
|
|
|
|
|
|
|
|
|
|
INDEX must not exceed the current number of workspaces."
|
|
|
|
|
(interactive)
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(if (and index
|
|
|
|
|
;; No need to move if it's the last one.
|
|
|
|
|
(< index (exwm-workspace--count)))
|
|
|
|
|
(exwm-workspace-move (make-frame) index)
|
|
|
|
|
(make-frame)))
|
2016-07-19 04:30:21 +02:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun exwm-workspace-delete (&optional frame-or-index)
|
|
|
|
|
"Delete the workspace FRAME-OR-INDEX."
|
|
|
|
|
(interactive)
|
2016-07-22 06:29:01 +02:00
|
|
|
|
(when (< 1 (exwm-workspace--count))
|
|
|
|
|
(delete-frame
|
|
|
|
|
(if frame-or-index
|
|
|
|
|
(exwm-workspace--workspace-from-frame-or-index frame-or-index)
|
|
|
|
|
exwm-workspace--current))))
|
2015-08-03 14:26:53 +02:00
|
|
|
|
|
2016-07-13 12:51:32 +02:00
|
|
|
|
(defun exwm-workspace--set-desktop (id)
|
|
|
|
|
"Set _NET_WM_DESKTOP for X window ID."
|
|
|
|
|
(with-current-buffer (exwm--id->buffer id)
|
2018-02-19 15:34:03 +01:00
|
|
|
|
(let ((desktop (exwm-workspace--position exwm--frame)))
|
|
|
|
|
(setq exwm--desktop desktop)
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ewmh:set-_NET_WM_DESKTOP
|
|
|
|
|
:window id
|
|
|
|
|
:data desktop)))))
|
2016-07-13 12:51:32 +02:00
|
|
|
|
|
2015-09-04 03:09:59 +02:00
|
|
|
|
;;;###autoload
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(defun exwm-workspace-move-window (frame-or-index &optional id)
|
|
|
|
|
"Move window ID to workspace FRAME-OR-INDEX."
|
2016-07-19 04:30:21 +02:00
|
|
|
|
(interactive (list
|
2018-03-03 18:36:36 +01:00
|
|
|
|
(cond
|
|
|
|
|
((null current-prefix-arg)
|
|
|
|
|
(let ((exwm-workspace--prompt-add-allowed t)
|
|
|
|
|
(exwm-workspace--prompt-delete-allowed t))
|
|
|
|
|
(exwm-workspace--prompt-for-workspace "Move to [+/-]: ")))
|
|
|
|
|
((and (integerp current-prefix-arg)
|
|
|
|
|
(<= 0 current-prefix-arg (exwm-workspace--count)))
|
|
|
|
|
current-prefix-arg)
|
|
|
|
|
(t 0))))
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
(let ((frame (exwm-workspace--workspace-from-frame-or-index frame-or-index))
|
2018-02-21 17:31:57 +01:00
|
|
|
|
old-frame container)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(unless id (setq id (exwm--buffer->id (window-buffer))))
|
|
|
|
|
(with-current-buffer (exwm--id->buffer id)
|
2015-09-09 13:08:51 +02:00
|
|
|
|
(unless (eq exwm--frame frame)
|
2015-09-16 15:32:38 +02:00
|
|
|
|
(unless exwm-workspace-show-all-buffers
|
|
|
|
|
(let ((name (replace-regexp-in-string "^\\s-*" "" (buffer-name))))
|
|
|
|
|
(exwm-workspace-rename-buffer
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(if (eq frame exwm-workspace--current)
|
2015-09-16 15:32:38 +02:00
|
|
|
|
name
|
|
|
|
|
(concat " " name)))))
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
(setq old-frame exwm--frame
|
|
|
|
|
exwm--frame frame)
|
|
|
|
|
(if (not exwm--floating-frame)
|
|
|
|
|
;; Tiling.
|
|
|
|
|
(progn
|
|
|
|
|
(set-window-buffer (get-buffer-window nil t)
|
|
|
|
|
(other-buffer nil t))
|
|
|
|
|
(unless (eq frame exwm-workspace--current)
|
|
|
|
|
;; Clear the 'exwm-selected-window' frame parameter.
|
|
|
|
|
(set-frame-parameter frame 'exwm-selected-window nil))
|
|
|
|
|
(set-window-buffer (frame-selected-window frame)
|
|
|
|
|
(exwm--id->buffer id))
|
|
|
|
|
(if (eq frame exwm-workspace--current)
|
|
|
|
|
(select-window (frame-selected-window frame))
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(unless (exwm-workspace--active-p frame)
|
2018-02-19 15:40:27 +01:00
|
|
|
|
(exwm-layout--hide id))))
|
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
|
|
|
|
;; Floating.
|
|
|
|
|
(setq container (frame-parameter exwm--floating-frame
|
|
|
|
|
'exwm-container))
|
2018-03-02 17:55:36 +01:00
|
|
|
|
(unless (equal (frame-parameter old-frame 'exwm-randr-output)
|
|
|
|
|
(frame-parameter frame 'exwm-randr-output))
|
2018-02-19 15:40:27 +01:00
|
|
|
|
(with-slots (x y)
|
|
|
|
|
(xcb:+request-unchecked+reply exwm--connection
|
|
|
|
|
(make-instance 'xcb:GetGeometry
|
|
|
|
|
:drawable container))
|
2018-02-20 15:17:22 +01:00
|
|
|
|
(with-slots ((x1 x)
|
|
|
|
|
(y1 y))
|
|
|
|
|
(exwm-workspace--get-geometry old-frame)
|
|
|
|
|
(with-slots ((x2 x)
|
|
|
|
|
(y2 y))
|
|
|
|
|
(exwm-workspace--get-geometry frame)
|
|
|
|
|
(setq x (+ x (- x2 x1))
|
|
|
|
|
y (+ y (- y2 y1)))))
|
2018-02-19 15:40:27 +01:00
|
|
|
|
(exwm--set-geometry id x y nil nil)
|
|
|
|
|
(exwm--set-geometry container x y nil nil)))
|
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
|
|
|
|
(if (exwm-workspace--minibuffer-own-frame-p)
|
|
|
|
|
(if (eq frame exwm-workspace--current)
|
|
|
|
|
(select-window (frame-root-window exwm--floating-frame))
|
|
|
|
|
(select-window (frame-selected-window exwm-workspace--current))
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(unless (exwm-workspace--active-p frame)
|
2018-02-19 15:40:27 +01:00
|
|
|
|
(exwm-layout--hide id)))
|
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
|
|
|
|
;; The frame needs to be recreated since it won't use the
|
|
|
|
|
;; minibuffer on the new workspace.
|
|
|
|
|
;; The code is mostly copied from `exwm-floating--set-floating'.
|
|
|
|
|
(let* ((old-frame exwm--floating-frame)
|
|
|
|
|
(new-frame
|
|
|
|
|
(with-current-buffer
|
|
|
|
|
(or (get-buffer "*scratch*")
|
|
|
|
|
(progn
|
|
|
|
|
(set-buffer-major-mode
|
|
|
|
|
(get-buffer-create "*scratch*"))
|
|
|
|
|
(get-buffer "*scratch*")))
|
|
|
|
|
(make-frame
|
|
|
|
|
`((minibuffer . ,(minibuffer-window frame))
|
|
|
|
|
(left . ,(* window-min-width -100))
|
|
|
|
|
(top . ,(* window-min-height -100))
|
|
|
|
|
(width . ,window-min-width)
|
|
|
|
|
(height . ,window-min-height)
|
|
|
|
|
(unsplittable . t)))))
|
|
|
|
|
(outer-id (string-to-number
|
|
|
|
|
(frame-parameter new-frame
|
|
|
|
|
'outer-window-id)))
|
|
|
|
|
(window-id (string-to-number
|
|
|
|
|
(frame-parameter new-frame 'window-id)))
|
|
|
|
|
(window (frame-root-window new-frame)))
|
|
|
|
|
(set-frame-parameter new-frame 'exwm-outer-id outer-id)
|
|
|
|
|
(set-frame-parameter new-frame 'exwm-id window-id)
|
|
|
|
|
(set-frame-parameter new-frame 'exwm-container container)
|
|
|
|
|
(make-frame-invisible new-frame)
|
|
|
|
|
(set-frame-size new-frame
|
|
|
|
|
(frame-pixel-width old-frame)
|
|
|
|
|
(frame-pixel-height old-frame)
|
|
|
|
|
t)
|
2015-08-08 14:39:05 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ReparentWindow
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
:window outer-id
|
|
|
|
|
:parent container
|
|
|
|
|
:x 0 :y 0))
|
|
|
|
|
(xcb:flush exwm--connection)
|
|
|
|
|
(with-current-buffer (exwm--id->buffer id)
|
|
|
|
|
(setq window-size-fixed nil
|
|
|
|
|
exwm--floating-frame new-frame)
|
|
|
|
|
(set-window-dedicated-p (frame-root-window old-frame) nil)
|
|
|
|
|
(remove-hook 'window-configuration-change-hook
|
|
|
|
|
#'exwm-layout--refresh)
|
|
|
|
|
(set-window-buffer window (current-buffer))
|
|
|
|
|
(add-hook 'window-configuration-change-hook
|
|
|
|
|
#'exwm-layout--refresh)
|
|
|
|
|
(set-window-dedicated-p window t))
|
|
|
|
|
;; Select a tiling window and delete the old frame.
|
|
|
|
|
(select-window (frame-selected-window exwm-workspace--current))
|
|
|
|
|
(delete-frame old-frame)
|
|
|
|
|
;; The rest is the same.
|
|
|
|
|
(make-frame-visible new-frame)
|
|
|
|
|
(exwm--set-geometry outer-id 0 0 nil nil)
|
2016-02-21 09:39:34 +01: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
|
|
|
|
(redisplay)
|
|
|
|
|
(if (eq frame exwm-workspace--current)
|
2016-02-21 09:39:34 +01:00
|
|
|
|
(with-current-buffer (exwm--id->buffer id)
|
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
|
|
|
|
(select-window (frame-root-window exwm--floating-frame)))
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(unless (exwm-workspace--active-p frame)
|
2018-02-19 15:40:27 +01:00
|
|
|
|
(exwm-layout--hide id)))))
|
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
|
|
|
|
;; Update the 'exwm-selected-window' frame parameter.
|
|
|
|
|
(when (not (eq frame exwm-workspace--current))
|
|
|
|
|
(with-current-buffer (exwm--id->buffer id)
|
|
|
|
|
(set-frame-parameter frame 'exwm-selected-window
|
|
|
|
|
(frame-root-window
|
|
|
|
|
exwm--floating-frame)))))
|
2016-07-13 12:51:32 +02:00
|
|
|
|
;; Set _NET_WM_DESKTOP.
|
|
|
|
|
(exwm-workspace--set-desktop id)
|
|
|
|
|
(xcb:flush exwm--connection)))
|
2015-09-17 13:48:50 +02:00
|
|
|
|
(setq exwm-workspace--switch-history-outdated t)))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2016-02-19 10:12:43 +01:00
|
|
|
|
;;;###autoload
|
2016-02-24 13:55:01 +01:00
|
|
|
|
(defun exwm-workspace-switch-to-buffer (buffer-or-name)
|
2015-09-16 15:32:38 +02:00
|
|
|
|
"Make the current Emacs window display another buffer."
|
2016-02-24 13:55:01 +01:00
|
|
|
|
(interactive
|
|
|
|
|
(let ((inhibit-quit t))
|
|
|
|
|
;; Show all buffers
|
|
|
|
|
(unless exwm-workspace-show-all-buffers
|
|
|
|
|
(dolist (pair exwm--id-buffer-alist)
|
|
|
|
|
(with-current-buffer (cdr pair)
|
|
|
|
|
(when (= ?\s (aref (buffer-name) 0))
|
2016-10-06 07:04:30 +02:00
|
|
|
|
(let ((buffer-list-update-hook
|
|
|
|
|
(remq #'exwm-input--on-buffer-list-update
|
|
|
|
|
buffer-list-update-hook)))
|
|
|
|
|
(rename-buffer (substring (buffer-name) 1)))))))
|
2016-02-24 13:55:01 +01:00
|
|
|
|
(prog1
|
|
|
|
|
(with-local-quit
|
2016-09-30 13:30:31 +02:00
|
|
|
|
(list (get-buffer (read-buffer-to-switch "Switch to buffer: "))))
|
2016-02-24 13:55:01 +01:00
|
|
|
|
;; Hide buffers on other workspaces
|
|
|
|
|
(unless exwm-workspace-show-all-buffers
|
|
|
|
|
(dolist (pair exwm--id-buffer-alist)
|
|
|
|
|
(with-current-buffer (cdr pair)
|
|
|
|
|
(unless (or (eq exwm--frame exwm-workspace--current)
|
|
|
|
|
(= ?\s (aref (buffer-name) 0)))
|
2016-10-06 07:04:30 +02:00
|
|
|
|
(let ((buffer-list-update-hook
|
|
|
|
|
(remq #'exwm-input--on-buffer-list-update
|
|
|
|
|
buffer-list-update-hook)))
|
|
|
|
|
(rename-buffer (concat " " (buffer-name)))))))))))
|
2016-02-24 13:55:01 +01:00
|
|
|
|
(when buffer-or-name
|
|
|
|
|
(with-current-buffer buffer-or-name
|
2016-02-25 11:36:54 +01:00
|
|
|
|
(if (eq major-mode 'exwm-mode)
|
|
|
|
|
;; EXWM buffer.
|
|
|
|
|
(if (eq exwm--frame exwm-workspace--current)
|
|
|
|
|
;; On the current workspace.
|
|
|
|
|
(if (not exwm--floating-frame)
|
|
|
|
|
(switch-to-buffer buffer-or-name)
|
|
|
|
|
;; Select the floating frame.
|
|
|
|
|
(select-frame-set-input-focus exwm--floating-frame)
|
|
|
|
|
(select-window (frame-root-window exwm--floating-frame)))
|
|
|
|
|
;; On another workspace.
|
2017-05-30 18:12:22 +02:00
|
|
|
|
(if exwm-layout-show-all-buffers
|
|
|
|
|
(exwm-workspace-move-window exwm-workspace--current
|
|
|
|
|
exwm--id)
|
|
|
|
|
(let ((window (get-buffer-window buffer-or-name exwm--frame)))
|
|
|
|
|
(if window
|
|
|
|
|
(set-frame-parameter exwm--frame
|
|
|
|
|
'exwm-selected-window window)
|
|
|
|
|
(set-window-buffer (frame-selected-window exwm--frame)
|
|
|
|
|
buffer-or-name)))
|
|
|
|
|
(exwm-workspace-switch exwm--frame)))
|
2016-02-25 11:36:54 +01:00
|
|
|
|
;; Ordinary buffer.
|
2016-02-24 13:55:01 +01:00
|
|
|
|
(switch-to-buffer buffer-or-name)))))
|
2015-09-09 13:08:51 +02:00
|
|
|
|
|
2015-07-26 10:04:21 +02:00
|
|
|
|
(defun exwm-workspace-rename-buffer (newname)
|
|
|
|
|
"Rename a buffer."
|
2015-08-26 13:35:19 +02:00
|
|
|
|
(let ((hidden (= ?\s (aref newname 0)))
|
|
|
|
|
(basename (replace-regexp-in-string "<[0-9]+>$" "" newname))
|
|
|
|
|
(counter 1)
|
|
|
|
|
tmp)
|
|
|
|
|
(when hidden (setq basename (substring basename 1)))
|
|
|
|
|
(setq newname basename)
|
|
|
|
|
(while (and (setq tmp (or (get-buffer newname)
|
|
|
|
|
(get-buffer (concat " " newname))))
|
|
|
|
|
(not (eq tmp (current-buffer))))
|
|
|
|
|
(setq newname (format "%s<%d>" basename (cl-incf counter))))
|
2016-10-06 07:04:30 +02:00
|
|
|
|
(let ((buffer-list-update-hook
|
|
|
|
|
(remq #'exwm-input--on-buffer-list-update
|
|
|
|
|
buffer-list-update-hook)))
|
|
|
|
|
(rename-buffer (concat (and hidden " ") newname)))))
|
2015-07-26 10:04:21 +02:00
|
|
|
|
|
2015-09-23 06:53:08 +02:00
|
|
|
|
(defun exwm-workspace--x-create-frame (orig-fun params)
|
|
|
|
|
"Set override-redirect on the frame created by `x-create-frame'."
|
|
|
|
|
(let ((frame (funcall orig-fun params)))
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ChangeWindowAttributes
|
|
|
|
|
:window (string-to-number
|
|
|
|
|
(frame-parameter frame 'outer-window-id))
|
|
|
|
|
:value-mask xcb:CW:OverrideRedirect
|
|
|
|
|
:override-redirect 1))
|
|
|
|
|
(xcb:flush exwm--connection)
|
|
|
|
|
frame))
|
|
|
|
|
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(defsubst exwm-workspace--minibuffer-attached-p ()
|
|
|
|
|
"Return non-nil if the minibuffer is attached.
|
|
|
|
|
|
|
|
|
|
Please check `exwm-workspace--minibuffer-own-frame-p' first."
|
|
|
|
|
(assq (frame-parameter exwm-workspace--minibuffer 'exwm-container)
|
|
|
|
|
exwm-workspace--id-struts-alist))
|
|
|
|
|
|
2016-07-22 06:26:29 +02:00
|
|
|
|
;;;###autoload
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(defun exwm-workspace-attach-minibuffer ()
|
|
|
|
|
"Attach the minibuffer so that it always shows."
|
|
|
|
|
(interactive)
|
|
|
|
|
(when (and (exwm-workspace--minibuffer-own-frame-p)
|
|
|
|
|
(not (exwm-workspace--minibuffer-attached-p)))
|
|
|
|
|
;; Reset the frame size.
|
|
|
|
|
(set-frame-height exwm-workspace--minibuffer 1)
|
|
|
|
|
(redisplay) ;FIXME.
|
|
|
|
|
(setq exwm-workspace--attached-minibuffer-height
|
|
|
|
|
(frame-pixel-height exwm-workspace--minibuffer))
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(exwm-workspace--show-minibuffer)
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(let ((container (frame-parameter exwm-workspace--minibuffer
|
|
|
|
|
'exwm-container)))
|
|
|
|
|
(push (cons container
|
|
|
|
|
(if (eq exwm-workspace-minibuffer-position 'top)
|
|
|
|
|
(vector 0 0 exwm-workspace--attached-minibuffer-height 0)
|
|
|
|
|
(vector 0 0 0 exwm-workspace--attached-minibuffer-height)))
|
|
|
|
|
exwm-workspace--id-struts-alist)
|
|
|
|
|
(exwm-workspace--update-struts)
|
|
|
|
|
(exwm-workspace--update-workareas)
|
|
|
|
|
(dolist (f exwm-workspace--list)
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(exwm-workspace--set-fullscreen f)))))
|
2016-07-19 13:23:37 +02:00
|
|
|
|
|
2016-07-22 06:26:29 +02:00
|
|
|
|
;;;###autoload
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(defun exwm-workspace-detach-minibuffer ()
|
|
|
|
|
"Detach the minibuffer so that it automatically hides."
|
|
|
|
|
(interactive)
|
|
|
|
|
(when (and (exwm-workspace--minibuffer-own-frame-p)
|
|
|
|
|
(exwm-workspace--minibuffer-attached-p))
|
|
|
|
|
(setq exwm-workspace--attached-minibuffer-height 0)
|
|
|
|
|
(let ((container (frame-parameter exwm-workspace--minibuffer
|
|
|
|
|
'exwm-container)))
|
|
|
|
|
(setq exwm-workspace--id-struts-alist
|
|
|
|
|
(assq-delete-all container exwm-workspace--id-struts-alist))
|
|
|
|
|
(exwm-workspace--update-struts)
|
|
|
|
|
(exwm-workspace--update-workareas)
|
|
|
|
|
(dolist (f exwm-workspace--list)
|
|
|
|
|
(exwm-workspace--set-fullscreen f))
|
|
|
|
|
(exwm-workspace--hide-minibuffer))))
|
2016-07-22 06:26:29 +02:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun exwm-workspace-toggle-minibuffer ()
|
|
|
|
|
"Attach the minibuffer if it's detached, or detach it if it's attached."
|
|
|
|
|
(interactive)
|
|
|
|
|
(when (exwm-workspace--minibuffer-own-frame-p)
|
|
|
|
|
(if (exwm-workspace--minibuffer-attached-p)
|
|
|
|
|
(exwm-workspace-detach-minibuffer)
|
|
|
|
|
(exwm-workspace-attach-minibuffer))))
|
2016-07-19 13:23:37 +02:00
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--update-minibuffer-height (&optional echo-area)
|
|
|
|
|
"Update the minibuffer frame height."
|
2016-08-01 13:53:04 +02:00
|
|
|
|
(unless (exwm-workspace--client-p)
|
|
|
|
|
(let ((height
|
|
|
|
|
(with-current-buffer
|
|
|
|
|
(window-buffer (minibuffer-window exwm-workspace--minibuffer))
|
|
|
|
|
(max 1
|
|
|
|
|
(if echo-area
|
|
|
|
|
(let ((width (frame-width exwm-workspace--minibuffer))
|
|
|
|
|
(result 0))
|
|
|
|
|
(mapc (lambda (i)
|
|
|
|
|
(setq result
|
|
|
|
|
(+ result
|
|
|
|
|
(ceiling (1+ (length i)) width))))
|
|
|
|
|
(split-string (or (current-message) "") "\n"))
|
|
|
|
|
result)
|
|
|
|
|
(count-screen-lines))))))
|
|
|
|
|
(when (and (integerp max-mini-window-height)
|
|
|
|
|
(> height max-mini-window-height))
|
|
|
|
|
(setq height max-mini-window-height))
|
|
|
|
|
(set-frame-height exwm-workspace--minibuffer height))))
|
2016-02-06 05:59:33 +01:00
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--on-ConfigureNotify (data _synthetic)
|
|
|
|
|
"Adjust the container to fit the minibuffer frame."
|
|
|
|
|
(let ((obj (make-instance 'xcb:ConfigureNotify))
|
2016-07-19 13:23:37 +02:00
|
|
|
|
workarea y)
|
2016-02-06 05:59:33 +01:00
|
|
|
|
(xcb:unmarshal obj data)
|
|
|
|
|
(with-slots (window height) obj
|
|
|
|
|
(when (eq (frame-parameter exwm-workspace--minibuffer 'exwm-outer-id)
|
|
|
|
|
window)
|
|
|
|
|
(when (and (floatp max-mini-window-height)
|
|
|
|
|
(> height (* max-mini-window-height
|
2016-02-19 10:12:43 +01:00
|
|
|
|
(exwm-workspace--current-height))))
|
2016-02-06 05:59:33 +01:00
|
|
|
|
(setq height (floor
|
|
|
|
|
(* max-mini-window-height
|
2016-02-19 10:12:43 +01:00
|
|
|
|
(exwm-workspace--current-height))))
|
2016-02-06 05:59:33 +01:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
|
|
|
|
:window window
|
|
|
|
|
:value-mask xcb:ConfigWindow:Height
|
|
|
|
|
:height height)))
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(when (/= (exwm-workspace--count) (length exwm-workspace--workareas))
|
|
|
|
|
;; There is a chance the workareas are not updated timely.
|
|
|
|
|
(exwm-workspace--update-workareas))
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(setq workarea (elt exwm-workspace--workareas
|
|
|
|
|
exwm-workspace-current-index)
|
|
|
|
|
y (if (eq exwm-workspace-minibuffer-position 'top)
|
|
|
|
|
(- (aref workarea 1)
|
|
|
|
|
exwm-workspace--attached-minibuffer-height)
|
|
|
|
|
(+ (aref workarea 1) (aref workarea 3) (- height)
|
|
|
|
|
exwm-workspace--attached-minibuffer-height)))
|
2016-02-06 05:59:33 +01:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
|
|
|
|
:window (frame-parameter exwm-workspace--minibuffer
|
|
|
|
|
'exwm-container)
|
2016-07-19 13:23:37 +02:00
|
|
|
|
:value-mask (logior xcb:ConfigWindow:Y
|
|
|
|
|
xcb:ConfigWindow:Height)
|
2016-02-06 05:59:33 +01:00
|
|
|
|
:y y
|
|
|
|
|
:height height))
|
|
|
|
|
(xcb:flush exwm--connection)))))
|
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--display-buffer (buffer alist)
|
2016-02-28 13:03:56 +01:00
|
|
|
|
"Display BUFFER as if the current workspace is selected."
|
|
|
|
|
;; Only when the floating minibuffer frame is selected.
|
|
|
|
|
;; This also protect this functions from being recursively called.
|
2016-02-06 05:59:33 +01:00
|
|
|
|
(when (eq (selected-frame) exwm-workspace--minibuffer)
|
2016-02-28 13:03:56 +01:00
|
|
|
|
(with-selected-frame exwm-workspace--current
|
|
|
|
|
(display-buffer buffer alist))))
|
2016-02-06 05:59:33 +01:00
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--show-minibuffer ()
|
|
|
|
|
"Show the minibuffer frame."
|
|
|
|
|
;; Cancel pending timer.
|
|
|
|
|
(when exwm-workspace--display-echo-area-timer
|
|
|
|
|
(cancel-timer exwm-workspace--display-echo-area-timer)
|
|
|
|
|
(setq exwm-workspace--display-echo-area-timer nil))
|
|
|
|
|
;; Show the minibuffer frame.
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(unless (exwm-workspace--minibuffer-attached-p)
|
|
|
|
|
(exwm--set-geometry (frame-parameter exwm-workspace--minibuffer
|
|
|
|
|
'exwm-container)
|
|
|
|
|
nil nil
|
|
|
|
|
(frame-pixel-width exwm-workspace--minibuffer)
|
|
|
|
|
(frame-pixel-height exwm-workspace--minibuffer)))
|
2016-02-06 05:59:33 +01:00
|
|
|
|
(xcb:+request exwm--connection
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
2016-02-06 05:59:33 +01:00
|
|
|
|
:window (frame-parameter exwm-workspace--minibuffer
|
2016-07-19 13:23:37 +02:00
|
|
|
|
'exwm-container)
|
|
|
|
|
:value-mask xcb:ConfigWindow:StackMode
|
|
|
|
|
:stack-mode xcb:StackMode:Above))
|
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
|
|
|
|
(xcb:flush exwm--connection))
|
2016-02-06 05:59:33 +01:00
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--hide-minibuffer ()
|
|
|
|
|
"Hide the minibuffer frame."
|
|
|
|
|
;; Hide the minibuffer frame.
|
2018-02-22 15:21:54 +01:00
|
|
|
|
(if (exwm-workspace--minibuffer-attached-p)
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
|
|
|
|
:window (frame-parameter exwm-workspace--minibuffer
|
|
|
|
|
'exwm-container)
|
|
|
|
|
:value-mask (logior (if exwm-manage--desktop
|
|
|
|
|
xcb:ConfigWindow:Sibling
|
|
|
|
|
0)
|
|
|
|
|
xcb:ConfigWindow:StackMode)
|
|
|
|
|
:sibling exwm-manage--desktop
|
|
|
|
|
:stack-mode (if exwm-manage--desktop
|
|
|
|
|
xcb:StackMode:Above
|
|
|
|
|
xcb:StackMode:Below)))
|
|
|
|
|
(exwm--set-geometry (frame-parameter exwm-workspace--minibuffer
|
|
|
|
|
'exwm-container)
|
|
|
|
|
nil nil 1 1))
|
2016-02-06 05:59:33 +01:00
|
|
|
|
(xcb:flush exwm--connection))
|
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--on-minibuffer-setup ()
|
|
|
|
|
"Run in minibuffer-setup-hook to show the minibuffer and its container."
|
2016-03-25 06:57:42 +01:00
|
|
|
|
(when (and (= 1 (minibuffer-depth))
|
2016-08-01 13:53:04 +02:00
|
|
|
|
(not (exwm-workspace--client-p)))
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(add-hook 'post-command-hook #'exwm-workspace--update-minibuffer-height)
|
2016-07-30 04:17:57 +02:00
|
|
|
|
(exwm-workspace--show-minibuffer))
|
|
|
|
|
;; FIXME: This is a temporary fix for the *Completions* buffer not
|
|
|
|
|
;; being correctly fitted by its displaying window. As with
|
|
|
|
|
;; `exwm-workspace--display-buffer', the problem is caused by
|
|
|
|
|
;; the fact that the minibuffer (rather than the workspace)
|
|
|
|
|
;; frame is the 'selected frame'. `get-buffer-window' will
|
|
|
|
|
;; fail to retrieve the correct window. It's likely there are
|
|
|
|
|
;; other related issues.
|
2016-07-31 07:16:51 +02:00
|
|
|
|
;; This is not required by Emacs 24.
|
|
|
|
|
(when (fboundp 'window-preserve-size)
|
|
|
|
|
(let ((window (get-buffer-window "*Completions*"
|
|
|
|
|
exwm-workspace--current)))
|
|
|
|
|
(when window
|
|
|
|
|
(fit-window-to-buffer window)
|
|
|
|
|
(window-preserve-size window)))))
|
2016-02-06 05:59:33 +01:00
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--on-minibuffer-exit ()
|
|
|
|
|
"Run in minibuffer-exit-hook to hide the minibuffer container."
|
2016-03-25 06:57:42 +01:00
|
|
|
|
(when (and (= 1 (minibuffer-depth))
|
2016-08-01 13:53:04 +02:00
|
|
|
|
(not (exwm-workspace--client-p)))
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(remove-hook 'post-command-hook #'exwm-workspace--update-minibuffer-height)
|
2016-02-06 05:59:33 +01:00
|
|
|
|
(exwm-workspace--hide-minibuffer)))
|
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--on-echo-area-dirty ()
|
|
|
|
|
"Run when new message arrives to show the echo area and its container."
|
|
|
|
|
(when (and (not (active-minibuffer-window))
|
2016-08-01 13:53:04 +02:00
|
|
|
|
(not (exwm-workspace--client-p))
|
2016-02-06 05:59:33 +01:00
|
|
|
|
(or (current-message)
|
|
|
|
|
cursor-in-echo-area))
|
2016-07-19 13:23:37 +02:00
|
|
|
|
(exwm-workspace--update-minibuffer-height t)
|
2016-02-06 05:59:33 +01:00
|
|
|
|
(exwm-workspace--show-minibuffer)
|
|
|
|
|
(unless (or (not exwm-workspace-display-echo-area-timeout)
|
|
|
|
|
exwm-input--during-command ;e.g. read-event
|
|
|
|
|
input-method-use-echo-area)
|
|
|
|
|
(setq exwm-workspace--display-echo-area-timer
|
|
|
|
|
(run-with-timer exwm-workspace-display-echo-area-timeout nil
|
|
|
|
|
#'exwm-workspace--on-echo-area-clear)))))
|
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--on-echo-area-clear ()
|
|
|
|
|
"Run in echo-area-clear-hook to hide echo area container."
|
2016-08-01 13:53:04 +02:00
|
|
|
|
(unless (exwm-workspace--client-p)
|
2016-03-25 06:57:42 +01:00
|
|
|
|
(unless (active-minibuffer-window)
|
|
|
|
|
(exwm-workspace--hide-minibuffer))
|
|
|
|
|
(when exwm-workspace--display-echo-area-timer
|
|
|
|
|
(cancel-timer exwm-workspace--display-echo-area-timer)
|
|
|
|
|
(setq exwm-workspace--display-echo-area-timer nil))))
|
2016-02-06 05:59:33 +01:00
|
|
|
|
|
2016-07-31 07:14:43 +02:00
|
|
|
|
(defun exwm-workspace--confirm-kill-emacs (prompt &optional force)
|
2016-02-07 04:25:49 +01:00
|
|
|
|
"Confirm before exiting Emacs."
|
2016-08-01 13:49:43 +02:00
|
|
|
|
(when (cond
|
|
|
|
|
((and force (not (eq force 'no-check)))
|
|
|
|
|
;; Force killing Emacs.
|
|
|
|
|
t)
|
|
|
|
|
((or (eq force 'no-check) (not exwm--id-buffer-alist))
|
|
|
|
|
;; Check if there's any unsaved file.
|
|
|
|
|
(pcase (catch 'break
|
|
|
|
|
(let ((kill-emacs-query-functions
|
|
|
|
|
(append kill-emacs-query-functions
|
|
|
|
|
(list (lambda ()
|
|
|
|
|
(throw 'break 'break))))))
|
|
|
|
|
(save-buffers-kill-emacs)))
|
|
|
|
|
(`break (y-or-n-p prompt))
|
|
|
|
|
(x x)))
|
|
|
|
|
(t
|
|
|
|
|
(yes-or-no-p (format "[EXWM] %d window(s) will be destroyed. %s"
|
|
|
|
|
(length exwm--id-buffer-alist) prompt))))
|
|
|
|
|
;; Run `kill-emacs-hook' (`server-force-stop' excluded) before Emacs
|
|
|
|
|
;; frames are unmapped so that errors (if any) can be visible.
|
|
|
|
|
(if (memq #'server-force-stop kill-emacs-hook)
|
|
|
|
|
(progn
|
|
|
|
|
(setq kill-emacs-hook (delq #'server-force-stop kill-emacs-hook))
|
|
|
|
|
(run-hooks 'kill-emacs-hook)
|
|
|
|
|
(setq kill-emacs-hook (list #'server-force-stop)))
|
|
|
|
|
(run-hooks 'kill-emacs-hook)
|
|
|
|
|
(setq kill-emacs-hook nil))
|
2016-07-30 13:01:33 +02:00
|
|
|
|
;; Hide & reparent out all frames (save-set can't be used here since
|
|
|
|
|
;; X windows will be re-mapped).
|
2016-02-21 13:19:45 +01:00
|
|
|
|
(when (exwm-workspace--minibuffer-own-frame-p)
|
2016-07-30 13:01:33 +02:00
|
|
|
|
(let ((id (frame-parameter exwm-workspace--minibuffer 'exwm-outer-id)))
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:UnmapWindow
|
|
|
|
|
:window id))
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ReparentWindow
|
|
|
|
|
:window id
|
|
|
|
|
:parent exwm--root
|
|
|
|
|
:x 0
|
|
|
|
|
:y 0))))
|
2016-02-20 14:52:07 +01:00
|
|
|
|
(dolist (f exwm-workspace--list)
|
2016-07-30 13:01:33 +02:00
|
|
|
|
(let ((id (frame-parameter f 'exwm-outer-id)))
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:UnmapWindow
|
|
|
|
|
:window id))
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ReparentWindow
|
|
|
|
|
:window id
|
|
|
|
|
:parent exwm--root
|
|
|
|
|
:x 0
|
|
|
|
|
:y 0))))
|
2016-08-01 13:49:43 +02:00
|
|
|
|
;; Restore the 'client' frame parameter (before `exwm--exit').
|
2016-07-30 13:01:33 +02:00
|
|
|
|
(when exwm-workspace--client
|
2016-05-23 13:13:42 +02:00
|
|
|
|
(dolist (f exwm-workspace--list)
|
|
|
|
|
(set-frame-parameter f 'client exwm-workspace--client))
|
|
|
|
|
(when (exwm-workspace--minibuffer-own-frame-p)
|
|
|
|
|
(set-frame-parameter exwm-workspace--minibuffer 'client
|
2016-08-01 13:49:43 +02:00
|
|
|
|
exwm-workspace--client)))
|
|
|
|
|
;; Exit each module.
|
|
|
|
|
(exwm--exit)
|
|
|
|
|
;; Destroy all resources created by this connection.
|
|
|
|
|
(xcb:disconnect exwm--connection)
|
|
|
|
|
(setq exwm--connection nil)
|
2016-07-30 13:01:33 +02:00
|
|
|
|
;; Set the return value.
|
2016-08-01 13:49:43 +02:00
|
|
|
|
t))
|
2016-05-23 13:13:42 +02:00
|
|
|
|
|
2016-07-13 12:51:32 +02:00
|
|
|
|
(defun exwm-workspace--set-desktop-geometry ()
|
|
|
|
|
"Set _NET_DESKTOP_GEOMETRY."
|
|
|
|
|
;; We don't support large desktop so it's the same with screen size.
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ewmh:set-_NET_DESKTOP_GEOMETRY
|
|
|
|
|
:window exwm--root
|
|
|
|
|
:width (x-display-pixel-width)
|
|
|
|
|
:height (x-display-pixel-height))))
|
|
|
|
|
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(defun exwm-workspace--add-frame-as-workspace (frame)
|
|
|
|
|
"Configure frame FRAME to be treated as a workspace."
|
|
|
|
|
(cond
|
|
|
|
|
((exwm-workspace--workspace-p frame)
|
|
|
|
|
(exwm--log "Frame `%s' is already a workspace" frame))
|
|
|
|
|
((not (display-graphic-p frame))
|
|
|
|
|
(exwm--log "Frame `%s' is not graphical" frame))
|
2017-05-29 19:25:58 +02:00
|
|
|
|
((not (string-equal
|
|
|
|
|
(replace-regexp-in-string "\\.0$" ""
|
|
|
|
|
(slot-value exwm--connection 'display))
|
|
|
|
|
(replace-regexp-in-string "\\.0$" ""
|
|
|
|
|
(frame-parameter frame 'display))))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(exwm--log "Frame `%s' is on a different DISPLAY (%S instead of %S)"
|
|
|
|
|
frame
|
|
|
|
|
(frame-parameter frame 'display)
|
|
|
|
|
(slot-value exwm--connection 'display)))
|
2016-07-19 04:33:11 +02:00
|
|
|
|
((frame-parameter frame 'unsplittable)
|
|
|
|
|
;; We create floating frames with the "unsplittable" parameter set.
|
|
|
|
|
;; Though it may not be a floating frame, we won't treat an
|
|
|
|
|
;; unsplittable frame as a workspace anyway.
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(exwm--log "Frame `%s' is floating" frame))
|
|
|
|
|
(t
|
|
|
|
|
(exwm--log "Adding frame `%s' as workspace" frame)
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(setq exwm-workspace--list (nconc exwm-workspace--list (list frame)))
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(let ((outer-id (string-to-number (frame-parameter frame
|
|
|
|
|
'outer-window-id)))
|
2016-08-09 07:34:29 +02:00
|
|
|
|
(window-id (string-to-number (frame-parameter frame 'window-id)))
|
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
|
|
|
|
(container (xcb:generate-id exwm--connection)))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;; Save window IDs
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(set-frame-parameter frame 'exwm-outer-id outer-id)
|
2016-08-09 07:34:29 +02:00
|
|
|
|
(set-frame-parameter frame 'exwm-id window-id)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(set-frame-parameter frame 'exwm-container container)
|
2016-08-01 13:53:04 +02:00
|
|
|
|
;; In case it's created by emacsclient.
|
|
|
|
|
(set-frame-parameter frame 'client nil)
|
2016-07-19 04:33:11 +02:00
|
|
|
|
;; Copy RandR frame parameters from the first workspace to
|
|
|
|
|
;; prevent potential problems. The values do not matter here as
|
|
|
|
|
;; they'll be updated by the RandR module later.
|
|
|
|
|
(let ((w (car exwm-workspace--list)))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(dolist (param '(exwm-randr-output
|
|
|
|
|
exwm-geometry))
|
2016-07-19 04:33:11 +02:00
|
|
|
|
(set-frame-parameter frame param (frame-parameter w param))))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
2016-02-03 05:12:24 +01:00
|
|
|
|
(make-instance 'xcb:CreateWindow
|
2016-08-12 13:18:32 +02:00
|
|
|
|
:depth 0
|
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
|
|
|
|
:wid container
|
2016-08-12 13:18:32 +02:00
|
|
|
|
:parent exwm--root
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
:x -1
|
|
|
|
|
:y -1
|
|
|
|
|
:width 1
|
|
|
|
|
:height 1
|
2016-08-12 13:18:32 +02:00
|
|
|
|
:border-width 0
|
|
|
|
|
:class xcb:WindowClass:InputOutput
|
|
|
|
|
:visual 0
|
|
|
|
|
:value-mask (logior xcb:CW:BackPixmap
|
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
|
|
|
|
xcb:CW:OverrideRedirect)
|
2016-08-12 13:18:32 +02:00
|
|
|
|
:background-pixmap xcb:BackPixmap:ParentRelative
|
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
|
|
|
|
:override-redirect 1))
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ConfigureWindow
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
:window container
|
2016-07-21 06:48:12 +02:00
|
|
|
|
:value-mask xcb:ConfigWindow:StackMode
|
|
|
|
|
:stack-mode xcb:StackMode:Below))
|
2016-02-03 05:12:24 +01:00
|
|
|
|
(exwm--debug
|
2016-02-20 14:52:07 +01:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ewmh:set-_NET_WM_NAME
|
|
|
|
|
:window container
|
|
|
|
|
:data
|
|
|
|
|
(format "EXWM workspace %d frame container"
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(exwm-workspace--position frame)))))
|
2016-02-03 05:12:24 +01:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ReparentWindow
|
2016-02-20 14:52:07 +01:00
|
|
|
|
:window outer-id :parent container :x 0 :y 0))
|
|
|
|
|
(xcb:+request 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
|
|
|
|
(make-instance 'xcb:MapWindow :window container)))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(xcb:flush exwm--connection)
|
|
|
|
|
;; Delay making the workspace fullscreen until Emacs becomes idle
|
2017-11-19 07:51:45 +01:00
|
|
|
|
(exwm--defer 0 #'set-frame-parameter frame 'fullscreen 'fullboth)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;; Update EWMH properties.
|
|
|
|
|
(exwm-workspace--update-ewmh-props)
|
2016-07-21 06:48:12 +02:00
|
|
|
|
(if exwm-workspace--create-silently
|
|
|
|
|
(setq exwm-workspace--switch-history-outdated t)
|
2016-07-21 07:02:07 +02:00
|
|
|
|
(exwm-workspace-switch frame t)
|
|
|
|
|
(run-hooks 'exwm-workspace-list-change-hook)))))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--remove-frame-as-workspace (frame)
|
|
|
|
|
"Stop treating frame FRAME as a workspace."
|
|
|
|
|
(cond
|
|
|
|
|
((not (exwm-workspace--workspace-p frame))
|
|
|
|
|
(exwm--log "Frame `%s' is not a workspace" frame))
|
|
|
|
|
(t
|
|
|
|
|
(exwm--log "Removing frame `%s' as workspace" frame)
|
2016-07-22 06:29:01 +02:00
|
|
|
|
(when (= 1 (exwm-workspace--count))
|
|
|
|
|
;; The user managed to delete the last workspace, so create a new one.
|
2016-07-25 06:14:26 +02:00
|
|
|
|
(exwm--log "Last workspace deleted; create a new one")
|
2016-07-22 06:29:01 +02:00
|
|
|
|
(let ((exwm-workspace--create-silently t))
|
|
|
|
|
(make-frame)))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(let* ((index (exwm-workspace--position frame))
|
|
|
|
|
(lastp (= index (1- (exwm-workspace--count))))
|
|
|
|
|
(nextw (elt exwm-workspace--list (+ index (if lastp -1 +1)))))
|
2016-07-19 04:24:23 +02:00
|
|
|
|
;; Need to remove the workspace from the list in order for
|
|
|
|
|
;; the correct calculation of indexes.
|
|
|
|
|
(setq exwm-workspace--list (delete frame exwm-workspace--list))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;; Clients need to be moved to some other workspace before this is being
|
|
|
|
|
;; removed.
|
|
|
|
|
(dolist (pair exwm--id-buffer-alist)
|
|
|
|
|
(with-current-buffer (cdr pair)
|
|
|
|
|
(when (eq exwm--frame frame)
|
|
|
|
|
(exwm-workspace-move-window nextw exwm--id))))
|
2016-07-19 04:24:23 +02:00
|
|
|
|
;; Update the _NET_WM_DESKTOP property of each X window affected.
|
|
|
|
|
(dolist (pair exwm--id-buffer-alist)
|
|
|
|
|
(when (<= (1- index)
|
|
|
|
|
(exwm-workspace--position (buffer-local-value 'exwm--frame
|
|
|
|
|
(cdr pair))))
|
|
|
|
|
(exwm-workspace--set-desktop (car pair))))
|
|
|
|
|
;; If the current workspace is deleted, switch to next one.
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(when (eq frame exwm-workspace--current)
|
|
|
|
|
(exwm-workspace-switch nextw)))
|
2016-07-21 06:44:05 +02:00
|
|
|
|
;; Reparent out the frame.
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ReparentWindow
|
|
|
|
|
:window (frame-parameter frame 'exwm-outer-id)
|
|
|
|
|
:parent exwm--root
|
|
|
|
|
:x 0
|
|
|
|
|
:y 0))
|
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
|
|
|
|
;; Destroy the container.
|
2016-07-21 06:44:05 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:DestroyWindow
|
Make X windows container-less
; This is an attempt to make (managed) X windows container-less, i.e. direct children of the root window. This is mainly to make EXWM compatible with third-party compositors. Other issues like wrong absolute position should also get resolved by the way. The workspace containers ("virtual roots") are also removed. However Emacs frames are still wrapped in containers to avoid unexpected stack reordering.
* exwm-cm.el: Make this module obsolete as EXWM supports third-party compositors now.
* exwm-core.el (exwm--container):
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating-hide)
(exwm-floating--start-moveresize, exwm-floating--stop-moveresize)
(exwm-floating--do-moveresize, exwm-floating-move):
* exwm-input.el (exwm-input--update-focus):
* exwm-layout.el (exwm-layout--show, exwm-layout--hide)
(exwm-layout-set-fullscreen, exwm-layout-unset-fullscreen):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window)
(exwm-manage--kill-buffer-query-function, exwm-manage--kill-client):
* exwm-workspace.el (exwm-workspace--set-fullscreen, exwm-workspace-switch)
(exwm-workspace-move-window, exwm-workspace--add-frame-as-workspace)
(exwm-workspace--remove-frame-as-workspace): Make adaptions for container-less X windows.
* exwm-workspace.el (exwm-workspace--update-ewmh-props):
* exwm.el (exwm--init-icccm-ewmh, exwm--exit-icccm-ewmh): No longer use virtual roots.
* exwm-input.el (exwm-input--on-workspace-list-change)
(exwm-input--update-global-prefix-keys, exwm-input--init, exwm-input--exit): From now on global key bindings are grabbed on the root window so it's no long required to re-grab them each time the workspace list changes. As a result `exwm-input--on-workspace-list-change' and its corresponding references are discarded. It remains to be seen if this change will raise input focus issues.
* exwm-manage.el (exwm-manage--manage-window): Explicitly set the workspace for newly managed X windows.
* exwm-floating.el (exwm-floating--set-floating): Avoid implicit reference to the current workspace.
* exwm-core.el (exwm--set-geometry): New function for setting the geometry of an X window.
* exwm-layout.el (exwm-layout--resize-container): Replaced by `exwm-layout--resize-container'.
* exwm-core.el (exwm--guide-window): New global variable recording the guide X window.
* exwm.el (exwm--init-icccm-ewmh): Set it.
* exwm-input.el (exwm-input--post-init): New function containing staffs for initialization but should better get called after the event loop starts.
* exwm.el (exwm-init): Use it.
2018-02-17 18:04:04 +01:00
|
|
|
|
:window (frame-parameter frame 'exwm-container)))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;; Update EWMH properties.
|
|
|
|
|
(exwm-workspace--update-ewmh-props)
|
|
|
|
|
;; Update switch history.
|
2016-07-19 04:34:38 +02:00
|
|
|
|
(setq exwm-workspace--switch-history-outdated t)
|
|
|
|
|
(run-hooks 'exwm-workspace-list-change-hook))))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--update-ewmh-props ()
|
|
|
|
|
"Update EWMH properties to match the workspace list."
|
|
|
|
|
(let ((num-workspaces (exwm-workspace--count)))
|
2016-07-19 04:24:23 +02:00
|
|
|
|
;; Set _NET_NUMBER_OF_DESKTOPS.
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ewmh:set-_NET_NUMBER_OF_DESKTOPS
|
|
|
|
|
:window exwm--root :data num-workspaces))
|
|
|
|
|
;; Set _NET_DESKTOP_GEOMETRY.
|
|
|
|
|
(exwm-workspace--set-desktop-geometry)
|
2016-08-15 12:42:35 +02:00
|
|
|
|
;; Update workareas.
|
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
|
|
|
|
(exwm-workspace--update-workareas))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(xcb:flush exwm--connection))
|
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--modify-all-x-frames-parameters (new-x-parameters)
|
|
|
|
|
"Modifies `window-system-default-frame-alist' for the X Window System.
|
|
|
|
|
NEW-X-PARAMETERS is an alist of frame parameters, merged into current
|
|
|
|
|
`window-system-default-frame-alist' for the X Window System. The parameters are
|
|
|
|
|
applied to all subsequently created X frames."
|
|
|
|
|
;; The parameters are modified in place; take current
|
|
|
|
|
;; ones or insert a new X-specific list.
|
|
|
|
|
(let ((x-parameters (or (assq 'x window-system-default-frame-alist)
|
|
|
|
|
(let ((new-x-parameters '(x)))
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(push new-x-parameters
|
|
|
|
|
window-system-default-frame-alist)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
new-x-parameters))))
|
|
|
|
|
(setf (cdr x-parameters)
|
|
|
|
|
(append new-x-parameters (cdr x-parameters)))))
|
|
|
|
|
|
2017-03-04 18:10:43 +01:00
|
|
|
|
(defun exwm-workspace--handle-focus-in (_orig-func _event)
|
|
|
|
|
"Replacement for `handle-focus-in'."
|
|
|
|
|
(interactive "e"))
|
|
|
|
|
|
|
|
|
|
(defun exwm-workspace--handle-focus-out (_orig-func _event)
|
|
|
|
|
"Replacement for `handle-focus-out'."
|
|
|
|
|
(interactive "e"))
|
|
|
|
|
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(defun exwm-workspace--init ()
|
|
|
|
|
"Initialize workspace module."
|
|
|
|
|
;; Prevent unexpected exit
|
|
|
|
|
(setq confirm-kill-emacs #'exwm-workspace--confirm-kill-emacs)
|
2016-07-25 06:14:26 +02:00
|
|
|
|
(exwm-workspace--modify-all-x-frames-parameters
|
|
|
|
|
'((internal-border-width . 0)))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(let ((initial-workspaces (frame-list)))
|
|
|
|
|
(if (not (exwm-workspace--minibuffer-own-frame-p))
|
|
|
|
|
;; Initialize workspaces with minibuffers.
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(when (< 1 (length initial-workspaces))
|
|
|
|
|
;; Exclude the initial frame.
|
|
|
|
|
(dolist (i initial-workspaces)
|
|
|
|
|
(unless (frame-parameter i 'window-id)
|
|
|
|
|
(setq initial-workspaces (delq i initial-workspaces))))
|
|
|
|
|
(setq exwm-workspace--client
|
2016-08-01 13:53:04 +02:00
|
|
|
|
(frame-parameter (car initial-workspaces) 'client))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(let ((f (car initial-workspaces)))
|
|
|
|
|
;; Remove the possible internal border.
|
|
|
|
|
(set-frame-parameter f 'internal-border-width 0)
|
|
|
|
|
;; Prevent user from deleting the first frame by accident.
|
|
|
|
|
(set-frame-parameter f 'client nil)))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;; Initialize workspaces without minibuffers.
|
|
|
|
|
(setq exwm-workspace--minibuffer
|
|
|
|
|
(make-frame '((window-system . x) (minibuffer . only)
|
|
|
|
|
(left . 10000) (right . 10000)
|
2016-07-21 06:44:05 +02:00
|
|
|
|
(width . 1) (height . 1)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(client . nil))))
|
|
|
|
|
;; Remove/hide existing frames.
|
|
|
|
|
(dolist (f initial-workspaces)
|
|
|
|
|
(if (frame-parameter f 'client)
|
|
|
|
|
(progn
|
|
|
|
|
(unless exwm-workspace--client
|
|
|
|
|
(setq exwm-workspace--client (frame-parameter f 'client)))
|
|
|
|
|
(make-frame-invisible f))
|
|
|
|
|
(when (eq 'x (framep f)) ;do not delete the initial frame.
|
|
|
|
|
(delete-frame f))))
|
|
|
|
|
;; This is the only usable minibuffer frame.
|
|
|
|
|
(setq default-minibuffer-frame exwm-workspace--minibuffer)
|
|
|
|
|
(exwm-workspace--modify-all-x-frames-parameters
|
|
|
|
|
'((minibuffer . nil)))
|
|
|
|
|
(let ((outer-id (string-to-number
|
|
|
|
|
(frame-parameter exwm-workspace--minibuffer
|
|
|
|
|
'outer-window-id)))
|
2016-08-09 07:34:29 +02:00
|
|
|
|
(window-id (string-to-number
|
|
|
|
|
(frame-parameter exwm-workspace--minibuffer
|
|
|
|
|
'window-id)))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(container (xcb:generate-id exwm--connection)))
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(set-frame-parameter exwm-workspace--minibuffer
|
|
|
|
|
'exwm-outer-id outer-id)
|
2016-08-09 07:34:29 +02:00
|
|
|
|
(set-frame-parameter exwm-workspace--minibuffer 'exwm-id window-id)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(set-frame-parameter exwm-workspace--minibuffer 'exwm-container
|
|
|
|
|
container)
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:CreateWindow
|
2016-08-12 13:18:32 +02:00
|
|
|
|
:depth 0
|
|
|
|
|
:wid container
|
|
|
|
|
:parent exwm--root
|
|
|
|
|
:x 0
|
|
|
|
|
:y 0
|
|
|
|
|
:width 1
|
|
|
|
|
:height 1
|
2016-07-19 04:24:23 +02:00
|
|
|
|
:border-width 0
|
2016-08-12 13:18:32 +02:00
|
|
|
|
:class xcb:WindowClass:InputOutput
|
|
|
|
|
:visual 0
|
|
|
|
|
:value-mask (logior xcb:CW:BackPixmap
|
|
|
|
|
xcb:CW:OverrideRedirect)
|
|
|
|
|
:background-pixmap xcb:BackPixmap:ParentRelative
|
2016-07-17 14:00:00 +02:00
|
|
|
|
:override-redirect 1))
|
|
|
|
|
(exwm--debug
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ewmh:set-_NET_WM_NAME
|
|
|
|
|
:window container
|
|
|
|
|
:data "Minibuffer container")))
|
2016-07-19 13:23:37 +02:00
|
|
|
|
;; Reparent the minibuffer frame to the container.
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ReparentWindow
|
|
|
|
|
:window outer-id :parent container :x 0 :y 0))
|
2016-07-19 13:23:37 +02:00
|
|
|
|
;; Map the container.
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:MapWindow
|
|
|
|
|
:window container))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;; Attach event listener for monitoring the frame
|
|
|
|
|
(xcb:+request exwm--connection
|
|
|
|
|
(make-instance 'xcb:ChangeWindowAttributes
|
|
|
|
|
:window outer-id
|
|
|
|
|
:value-mask xcb:CW:EventMask
|
|
|
|
|
:event-mask xcb:EventMask:StructureNotify))
|
|
|
|
|
(xcb:+event exwm--connection 'xcb:ConfigureNotify
|
|
|
|
|
#'exwm-workspace--on-ConfigureNotify))
|
|
|
|
|
;; Show/hide minibuffer / echo area when they're active/inactive.
|
|
|
|
|
(add-hook 'minibuffer-setup-hook #'exwm-workspace--on-minibuffer-setup)
|
|
|
|
|
(add-hook 'minibuffer-exit-hook #'exwm-workspace--on-minibuffer-exit)
|
|
|
|
|
(setq exwm-workspace--timer
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(run-with-idle-timer 0 t #'exwm-workspace--on-echo-area-dirty))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(add-hook 'echo-area-clear-hook #'exwm-workspace--on-echo-area-clear)
|
2016-07-19 13:18:00 +02:00
|
|
|
|
;; Recreate one frame with the external minibuffer set.
|
|
|
|
|
(setq initial-workspaces (list (make-frame '((window-system . x)
|
|
|
|
|
(client . nil)))))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;; The default behavior of `display-buffer' (indirectly called by
|
|
|
|
|
;; `minibuffer-completion-help') is not correct here.
|
|
|
|
|
(cl-pushnew '(exwm-workspace--display-buffer) display-buffer-alist
|
|
|
|
|
:test #'equal))
|
|
|
|
|
;; Prevent `other-buffer' from selecting already displayed EXWM buffers.
|
|
|
|
|
(modify-all-frames-parameters
|
|
|
|
|
'((buffer-predicate . exwm-layout--other-buffer-predicate)))
|
2016-07-19 04:30:21 +02:00
|
|
|
|
;; Create remaining workspaces.
|
|
|
|
|
(dotimes (_ (- exwm-workspace-number (length initial-workspaces)))
|
|
|
|
|
(nconc initial-workspaces (list (make-frame '((window-system . x)
|
|
|
|
|
(client . nil))))))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;; Configure workspaces
|
|
|
|
|
(dolist (i initial-workspaces)
|
|
|
|
|
(exwm-workspace--add-frame-as-workspace i)))
|
2015-07-18 15:16:14 +02:00
|
|
|
|
(xcb:flush exwm--connection)
|
2015-09-23 06:53:08 +02:00
|
|
|
|
;; We have to advice `x-create-frame' or every call to it would hang EXWM
|
|
|
|
|
(advice-add 'x-create-frame :around #'exwm-workspace--x-create-frame)
|
2017-03-04 18:10:43 +01:00
|
|
|
|
;; We have to manually handle focus-in and focus-out events for Emacs
|
|
|
|
|
;; frames.
|
|
|
|
|
(advice-add 'handle-focus-in :around #'exwm-workspace--handle-focus-in)
|
|
|
|
|
(advice-add 'handle-focus-out :around #'exwm-workspace--handle-focus-out)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
;; Make new frames create new workspaces.
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(add-hook 'after-make-frame-functions
|
|
|
|
|
#'exwm-workspace--add-frame-as-workspace)
|
|
|
|
|
(add-hook 'delete-frame-functions
|
|
|
|
|
#'exwm-workspace--remove-frame-as-workspace)
|
2015-07-17 13:16:08 +02:00
|
|
|
|
;; Switch to the first workspace
|
2017-01-02 17:14:33 +01:00
|
|
|
|
(exwm-workspace-switch 0 t)
|
|
|
|
|
;; Prevent frame parameters introduced by this module from being
|
|
|
|
|
;; saved/restored.
|
2018-02-21 17:31:57 +01:00
|
|
|
|
(dolist (i '(exwm-active exwm-outer-id exwm-id exwm-container exwm-geometry
|
|
|
|
|
exwm-selected-window exwm-urgency fullscreen))
|
2017-01-02 17:14:33 +01:00
|
|
|
|
(push (cons i :never) frameset-filter-alist)))
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
2016-05-23 13:13:42 +02:00
|
|
|
|
(defun exwm-workspace--exit ()
|
|
|
|
|
"Exit the workspace module."
|
|
|
|
|
(setq confirm-kill-emacs nil
|
|
|
|
|
exwm-workspace--list nil
|
|
|
|
|
exwm-workspace--client nil
|
|
|
|
|
exwm-workspace--minibuffer nil
|
2016-07-30 11:48:09 +02:00
|
|
|
|
exwm-workspace--fullscreen-frame-count 0
|
2016-05-23 13:13:42 +02:00
|
|
|
|
default-minibuffer-frame nil)
|
|
|
|
|
(remove-hook 'minibuffer-setup-hook #'exwm-workspace--on-minibuffer-setup)
|
|
|
|
|
(remove-hook 'minibuffer-exit-hook #'exwm-workspace--on-minibuffer-exit)
|
|
|
|
|
(when exwm-workspace--timer
|
|
|
|
|
(cancel-timer exwm-workspace--timer)
|
|
|
|
|
(setq exwm-workspace--timer nil))
|
|
|
|
|
(remove-hook 'echo-area-clear-hook #'exwm-workspace--on-echo-area-clear)
|
|
|
|
|
(setq display-buffer-alist
|
|
|
|
|
(cl-delete '(exwm-workspace--display-buffer) display-buffer-alist
|
|
|
|
|
:test #'equal))
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(advice-remove 'x-create-frame #'exwm-workspace--x-create-frame)
|
2017-03-04 18:10:43 +01:00
|
|
|
|
(advice-remove 'handle-focus-in #'exwm-workspace--handle-focus-in)
|
|
|
|
|
(advice-remove 'handle-focus-out #'exwm-workspace--handle-focus-out)
|
2016-07-19 04:24:23 +02:00
|
|
|
|
(remove-hook 'after-make-frame-functions
|
|
|
|
|
#'exwm-workspace--add-frame-as-workspace)
|
|
|
|
|
(remove-hook 'delete-frame-functions
|
|
|
|
|
#'exwm-workspace--remove-frame-as-workspace))
|
2016-05-23 13:13:42 +02:00
|
|
|
|
|
2016-02-12 07:10:11 +01:00
|
|
|
|
(defun exwm-workspace--post-init ()
|
|
|
|
|
"The second stage in the initialization of the workspace module."
|
2016-07-21 06:44:05 +02:00
|
|
|
|
(when exwm-workspace--client
|
|
|
|
|
;; Reset the 'fullscreen' frame parameter to make emacsclinet frames
|
|
|
|
|
;; fullscreen (even without the RandR module enabled).
|
|
|
|
|
(dolist (i exwm-workspace--list)
|
|
|
|
|
(set-frame-parameter i 'fullscreen nil)
|
|
|
|
|
(set-frame-parameter i 'fullscreen 'fullboth)))
|
2016-02-19 10:12:43 +01:00
|
|
|
|
;; Wait until all workspace frames are resized.
|
|
|
|
|
(with-timeout (1)
|
2016-07-17 14:00:00 +02:00
|
|
|
|
(while (< exwm-workspace--fullscreen-frame-count (exwm-workspace--count))
|
2016-07-16 08:34:57 +02:00
|
|
|
|
(accept-process-output nil 0.1)))
|
|
|
|
|
(setq exwm-workspace--fullscreen-frame-count nil))
|
2016-02-12 07:10:11 +01:00
|
|
|
|
|
2015-07-17 13:16:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(provide 'exwm-workspace)
|
|
|
|
|
|
|
|
|
|
;;; exwm-workspace.el ends here
|