stumpwm-devel
[Top][All Lists]
Advanced

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

[STUMP] [PATCH] redisplay functionality - window size increment hints


From: Michael Raskin
Subject: [STUMP] [PATCH] redisplay functionality - window size increment hints
Date: Wed, 29 Oct 2008 10:43:41 +0300
User-agent: Thunderbird 2.0.0.16 (X11/20080904)

                Hello
        I added some support for window size increment hints in redisplay
command. I must note, that frame resizing ignores those hints when
resizing window in a frame...
>From 4978b3f1bb6cc9b896df7a315e158945385d9c50 Mon Sep 17 00:00:00 2001
From: 38a938c2 <address@hidden>
Date: Wed, 29 Oct 2008 10:30:44 +0300
Subject: [PATCH] Updated redisplay command

---
 bindings.lisp |    4 ++-
 window.lisp   |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/bindings.lisp b/bindings.lisp
index 3d3577c..eb9ebef 100644
--- a/bindings.lisp
+++ b/bindings.lisp
@@ -135,7 +135,9 @@ from most specific groups to most general groups.")
   (kbd "#")   "mark"
   (kbd "F11") "fullscreen"
   (kbd "A")   "title"
-  (kbd "i")   "info")
+  (kbd "i")   "info"
+  (kbd "l")   "redisplay"
+  )
 
 (fill-keymap *tile-group-top-map*
   *escape-key* '*tile-group-root-map*)
diff --git a/window.lisp b/window.lisp
index cb7157e..9fb9da3 100644
--- a/window.lisp
+++ b/window.lisp
@@ -534,6 +534,66 @@ and bottom_end_x."
       (update xlib:drawable-border-width nil border-width)
       )))
 
+(defun to-top-left-corner (window)
+  "Move the window to the top left corner of corresponding frame."
+  (let ((frame (window-frame window)))
+    (set-window-geometry window
+      :x (frame-x frame)
+      :y (frame-y frame))))
+
+(defun window-width-inc (window)
+  "Find out what is the correct step to change window width"
+  (or
+    (xlib:wm-size-hints-width-inc (window-normal-hints window))
+    1))
+
+(defun window-height-inc (window)
+  "Find out what is the correct step to change window height"
+  (or
+    (xlib:wm-size-hints-height-inc (window-normal-hints window))
+    1))
+
+(defun window-allowed-width (window desired-width)
+  "Find the closest allowed width not more than desired-width"
+  (- desired-width (mod desired-width (window-width-inc window))))
+
+(defun window-allowed-height (window desired-height)
+  "Find the closest allowed height not more than desired-height"
+  (- desired-height (mod desired-height (window-height-inc window))))
+
+(defun fill-frame (window)
+  "Resize the window to occupy entire frame."
+  (to-top-left-corner window)
+  (let ((frame (window-frame window)))
+    (set-window-geometry window
+      :width (window-allowed-width window (frame-width frame))
+      :height (window-allowed-height window (frame-height frame))
+      )))
+
+(defcommand refresh () ()
+  "Refresh current window without changing its size"
+  (let* ((window (current-window))
+         (w (window-width window))
+         (h (window-height window)))
+    (set-window-geometry window
+      :width (- w (window-width-inc window))
+      :height (- h (window-height-inc window)))
+    (maximize-window window)
+    (set-window-geometry window
+      :width w
+      :height h)
+    (maximize-window window)))
+
+(defcommand redisplay () ()
+  "Refresh current window by a pair of resizes, also make it occupy entire 
frame."
+  (let ((window (current-window)))
+    (set-window-geometry window
+      :width (- (window-width window) (window-width-inc window))
+      :height (- (window-width window) (window-height-inc window)))
+    (maximize-window window)
+    (fill-frame window)
+    (maximize-window window)))
+
 (defun find-free-window-number (group)
   "Return a free window number for GROUP."
   (find-free-number (mapcar 'window-number (group-windows group))))
-- 
1.6.0.2


reply via email to

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