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

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

[elpa] externals/exwm dbc06b5 2/2: Add initial support for per-applicati


From: Chris Feng
Subject: [elpa] externals/exwm dbc06b5 2/2: Add initial support for per-application configurations
Date: Thu, 1 Mar 2018 11:57:32 -0500 (EST)

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

    Add initial support for per-application configurations
    
    * exwm-core.el (exwm--configurations): New buffer-local variable
    recording the configurations of an X window.
    * exwm-manage.el (exwm-manage-configurations): New user option as the
    per-application configurations.
    (exwm-manage--get-configurations): New function for fetching the
    configurations of this X window.
    (exwm-manage--manage-window): Fetch the configurations and check if
    the X window should be floating/tiling.
---
 exwm-core.el   |  1 +
 exwm-manage.el | 50 +++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/exwm-core.el b/exwm-core.el
index 649ef04..0f48de2 100644
--- a/exwm-core.el
+++ b/exwm-core.el
@@ -130,6 +130,7 @@ least SECS seconds later."
 
 ;; Internal variables
 (defvar-local exwm--id nil)               ;window ID
+(defvar-local exwm--configurations nil)   ;initial configurations.
 (defvar-local exwm--frame nil)            ;workspace frame
 (defvar-local exwm--floating-frame nil)   ;floating frame
 (defvar-local exwm--mode-line-format nil) ;save mode-line-format
diff --git a/exwm-manage.el b/exwm-manage.el
index 64f8028..3954d3e 100644
--- a/exwm-manage.el
+++ b/exwm-manage.el
@@ -47,6 +47,26 @@ You can still make the X windows floating afterwards."
   "Seconds to wait before killing a client."
   :type 'integer)
 
+(defcustom exwm-manage-configurations nil
+  "Per-application configurations."
+  :type '(alist :key-type (sexp :tag "Matching criterion" nil)
+                :value-type
+                (plist :tag "Configurations"
+                       :key-type
+                       (choice
+                        (const :tag "Floating" floating)
+                        (const :tag "X" x)
+                        (const :tag "Y" y)
+                        (const :tag "Width" width)
+                        (const :tag "Height" height)
+                        (const :tag "Border width" border-width)
+                        (const :tag "Char-mode" char-mode)
+                        (const :tag "Prefix keys" prefix-keys)
+                        (const :tag "Simulation keys" simulation-keys)
+                        ;; For forward compatibility.
+                        (other))
+                       :value-type (sexp :tag "Value" nil))))
+
 ;; FIXME: Make the following values as small as possible.
 (defconst exwm-manage--height-delta-min 5)
 (defconst exwm-manage--width-delta-min 5)
@@ -140,6 +160,14 @@ You can still make the X windows floating afterwards."
                      :window exwm--root
                      :data (vconcat (mapcar #'car exwm--id-buffer-alist)))))
 
+(cl-defun exwm-manage--get-configurations ()
+  "Retrieve configurations for this buffer."
+  (when (derived-mode-p 'exwm-mode)
+    (dolist (i exwm-manage-configurations)
+      (save-current-buffer
+        (when (eval (car i))
+          (cl-return-from exwm-manage--get-configurations (cdr i)))))))
+
 (defun exwm-manage--manage-window (id)
   "Manage window ID."
   (exwm--log "Try to manage #x%x" id)
@@ -169,6 +197,7 @@ You can still make the X windows floating afterwards."
       (exwm--update-hints id)
       (exwm-manage--update-geometry id)
       (exwm-manage--update-mwm-hints id)
+      (setq exwm--configurations (exwm-manage--get-configurations))
       ;; No need to manage (please check OverrideRedirect outside)
       (when (or
              (not
@@ -252,13 +281,20 @@ You can still make the X windows floating afterwards."
       (xcb:flush exwm--connection)
       (exwm--update-title id)
       (exwm--update-protocols id)
-      (if (and (not exwm-manage-force-tiling)
-               (or exwm-transient-for exwm--fixed-size
-                   (memq xcb:Atom:_NET_WM_WINDOW_TYPE_UTILITY exwm-window-type)
-                   (memq xcb:Atom:_NET_WM_WINDOW_TYPE_DIALOG
-                         exwm-window-type)))
-          (exwm-floating--set-floating id)
-        (exwm-floating--unset-floating id))
+      (if (plist-member exwm--configurations 'floating)
+          ;; User has specified whether it should be floating.
+          (if (plist-get exwm--configurations 'floating)
+              (exwm-floating--set-floating id)
+            (exwm-floating--unset-floating id))
+        ;; Try to determine if it should be floating.
+        (if (and (not exwm-manage-force-tiling)
+                 (or exwm-transient-for exwm--fixed-size
+                     (memq xcb:Atom:_NET_WM_WINDOW_TYPE_UTILITY
+                           exwm-window-type)
+                     (memq xcb:Atom:_NET_WM_WINDOW_TYPE_DIALOG
+                           exwm-window-type)))
+            (exwm-floating--set-floating id)
+          (exwm-floating--unset-floating id)))
       (exwm-input-grab-keyboard id)
       (setq exwm-workspace--switch-history-outdated t)
       (exwm--update-desktop id)



reply via email to

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