← Back to team overview

compiz team mailing list archive

[Merge] lp:~unity-team/compiz/trunk.stackattackhack into lp:~unity-team/compiz/trunk

 

David Barth has proposed merging lp:~unity-team/compiz/trunk.stackattackhack into lp:~unity-team/compiz/trunk.

Requested reviews:
  compiz packagers (compiz)

For more details, see:
https://code.launchpad.net/~unity-team/compiz/trunk.stackattackhack/+merge/55554

Adds the timeout stack sync
-- 
https://code.launchpad.net/~unity-team/compiz/trunk.stackattackhack/+merge/55554
Your team compiz packagers is requested to review the proposed merge of lp:~unity-team/compiz/trunk.stackattackhack into lp:~unity-team/compiz/trunk.
=== modified file 'metadata/core.xml.in'
--- metadata/core.xml.in	2010-06-12 07:43:36 +0000
+++ metadata/core.xml.in	2011-03-30 14:29:23 +0000
@@ -38,6 +38,13 @@
 		<min>1000</min>
 		<max>30000</max>
 	    </option>
+	    <option name="sync_stacks_timeout" type="int">
+		<_short>Stack Sync Timeout</_short>
+		<_long>Interval between each time the stack is synched</_long>
+		<default>60</default>
+		<min>10</min>
+		<max>1000</max>
+	    </option>
 	    <option name="default_icon" type="string">
 		<_short>Default Icon</_short>
 		<_long>Default window icon image</_long>

=== modified file 'src/privatescreen.h'
--- src/privatescreen.h	2011-03-13 15:50:39 +0000
+++ src/privatescreen.h	2011-03-30 14:29:23 +0000
@@ -246,6 +246,8 @@
 
 	void setAudibleBell (bool audible);
 
+	bool syncStacks ();
+
 	bool handlePingTimeout ();
 
 	bool handleActionEvent (XEvent *event);
@@ -419,6 +421,9 @@
 	unsigned int lastPing;
 	CompTimer    pingTimer;
 
+	/* Stack Attack Hack */
+	CompTimer    stackAttackTimer;
+
 	Window activeWindow;
 	Window nextActiveWindow;
 

=== modified file 'src/screen.cpp'
--- src/screen.cpp	2011-03-27 04:14:46 +0000
+++ src/screen.cpp	2011-03-30 14:29:23 +0000
@@ -615,6 +615,59 @@
     return true;
 }
 
+bool
+PrivateScreen::syncStacks ()
+{
+    Window *children;
+    unsigned int nchildren;
+    Window root_return, parent_return;
+
+    CompWindowList syncedList;
+
+    XGrabServer (screen->dpy ());
+    XQueryTree (screen->dpy (), screen->root (), &root_return,
+		&parent_return, &children, &nchildren);
+    XUngrabServer (screen->dpy ());
+
+    /* For each window in the tree, try and find
+     * the CompWindow equavilent and then stack
+     * based on that */
+
+    for (unsigned int i = 0; i < nchildren; i++)
+    {
+	CompWindow *w = screen->findTopLevelWindow (children[i], true);
+
+	if (w)
+	    syncedList.push_back (w);
+    }
+#if 0
+    fprintf (stderr, "real window list: \n");
+    foreach (CompWindow *w, screen->windows ())
+    {
+	fprintf (stderr, " - id 0x%x\n", w->id ());
+    }
+
+    fprintf (stderr, "synced window list: \n");
+    foreach (CompWindow *w, screen->windows ())
+    {
+	fprintf (stderr, " - id 0x%x\n", w->id ());
+    }
+#endif
+
+    while (screen->windows ().size ())
+    {
+	CompWindow *w = screen->windows ().back ();
+
+	screen->unhookWindow (w);
+    }
+
+    foreach (CompWindow *w, syncedList)
+	screen->insertWindow (w, screen->windows ().size () ?
+				  screen->windows ().back ()->id () : 0);
+
+    return true;
+}
+
 CompOption::Vector &
 CompScreen::getOptions ()
 {
@@ -646,6 +699,10 @@
 	case CoreOptions::ActivePlugins:
 	    dirtyPluginList = true;
 	    break;
+	case CoreOptions::SyncStacksTimeout:
+	    stackAttackTimer.stop ();
+	    stackAttackTimer.setTimes (optionGetSyncStacksTimeout (), optionGetSyncStacksTimeout () * 1.4);
+	    break;
 	case CoreOptions::PingDelay:
 	    pingTimer.setTimes (optionGetPingDelay (),
 				optionGetPingDelay () + 500);
@@ -4584,6 +4641,9 @@
 
     priv->pingTimer.start ();
 
+    priv->stackAttackTimer.setTimes (priv->optionGetSyncStacksTimeout (), priv->optionGetSyncStacksTimeout () * 1.4);
+    priv->stackAttackTimer.start ();
+
     priv->addScreenActions ();
 
     /* Need to set a default here so that the value isn't uninitialized
@@ -4776,6 +4836,8 @@
     pingTimer.setCallback (
 	boost::bind (&PrivateScreen::handlePingTimeout, this));
 
+    stackAttackTimer.setCallback (boost::bind (&PrivateScreen::syncStacks, this));
+
     startupSequenceTimer.setCallback (
 	boost::bind (&PrivateScreen::handleStartupSequenceTimeout, this));
     startupSequenceTimer.setTimes (1000, 1500);


Follow ups