Re: [Sawfish] Keeping the correct focus on desktop switch

[ Thread Index | Date Index | More lists.tuxfamily.org/sawfish Archives ]


Hi,

On Sun, 15 Dec 2013 11:45:34 +0100
wrote "Robert 'Bobby' Zenz" <Robert.Zenz@xxxxxxxxxxxxxx>:

>Thanks for looking.
>So if I understand that comment right, sticky windows are
>floating to the top of the window list if they were focused once? That
>sounds complicated to fix.
>
>Personally I wouldn't give sticky windows a different weight in the
>window ordering/focus order at all, would it be possible to treat them
>like every other window on the workspace? I think that should solve the
>problem, but will most likely raise others (actually it sounds
>like opening a can of worms, to be honest)...like when switching
>workspaces with a sticky window focused.
>
>Well, let's start simple, here's my opinion on how it should behave:
>If a non-sticky window is focused, it should obviously lose the focus
>when switching workspaces and regain the focus after returning to that
>workspace. If a sticky window is focused, it should keep the focus even
>when switching workspaces, basically "overwriting" the last focused
>window on the workspace.
>
>Or did I misunderstand something along the way?
>


What happened by sticky windows:
"on-viewport-change" set the order by the window to nil. If you change
the workspace the sticky window lost the focus and the window in order
after the sticky window got the focus (if available). This patch record
the window with the focus on each workspace before you switch the
workspace and if you reenter the workspace the record window (that with
the focus) got the focus back (and also the window order after the
focus window should correct, except a sticky window was focused on a
other workspace it will raise in the order after the (recorded) focus
window on the other workspaces ...). But patch need more testing.

-- 
Regards,
Fuchur

GPG Fingerprint: CA3B 8204 5B3E 6D48 6D53  C116 E5BC 70D5 B8D7 B2B0
--- sawfish/lisp/sawfish/wm/util/window-order.jl.orgi
+++ sawfish/lisp/sawfish/wm/util/window-order.jl
@@ -90,29 +90,35 @@
     (let loop ((rest (window-order current-workspace nil)))
       (cond ((null rest) nil)
 	    ((or (window-get (car rest) 'never-focus)
+             (dock-window-p (car rest));; panel/pager workspace switcher
 		 (and (listp windows) (not (memq (car rest) windows))))
 	     (loop (cdr rest)))
 	    (t (car rest)))))
 
   (define (window-order-focus-most-recent)
     (set-input-focus (window-order-most-recent)))
-
-  (define (on-viewport-change)
-    ;; The problem is that any sticky windows that have been focused once
-    ;; will _always_ rise to the top of the order when switching viewports
-    ;; (since the topmost window is _always_ focused when entering a new
-    ;; workspace). The hacky solution is to remove the order of any sticky
-    ;; windows
-    (let ((order (window-order current-workspace)))
-      (mapc (lambda (w)
-	      (when (window-get w 'sticky-viewport)
-		(window-put w 'order nil))) order))
+  
+  ;; The problem is that any sticky windows that have been focused once
+  ;; will _always_ rise to the top of the order when switching viewports
+  ;; (since the topmost window is _always_ focused when entering a new
+  ;; workspace). The hacky solution is to record the "input-focus" window
+  ;; if leave a workspace and restore if reenter the workspace. 
+  (define focus-most-recent-at-workspace nil)
+  (define (record-focus-most-recent-at-workspace)
+    (setq focus-most-recent-at-workspace 
+          (remove (assoc (car (list current-workspace)) focus-most-recent-at-workspace) 
+                  focus-most-recent-at-workspace))
+    (setq focus-most-recent-at-workspace 
+          (append focus-most-recent-at-workspace 
+                  (cons (cons (car (list current-workspace)) (window-order-most-recent))))))
+  (define (restore-focus-most-recent-at-workspace)
     (unless (eq focus-mode 'enter-exit)
-      (window-order-focus-most-recent)))
+      (set-input-focus (cdr (assoc (car (list current-workspace)) focus-most-recent-at-workspace)))))
 
   (sm-add-saved-properties 'order)
   (add-swapped-properties 'order)
 
   (add-hook 'sm-after-restore-hook window-order-compress)
   (add-hook 'iconify-window-hook window-order-pop)
-  (add-hook 'viewport-moved-hook on-viewport-change))
+  (add-hook 'leave-workspace-hook record-focus-most-recent-at-workspace)
+  (add-hook 'enter-workspace-hook restore-focus-most-recent-at-workspace))

Attachment: signature.asc
Description: PGP signature



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/