Merge lp:~compiz-team/compiz-core/compiz-core.fix_geometry_cycling into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury
Status: Merged
Approved by: Mirco Müller
Approved revision: 2798
Merged at revision: 2812
Proposed branch: lp:~compiz-team/compiz-core/compiz-core.fix_geometry_cycling
Merge into: lp:compiz-core/0.9.5
Diff against target: 94 lines (+24/-1)
2 files modified
src/privatewindow.h (+3/-0)
src/window.cpp (+21/-1)
To merge this branch: bzr merge lp:~compiz-team/compiz-core/compiz-core.fix_geometry_cycling
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Review via email: mp+73127@code.launchpad.net

Description of the change

Don't allow outdated server position to move a window back if a plugin
has already requested at a point in time past when the server was told to move
the window to change the geometry without syncing the position.

This should solve the problem of plugin A doing w->move, w->syncPosition and plugin
B doing w->move (wait) w->syncPosition where we return to handleEvent in between
the move and the position sync and the server will send us a ConfigureNotify
event for the position that was last sent to the server even if a plugin
has more recently updated the current geometry, and this geometry recieved
from the server will overwrite the current plugin's working geometry that
it was going to sync anyways later and cause moveNotify to be called.

At the moment, we're just comparing timestamps from when the geometry was
last updated by a plugin and when geometry was last sent to the server. Note
that in reality, CompWindow::move should not be updating priv->geometry directly,
this should only really be allowed to be updated by the server. However, it
doesn't make sense for it to update priv->serverGeometry as that was the
geometry last sent to the server. In reality, a larger API break will be
needed in order to represent the four possible states of geometry at any given
time.

a) geometry by the compositor (current geometry, not pending to send to server)
b) geometry last sent to server
c) geometry last recieved by the server
d) current server side geometry (which must be retrieved via a round-trip
   to the server)

Note that I don't think that this change should go in the 0.9.5.x series, but we should really wait for 0.9.7

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

I don't have my system setup to compile compiz atm, but as far as I can tell all this look ok. BTW just get into the habit of initializing any declared variables/structs (lastGeometryUpdate, lastConfigureRequest).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/privatewindow.h'
--- src/privatewindow.h 2011-08-23 06:16:21 +0000
+++ src/privatewindow.h 2011-08-27 05:17:02 +0000
@@ -238,6 +238,9 @@
238 XSizeHints sizeHints;238 XSizeHints sizeHints;
239 XWMHints *hints;239 XWMHints *hints;
240240
241 struct timeval lastGeometryUpdate;
242 struct timeval lastConfigureRequest;
243
241 bool inputHint;244 bool inputHint;
242 bool alpha;245 bool alpha;
243 int width;246 int width;
244247
=== modified file 'src/window.cpp'
--- src/window.cpp 2011-08-23 13:15:20 +0000
+++ src/window.cpp 2011-08-27 05:17:02 +0000
@@ -768,6 +768,8 @@
768 if (!frame)768 if (!frame)
769 return;769 return;
770770
771 gettimeofday (&lastConfigureRequest, NULL);
772
771 if (input.left || input.right || input.top || input.bottom)773 if (input.left || input.right || input.top || input.bottom)
772 {774 {
773 int x, y, width, height;775 int x, y, width, height;
@@ -1483,6 +1485,8 @@
1483 dwidth = gm.width () - priv->geometry.width ();1485 dwidth = gm.width () - priv->geometry.width ();
1484 dheight = gm.height () - priv->geometry.height ();1486 dheight = gm.height () - priv->geometry.height ();
14851487
1488 gettimeofday (&priv->lastGeometryUpdate, NULL);
1489
1486 priv->geometry.set (gm.x (), gm.y (),1490 priv->geometry.set (gm.x (), gm.y (),
1487 gm.width (), gm.height (),1491 gm.width (), gm.height (),
1488 gm.border ());1492 gm.border ());
@@ -1505,7 +1509,13 @@
1505 dx = gm.x () - priv->geometry.x ();1509 dx = gm.x () - priv->geometry.x ();
1506 dy = gm.y () - priv->geometry.y ();1510 dy = gm.y () - priv->geometry.y ();
15071511
1508 move (dx, dy);1512 /* Don't move the window here if a plugin has already updated
1513 * the geometry of that window after the last time the server
1514 * was sent a configure request since the configureNotify we
1515 * receieve here will be out of date. Instead wait for the plugin
1516 * to call syncPosition again */
1517 if (TIMEVALDIFF (&priv->lastConfigureRequest, &priv->lastGeometryUpdate))
1518 move (dx, dy);
1509 }1519 }
15101520
1511 return true;1521 return true;
@@ -1719,6 +1729,8 @@
1719 priv->geometry.setX (priv->geometry.x () + dx);1729 priv->geometry.setX (priv->geometry.x () + dx);
1720 priv->geometry.setY (priv->geometry.y () + dy);1730 priv->geometry.setY (priv->geometry.y () + dy);
17211731
1732 gettimeofday (&priv->lastGeometryUpdate, NULL);
1733
1722 priv->region.translate (dx, dy);1734 priv->region.translate (dx, dy);
1723 priv->inputRegion.translate (dx, dy);1735 priv->inputRegion.translate (dx, dy);
1724 if (!priv->frameRegion.isEmpty ())1736 if (!priv->frameRegion.isEmpty ())
@@ -1736,6 +1748,8 @@
1736 priv->serverGeometry.setX (priv->geometry.x ());1748 priv->serverGeometry.setX (priv->geometry.x ());
1737 priv->serverGeometry.setY (priv->geometry.y ());1749 priv->serverGeometry.setY (priv->geometry.y ());
17381750
1751 gettimeofday (&priv->lastConfigureRequest, NULL);
1752
1739 XMoveWindow (screen->dpy (), ROOTPARENT (this),1753 XMoveWindow (screen->dpy (), ROOTPARENT (this),
1740 priv->geometry.x () - priv->input.left,1754 priv->geometry.x () - priv->input.left,
1741 priv->geometry.y () - priv->input.top);1755 priv->geometry.y () - priv->input.top);
@@ -2477,6 +2491,8 @@
2477 {2491 {
2478 XWindowChanges wc = *xwc;2492 XWindowChanges wc = *xwc;
24792493
2494 gettimeofday (&lastConfigureRequest, NULL);
2495
2480 wc.x -= input.left - serverGeometry.border ();2496 wc.x -= input.left - serverGeometry.border ();
2481 wc.y -= input.top - serverGeometry.border ();2497 wc.y -= input.top - serverGeometry.border ();
2482 wc.width += input.left + input.right + serverGeometry.border ();2498 wc.width += input.left + input.right + serverGeometry.border ();
@@ -5315,6 +5331,8 @@
53155331
5316 screen->insertWindow (this, aboveId);5332 screen->insertWindow (this, aboveId);
53175333
5334 gettimeofday (&priv->lastGeometryUpdate, NULL);
5335
5318 priv->attrib = wa;5336 priv->attrib = wa;
5319 priv->serverGeometry.set (priv->attrib.x, priv->attrib.y,5337 priv->serverGeometry.set (priv->attrib.x, priv->attrib.y,
5320 priv->attrib.width, priv->attrib.height,5338 priv->attrib.width, priv->attrib.height,
@@ -5883,6 +5901,8 @@
5883 return false;5901 return false;
5884 }5902 }
58855903
5904 gettimeofday (&lastConfigureRequest, NULL);
5905
5886 if (attrib.override_redirect)5906 if (attrib.override_redirect)
5887 return false;5907 return false;
58885908

Subscribers

People subscribed via source and target branches