Re: two new window-matchers



On Fri, 17 Sep 2010 20:27:23 +0200, Christopher Roy Bratusek wrote:
> I just added two new window-matchers:
> - fixed-size

It must be ok.

> - never-close

Let me propose this: the window won't be killed only when it's called
interactively. User has the right to choose between delete-window and
-safely as a binding to close-button, so revert the binding to
delete-window. Both fuctions (plus `delete-group' and
'delete-window-instance') respect never-close.

The attached patch implements this. You can commit it with
$ cat a.patch | git am 

Teika (Teika kazura)
>From ab6a8df4764ec6b7f59c637a8a31c2525e50ad7c Mon Sep 17 00:00:00 2001
From: Teika kazura <teika lavabit com>
Date: Tue, 21 Sep 2010 11:22:47 +0900
Subject: [PATCH] The window-property 'never-close' spec change.

It was only used in delete-window-safely. But now, this property is valid
for some others too, but only when they are called interactively. This
allows user to choose the mouse binding of "close-button".

The key binding of "close-button" is reverted to 'delete-window', the previous.
---
 ChangeLog                  |   11 +++++++++++
 lisp/sawfish/wm/keymaps.jl |    2 +-
 lisp/sawfish/wm/windows.jl |   24 ++++++++++++++----------
 3 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d22b048..97fdc75 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2010-09-21  Teika kazura <teika lavabit com>
+	* lisp/sawfish/wm/keymaps.jl
+	* lisp/sawfish/wm/windows.jl: window-property 'never-delete'
+	spec change.
+	It was only used in delete-window-safely. But now, this property
+	is valid for some others too, but only when they are called
+	interactively. This allows user to choose the mouse binding of
+	"close-button".
+        The key binding of "close-button" is reverted to 'delete-window',
+	the previous.
+
 2010-09-19  Christopher Bratusek <zanghar freenet de>
 	* lisp/sawfish/wm/ext/old-window-menu.jl: removed. it has been replaced
 	by beos-window-menu in version 0.28.1
diff --git a/lisp/sawfish/wm/keymaps.jl b/lisp/sawfish/wm/keymaps.jl
index 09c0496..32552ee 100644
--- a/lisp/sawfish/wm/keymaps.jl
+++ b/lisp/sawfish/wm/keymaps.jl
@@ -138,7 +138,7 @@ a window. (Only mouse-bindings are evaluated in this map.)"
   (defcustom close-button-keymap (bind-keys (make-keymap)
 				   "Button3-Click1" 'popup-window-menu
 				   "S-Button1-Off" 'delete-group
-				   "Button1-Off" 'delete-window-safely)
+				   "Button1-Off" 'delete-window)
     "Keymap containing bindings active when the pointer is in the close button
 of a window. (Only mouse-bindings are evaluated in this map.)"
     :group bindings
diff --git a/lisp/sawfish/wm/windows.jl b/lisp/sawfish/wm/windows.jl
index 9145680..28d7120 100644
--- a/lisp/sawfish/wm/windows.jl
+++ b/lisp/sawfish/wm/windows.jl
@@ -404,20 +404,24 @@ use. Otherwise (window-size-hints W) is used."
 ;;; deleting windows
 
   (define (delete-window w #!optional safely)
-    "Delete the window."
-    (cond
-     ((window-supports-wm-protocol-p w 'WM_DELETE_WINDOW)
-      (send-client-message w 'WM_PROTOCOLS (vector (x-atom 'WM_DELETE_WINDOW)
-						   (x-server-timestamp)) 32))
-     (safely (beep))
-     (t (x-kill-client w))))
+    "Delete a window. If the window does not support that protocol,
+kill the client."
+    (unless (and (memq this-command
+		       '(delete-window delete-window-safely
+			 delete-group delete-window-instance))
+		 (window-get w 'never-delete))
+      (cond
+       ((window-supports-wm-protocol-p w 'WM_DELETE_WINDOW)
+	(send-client-message w 'WM_PROTOCOLS (vector (x-atom 'WM_DELETE_WINDOW)
+						     (x-server-timestamp)) 32))
+       (safely (beep))
+       (t (x-kill-client w)))))
 
   (define-command 'delete-window delete-window #:spec "%W")
 
   (define (delete-window-safely w)
-    "Delete the window, or beep if the window can't be closed safely."
-    (if (not (window-get w 'never-delete))
-      (delete-window w t)))
+    "Delete a window, or beep if the window can't be closed safely."
+    (delete-window w t))
 
   (define-command 'delete-window-safely delete-window-safely #:spec "%W")
 
-- 
1.7.2.2



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