Minor cleanups

; Eliminate compile warnings.
; Rename frame parameter 'exwm--urgency' to 'exwm-urgency'.
; Simplify expressions.
This commit is contained in:
Chris Feng 2016-07-21 12:41:51 +08:00
parent 3909f65bae
commit 6571bb5761
6 changed files with 25 additions and 34 deletions

View file

@ -221,8 +221,7 @@
(setq mode-name (setq mode-name
'(:eval (propertize "EXWM" 'face '(:eval (propertize "EXWM" 'face
(when (cl-some (lambda (i) (when (cl-some (lambda (i)
(frame-parameter i (frame-parameter i 'exwm-urgency))
'exwm--urgency))
exwm-workspace--list) exwm-workspace--list)
'font-lock-warning-face)))) 'font-lock-warning-face))))
;; Change major-mode is not allowed ;; Change major-mode is not allowed

View file

@ -67,6 +67,7 @@
xcb:Atom:_NET_WM_ACTION_CLOSE))))) xcb:Atom:_NET_WM_ACTION_CLOSE)))))
(defvar exwm-workspace--current) (defvar exwm-workspace--current)
(defvar exwm-workspace--struts)
(declare-function exwm-layout--refresh "exwm-layout.el" ()) (declare-function exwm-layout--refresh "exwm-layout.el" ())
(declare-function exwm-layout--show "exwm-layout.el" (id &optional window)) (declare-function exwm-layout--show "exwm-layout.el" (id &optional window))
@ -96,8 +97,7 @@
(height . ,window-min-height) (height . ,window-min-height)
(unsplittable . t))))) ;and fix the size later (unsplittable . t))))) ;and fix the size later
(outer-id (string-to-number (frame-parameter frame 'outer-window-id))) (outer-id (string-to-number (frame-parameter frame 'outer-window-id)))
(container (with-current-buffer (exwm--id->buffer id) (container (buffer-local-value 'exwm--container (exwm--id->buffer id)))
exwm--container))
(frame-container (xcb:generate-id exwm--connection)) (frame-container (xcb:generate-id exwm--connection))
(window (frame-first-window frame)) ;and it's the only window (window (frame-first-window frame)) ;and it's the only window
(x (slot-value exwm--geometry 'x)) (x (slot-value exwm--geometry 'x))
@ -524,8 +524,8 @@
;; Unmanaged. ;; Unmanaged.
(eq major-mode 'exwm-mode)) (eq major-mode 'exwm-mode))
(let ((edges (window-inside-absolute-pixel-edges (frame-selected-window))) (let ((edges (window-inside-absolute-pixel-edges (frame-selected-window)))
(id (with-current-buffer (window-buffer (frame-selected-window)) (id (buffer-local-value 'exwm--id
exwm--id))) (window-buffer (frame-selected-window)))))
(xcb:+request exwm--connection (xcb:+request exwm--connection
(make-instance 'xcb:SendEvent (make-instance 'xcb:SendEvent
:propagate 0 :destination id :propagate 0 :destination id
@ -570,7 +570,7 @@
(setq container-or-id (setq container-or-id
(if (bufferp buffer-or-id) (if (bufferp buffer-or-id)
;; Managed. ;; Managed.
(with-current-buffer buffer-or-id exwm--container) (buffer-local-value 'exwm--container buffer-or-id)
;; Unmanaged. ;; Unmanaged.
buffer-or-id)) buffer-or-id))
(xcb:+request exwm--connection (xcb:+request exwm--connection

View file

@ -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)) (if (not (eq exwm--frame exwm-workspace--current))
;; Do not focus X windows on other workspace ;; Do not focus X windows on other workspace
(progn (progn
(set-frame-parameter exwm--frame 'exwm--urgency t) (set-frame-parameter exwm--frame 'exwm-urgency t)
(setq exwm-workspace--switch-history-outdated t) (setq exwm-workspace--switch-history-outdated t)
(force-mode-line-update) (force-mode-line-update)
;; The application may have changed its input focus ;; The application may have changed its input focus

View file

@ -420,8 +420,8 @@ manager is shutting down."
(xcb:+request exwm--connection (xcb:+request exwm--connection
(make-instance 'xcb:UnmapWindow :window exwm--container)) (make-instance 'xcb:UnmapWindow :window exwm--container))
(xcb:flush exwm--connection) (xcb:flush exwm--connection)
(run-with-timer exwm-manage-ping-timeout nil (run-with-timer exwm-manage-ping-timeout nil #'exwm-manage--kill-client
`(lambda () (exwm-manage--kill-client ,id))) id)
;; Wait for DestroyNotify event. ;; Wait for DestroyNotify event.
(throw 'return nil)) (throw 'return nil))
;; Try to determine if the X window is dead with _NET_WM_PING. ;; Try to determine if the X window is dead with _NET_WM_PING.

View file

@ -128,7 +128,7 @@ NIL if FRAME is not a workspace"
(int-to-string j) (int-to-string j)
'face 'face
(cond ((frame-parameter (elt exwm-workspace--list j) (cond ((frame-parameter (elt exwm-workspace--list j)
'exwm--urgency) 'exwm-urgency)
'(:foreground "orange")) '(:foreground "orange"))
((aref not-empty j) '(:foreground "green")) ((aref not-empty j) '(:foreground "green"))
(t nil))))) (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 (when exwm-workspace--fullscreen-frame-count
(cl-incf 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 () (defun exwm-workspace--resize-minibuffer-frame ()
"Resize minibuffer (and its container) to fit the size of workspace." "Resize minibuffer (and its container) to fit the size of workspace."
(cl-assert (exwm-workspace--minibuffer-own-frame-p)) (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) exwm-workspace-current-index index)
(unless (exwm-workspace--workspace-p (selected-frame)) (unless (exwm-workspace--workspace-p (selected-frame))
;; Save the floating frame window selected on the previous workspace. ;; Save the floating frame window selected on the previous workspace.
(set-frame-parameter (with-current-buffer (window-buffer) (set-frame-parameter (buffer-local-value 'exwm--frame (window-buffer))
exwm--frame)
'exwm-selected-window (selected-window))) 'exwm-selected-window (selected-window)))
(select-window window) (select-window window)
(set-frame-parameter frame 'exwm-selected-window nil) (set-frame-parameter frame 'exwm-selected-window nil)
@ -455,7 +459,7 @@ The optional FORCE option is for internal use only."
name name
(concat " " name))))))) (concat " " name)))))))
;; Update demands attention flag ;; Update demands attention flag
(set-frame-parameter frame 'exwm--urgency nil) (set-frame-parameter frame 'exwm-urgency nil)
;; Update switch workspace history ;; Update switch workspace history
(setq exwm-workspace--switch-history-outdated t) (setq exwm-workspace--switch-history-outdated t)
;; Set _NET_CURRENT_DESKTOP ;; 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) (assq (frame-parameter exwm-workspace--minibuffer 'exwm-container)
exwm-workspace--id-struts-alist)) 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 () (defun exwm-workspace-attach-minibuffer ()
"Attach the minibuffer so that it always shows." "Attach the minibuffer so that it always shows."
(interactive) (interactive)
@ -1126,10 +1125,8 @@ If the minibuffer is detached, this value is 0.")
(make-instance 'xcb:MapWindow :window workspace))) (make-instance 'xcb:MapWindow :window workspace)))
(xcb:flush exwm--connection) (xcb:flush exwm--connection)
;; Delay making the workspace fullscreen until Emacs becomes idle ;; Delay making the workspace fullscreen until Emacs becomes idle
(run-with-idle-timer 0 nil (run-with-idle-timer 0 nil #'set-frame-parameter
`(lambda () frame 'fullscreen 'fullboth)
(set-frame-parameter ,frame
'fullscreen 'fullboth)))
;; Update EWMH properties. ;; Update EWMH properties.
(exwm-workspace--update-ewmh-props) (exwm-workspace--update-ewmh-props)
(exwm-workspace-switch frame t) (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) (exwm--log "Removing frame `%s' as workspace" frame)
(let* ((index (exwm-workspace--position frame)) (let* ((index (exwm-workspace--position frame))
(lastp (= index (1- (exwm-workspace--count)))) (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))))) (nextw (elt exwm-workspace--list (+ index (if lastp -1 +1)))))
;; Need to remove the workspace from the list in order for ;; Need to remove the workspace from the list in order for
;; the correct calculation of indexes. ;; the correct calculation of indexes.

13
exwm.el
View file

@ -214,8 +214,8 @@
(setq exwm--hints-urgency t)))) (setq exwm--hints-urgency t))))
(when (and exwm--hints-urgency (when (and exwm--hints-urgency
(not (eq exwm--frame exwm-workspace--current))) (not (eq exwm--frame exwm-workspace--current)))
(unless (frame-parameter exwm--frame 'exwm--urgency) (unless (frame-parameter exwm--frame 'exwm-urgency)
(set-frame-parameter exwm--frame 'exwm--urgency t) (set-frame-parameter exwm--frame 'exwm-urgency t)
(setq exwm-workspace--switch-history-outdated t)))))))) (setq exwm-workspace--switch-history-outdated t))))))))
(defun exwm--update-protocols (id &optional force) (defun exwm--update-protocols (id &optional force)
@ -361,8 +361,8 @@
((= type xcb:Atom:_NET_WM_MOVERESIZE) ((= type xcb:Atom:_NET_WM_MOVERESIZE)
(let ((direction (elt data 2)) (let ((direction (elt data 2))
(buffer (exwm--id->buffer id))) (buffer (exwm--id->buffer id)))
(unless (and buffer (with-current-buffer buffer (unless (and buffer
(not exwm--floating-frame))) (not (buffer-local-value 'exwm--floating-frame buffer)))
(cond ((= direction (cond ((= direction
xcb:ewmh:_NET_WM_MOVERESIZE_SIZE_KEYBOARD) xcb:ewmh:_NET_WM_MOVERESIZE_SIZE_KEYBOARD)
;; FIXME ;; FIXME
@ -379,8 +379,7 @@
(let ((buffer (exwm--id->buffer id)) (let ((buffer (exwm--id->buffer id))
left right top btm) left right top btm)
(if (or (not buffer) (if (or (not buffer)
(with-current-buffer buffer (not (buffer-local-value 'exwm--floating-frame buffer)))
(not exwm--floating-frame)))
(setq left 0 right 0 top 0 btm 0) (setq left 0 right 0 top 0 btm 0)
(setq left exwm-floating-border-width (setq left exwm-floating-border-width
right exwm-floating-border-width right exwm-floating-border-width
@ -451,7 +450,7 @@
(when (memq xcb:Atom:_NET_WM_STATE_DEMANDS_ATTENTION props) (when (memq xcb:Atom:_NET_WM_STATE_DEMANDS_ATTENTION props)
(when (= action xcb:ewmh:_NET_WM_STATE_ADD) (when (= action xcb:ewmh:_NET_WM_STATE_ADD)
(unless (eq exwm--frame exwm-workspace--current) (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))) (setq exwm-workspace--switch-history-outdated t)))
;; xcb:ewmh:_NET_WM_STATE_REMOVE? ;; xcb:ewmh:_NET_WM_STATE_REMOVE?
;; xcb:ewmh:_NET_WM_STATE_TOGGLE? ;; xcb:ewmh:_NET_WM_STATE_TOGGLE?