From 6571bb5761241be16c49f4b9af4314851b36eb18 Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Thu, 21 Jul 2016 12:41:51 +0800 Subject: [PATCH] Minor cleanups ; Eliminate compile warnings. ; Rename frame parameter 'exwm--urgency' to 'exwm-urgency'. ; Simplify expressions. --- exwm-core.el | 3 +-- exwm-floating.el | 10 +++++----- exwm-input.el | 2 +- exwm-manage.el | 4 ++-- exwm-workspace.el | 27 ++++++++++----------------- exwm.el | 13 ++++++------- 6 files changed, 25 insertions(+), 34 deletions(-) diff --git a/exwm-core.el b/exwm-core.el index fe46c8b..f0508c6 100644 --- a/exwm-core.el +++ b/exwm-core.el @@ -221,8 +221,7 @@ (setq mode-name '(:eval (propertize "EXWM" 'face (when (cl-some (lambda (i) - (frame-parameter i - 'exwm--urgency)) + (frame-parameter i 'exwm-urgency)) exwm-workspace--list) 'font-lock-warning-face)))) ;; Change major-mode is not allowed diff --git a/exwm-floating.el b/exwm-floating.el index 27a5016..7931c66 100644 --- a/exwm-floating.el +++ b/exwm-floating.el @@ -67,6 +67,7 @@ xcb:Atom:_NET_WM_ACTION_CLOSE))))) (defvar exwm-workspace--current) +(defvar exwm-workspace--struts) (declare-function exwm-layout--refresh "exwm-layout.el" ()) (declare-function exwm-layout--show "exwm-layout.el" (id &optional window)) @@ -96,8 +97,7 @@ (height . ,window-min-height) (unsplittable . t))))) ;and fix the size later (outer-id (string-to-number (frame-parameter frame 'outer-window-id))) - (container (with-current-buffer (exwm--id->buffer id) - exwm--container)) + (container (buffer-local-value 'exwm--container (exwm--id->buffer id))) (frame-container (xcb:generate-id exwm--connection)) (window (frame-first-window frame)) ;and it's the only window (x (slot-value exwm--geometry 'x)) @@ -524,8 +524,8 @@ ;; Unmanaged. (eq major-mode 'exwm-mode)) (let ((edges (window-inside-absolute-pixel-edges (frame-selected-window))) - (id (with-current-buffer (window-buffer (frame-selected-window)) - exwm--id))) + (id (buffer-local-value 'exwm--id + (window-buffer (frame-selected-window))))) (xcb:+request exwm--connection (make-instance 'xcb:SendEvent :propagate 0 :destination id @@ -570,7 +570,7 @@ (setq container-or-id (if (bufferp buffer-or-id) ;; Managed. - (with-current-buffer buffer-or-id exwm--container) + (buffer-local-value 'exwm--container buffer-or-id) ;; Unmanaged. buffer-or-id)) (xcb:+request exwm--connection diff --git a/exwm-input.el b/exwm-input.el index b0c9b2c..c1028ac 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -116,7 +116,7 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.") (if (not (eq exwm--frame exwm-workspace--current)) ;; Do not focus X windows on other workspace (progn - (set-frame-parameter exwm--frame 'exwm--urgency t) + (set-frame-parameter exwm--frame 'exwm-urgency t) (setq exwm-workspace--switch-history-outdated t) (force-mode-line-update) ;; The application may have changed its input focus diff --git a/exwm-manage.el b/exwm-manage.el index 7a3a18b..260571b 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -420,8 +420,8 @@ manager is shutting down." (xcb:+request exwm--connection (make-instance 'xcb:UnmapWindow :window exwm--container)) (xcb:flush exwm--connection) - (run-with-timer exwm-manage-ping-timeout nil - `(lambda () (exwm-manage--kill-client ,id))) + (run-with-timer exwm-manage-ping-timeout nil #'exwm-manage--kill-client + id) ;; Wait for DestroyNotify event. (throw 'return nil)) ;; Try to determine if the X window is dead with _NET_WM_PING. diff --git a/exwm-workspace.el b/exwm-workspace.el index 060be3b..80a7cbd 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -128,7 +128,7 @@ NIL if FRAME is not a workspace" (int-to-string j) 'face (cond ((frame-parameter (elt exwm-workspace--list j) - 'exwm--urgency) + 'exwm-urgency) '(:foreground "orange")) ((aref not-empty j) '(:foreground "green")) (t nil))))) @@ -300,6 +300,11 @@ Value nil means to use the default position which is fixed at bottom, while (when exwm-workspace--fullscreen-frame-count (cl-incf exwm-workspace--fullscreen-frame-count))) +(defvar exwm-workspace--attached-minibuffer-height 0 + "Height (in pixel) of the attached minibuffer. + +If the minibuffer is detached, this value is 0.") + (defun exwm-workspace--resize-minibuffer-frame () "Resize minibuffer (and its container) to fit the size of workspace." (cl-assert (exwm-workspace--minibuffer-own-frame-p)) @@ -429,8 +434,7 @@ The optional FORCE option is for internal use only." exwm-workspace-current-index index) (unless (exwm-workspace--workspace-p (selected-frame)) ;; Save the floating frame window selected on the previous workspace. - (set-frame-parameter (with-current-buffer (window-buffer) - exwm--frame) + (set-frame-parameter (buffer-local-value 'exwm--frame (window-buffer)) 'exwm-selected-window (selected-window))) (select-window window) (set-frame-parameter frame 'exwm-selected-window nil) @@ -455,7 +459,7 @@ The optional FORCE option is for internal use only." name (concat " " name))))))) ;; Update demands attention flag - (set-frame-parameter frame 'exwm--urgency nil) + (set-frame-parameter frame 'exwm-urgency nil) ;; Update switch workspace history (setq exwm-workspace--switch-history-outdated t) ;; Set _NET_CURRENT_DESKTOP @@ -791,11 +795,6 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first." (assq (frame-parameter exwm-workspace--minibuffer 'exwm-container) exwm-workspace--id-struts-alist)) -(defvar exwm-workspace--attached-minibuffer-height 0 - "Height (in pixel) of the attached minibuffer. - -If the minibuffer is detached, this value is 0.") - (defun exwm-workspace-attach-minibuffer () "Attach the minibuffer so that it always shows." (interactive) @@ -1126,10 +1125,8 @@ If the minibuffer is detached, this value is 0.") (make-instance 'xcb:MapWindow :window workspace))) (xcb:flush exwm--connection) ;; Delay making the workspace fullscreen until Emacs becomes idle - (run-with-idle-timer 0 nil - `(lambda () - (set-frame-parameter ,frame - 'fullscreen 'fullboth))) + (run-with-idle-timer 0 nil #'set-frame-parameter + frame 'fullscreen 'fullboth) ;; Update EWMH properties. (exwm-workspace--update-ewmh-props) (exwm-workspace-switch frame t) @@ -1148,10 +1145,6 @@ If the minibuffer is detached, this value is 0.") (exwm--log "Removing frame `%s' as workspace" frame) (let* ((index (exwm-workspace--position frame)) (lastp (= index (1- (exwm-workspace--count)))) - ;; As we are removing this workspace, the one on its left is its - ;; natural substitutes... except when this is already the last one - ;; and there is none on its left. - ;; FIXME (ch11ng): Which direction is "left"? (nextw (elt exwm-workspace--list (+ index (if lastp -1 +1))))) ;; Need to remove the workspace from the list in order for ;; the correct calculation of indexes. diff --git a/exwm.el b/exwm.el index b6bc164..f7df651 100644 --- a/exwm.el +++ b/exwm.el @@ -214,8 +214,8 @@ (setq exwm--hints-urgency t)))) (when (and exwm--hints-urgency (not (eq exwm--frame exwm-workspace--current))) - (unless (frame-parameter exwm--frame 'exwm--urgency) - (set-frame-parameter exwm--frame 'exwm--urgency t) + (unless (frame-parameter exwm--frame 'exwm-urgency) + (set-frame-parameter exwm--frame 'exwm-urgency t) (setq exwm-workspace--switch-history-outdated t)))))))) (defun exwm--update-protocols (id &optional force) @@ -361,8 +361,8 @@ ((= type xcb:Atom:_NET_WM_MOVERESIZE) (let ((direction (elt data 2)) (buffer (exwm--id->buffer id))) - (unless (and buffer (with-current-buffer buffer - (not exwm--floating-frame))) + (unless (and buffer + (not (buffer-local-value 'exwm--floating-frame buffer))) (cond ((= direction xcb:ewmh:_NET_WM_MOVERESIZE_SIZE_KEYBOARD) ;; FIXME @@ -379,8 +379,7 @@ (let ((buffer (exwm--id->buffer id)) left right top btm) (if (or (not buffer) - (with-current-buffer buffer - (not exwm--floating-frame))) + (not (buffer-local-value 'exwm--floating-frame buffer))) (setq left 0 right 0 top 0 btm 0) (setq left exwm-floating-border-width right exwm-floating-border-width @@ -451,7 +450,7 @@ (when (memq xcb:Atom:_NET_WM_STATE_DEMANDS_ATTENTION props) (when (= action xcb:ewmh:_NET_WM_STATE_ADD) (unless (eq exwm--frame exwm-workspace--current) - (set-frame-parameter exwm--frame 'exwm--urgency t) + (set-frame-parameter exwm--frame 'exwm-urgency t) (setq exwm-workspace--switch-history-outdated t))) ;; xcb:ewmh:_NET_WM_STATE_REMOVE? ;; xcb:ewmh:_NET_WM_STATE_TOGGLE?