Quantcast Display worskpace when cycling - Sawfish
Recent changes Random page
GAMING
Technology
 
Gaming
Entertainment
Science Fiction
Biggest wikis
Hobbies
Music
See more...

Display worskpace when cycling

From Sawfish

Jump to: navigation, search
Browse all patches

[edit] Author

Daniel M German

[edit] Synopsis

This patch adds 2 features that work in tandem:

1. display-wininfo displays the workspace where the window (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).

[edit] Patch testing

  1. Copy/paste the patch listed below into some file, eg. TEST.diff.
  2. If you don't have sawfish sources yet, then make a fresh checkout:
    svn checkout svn://svn.gnome.org/svn/sawfish/trunk
  3. Go into the directory where sawfish sources reside, eg. cd trunk
  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 sawifsh with those instructions or with those: 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 how to prepare a patch - this instruction is useful for patch testing also.

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

Index: lisp/sawfish/wm/commands/x-cycle.jl
===================================================================
--- lisp/sawfish/wm/commands/x-cycle.jl	(revision 4225)
+++ lisp/sawfish/wm/commands/x-cycle.jl	(working copy)
@@ -122,6 +122,13 @@
   (defvar cycle-raise-windows t
     "Raise windows while they're temporarily selected during cycling.")
 
+  (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-keymap (make-keymap)
     "Keymap containing bindings active only during window cycling operations."
     :group bindings
@@ -193,21 +200,53 @@
 	  (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))
-	(raise-window* win))
-      (when cycle-show-window-names
-	(cycle-display-message))
-      (when (window-really-wants-input-p win)
-	(set-input-focus win))
-      (allow-events 'sync-keyboard)))
 
+      ;; 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))
+	      (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
+	(progn 
+	  ; 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
+	  ; as 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
+      (allow-events 'sync-keyboard)
+      ) ; end of let
+    ) ; end of define
+      
   (define (cycle-begin windows step)
     "Cycle through all windows in order of recent selections."
     (let ((tail-command nil)
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

[edit] Community's reasons for inclusion or rejection

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: Image:Yes.png vote: yes., Image:No_.png vote: no., Image:Try.png vote: let's try in experimental., Image:Wtf.png vote: pondering. or Image:Suspend.png wait for next release.
  • Image:Wtf.png 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)
Rate this article:
Share this article: