emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/exwm 48b15e2 1/2: Improve user options


From: Chris Feng
Subject: [elpa] externals/exwm 48b15e2 1/2: Improve user options
Date: Fri, 13 Sep 2019 14:01:08 -0400 (EDT)

branch: externals/exwm
commit 48b15e25ad9009b1135db6344de156ef4154758f
Author: Chris Feng <address@hidden>
Commit: Chris Feng <address@hidden>

    Improve user options
    
    * exwm-floating.el (exwm-floating-border-color)
    (exwm-floating-border-width): Make changes take effect w/o restart.
    (exwm-floating--init-border): Refactored out from
    `exwm-floating--init'.
    
    * exwm-workspace.el (exwm-workspace-minibuffer-position): Clarify
    a restart is required.
---
 exwm-floating.el  | 111 +++++++++++++++++++++++++++++++++++++++++-------------
 exwm-workspace.el |   4 +-
 2 files changed, 87 insertions(+), 28 deletions(-)

diff --git a/exwm-floating.el b/exwm-floating.el
index f4557eb..27ee574 100644
--- a/exwm-floating.el
+++ b/exwm-floating.el
@@ -44,20 +44,70 @@ context of the corresponding buffer."
 context of the corresponding buffer."
   :type 'hook)
 
+(defvar exwm-floating--border-pixel nil
+  "Border pixel drawn around floating X windows.")
+
 (defcustom exwm-floating-border-color "navy"
   "Border color of floating windows."
-  :type 'color)
+  :type 'color
+  :initialize #'custom-initialize-default
+  :set (lambda (symbol value)
+         (set-default symbol value)
+         ;; Change border color for all floating X windows.
+         (exwm-floating--init-border)
+         (dolist (pair exwm--id-buffer-alist)
+           (with-current-buffer (cdr pair)
+             (when exwm--floating-frame
+               (xcb:+request exwm--connection
+                   (make-instance 'xcb:ChangeWindowAttributes
+                                  :window
+                                  (frame-parameter exwm--floating-frame
+                                                   'exwm-container)
+                                  :value-mask xcb:CW:BorderPixel
+                                  :border-pixel
+                                  exwm-floating--border-pixel)))))
+         (when exwm--connection
+           (xcb:flush exwm--connection))))
 
 (defcustom exwm-floating-border-width 1
   "Border width of floating windows."
-  :type 'integer)
+  :type '(integer
+          :validate (lambda (widget)
+                      (when (< (widget-value widget) 0)
+                        (widget-put widget :error "Border width is at least 0")
+                        widget)))
+  :initialize #'custom-initialize-default
+  :set (lambda (symbol value)
+         (let ((delta (- value exwm-floating-border-width))
+               container)
+           (set-default symbol value)
+           ;; Change border width for all floating X windows.
+           (dolist (pair exwm--id-buffer-alist)
+             (with-current-buffer (cdr pair)
+               (when exwm--floating-frame
+                 (setq container (frame-parameter exwm--floating-frame
+                                                  'exwm-container))
+                 (with-slots (x y)
+                     (xcb:+request-unchecked+reply exwm--connection
+                         (make-instance 'xcb:GetGeometry
+                                        :drawable container))
+                   (xcb:+request exwm--connection
+                       (make-instance 'xcb:ConfigureWindow
+                                      :window container
+                                      :value-mask
+                                      (logior xcb:ConfigWindow:X
+                                              xcb:ConfigWindow:Y
+                                              xcb:ConfigWindow:BorderWidth)
+                                      :border-width value
+                                      :x (- x delta)
+                                      :y (- y delta)))))))
+           (when exwm--connection
+             (xcb:flush exwm--connection)))))
 
 (defvar exwm-floating--border-colormap nil
   "Colormap used by the border pixel.
 
 This is also used by X window containers.")
-(defvar exwm-floating--border-pixel nil
-  "Border pixel drawn around floating X windows.")
 
 ;; Cursors for moving/resizing a window
 (defvar exwm-floating--cursor-move nil)
@@ -679,32 +729,39 @@ Both DELTA-X and DELTA-Y default to 1.  This command 
should be bound locally."
                           nil nil))
     (xcb:flush exwm--connection)))
 
+(defun exwm-floating--init-border ()
+  "Initialize border colormap and pixel."
+  (exwm--log)
+  ;; Use the default colormap.
+  (unless exwm-floating--border-colormap
+    (with-slots (roots) (xcb:get-setup exwm--connection)
+      (with-slots (default-colormap) (car roots)
+        (setq exwm-floating--border-colormap default-colormap))))
+  ;; Free any previously allocated pixel.
+  (when exwm-floating--border-pixel
+    (xcb:+request exwm--connection
+        (make-instance 'xcb:FreeColors
+                       :cmap exwm-floating--border-colormap
+                       :plane-mask 0
+                       :pixels (vector exwm-floating--border-pixel)))
+    (setq exwm-floating--border-pixel nil))
+  ;; Allocate new pixel.
+  (let ((color (x-color-values (or exwm-floating-border-color "")))
+         reply)
+    (when color
+      (setq reply (xcb:+request-unchecked+reply exwm--connection
+                      (make-instance 'xcb:AllocColor
+                                     :cmap exwm-floating--border-colormap
+                                     :red (pop color)
+                                     :green (pop color)
+                                     :blue (pop color))))
+      (when reply
+        (setq exwm-floating--border-pixel (slot-value reply 'pixel))))))
+
 (defun exwm-floating--init ()
   "Initialize floating module."
   (exwm--log)
-  ;; Check border width.
-  (unless (and (integerp exwm-floating-border-width)
-               (> exwm-floating-border-width 0))
-    (setq exwm-floating-border-width 0))
-  ;; Initialize border pixel.
-  (when (> exwm-floating-border-width 0)
-    (setq exwm-floating--border-colormap
-          (slot-value (car (slot-value
-                            (xcb:get-setup exwm--connection) 'roots))
-                      'default-colormap))
-    (unless (stringp exwm-floating-border-color)
-      (setq exwm-floating-border-color ""))
-    (let* ((color (x-color-values exwm-floating-border-color))
-           reply)
-      (when color
-        (setq reply (xcb:+request-unchecked+reply exwm--connection
-                        (make-instance 'xcb:AllocColor
-                                       :cmap exwm-floating--border-colormap
-                                       :red (pop color)
-                                       :green (pop color)
-                                       :blue (pop color))))
-        (when reply
-          (setq exwm-floating--border-pixel (slot-value reply 'pixel))))))
+  (exwm-floating--init-border)
   ;; Initialize cursors for moving/resizing a window
   (xcb:cursor:init exwm--connection)
   (setq exwm-floating--cursor-move
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 7b18cde..ac4cb98 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -62,7 +62,9 @@ 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."
+  "Position of the minibuffer frame.
+
+A restart is required for this change to take effect."
   :type '(choice (const :tag "Bottom (fixed)" nil)
                  (const :tag "Bottom (auto-hide)" bottom)
                  (const :tag "Top (auto-hide)" top)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]