Wikia

Sawfish

Display worskpace when cycling

773pages on
this wiki
Talk0
Browse all patches

Author Edit

Daniel M German (Updated by Teika kazura)

Synopsis Edit

This patch adds 2 features that work in tandem:

1. display-wininfo displays the workspace in which the window lies. (if the display-wininfo-show-workspace variable is not nil)

2. the option to indicate if one should switch to a different workspace when cycling windows (like when using Alt-Tab). This option is enabled only if cycle-switch-workspaces is nil.

I have checked and only x-cycle uses display-wininfo, so this patch should have no side effects.

Update July 23, 10:31. I have updated the patch. If the variable cycle-show-window-names is nil (user wants no name of window displayed when cycling) AND cycle-switch-workspaces is nil (user does not want to momentarily switch workspaces) then the title of the window is displayed (otherwise there is no visual clue).

Patch testing Edit

  1. Copy/paste the patch listed below into some file, eg. TEST.diff.
  2. If you don't have sawfish sources yet, have one, as described get it from GIT repo.
  3. Go into the directory where sawfish sources reside, eg. cd sawfish
  4. Test if the patch applies cleanly with this command:
    patch -p1 --ignore-whitespace --dry-run < TEST.diff
    in case of problems try also: -p0 or -p2
  5. If it applies cleanly, then remove the --dry-run from above command and run it again, otherwise ask on the mailing list.
  6. Compile sawfish: ./autogen.sh && make
  7. Install it for testing, but it depends on your linux distribution.
    1. It is always better to install sawfish as your distribution package, but it is different for each distribution.
    2. So you may try make install, which will install sawifish in /usr/local/share/sawfish/ (if you have write access). But then make sure that you run the correct version and delete it from that directory afterwards, to avoid any conflicts.
  8. Se also

PS: edit this template if you feel that those instructions can be improved.

diff --git a/lisp/sawfish/wm/commands/x-cycle.jl b/lisp/sawfish/wm/commands/x-cycle.jl
index bc72ce3..dbffb64 100644
--- a/lisp/sawfish/wm/commands/x-cycle.jl
+++ b/lisp/sawfish/wm/commands/x-cycle.jl
@@ -119,6 +119,11 @@
     :group (focus cycle)
     :type boolean)
 
+  (defcustom cycle-switch-workspaces t
+    "Switch temporarily to the workspace where the window is (except for windows that really want focus)."
+    :group (focus cycle)
+    :type boolean)
+
   (defcustom cycle-raise-windows t
     "Raise windows while they're temporarily selected during cycling."
     :type boolean
@@ -196,20 +201,47 @@
           (setq win (forwards win (fluid x-cycle-current) count))
         (setq win (car win)))
       (fluid-set x-cycle-current win)
-      (when (not (window-get win 'sticky))
-        (select-workspace (nearest-workspace-with-window
-                           win current-workspace)))
-      (move-viewport-to-window win)
-      (when (window-get win 'iconified)
-        (show-window win))
-      (when cycle-raise-windows
-        (fluid-set x-cycle-stacking (stacking-order))
-        (warp-pointer-if-necessary win)
-        (raise-window* win))
-      (when cycle-show-window-names
-        (cycle-display-message))
-      (when (window-really-wants-input-p win)
-        (set-input-focus win))
+
+      ;; weird combinations of variables might mean that sometimes
+      ;; we display window names, and we sometimes do not.
+      ;; so clean up before the next window is cycled
+      (remove-message)
+
+      (if cycle-switch-workspaces
+	  (progn
+	    (when (not (window-get win 'sticky))
+	      ;; switch workspace if we have to
+	      (select-workspace (nearest-workspace-with-window
+				 win current-workspace)))
+	    (move-viewport-to-window win)
+	    (when (window-get win 'iconified)
+	      (show-window win))
+	    (when cycle-raise-windows
+	      (fluid-set x-cycle-stacking (stacking-order))
+	      (warp-pointer-if-necessary win)
+	      (raise-window* win))
+	    (when cycle-show-window-names
+	      (cycle-display-message))
+	    (when (window-really-wants-input-p win)
+	      (set-input-focus win))
+	    )
+	;; otherwise show only the name
+
+	;; when raise windows and window in workspace, raise it
+	(when (and cycle-raise-windows
+		   (window-in-workspace-p win current-workspace)
+		   )
+	  (fluid-set x-cycle-stacking (stacking-order))
+	  (raise-window* win))
+	;; display message
+	;; if wanted, or window is in another workspace
+	;; since there would be no other visual clue
+	(when (or cycle-show-window-names
+		  (not (window-in-workspace-p win current-workspace)))
+	  (cycle-display-message)
+	  )
+
+	) ;; end of (if cycle-switch-workspaces ...)
       (allow-events 'sync-keyboard)
       (call-window-hook 'after-cycle-step-hook win)))

The following is a part of the patch submitted by the author, but it is already applied on 1 Jan 2009, as commit 0d69a27.

Index: lisp/sawfish/wm/util/display-wininfo.jl
===================================================================
--- lisp/sawfish/wm/util/display-wininfo.jl	(revision 4225)
+++ lisp/sawfish/wm/util/display-wininfo.jl	(working copy)
@@ -32,7 +32,9 @@
 	  sawfish.wm.images
 	  sawfish.wm.misc
 	  sawfish.wm.util.x
-	  sawfish.wm.windows)
+	  sawfish.wm.windows
+	  sawfish.wm.workspace
+	  )
 
 ;;; variables
 
@@ -42,6 +44,8 @@
 
   (defconst icon-size (32 . 32))
 
+  (defvar display-wininfo-show-workspace nil)
+
   ;; window currently displayed, or nil
   (define info-window nil)
 
@@ -79,8 +83,18 @@
   ;; Returns a list of strings describing window W in some way
   (define (window-info w)
     (list (concat (and (window-get w 'iconified) ?[)
-		  (window-name w)
-		  (and (window-get w 'iconified) ?]))))
+                  (window-name w)
+                  (and (window-get w 'iconified) ?])
+		  ; potentially include the workspace where the window is
+		  (if (and
+		       display-wininfo-show-workspace
+		       (not (window-in-workspace-p w current-workspace)))
+		      (concat " <" (number->string (car (window-workspaces w))) ">")
+		    ""
+		    )
+                  )
+          )
+    )
 
 ;;; entry point

Community's reasons for inclusion or rejection Edit

Patch submitters, please vote also! Yes, obviosuly your vote will be positive, but it's the place to give your explanation why this patch is good for all Sawfish users, and why it is correct - good reasons for inclusion.

When voting anonymously please write your name, so that it can be associated with your posts on the mailing list. If you are logged in you can sign yourself by typing four tilda characters: ~~~~.

  • Please vote with: Yes vote: yes., No vote: no., Try vote: let's try in experimental., Wtf vote: pondering. or Suspend wait for next release.
  • Wtf vote: pondering. I'm unable to make any decision here. Dear sawfish users, please test this patch and put your votes :) Janek Kozicki 16:51, 17 September 2008 (UTC)
  • Wtf vote: pondering. It's good, but better can be achieved. See [1] and [2]. - Teika kazura 02:05, 2 June 2009 (UTC)
  • No vote: no. Just displaying the workspace name when cycling is easier via my display-ws-name function. But since display-message currently does not support position and timeout params it's currently out of 1.6.0. Either way I'm rejecting this patch Flashrider [Christopher Bratusek] 14:42, November 14, 2009 (UTC)

Around Wikia's network

Random Wiki