From ed6a18a697bc1eb8bf09a12c04ffa3200a5248cd Mon Sep 17 00:00:00 2001 From: Adrián Medraño Calvo Date: Sun, 17 Jul 2016 12:00:00 +0000 Subject: Add `exwm-workspace--position' helper * exwm-workspace.el (exwm-workspace--position): New function. * exwm-layout.el (exwm-layout--refresh): * exwm-input.el (exwm-input--on-ButtonPress): * exwm-workspace.el (exwm-workspace--update-switch-history): * exwm.el (exwm--on-ClientMessage, exwm-workspace--init): Use it. --- exwm-input.el | 5 +++-- exwm-layout.el | 3 ++- exwm-workspace.el | 13 ++++++++++--- exwm.el | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/exwm-input.el b/exwm-input.el index 67e9a7439a52..d581e7e85785 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -179,6 +179,7 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.") (declare-function exwm-floating--start-moveresize "exwm-floating.el" (id &optional type)) +(declare-function exwm-workspace--position "exwm-workspace.el" (frame)) (defvar exwm-workspace--list) @@ -208,14 +209,14 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.") (if (memq frame exwm-workspace--list) ;; The X window is on another workspace (exwm-workspace-switch - (cl-position frame exwm-workspace--list)) + (exwm-workspace--position frame)) (with-current-buffer (window-buffer window) (when (and (eq major-mode 'exwm-mode) (not (eq exwm--frame exwm-workspace--current))) ;; The floating X window is on another workspace (exwm-workspace-switch - (cl-position exwm--frame exwm-workspace--list)))))) + (exwm-workspace--position exwm--frame)))))) ;; It has been reported that the `window' may have be deleted (if (window-live-p window) (select-window window) diff --git a/exwm-layout.el b/exwm-layout.el index 92ca677e565d..db1aa0d5fdfa 100644 --- a/exwm-layout.el +++ b/exwm-layout.el @@ -161,6 +161,7 @@ (declare-function exwm-workspace--current-width "exwm-workspace.el") (declare-function exwm-workspace--get-geometry "exwm-workspace.el" (frame)) (declare-function exwm-workspace--minibuffer-own-frame-p "exwm-workspace.el") +(declare-function exwm-workspace--position "exwm-workspace.el" (frame)) (declare-function exwm-workspace--set-fullscreen "exwm-workspace.el" (frame)) (declare-function exwm-workspace-move-window "exwm-workspace.el" (index &optional id)) @@ -346,7 +347,7 @@ selected by `other-buffer'." (if (eq frame exwm--frame) (exwm-layout--show exwm--id window) (exwm-workspace-move-window - (cl-position frame exwm-workspace--list) exwm--id)) + (exwm-workspace--position frame) exwm--id)) ;; Make sure this buffer is not displayed elsewhere. Note down ;; windows displaying an EXWM-buffer now displayed elsewhere; we ;; need to display with some other buffer there. diff --git a/exwm-workspace.el b/exwm-workspace.el index b2138aa138a7..641f3f2f227e 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -29,6 +29,13 @@ (defvar exwm-workspace-number 4 "Number of workspaces (1 ~ 10).") (defvar exwm-workspace--list nil "List of all workspaces (Emacs frames).") + +(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)) + (defvar exwm-workspace--switch-map (let ((map (make-sparse-keymap))) (define-key map [t] (lambda () (interactive))) @@ -72,7 +79,7 @@ (with-current-buffer (cdr i) (when exwm--frame (setf (aref not-empty - (cl-position exwm--frame exwm-workspace--list)) + (exwm-workspace--position exwm--frame)) t)))) (setq exwm-workspace--switch-history (mapcar @@ -948,13 +955,13 @@ applied to all subsequently created X frames." :window workspace :data (format "EXWM workspace %d" - (cl-position i exwm-workspace--list)))) + (exwm-workspace--position i)))) (xcb:+request exwm--connection (make-instance 'xcb:ewmh:set-_NET_WM_NAME :window container :data (format "EXWM workspace %d frame container" - (cl-position i exwm-workspace--list))))) + (exwm-workspace--position i))))) (xcb:+request exwm--connection (make-instance 'xcb:ReparentWindow :window outer-id :parent container :x 0 :y 0)) diff --git a/exwm.el b/exwm.el index 814104a86dd2..4a6e9fd5d2ac 100644 --- a/exwm.el +++ b/exwm.el @@ -438,7 +438,7 @@ ;; FIXME: check (may require other properties set) (when (memq xcb:Atom:_NET_WM_STATE_DEMANDS_ATTENTION props) (when (= action xcb:ewmh:_NET_WM_STATE_ADD) - (let ((idx (cl-position exwm--frame exwm-workspace--list))) + (let ((idx (exwm-workspace--position exwm--frame))) (unless (= idx exwm-workspace-current-index) (set-frame-parameter exwm--frame 'exwm--urgency t) (setq exwm-workspace--switch-history-outdated t)))) -- cgit 1.4.1