On Fri, 2007-01-26 at 18:28 -0500, David Reveman wrote:
> On Thu, 2007-01-25 at 10:32 +0100, Stjepan Glavina wrote:
> > It would be great if switcher would rotate cube to the selected window
> > when switching. Beryl has "autorotate" option for this. I find it very
> > useful.
> 
> Yes, I guess that can be useful.
> 
> - David
> 

I've just made a patch.
Tell me what you think about it.

Stjepan
--- switcher_orig.c	2007-01-27 08:30:23.000000000 +0100
+++ switcher.c	2007-01-27 09:01:38.000000000 +0100
@@ -83,6 +83,8 @@
 
 #define SWITCH_MINIMIZED_DEFAULT TRUE
 
+#define SWITCH_AUTOROTATE_DEFAULT TRUE
+
 static char *winType[] = {
     N_("Toolbar"),
     N_("Utility"),
@@ -123,7 +125,8 @@
 #define SWITCH_SCREEN_OPTION_ZOOM	  8
 #define SWITCH_SCREEN_OPTION_ICON	  9
 #define SWITCH_SCREEN_OPTION_MINIMIZED	  10
-#define SWITCH_SCREEN_OPTION_NUM	  11
+#define SWITCH_SCREEN_OPTION_AUTOROTATE  11
+#define SWITCH_SCREEN_OPTION_NUM	  12
 
 typedef struct _SwitchScreen {
     PreparePaintScreenProc preparePaintScreen;
@@ -284,6 +287,7 @@
     case SWITCH_SCREEN_OPTION_MIPMAP:
     case SWITCH_SCREEN_OPTION_ICON:
     case SWITCH_SCREEN_OPTION_MINIMIZED:
+    case SWITCH_SCREEN_OPTION_AUTOROTATE:
 	if (compSetBoolOption (o, value))
 	    return TRUE;
 	break;
@@ -445,6 +449,13 @@
     o->longDesc	  = N_("Show minimized windows");
     o->type	  = CompOptionTypeBool;
     o->value.b    = SWITCH_MINIMIZED_DEFAULT;
+    
+    o = &ss->opt[SWITCH_SCREEN_OPTION_AUTOROTATE];
+    o->name	  = "auto_rotate";
+    o->shortDesc  = N_("Auto Rotate");
+    o->longDesc	  = N_("Rotate to the selected window while switching");
+    o->type	  = CompOptionTypeBool;
+    o->value.b    = SWITCH_AUTOROTATE_DEFAULT;
 }
 
 static void
@@ -631,6 +642,31 @@
 
     if (w)
     {
+    if (ss->opt[SWITCH_SCREEN_OPTION_AUTOROTATE].value.b)
+    {
+	    XEvent xev;
+	    int i, j;
+
+	    defaultViewportForWindow(w, &i, &j);
+
+	    xev.xclient.type = ClientMessage;
+	    xev.xclient.display = s->display->display;
+	    xev.xclient.format = 32;
+
+	    xev.xclient.message_type = s->display->desktopViewportAtom;
+	    xev.xclient.window = s->root;
+
+	    xev.xclient.data.l[0] = i * s->width;
+	    xev.xclient.data.l[1] = j * s->height;
+	    xev.xclient.data.l[2] = 0;
+	    xev.xclient.data.l[3] = 0;
+	    xev.xclient.data.l[4] = 0;
+
+	    XSendEvent(s->display->display,
+	               s->root, FALSE,
+	               SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+	}
+	
 	Window old = ss->selectedWindow;
 
 	ss->lastActiveNum  = w->activeNum;
_______________________________________________
compiz mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/compiz

Reply via email to