From 55cec760ca3cee21e735bff9a9a5229b222b97ff Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Sun, 21 Feb 2016 20:19:45 +0800 Subject: [PATCH] Fix emacsclient related issues * exwm-systemtray.el (exwm-systemtray-height): The value is not available when emacsclient has just loaded the library (and it crashes emacsclient). * exwm-workspace.el (exwm-workspace--init): Set `default-minibuffer-frame' later to prevent it from being modified when using emacsclient. * exwm-floating.el: * exwm-randr.el: * exwm-systemtray.el: * exwm-workspace.el: * exwm.el: Use `exwm-workspace--minibuffer-own-frame-p' instead of the raw variable. --- exwm-floating.el | 3 +-- exwm-randr.el | 3 +-- exwm-systemtray.el | 14 +++++++------- exwm-workspace.el | 9 +++++---- exwm.el | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/exwm-floating.el b/exwm-floating.el index 97d673c..b562019 100644 --- a/exwm-floating.el +++ b/exwm-floating.el @@ -53,7 +53,6 @@ (defvar exwm-workspace--list) (defvar exwm-workspace-current-index) (defvar exwm-workspace--switch-history-outdated) -(defvar exwm-workspace-minibuffer-position) (declare-function exwm-layout--refresh "exwm-layout.el") (declare-function exwm-layout--show "exwm-layout.el") @@ -104,7 +103,7 @@ ;; FIXME: check normal hints restrictions (let* ((display-width (frame-pixel-width original-frame)) (display-height (- (frame-pixel-height original-frame) - (if exwm-workspace-minibuffer-position + (if (exwm-workspace--minibuffer-own-frame-p) 0 (window-pixel-height (minibuffer-window original-frame))) diff --git a/exwm-randr.el b/exwm-randr.el index 7f9b443..e761d8f 100644 --- a/exwm-randr.el +++ b/exwm-randr.el @@ -54,7 +54,6 @@ (defvar exwm-randr-refresh-hook nil "Normal hook run when the RandR module just refreshed.") -(defvar exwm-workspace-minibuffer-position) (defvar exwm-layout--fullscreen-frame-count) (defvar exwm-workspace-number) (defvar exwm-workspace--list) @@ -94,7 +93,7 @@ (setq default-geometry geometry))))))) (exwm--log "(randr) outputs: %s" output-plist) (when output-plist - (setq workarea-offset (if exwm-workspace-minibuffer-position + (setq workarea-offset (if (exwm-workspace--minibuffer-own-frame-p) 0 (window-pixel-height (minibuffer-window)))) (setq exwm-layout--fullscreen-frame-count 0) diff --git a/exwm-systemtray.el b/exwm-systemtray.el index e9a9745..861304a 100644 --- a/exwm-systemtray.el +++ b/exwm-systemtray.el @@ -43,9 +43,7 @@ ;; GTK icons require at least 16 pixels to show normally. (defconst exwm-systemtray--icon-min-size 16 "Minimum icon size.") -(defvar exwm-systemtray-height (max exwm-systemtray--icon-min-size - (line-pixel-height)) - "System tray height. +(defvar exwm-systemtray-height nil "System tray height. You shall use the default value if using auto-hide minibuffer.") @@ -258,12 +256,11 @@ You shall use the default value if using auto-hide minibuffer.") (t (exwm--log "(System Tray) Unknown opcode message: %s" obj))))))) -(defvar exwm-workspace-minibuffer-position) (defvar exwm-workspace--current) (defun exwm-systemtray--on-workspace-switch () "Reparent/Refresh the system tray in `exwm-workspace-switch-hook'." - (unless exwm-workspace-minibuffer-position + (unless (exwm-workspace--minibuffer-own-frame-p) (xcb:+request exwm-systemtray--connection (make-instance 'xcb:ReparentWindow :window exwm-systemtray--embedder @@ -277,7 +274,7 @@ You shall use the default value if using auto-hide minibuffer.") (defun exwm-systemtray--on-randr-refresh () "Reposition/Refresh the system tray in `exwm-randr-refresh-hook'." - (unless exwm-workspace-minibuffer-position + (unless (exwm-workspace--minibuffer-own-frame-p) (xcb:+request exwm-systemtray--connection (make-instance 'xcb:ConfigureWindow :window exwm-systemtray--embedder @@ -295,6 +292,9 @@ You shall use the default value if using auto-hide minibuffer.") (cl-assert (not exwm-systemtray--list)) (cl-assert (not exwm-systemtray--selection-owner-window)) (cl-assert (not exwm-systemtray--embedder)) + (unless exwm-systemtray-height + (setq exwm-systemtray-height (max exwm-systemtray--icon-min-size + (line-pixel-height)))) ;; Create a new connection. (setq exwm-systemtray--connection (xcb:connect-to-socket)) (set-process-query-on-exit-flag (slot-value exwm-systemtray--connection @@ -345,7 +345,7 @@ You shall use the default value if using auto-hide minibuffer.") :border-width 0 :class xcb:WindowClass:CopyFromParent :visual 0 :value-mask xcb:CW:EventMask :event-mask xcb:EventMask:SubstructureNotify)) - (if exwm-workspace-minibuffer-position + (if (exwm-workspace--minibuffer-own-frame-p) (setq parent (frame-parameter exwm-workspace--minibuffer 'exwm-container) ;; Vertically centered. diff --git a/exwm-workspace.el b/exwm-workspace.el index 99bc605..07bfdd9 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -274,7 +274,7 @@ The optional FORCE option is for internal use only." (frame-parameter frame 'exwm-workspace) :x x :y y)) (xcb:flush exwm--connection) - (unless exwm-workspace-minibuffer-position + (unless (exwm-workspace--minibuffer-own-frame-p) ;; The frame needs to be recreated since it won't use the ;; minibuffer on the new workspace. (let* ((old-frame exwm--floating-frame) @@ -567,7 +567,7 @@ This functions is modified from `display-buffer-reuse-window' and (xcb:+request exwm--connection (make-instance 'xcb:MapWindow :window (car i)))) ;; Reparent out the minibuffer frame. - (when exwm-workspace-minibuffer-position + (when (exwm-workspace--minibuffer-own-frame-p) (xcb:+request exwm--connection (make-instance 'xcb:ReparentWindow :window (frame-parameter exwm-workspace--minibuffer @@ -614,13 +614,14 @@ This functions is modified from `display-buffer-reuse-window' and (setq exwm-workspace--minibuffer (make-frame '((window-system . x) (minibuffer . only) (left . 10000) (right . 10000) - (width . 0) (height . 0))) - default-minibuffer-frame exwm-workspace--minibuffer) + (width . 0) (height . 0)))) ;; Remove/hide existing frames. (dolist (f old-frames) (if (frame-parameter f 'client) (make-frame-invisible f) (delete-frame f)))) + ;; This is the only usable minibuffer frame. + (setq default-minibuffer-frame exwm-workspace--minibuffer) (let ((outer-id (string-to-number (frame-parameter exwm-workspace--minibuffer 'outer-window-id))) diff --git a/exwm.el b/exwm.el index b425acf..d3d2c10 100644 --- a/exwm.el +++ b/exwm.el @@ -462,7 +462,7 @@ (let* ((workareas (vector 0 0 (x-display-pixel-width) (- (x-display-pixel-height) - (if exwm-workspace-minibuffer-position + (if (exwm-workspace--minibuffer-own-frame-p) 0 (window-pixel-height (minibuffer-window)))))) (workareas (mapconcat (lambda (_) workareas)