sawfish-pager



Here's a patch to fix the bug in sawfish-pager where it doesn't display
the windows in the proper viewport.  I also pushed a couple of fixes to
bugs in sawfish.wm.viewport that turned up in the course of getting
sawfish-pager working properly.

--- pager.jl	2009-12-15 11:55:47.000000000 -0600
+++ pager.jl.new	2010-01-06 10:04:56.000000000 -0600
@@ -238,53 +238,78 @@
       (let* ((x (car (window-position w)))
 	     (y (cdr (window-position w)))
 	     (dim (window-frame-dimensions w))
+             ;; l1 is a list of elements for each workspace the window
+             ;; is present in. These elements describe the location of
+             ;; that workspace in the pager display.  Each one is a
+             ;; list of six values; the first four values are the
+             ;; left, top, right and bottom edges of the workspace.
+             ;; The last two are the viewport-[x,y]-offset coordinates
+             ;; for the currently active viewport in that workspace.
+             ;; The first four values are scaled to the pager display,
+             ;; the offset values are not (to minimize rounding
+             ;; errors).
 	     (l1 (if pager-show-all-workspaces
-		     (or (mapcar (lambda (ws)
-				   (nth (- ws (car ws-limits)) ws-list))
-				 (window-workspaces w))
-			 (if (and pager-stickies-on-all-workspaces
-				  (window-get w 'sticky))
-			     ws-list
-			   (list (nth (- current-workspace (car ws-limits)) ws-list))))
-		   (list (car ws-list)))))
+		     (or (mapcar
+                          (lambda (ws)
+                            (append 
+                             (nth (- ws (car ws-limits)) ws-list)
+                             (if (eql ws current-workspace)
+                                 `(,viewport-x-offset ,viewport-y-offset)
+                               (let ((vp-data
+                                      (assoc ws workspace-viewport-data)))
+                                 (if vp-data
+                                     `(,(nth 1 vp-data) ,(nth 2 vp-data))
+                                   ;; No vp data yet for ws:
+                                   '(0 0))))))
+                          (if (and pager-stickies-on-all-workspaces
+                                   (window-get w 'sticky))
+                              ws-list
+                            (or (window-workspaces w)
+                                (list (- current-workspace
+                                         (car ws-limits)))))))
+		   (list (append (car ws-list)
+                                 `(,viewport-x-offset ,viewport-y-offset))))))
 	(setq dim `(,(max 3 (scale (car dim) 'x)) ,(max 3 (scale (cdr dim)))))
 	(if (and pager-stickies-on-all-viewports
-		 (or (> vp-rows 1) (> vp-columns 1))
-		 (window-get w 'sticky-viewport))
-	    (let* ((vxo (mod viewport-x-offset (screen-width)))
-		   (vyo (mod viewport-y-offset (screen-height)))
-		   (j1 (- vp-rows (if (> vyo 0) 2 1)))
-		   (wh `(,vp-width ,vp-height)))
-	      (setq x (scale (+ x vxo) 'x)
-		    y (scale (+ y vyo)))
-	      (let loop ((l l1)
-			 (i (- vp-columns (if (> vxo 0) 2 1)))
-			 (j j1)
-			 r)
-		(cond ((< i 0)
-		       r)
-		      ((< j 0)
-		       (loop l (1- i) j1 r))
-		      (l
-		       (loop (cdr l) i j
-			     `((,(window-id w)
-				,(+ x (* i vp-width) (caar l))
-				,(+ y (* j vp-height) (cadar l))
-				,dim
-				,(+ (scale vxo 'x) (* i vp-width) (caar l))
-				,(+ (scale vyo) (* j vp-height) (cadar l))
-				,@wh)
-			       ,@r)))
-		      ((loop l1 i (1- j) r)))))
-	  (setq x (scale (+ x viewport-x-offset) 'x)
-		y (scale (+ y viewport-y-offset)))
-	  (mapcar (lambda (ws)
-		    `(,(window-id w)
-		      ,(+ x (car ws))
-		      ,(+ y (cadr ws))
-		      ,dim
-		      ,@ws))
-		  l1)))))
+                 (or (> vp-rows 1) (> vp-columns 1))
+                 (window-get w 'sticky-viewport))
+            (let* ((vxo (mod viewport-x-offset (screen-width)))
+                   (vyo (mod viewport-y-offset (screen-height)))
+                   (j1 (- vp-rows (if (> vyo 0) 2 1)))
+                   (wh `(,vp-width ,vp-height)))
+              (setq x (scale (+ x vxo) 'x)
+                    y (scale (+ y vyo)))
+              (let loop ((l l1)
+                         (i (- vp-columns (if (> vxo 0) 2 1)))
+                         (j j1)
+                         r)
+                (cond ((< i 0)
+                       r)
+                      ((< j 0)
+                       (loop l (1- i) j1 r))
+                      (l
+                       (loop (cdr l) i j
+                             `((,(window-id w)
+                                ,(+ x (* i vp-width) (caar l))
+                                ,(+ y (* j vp-height) (cadar l))
+                                ,dim
+                                ,(+ (scale vxo 'x) (* i vp-width) (caar l))
+                                ,(+ (scale vyo) (* j vp-height) (cadar l))
+                                ,@wh)
+                               ,@r)))
+                      ((loop l1 i (1- j) r)))))
+          (mapcar (lambda (ws)
+                    (let ((vp-x (nth 4 (car l1)))
+                          (vp-y (nth 5 (car l1))))
+                      `(,(window-id w)
+                        ,(+ (scale (+ x vp-x) 'x) (car ws))
+                        ,(+ (scale (+ y vp-y)) (cadr ws))
+                        ,dim
+                        ,(car ws)
+                        ,(nth 1 ws)
+                        ,(nth 2 ws)
+                        ,(nth 3 ws))))
+                  l1)))))
 
 ;;; Functions that talk to the C program
 
@@ -335,14 +360,26 @@
   ;; calculates all kinds of sizes and tells the pager
   (define (send-size #!optional force init)
     (let* ((wsl (workspace-limits))
-	   (n (- (cdr wsl) (car wsl))))
+	   (n (- (cdr wsl) (car wsl)))
+           (vp-dims
+            (if pager-show-all-workspaces
+                ;; Maximum viewport dimensions, accross all workspaces:
+                (let ((dims (cons viewport-dimensions
+                                  (mapcar (lambda (e)
+                                            (unless (eq (car e)
+                                                        current-workspace)
+                                              (nth 3 e)))
+                                          workspace-viewport-data))))
+                  (cons (apply max (mapcar car dims))
+                        (apply max (mapcar cdr dims))))
+              viewport-dimensions)))
       (unless (and (not force)
 		   (equal wsl ws-limits)
-		   (eql (car viewport-dimensions) vp-columns)
-		   (eql (cdr viewport-dimensions) vp-rows))
+		   (eql (car vp-dims) vp-columns)
+		   (eql (cdr vp-dims) vp-rows))
 	(setq ws-limits wsl
-	      vp-columns (car viewport-dimensions)
-	      vp-rows (cdr viewport-dimensions)
+	      vp-columns (car vp-dims)
+	      vp-rows (cdr vp-dims)
 	      vp-width (quotient (screen-width) pager-shrink-factor)
 	      vp-height (quotient (screen-height) pager-shrink-factor)
 	      ws-width (1+ (* vp-columns vp-width))
-- 
Jeremy Hankins <nowan nowan org>


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