[sawfish] improve KDE3 Integration, remove hard-coded focus logic by focus-revert, update focus-modes against



commit a2117caef6f0b7f1c50039575e8d9872bc3ca669
Author: chrisb <zanghar freenet de>
Date:   Fri Jun 19 20:02:45 2009 +0200

    improve KDE3 Integration, remove hard-coded focus logic by focus-revert, update focus-modes against focus-revert [Timo Korvola]

 ChangeLog                          |    6 +++
 README.IMPORTANT                   |   11 ++++++
 lisp/sawfish/wm/focus.jl           |   47 +++++++++++++++++++++----
 lisp/sawfish/wm/state/transient.jl |   66 +++++++++++++++++------------------
 man/news.texi                      |    4 ++
 5 files changed, 92 insertions(+), 42 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index dc2a3ac..888fc50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,12 @@
 	* lisp/sawfish/wm/ext/match-window.jl: expose fixed-position,
 	never-iconify, never-maximize in the Window-Matcher UI
 
+	* lisp/sawfish/wm/focus.jl
+	* lisp/sawfish/wm/state/transient.jl: improve kde3 integration
+	and new focus-revert logic [Timo Korvola]
+
+	* README.IMPORTANT: Note about double-click in UI
+
 2009-06-01  Christopher Bratusek <zanghar freenet de>
 	* lisp/sawfish/gtk/widget.jl: UTF-8 Support
 
diff --git a/README.IMPORTANT b/README.IMPORTANT
index ac87451..d006b63 100644
--- a/README.IMPORTANT
+++ b/README.IMPORTANT
@@ -35,3 +35,14 @@ simply add the following flag to configure:
 (eg: ./configure --prefix=/usr --without-xorg-x11r7)
 
  - Christopher Bratusek <zanghar freenet de>
+
+Sawfish-UI GtkTree:
+*******************
+
+recently the old GtkNotebook UI has been replaced by a GtkTree
+UI, sadly this widget does currently not support single-clicking
+it, so you need to double-click it. 
+
+but: the old ui is -of course- still available, use:
+
+sawfish-ui --flatten
diff --git a/lisp/sawfish/wm/focus.jl b/lisp/sawfish/wm/focus.jl
index 4ee1732..9f10737 100644
--- a/lisp/sawfish/wm/focus.jl
+++ b/lisp/sawfish/wm/focus.jl
@@ -28,6 +28,7 @@
 	    focus-push-map
 	    focus-pop-map
 	    warp-pointer-if-necessary
+           focus-revert
 	    focus-within-click-event)
 
     (open rep
@@ -77,7 +78,8 @@ click-to-focus button press event.")
 used to implement this focus mode, it will be called with arguments `(WINDOW
 EVENT-NAME)', where EVENT-NAME may be one of the following symbols:
 `pointer-in', `pointer-out', `focus-in', `focus-out', `add-window'
-`before-mode-change', `after-mode-change'"
+`before-mode-change', `after-mode-change', `warp-if-necessary' and
+`focus-revert'."
 
     (unless (memq name focus-modes)
       (setq focus-modes (nconc focus-modes (list name))))
@@ -132,13 +134,22 @@ EVENT-NAME)', where EVENT-NAME may be one of the following symbols:
   (define (warp-pointer-if-necessary #!optional (w (input-focus)))
     (focus-invoke-mode w 'warp-if-necessary))
 
+  ;; Put focus in some window that hopefully feels natural.  This is
+  ;; typically used when the window in focus has disappeared.  Thus
+  ;; there is no reference window.
+  (define (focus-revert)
+    (let ((fun (focus-mode-ref focus-mode)))
+      (when fun (fun nil 'focus-revert))))
+
 ;;; modes
 
   (define-focus-mode 'enter-exit
     (lambda (w action . args)
       (case action
 	((pointer-in)
-	 (when (window-really-wants-input-p w)
+	 (when (and (window-really-wants-input-p w)
+                    ;; ignore grab/ungrab enter events
+                    (eq (car args) 'normal))
 	   (set-input-focus w)))
 	((pointer-out)
 	 ;; ignore grab/ungrab leave events
@@ -149,18 +160,33 @@ EVENT-NAME)', where EVENT-NAME may be one of the following symbols:
 	 (set-input-focus w))
 	((warp-if-necessary)
 	 (unless (eq (query-pointer-window) w)
-	   (warp-cursor-to-window w))))))
+	   (warp-cursor-to-window w)))
+        ((focus-revert)
+         (setq w (query-pointer-window))
+         (when (or (null w)
+                   (window-really-wants-input-p w))
+           (set-input-focus w))))))
 
   (define-focus-mode 'enter-only
-    (lambda (w action)
+    (lambda (w action . args)
       (case action
 	((pointer-in)
-	 (when (window-really-wants-input-p w)
+	 (when (and (window-really-wants-input-p w)
+                    ;; ignore grab/ungrab enter events
+                    (eq (car args) 'normal))
 	   (set-input-focus w)))
 	((warp-if-necessary)
 	 (let ((current (query-pointer-window)))
 	   (unless (or (eq current w) (desktop-window-p current))
-	     (warp-cursor-to-window w)))))))
+	     (warp-cursor-to-window w))))
+        ((focus-revert)
+         (setq w (query-pointer-window))
+         (when (or (null w)
+                   (desktop-window-p w))
+           (setq w (window-order-most-recent)))
+         (when (or (null w)
+                   (window-really-wants-input-p w))
+           (set-input-focus w))))))
 
   (define (focus-click)
     (let ((w (current-event-window))
@@ -212,12 +238,17 @@ EVENT-NAME)', where EVENT-NAME may be one of the following symbols:
 	((after-mode-change)
 	 (unless (or (not (window-really-wants-input-p w))
 		     (eq w (input-focus)))
-	   (focus-push-map w click-to-focus-map))))))
+	   (focus-push-map w click-to-focus-map)))
+        ((focus-revert)
+         (setq w (window-order-most-recent))
+         (when (or (null w)
+                   (window-really-wants-input-p w))
+           (set-input-focus w))))))
 
   (define-focus-mode 'enter-click
     (lambda (w action . args)
       (case action
-        ((pointer-in warp-if-necessary)
+        ((pointer-in warp-if-necessary focus-revert)
          (apply (focus-mode-ref 'enter-only) w action args))
         ((focus-in focus-out add-window before-mode-change after-mode-change)
          (apply (focus-mode-ref 'click) w action args)))))
diff --git a/lisp/sawfish/wm/state/transient.jl b/lisp/sawfish/wm/state/transient.jl
index 25f397b..d308d4e 100644
--- a/lisp/sawfish/wm/state/transient.jl
+++ b/lisp/sawfish/wm/state/transient.jl
@@ -37,6 +37,7 @@
 	  sawfish.wm.events
 	  sawfish.wm.custom
 	  sawfish.wm.commands
+         sawfish.wm.focus
 	  sawfish.wm.windows
 	  sawfish.wm.stacking
 	  sawfish.wm.viewport
@@ -154,22 +155,29 @@ the level of any transient windows it has."
 
 ;;; hooks
 
+  ;; 1. Transients of the currently focused window get focus.
+  ;; 2. Transients of root belonging to the same window group as the
+  ;;    currently focused window get focus, unless the currently focused
+  ;;    window is also transient (wacky special case code in transient-of-p).
+  ;; 3. Other transients for root, transients for a desktop window
+  ;;    or non-transients may get focus depending on options (yes, we
+  ;;    also handle non-transients).
   (define (transient-map-window w)
-    (cond ((and (window-transient-p w)
-		(window-really-wants-input-p w)
-		(window-visible-p w)
-		(input-focus)
-		(transient-of-p w (input-focus) #:allow-root t))
-	   (set-input-focus w))
-	  ((and (or (and focus-windows-when-mapped
-			 (not (window-get w 'never-focus))
-			 (not (window-get w 'inhibit-focus-when-mapped)))
-		    (window-get w 'focus-when-mapped))
-		(or (not (window-transient-p w))
-		    (eql (window-transient-p w) (root-window-id)))
-		(window-really-wants-input-p w)
-		(window-visible-p w))
-	   (set-input-focus w))))
+    (when (and (window-really-wants-input-p w)
+               (window-visible-p w)
+               (or (let ((focus (input-focus)))
+                     (and focus (transient-of-p w focus #:allow-root t)))
+                   (let ((x-for-id (window-transient-p w)))
+                     (and (or (not x-for-id)
+                              (eql x-for-id (root-window-id))
+                              (let ((x-for (get-window-by-id x-for-id)))
+                                (and x-for (window-get x-for 'desktop))))
+                          (or (and
+                               focus-windows-when-mapped
+                               (not (window-get w 'never-focus))
+                               (not (window-get w 'inhibit-focus-when-mapped)))
+                              (window-get w 'focus-when-mapped))))))
+      (set-input-focus w)))
 
   ;; If a transient window gets unmapped that currently has the input
   ;; focus, pass it (the focus) to its parent. Otherwise, pass the focus
@@ -184,25 +192,15 @@ the level of any transient windows it has."
 			 (or (window-order-most-recent
 			      #:windows (delq w (windows-in-group w)))
 			     (get-window-by-id (window-transient-p w))))))
-	(when (or (not parent)
-		  (not (window-mapped-p parent))
-		  (not (window-visible-p parent))
-		  (window-outside-viewport-p parent)
-		  (not (window-really-wants-input-p parent)))
-	  ;; if no parent, choose the topmost window (if in click-to-focus
-	  ;; mode) or the window under the pointer otherwise
-	  (if (eq focus-mode 'click)
-	      (setq parent nil)
-	    (setq parent (query-pointer-window))
-	    (when (and (eq focus-mode 'enter-only)
-		       parent (desktop-window-p parent))
-	      ;; in sloppy-focus mode, don't want to focus on the
-	      ;; desktop window just because the pointer is under it
-	      (setq parent nil)))
-	  (unless (or parent (eq focus-mode 'enter-exit))
-	    (setq parent (window-order-most-recent))))
-	(when (or (null parent) (window-really-wants-input-p parent))
-	  (set-input-focus parent)))))
+	(if (and parent
+                 (window-mapped-p parent)
+                 (window-visible-p parent)
+                 (not (window-outside-viewport-p parent))
+                 (window-really-wants-input-p parent)
+                 (not (window-get parent 'desktop)))
+            (set-input-focus parent)
+          ;; No parent to give focus back to.
+          (focus-revert)))))
 
   (add-hook 'map-notify-hook transient-map-window)
   (add-hook 'unmap-notify-hook transient-unmap-window)
diff --git a/man/news.texi b/man/news.texi
index 36c1994..56aae2f 100644
--- a/man/news.texi
+++ b/man/news.texi
@@ -83,6 +83,10 @@ To use the old style, put @code{(define-special-variable customize-program "sawf
 
 @item Tabbed Windowing Support [Yann Hodique, Scott Scriven, Nathan Froyd, Christopher Bratusek]
 
+ item Improved KDE3 Integration [Timo Korvola]
+
+ item Replaced hardcoded focus logic by focus-revert function [Timo Korvola]
+
 @item Tabbed Windowing Support: Raise Tabs on hover [Christopher Bratusek]
 
 @item Warp cursor to cycled windows, if warp-cursor is enabled [Christopher Bratusek]



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