Re: sawfish, FC2 and workspaces



On Sun, Apr 11, 2004 at 02:27:40PM -0700, John Harper wrote:
> 
> 2. call (set-number-of-workspaces n)

After a help on this list, some hacking and using undocumented
but used in sources features, :-)  I came up with something
like that for ~/.sawfish/rc to make it aware of workspace
configuration changes made with a gnome applet:

;; set a number of workspaces to what was recorded
;; by "Workspace Switcher Preferences"
(set-number-of-workspaces
 (let* ((str (make-string-output-stream))
	(proc (make-process str)))
   (call-process proc nil "gconftool-2"
		 "-g" "/apps/metacity/general/num_workspaces")
   (let ((var (get-output-stream-string str)))
     (let ((nvar 
	     (string-looking-at "[0-9]+" var)
	     (string->number (substring var (match-start) (match-end)))))
       (cond
	((numberp nvar) nvar)
	(t 4)))))) ;; if we do not know any better then make this 4

If somebody has something simpler which does the same job then I
would not mind to see it.

It seems that one can use equally well "gconftool-1" instead of
"gconftool-2".  Also this program appears to return always status 0,
regardless if a desired value was retrieved or not, so I cannot
do checking with '(zerop (call-process ... ))'.

As for a pager misbehaviour on mouse clicks this indeed looks like
a bug in 'libwnck' and not precisely in a pager itself.  To make
that easier to find I attach a short patch for that I grabbed
from bugzilla.gnome.org and rediffed for libwnck-2.6.0.1.  I filed
a bug report also at bugzilla.redhat.com and we will see. :-)

   Michal

--- libwnck-2.6.0.1/libwnck/pager.c.vpswitch	2003-10-23 09:43:30.000000000 -0600
+++ libwnck-2.6.0.1/libwnck/pager.c	2004-04-12 11:29:40.461460297 -0600
@@ -1152,14 +1152,30 @@ wnck_pager_button_release (GtkWidget    
 
 	  if (space)
             {
-              wnck_workspace_activate (space);
+              int screen_width, screen_height;
+
+              /* Don't switch the desktop if we're already there */
+              if (space != wnck_screen_get_active_workspace (pager->priv->screen))
+                wnck_workspace_activate (space);
 
               /* EWMH only lets us move the viewport for the active workspace,
                * but we just go ahead and hackily assume that the activate
                * just above takes effect prior to moving the viewport
                */
-              wnck_screen_move_viewport (pager->priv->screen,
-                                         viewport_x, viewport_y);
+
+              /* Transform the pointer location to viewport origin, assuming
+               * that we want the nearest "regular" viewport containing the
+               * pointer.
+               */
+              screen_width = wnck_screen_get_width (pager->priv->screen);
+              screen_height = wnck_screen_get_height (pager->priv->screen);
+              viewport_x = (viewport_x / screen_width) * screen_width;
+              viewport_y = (viewport_y / screen_height) * screen_height;
+              
+              if (wnck_workspace_get_viewport_x(space) != viewport_x ||
+                  wnck_workspace_get_viewport_y(space) != viewport_y)
+                wnck_screen_move_viewport (pager->priv->screen,
+                                           viewport_x, viewport_y);
               
               if (pager->priv->drag_window)
                 wnck_window_activate (pager->priv->drag_window);


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