Merge lp:~smspillaz/compiz-core/compiz-core.work_923683 into lp:compiz-core/0.9.8

Proposed by Sam Spilsbury on 2012-04-19
Status: Merged
Merged at revision: 3110
Proposed branch: lp:~smspillaz/compiz-core/compiz-core.work_923683
Merge into: lp:compiz-core/0.9.8
Prerequisite: lp:~smspillaz/compiz-core/compiz-core.fix_969101
Diff against target: 2394 lines (+509/-779)
19 files modified
plugins/composite/src/window.cpp (+15/-35)
plugins/decor/src/decor.cpp (+66/-53)
plugins/decor/src/decor.h (+2/-3)
plugins/move/src/move.cpp (+2/-4)
plugins/opengl/src/paint.cpp (+11/-18)
plugins/opengl/src/privates.h (+7/-1)
plugins/opengl/src/window.cpp (+39/-17)
plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp (+4/-6)
plugins/place/src/place.cpp (+19/-24)
plugins/resize/src/resize.cpp (+1/-11)
plugins/resize/src/resize.h (+0/-2)
plugins/wobbly/src/wobbly.cpp (+5/-4)
src/event.cpp (+1/-1)
src/privatewindow.h (+7/-8)
src/screen.cpp (+4/-2)
src/window.cpp (+270/-543)
src/window/geometry/include/core/windowgeometry.h (+6/-0)
src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp (+10/-0)
src/windowgeometry.cpp (+40/-47)
To merge this branch: bzr merge lp:~smspillaz/compiz-core/compiz-core.work_923683
Reviewer Review Type Date Requested Status
Daniel van Vugt 2012-04-19 Approve on 2012-04-24
Alan Griffiths 2012-04-19 Approve on 2012-04-23
Sam Spilsbury Pending
Review via email: mp+102687@code.launchpad.net

This proposal supersedes a proposal from 2012-04-19.

Description of the change

Resubmitted now that lp:~smspillaz/compiz-core/compiz-core.fix_969108.2 and lp:~smspillaz/compiz-core/compiz-core.fix_969101 are active

Always use the asynchronous codepaths in core. This commit changes the following:

 * CompWindow::move is now just a wrapper around CompWindow::configureXWindow
 * CompWindow::configureXWindow will always call through to moveNotify
 * moveNotify and resizeNotify are only ever called pre-request in the case of
   managed windows (SubstructureRedirectMask guaruntees they will end up in
   the right place) and post ConfigureNotify for override redirect windows
 * resizeNotify is always called post ConfigureNotify regardless of whether
   or not the window is managed or not
 * various const correctness where it made sense
 * cleaned up the whole geometry.width () + geometry.border () * 2 nonsense
 * removed priv->width and priv->height , which was just redundant data used for
   window shading and honestly, is a ticking time bomb for future maintainers.
 * CompWindow::syncPosition is now deprecated and a no-op
 * Removed the majority of PrivateWindow::updateFrameWindow - this function had a lot
   of redundant code which PrivateWindow::reconfigureXWindow had anyways - the big work
   there was to send synthetic ConfigureNotify events to ourselves to notify windows
   moving within frame windows that don't move themselves. Its safer to use
   reconfigureXWindow in this case and probably more sane too.
   We should look into removing the other update* functions.

Testing plan?

I would imagine here that the PendingConfigureRequests object can probably be split out into something testable, as can the logic to strip flags from frame window geometry and client window geometry updates.

To post a comment you must log in.
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal
Download full text (10.3 KiB)

The diff is big and scary, but its not too complicated. I'll explain each separate part

1 === modified file 'include/core/window.h'
2 --- include/core/window.h 2012-01-20 15:20:44 +0000
3 +++ include/core/window.h 2012-01-31 17:12:59 +0000
4 @@ -398,9 +398,9 @@
5
6 bool hasUnmapReference ();
7
8 - bool resize (XWindowAttributes);
9 + bool resize (const XWindowAttributes &);
10
11 - bool resize (Geometry);
12 + bool resize (const Geometry &);
13
14 bool resize (int x, int y, int width, int height,
15 int border = 0);

const correctness

31 int x1, x2, y1, y2;
32
33 - CompWindow::Geometry geom = priv->window->geometry ();
34 - CompWindowExtents output = priv->window->output ();
35 + const CompWindow::Geometry &geom = priv->window->serverGeometry ();
36 + const CompWindowExtents &output = priv->window->output ();

more const correctness

35 + const CompWindow::Geometry &geom = priv->window->serverGeometry ();
36 + const CompWindowExtents &output = priv->window->output ();

Lots of this - in paint code we want to use serverFoo because it was the last thing sent to the server. And this is always guarunteed to come back to us.

166 - unsigned int width = window->size ().width ();
167 - unsigned int height = window->size ().height ();
168 + unsigned int width = window->geometry ().width ();
169 + unsigned int height = window->geometry ().height ();

CompWindow::size was just returning CompSize (priv->width, priv->height) which was just redundant data which should be removed. Replaced it with geometry () for clarity

299 + void move (int dx, int dy, bool sync);
300 + bool resize (int dx, int dy, int dwidth, int dheight, int dborder);
301 + bool resize (const CompWindow::Geometry &g);
302 + bool resize (const XWindowAttributes &attrib);
303 +

Added PrivateWindow::move and PrivateWindow::resize - to be called whenever a new position / size comes back from the server. (cut'n'paste code from CompWindow::move and CompWindow::resize

335 -
336 - gettimeofday (&lastConfigureRequest, NULL);
337 - /* Flush any changes made to serverFrameGeometry or serverGeometry to the server
338 - * since there is a race condition where geometries will go out-of-sync with
339 - * window movement */
340 -
341 - window->syncPosition ();
342 -
343 - if (serverInput.left || serverInput.right || serverInput.top || serverInput.bottom)
344 - {
345 - int bw = serverGeometry.border () * 2;
346 -
347 - xwc.x = serverGeometry.x () - serverInput.left;
348 - xwc.y = serverGeometry.y () - serverInput.top;
349 - xwc.width = serverGeometry.width () + serverInput.left + serverInput.right + bw;
350 - if (shaded)
351 - xwc.height = serverInput.top + serverInput.bottom + bw;
352 - else
353 - xwc.height = serverGeometry.height () + serverInput.top + serverInput.bottom + bw;
354 -
355 - if (shaded)
356 - height = serverInput.top + serverInput.bottom;
357 -
358 - if (serverFrameGeometry.x () == xwc.x)
359 - valueMask &= ~(CWX);
360 - else
361 - serverFrameGeometry.setX (xwc.x);
362 -
*snip*
616 - XMoveResizeWindow (screen->dpy (), id, 0, 0,
617 - serverGeometry.width (), serverGeometry.height ());
618 - window->sendConfigureNotify ();
619 - window->windowNotify (CompWindowNotifyFrameUpdate...

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

824 -
825 - if (!pendingConfigures.pending ())
826 - {
827 - /* Tell plugins its ok to start doing stupid things again but
828 - * obviously FIXME */
829 - CompOption::Vector options;
830 - CompOption::Value v;
831 -
832 - options.push_back (CompOption ("window", CompOption::TypeInt));
833 - v.set ((int) id);
834 - options.back ().set (v);
835 - options.push_back (CompOption ("active", CompOption::TypeInt));
836 - v.set ((int) 0);
837 - options.back ().set (v);
838 -
839 - /* Notify other plugins that it is unsafe to change geometry or serverGeometry
840 - * FIXME: That API should not be accessible to plugins, this is a hack to avoid
841 - * breaking ABI */
842 -
843 - screen->handleCompizEvent ("core", "lock_position", options);
844 - }

DIE

924 -bool
925 -PrivateWindow::checkClear ()
926 -{
927 - if (pendingConfigures.pending ())
928 - {
929 - /* FIXME: This is a hack to avoid performance regressions
930 - * and must be removed in 0.9.6 */
931 - compLogMessage ("core", CompLogLevelWarn, "failed to receive ConfigureNotify event on 0x%x\n",
932 - id);
933 - pendingConfigures.dump ();
934 - pendingConfigures.clear ();
935 - }
936 -
937 - return false;
938 -}
939 -
940 void
941 compiz::X11::PendingEventQueue::add (PendingEvent::Ptr p)
942 {
943 @@ -2454,21 +2148,6 @@
944 mValueMask (valueMask),
945 mXwc (*xwc)
946 {
947 - CompOption::Vector options;
948 - CompOption::Value v;
949 -
950 - options.push_back (CompOption ("window", CompOption::TypeInt));
951 - v.set ((int) w);
952 - options.back ().set (v);
953 - options.push_back (CompOption ("active", CompOption::TypeInt));
954 - v.set ((int) 1);
955 - options.back ().set (v);
956 -
957 - /* Notify other plugins that it is unsafe to change geometry or serverGeometry
958 - * FIXME: That API should not be accessible to plugins, this is a hack to avoid
959 - * breaking ABI */
960 -
961 - screen->handleCompizEvent ("core", "lock_position", options);
962 }

DIE

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

GOOD IN THEORY:

* Most of the description sounds like steps in the right direction.

* Simplified: Replacing 559 lines of code with 247.

UNSURE ABOUT THE THEORY:

* "composite and opengl now use the geometry last sent to the server"
This should give maximum performance, sure, but what if (for some reason) the server rejects the configure request as being somehow invalid? Would you ever encounter that, like moving a window to an invalid location?
For stability and correctness (which should be the primary goal right now) don't we want "composite and opengl now use the geometry last received from the server"?

* Caveat #1 is not really a caveat. It's the right (intended) design. But if you want to see a (buggy) example of how to solve the chattiness look at the timer code here:
https://code.launchpad.net/~vanvugt/compiz-core/fix-764330-trunk/+merge/86497
This was slightly buggy though as it broke keyboatrd-initiated moves (incorrect pointer warp). Simple to fix, probably.

* Still no XFlush's to ensure XConfigureWindow happens immediately. Or are there adequate XSyncs already?

BAD IN THEORY:

* The diff is too big for a mere mortal (who hasn't worked on all the code before) to fully load into their mental interpreter and evaluate its theoretical correctness. Please read that sentence again; it's important.

GOOD IN PRACTICE:

* Window movement is smooth and predictable, but not really better than in oneiric.

BAD IN PRACTICE:

* The bug introduced is worse than the bug being fixed; Window contents offset from the frame/decorations whenever a window is created or maximized.

* All that code, but we still haven't reduced the lag below oneiric-levels. Still not as good as Gnome Shell.

CONCLUSION:

The theory is mostly good but there is at least one serious bug that needs fixing. We probably shouldn't risk 0.9.7.0 any more with large changes like this. We should aim to get this code into a later release when it's more stable, not 0.9.7.0.

review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal
Download full text (3.2 KiB)

> GOOD IN THEORY:
>
> * Most of the description sounds like steps in the right direction.
>
> * Simplified: Replacing 559 lines of code with 247.
>
>
> UNSURE ABOUT THE THEORY:
>
> * "composite and opengl now use the geometry last sent to the server"
> This should give maximum performance, sure, but what if (for some reason) the
> server rejects the configure request as being somehow invalid? Would you ever
> encounter that, like moving a window to an invalid location?
> For stability and correctness (which should be the primary goal right now)
> don't we want "composite and opengl now use the geometry last received from
> the server"?

See http://tronche.com/gui/x/xlib/window/XConfigureWindow.html

Since we have SubstructureRedirectMask, it is guarunteed that any ConfigureWindow request we make on a child of the root window is guarunteed to end up in that position (hence the event tracker).

The only error cases I can think of is where you ask for a window to be of a size < 0 or > MAXSHORT. Ideally we should check for that case.

>
> * Caveat #1 is not really a caveat. It's the right (intended) design. But if
> you want to see a (buggy) example of how to solve the chattiness look at the
> timer code here:
> https://code.launchpad.net/~vanvugt/compiz-core/fix-764330-trunk/+merge/86497
> This was slightly buggy though as it broke keyboatrd-initiated moves
> (incorrect pointer warp). Simple to fix, probably.
>

There are some optimizations that can be done here - for example, if a window is grabbed, you can withold sending positions to the server until it is ungrabbed, or there is some other reason why you would want to do that. When that happens you can send it all at once.

> * Still no XFlush's to ensure XConfigureWindow happens immediately. Or are
> there adequate XSyncs already?

The GLib mainloop work introduced an XFlush as soon as we have finished dispatching the X event source.

>
>
> BAD IN THEORY:
>
> * The diff is too big for a mere mortal (who hasn't worked on all the code
> before) to fully load into their mental interpreter and evaluate its
> theoretical correctness. Please read that sentence again; it's important.

Indeed. The good thing is that its mostly all deletion and consolidation.

>
>
> GOOD IN PRACTICE:
>
> * Window movement is smooth and predictable, but not really better than in
> oneiric.
>
>
> BAD IN PRACTICE:
>
> * The bug introduced is worse than the bug being fixed; Window contents offset
> from the frame/decorations whenever a window is created or maximized.

Alright. I haven't seen this yet, but I have an idea of what might cause it. Will have a look into it when I get some time.

>
> * All that code, but we still haven't reduced the lag below oneiric-levels.
> Still not as good as Gnome Shell.

This will be fixed once the chattyness goes away. (as above). Watch your X.org CPU usage as you move windows - it skyrockets because at the moment we flood it with requests.

>
>
> CONCLUSION:
>
> The theory is mostly good but there is at least one serious bug that needs
> fixing. We probably shouldn't risk 0.9.7.0 any more with large changes like
> this. We should aim to get this code into a later r...

Read more...

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

OK, I'm still wading through the changes. But I feel like a rant...

1307 CompSize
1308 CompWindow::size () const
1309 {
1310 - return CompSize (priv->width + priv->geometry.border () * 2,
1311 - priv->height + priv->geometry.border () * 2);
1312 + return CompSize (priv->geometry.width () + priv->geometry.border () * 2,
1313 + priv->geometry.height () + priv->geometry.border () * 2);
1314 }

As a change this doesn't look too bad - but it ignores a horrid design!

1. Chained operations like "priv->geometry.width ()" imply too muck knowledge of the details of "priv".
   That is "priv->width ()" would reflect less coupling.

2. You're tracing the path "priv->geometry..." many times, which suggests that the logic belongs in "geometry".
   "return priv->geometry.size ()" or "return CompSize(priv->geometry)" would reflect better coherence.

So, assuming (because borders may be optional?) that there's an unambiguous mapping from CompWindow::Geometry:

a. Add a constructor to CompSize: "explicit CompSize(CompWindow::Geometry const& g) : mWidth(g.width () + g.border () * 2) ..."
b. Add an inline method "CompSize PrivateWindow::size () const { return CompSize(priv->geometry); }"
c. Rewrite the above as "CompSize CompWindow::size () const { "return priv->size ()"; }"

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

264 - /* been shaded */
265 + /* been shaded
266 if (w->priv->height == 0)
267 {
268 if (w->id () == priv->activeWindow)
269 w->moveInputFocusTo ();
270 - }
271 + }*/

Comments are not for storing old versions of the code - that's what we use bzr for. ;)

review: Needs Fixing
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

There's a lot of "<blah>.width () + <blah>.border () * 2" and "<blah>.height () + <blah>.border () * 2" around. Surely CompWindow::Geometry could have a "widthWithBorders" method - or maybe a free function?

I'm tempted by

template<Typename T>
inline int heightWithBorders(T const& blah) { return blah.height () + blah.border () * 2; }

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> OK, I'm still wading through the changes. But I feel like a rant...
>
> 1307 CompSize
> 1308 CompWindow::size () const
> 1309 {
> 1310 - return CompSize (priv->width + priv->geometry.border () * 2,
> 1311 - priv->height + priv->geometry.border () * 2);
> 1312 + return CompSize (priv->geometry.width () + priv->geometry.border ()
> * 2,
> 1313 + priv->geometry.height () + priv->geometry.border () * 2);
> 1314 }
>
> As a change this doesn't look too bad - but it ignores a horrid design!
>
> 1. Chained operations like "priv->geometry.width ()" imply too muck knowledge
> of the details of "priv".
> That is "priv->width ()" would reflect less coupling.

Probably, although priv is just a private member with implementation details, I don't really see this as a large design problem.

>
> 2. You're tracing the path "priv->geometry..." many times, which suggests that
> the logic belongs in "geometry".
> "return priv->geometry.size ()" or "return CompSize(priv->geometry)" would
> reflect better coherence.
>
> So, assuming (because borders may be optional?) that there's an unambiguous
> mapping from CompWindow::Geometry:
>
> a. Add a constructor to CompSize: "explicit CompSize(CompWindow::Geometry
> const& g) : mWidth(g.width () + g.border () * 2) ..."
> b. Add an inline method "CompSize PrivateWindow::size () const { return
> CompSize(priv->geometry); }"
> c. Rewrite the above as "CompSize CompWindow::size () const { "return
> priv->size ()"; }"

+1 for all three

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> 264 - /* been shaded */
> 265 + /* been shaded
> 266 if (w->priv->height == 0)
> 267 {
> 268 if (w->id () == priv->activeWindow)
> 269 w->moveInputFocusTo ();
> 270 - }
> 271 + }*/
>
> Comments are not for storing old versions of the code - that's what we use bzr
> for. ;)

Indeed, this is a small portion of the code and I'm not yet sure what to do with it. When I get around to revisiting this section (when I actually get time to look at this again, wanted to get it up for review early) I'll see what can be done.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> There's a lot of "<blah>.width () + <blah>.border () * 2" and "<blah>.height
> () + <blah>.border () * 2" around. Surely CompWindow::Geometry could have a
> "widthWithBorders" method - or maybe a free function?
>
> I'm tempted by
>
> template<Typename T>
> inline int heightWithBorders(T const& blah) { return blah.height () +
> blah.border () * 2; }

I'm not really sure ?

The complexity here comes from a legacy part of the X Server coming into play - a window could have fixed dimentions, but also specify a "border" which would be exclusive of the fixed dimentions, so you'd have to take this into account for all positioning operations (Xterm comes to mind here).

I definitely agree that geom.width () + geom.border () * 2 feels fragile and indeed, that has tripped me up many times before. Maybe a default parameter with a bitflag makes sense here, eg IncludeBorder , IncludeBorderFirst , IncludeBorderSecond (as it is on both sides)

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

I'll note that the above isn't *really* all that relevant to this merge though, but good things to keep in mind in any case. I'd rather not see the diff get any better except for adding tests.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Please resubmit for target branch lp:compiz-core (0.9.7)

review: Resubmit
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

A lot of the above is about making the code better (which the proposal doesn't attempt). However, in a previous version I pointed out that:

> 264 - /* been shaded */
> 265 + /* been shaded
> 266 if (w->priv->height == 0)
> 267 {
> 268 if (w->id () == priv->activeWindow)
> 269 w->moveInputFocusTo ();
> 270 - }
> 271 + }*/
>
> Comments are not for storing old versions of the code - that's what we use bzr for. ;)

I still think that needs fixing.

review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Alright, I've updated this so that there's no distorted windows on decoration size change. Was (ironically) a race condition.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

For the sake of not making this diff any bigger, I'm not going to introduce unit tests here.

As for testing this I'd say the following is appropriate:

 * Add testcase for PendingConfigureEvent
 * Add testcase for rectsToRegion (serverGeometry should really be DI'd here)

Notes for the future:

 * As alan has said - the whole priv->geometry ().width () + priv->geometry ().border () * 2 is /really/ awkward and error prone, but we need it to support windows like xterm that still use this (stupid, legacy) attribute on their windows. I would say that the role of compiz::window::Geometry should thus be expanded somewhat
   - it should also encapsulate priv->region and really, geometry::x and friends should be made with reference to that. Ideally we'll store two regions, one with borders and one without. That sucks, since its a little memory hungry, but at least the cost is only really born whenever those regions need to be updated (::translate on a region with one rectangle is basically free, slightly more complicated on regions with multiple rects (eg, shaped window). The default should be to return the size /without/ borders, and have a default-parameter enum to get the size with borders.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Unfortunately still fails basic testing. The same bug remains;

* The bug introduced is worse than the bug being fixed; Window contents offset from the frame/decorations whenever a window is created or maximized.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Also... I would have thought/hoped that a simplified/stable solution would eliminate "serverGeometry" completely.

        /**
        * Geometry retrieved from the
         * last ConfigureNotify event received
         */
        Geometry & geometry () const;

        /**
         * Geometry last sent to the server
         */
        Geometry & serverGeometry () const;

I understand why we have, and why we might want, serverGeometry. However it is an optimization which only makes sense to attempt if the code is stable and bug-free to begin with.

While serious bugs remain, I think the first goal should be to simplify the logic down to just using "geometry" and remove or stub "serverGeometry".

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> Also... I would have thought/hoped that a simplified/stable solution would
> eliminate "serverGeometry" completely.
>
> /**
> * Geometry retrieved from the
> * last ConfigureNotify event received
> */
> Geometry & geometry () const;
>
> /**
> * Geometry last sent to the server
> */
> Geometry & serverGeometry () const;
>
> I understand why we have, and why we might want, serverGeometry. However it is
> an optimization which only makes sense to attempt if the code is stable and
> bug-free to begin with.
>
> While serious bugs remain, I think the first goal should be to simplify the
> logic down to just using "geometry" and remove or stub "serverGeometry".

There are some usescases for when we need to know what the last /received/ geometry from the server is. That's why the whole geometry/serverGeometry thing exists.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Also, I'm not seeing this offset problem - could you give me some steps to reproduce it ?

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> > Also... I would have thought/hoped that a simplified/stable solution would
> > eliminate "serverGeometry" completely.
> >
> > /**
> > * Geometry retrieved from the
> > * last ConfigureNotify event received
> > */
> > Geometry & geometry () const;
> >
> > /**
> > * Geometry last sent to the server
> > */
> > Geometry & serverGeometry () const;
> >
> > I understand why we have, and why we might want, serverGeometry. However it
> is
> > an optimization which only makes sense to attempt if the code is stable and
> > bug-free to begin with.
> >
> > While serious bugs remain, I think the first goal should be to simplify the
> > logic down to just using "geometry" and remove or stub "serverGeometry".
>
>
> There are some usescases for when we need to know what the last /received/
> geometry from the server is. That's why the whole geometry/serverGeometry
> thing exists.

Hmm, we could make it so that serverGeometry is returned for managed windows and geometry is returned for override redirect windows on the public API. That of course means that we have to break the public API and update all the plugins.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

The practical problem:

Just start compiz --replace composite opengl move resize decor
and gtk-window-decorator --replace
Then every window will have its contents horizontally shifted around 15 pixels from the correct location relative to its decorations. The shift occurs whenever a window is created, maximized or restored. The shift goes away (corrects itself) when you start moving the window. On a positive note, the lag *appears* totally fixed and dragging windows is performing as well as Gnome Shell now.

The theoretical problem:

You can ignore my comments about geometry/serverGeometry for now. They are insignificant compared to the above bug. And besides, the use of both geometry and serverGeometry now appears to be yielding the desired reduction in lag.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Screenshot of the bug introduced by this branch:
https://launchpadlibrarian.net/92172452/shift.png

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Alright, I'll have another look into it ? (Not seeing it here :( )

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

And it gets worse:
* The usual lag has come back. I have no idea how or why it was fixed when I ran it the first time.
* When dragging windows around, the area of desktop recently exposed flashes white.

So there is no improvement in performance and 2 serious regressions introduced :(

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

    //XSynchronize (dpy, TRUE);

:) Haven't merged your other branch

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Yikes. That would be another regression to be missing:
src/screen.cpp: XSynchronize (dpy, synchronousX ? True : False);

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Perhaps remember to pull from trunk more often.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

where trunk == lp:compiz-core

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Why doesn't the removal of XSynchronize show up in the below diff? It's obvious if I merge the branch myself. Maybe LaunchPad needs a kick to update the below diff?

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I think the horizontal shift bug is coming from upstream lp:compiz-core, and is exposed moreso by this branch. I can reproduce the same kind of horizontal shift jitter using just lp:compiz-core and resizing a window rapidly.

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> The default should be to return the size /without/ borders,
> and have a default-parameter enum to get the size with borders.

There are very few designs where default parameters are better than multiple functions. This isn't one.

auto sizeWithoutBorders = geometry.size();
auto sizeWithBorders = geometry.sizeWithBorders(); // not geometry.size(::compiz::geometry::WithBorders);

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

OK, the horizontal shifting bug does not seem to be caused by this branch. Just made worse by this branch.

Sam, please review that nasty issue first: bug 928173.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

This branch will incidentally help with a lot of the resizing issues, so I think it should be merged first.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I would prefer not to approve this branch so long as the offset/shift bug is as bad as it is. If absolutely necessary, we could release without a fix for bug 928173 because it is hidden by the default Ubuntu config. But introducing this branch makes the bug unacceptably worse, as the screenshot showed.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

To clarify, "unacceptably worse" means that the bug will no longer be hidden in Ubuntu and will occur on every new window that opens. At least on my machine (and presumably others).

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

.... I'm still not even seeing this issue.

I can look into resizing tonight if you really think that this is a blocker.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I think I may have confused the situation by suggesting the regression introduced by this branch is bug 928173. The symptoms are actually slightly different. It's only a theory that it's the same bug, because the size of the horizontal offset looks similar.

The bug I see with this branch would be worthy of a new bug report (a critical regression) that I don't want to log. And we won't have to log that bug so long as it's fixed before this branch is merged.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Wed, 8 Feb 2012, Daniel van Vugt wrote:

> I think I may have confused the situation by suggesting the regression introduced by this branch is bug 928173. The symptoms are actually slightly different. It's only a theory that it's the same bug, because the size of the horizontal offset looks similar.
>
> The bug I see with this branch would be worthy of a new bug report (a critical regression) that I don't want to log. And we won't have to log that bug so long as it's fixed before this branch is merged.
> --
> https://code.launchpad.net/~smspillaz/compiz-core/compiz-core.work_923683/+merge/91654
> You are the owner of lp:~smspillaz/compiz-core/compiz-core.work_923683.
>

Alright.

I am looking into the decor plugin for a way to resolve this.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Despite the success of the fix for #928173: lp:~smspillaz/compiz-core/compiz-core.decor_928173
the offset bug introduced by this branch persists.

This confirms that the horizontal offset/shift problems introduced (or exposed) by this branch are certainly not the same as bug 928173.

review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

I still can't even observe this problem that you're referring to :(

Can you specify, exactly what windows this occurs on and /exact/ steps to reproduce it ?

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Steps to reproduce the issue:

1. Start with an exact clone of lp:compiz-core
2. Merge in lp:~smspillaz/compiz-core/compiz-core.work_923683
3. Build and install it.
4. Run compiz --replace composite opengl move resize decor
5. Run gtk-window-decorator --replace

Now every window will be corrupted. Not just the existing ones, but any new ones you open too. The corruption persists during window resizing, but vanishes as soon as you move a window.

Here is a new screenshot:
https://launchpadlibrarian.net/92390683/shifted2.png

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Is the window itself shifted (eg are the input regions correctly lined up) or is it just the image that is shifted ?

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

The window itself is shifted. The input regions correctly line up with the image still.

However, it looks like the damage events are not shifted. This causes some redraw problems.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Can you post the xwininfo -all of the window, xwininfo -all -id of the parent and xwininfo -all -parent of the parent of that ?

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Attachments sent via email. This is interesting though;

$ diff correct.xwininfo shifted.xwininfo
11c11
< 0x2c03ca7 (has no name): () 1x1+-1+-1 +45+69
---
> 0x2c03ca7 (has no name): () 1x1+-1+-1 +34+69
13c13
< Absolute upper-left X: 46
---
> Absolute upper-left X: 35
31,32c31,32
< Corners: +46+70 -1232+70 -1232-720 +46-720
< -geometry 80x24+35+41
---
> Corners: +35+70 -1243+70 -1243-720 +35-720
> -geometry 80x24+34+41

It looks like geometry/serverGeometry might be out of sync.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

And why do I have so many 1x1 pixel windows?! I swear occasionally I see them on screen too.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Sun, 12 Feb 2012, Daniel van Vugt wrote:

> And why do I have so many 1x1 pixel windows?!

Applications use them as a means of doing IPC. Gtk+ is a serial offender
here.

> I swear occasionally I see them on screen too.

Under what circumstances?

> --
> https://code.launchpad.net/~smspillaz/compiz-core/compiz-core.work_923683/+merge/91654
> You are the owner of lp:~smspillaz/compiz-core/compiz-core.work_923683.
>

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Sun, 12 Feb 2012, Daniel van Vugt wrote:

The frame window is in the wrong position. This means that serverGeometry
isn't the last thing sent to the server. serverGeometry is still writable
in this branch, so it could be $evilplugin doing the wrong thing here.

I don't want to spend any more time on this until wednesday. So I'll pick
it up then.

(compiz run with --debug will have some logs which can confirm this btw)

Incidentally, you don't see any of those "unmatched ConfigureNotify"
warnings do you? They're all gone here but they indicate the first sign of
trouble.

> Attachments sent via email. This is interesting though;
>
> $ diff correct.xwininfo shifted.xwininfo
> 11c11
> < 0x2c03ca7 (has no name): () 1x1+-1+-1 +45+69
> ---
>> 0x2c03ca7 (has no name): () 1x1+-1+-1 +34+69
> 13c13
> < Absolute upper-left X: 46
> ---
>> Absolute upper-left X: 35
> 31,32c31,32
> < Corners: +46+70 -1232+70 -1232-720 +46-720
> < -geometry 80x24+35+41
> ---
>> Corners: +35+70 -1243+70 -1243-720 +35-720
>> -geometry 80x24+34+41
>
> It looks like geometry/serverGeometry might be out of sync.
> --
> https://code.launchpad.net/~smspillaz/compiz-core/compiz-core.work_923683/+merge/91654
> You are the owner of lp:~smspillaz/compiz-core/compiz-core.work_923683.
>

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

It's random and very rare. But sometimes I see 1-pixel windows (with shadow). Can't ever seem to get xwininfo for them. Sometimes I also get very large white anonymous windows blocking my view. But it's all very hard to reproduce. And off-topic.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Correct. I did stop getting "Warn: failed to receive ConfigureNotify event on ..." when using this branch.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Well, you should stop getting "failed to receive" since I've removed the timeout which checks for unmatched events :) (A necessary hack coming up to the oneiric release).

I'm more interested in warnings that say "unmatched ConfigureNotify"

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Could you have a look again to see if the issue is still occurring for you ? I've just re-synced with trunk, so it may be fixed.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

OK, I found the issue. Its actually a bug that's been in the code for quite some time which would cause the client to not move within the frame when the frame was updated until the client position itself was updated.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

There's still one more issue here though to do with override redirect windows not getting their paint regions updated, so that needs to be looked into as well. And tests.

review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

^ Those fix the offset issue confirmed here (was finally able to reproduce it with qtcreator)

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

1. Confirmed the shifted window regression is now fixed. Seems to work without any obvious bugs now.

2. I'm not entirely sure about replacing geometry with serverGeometry. I thought it would be a good idea to do the opposite. There would be a slight performance penalty, but using just "geometry" would guarantee that compiz always agrees with the actual server geometry, instead of guessing/assuming that serverGeometry is accepted by the server (which does not always seem to be true, hence bug 886192).

3. There are two instances of double semicolons ";;" in this proposal.

4. I suspect this proposal will conflict just slightly with the proposal for bug 940139. But it should be minor.

5. NEW REGRESSION:
375 - XSynchronize (dpy, synchronousX ? True : False);
376 +// priv->connection = XGetXCBConnection (priv->dpy);

6. Why always two spaces before "* 2" ?

review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> 2. I'm not entirely sure about replacing geometry with serverGeometry. I
> thought it would be a good idea to do the opposite. There would be a slight
> performance penalty, but using just "geometry" would guarantee that compiz
> always agrees with the actual server geometry, instead of guessing/assuming
> that serverGeometry is accepted by the server (which does not always seem to
> be true, hence bug 886192).
>

serverGeometry will always be "accepted" by the server as long as the window is managed and the requested window geometry will not generate a BadValue error (eg, 0 < 1 < MAXINT) (eg, it is not override redirect and it is a child of a window for which we have a SubstructureRedirectMask.

Bug 886192 is not an example of this. In fact, the behaviour exhibited by bug 886192 is primarily /because/ we use the geometry last received from the server rather than geometry last sent, and the latency of which explains the reason why the window movement lags the cursor, because the server is "catching up".

The only case where you can't guaruntee that a similar update for geometry is going to be delivered by the server for serverGeometry as stored on XConfigureWindow is either in the case that A) Another client has SubstructureRedirectMask on the root window or a parent window owned by compiz and in that case compiz shouldn't even touch that window at all or B) override redirect windows, and as you can see in the code, we /always/ use geometry for override redirect windows in placement sensitive operations. Incidentally, override redirect windows are why getting window stacking right is such a nightmare, but thats a topic for another day.

> 3. There are two instances of double semicolons ";;" in this proposal.

Fix
>
> 4. I suspect this proposal will conflict just slightly with the proposal for
> bug 940139. But it should be minor.

Yes, fixable

>
> 5. NEW REGRESSION:
> 375 - XSynchronize (dpy, synchronousX ? True : False);
> 376 +// priv->connection = XGetXCBConnection (priv->dpy);

Please elaborate further on why this is a regression.

>
> 6. Why always two spaces before "* 2" ?

Most likely copy-and-paste errors

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

#5 is a regression because it will make "--sync" be ignored. Line 375 is important and should not be deleted.

review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Mon, 27 Feb 2012, Daniel van Vugt wrote:

> Review: Needs Fixing
>
> #5 is a regression because it will make "--sync" be ignored. Line 375 is important and should not be deleted.

Thank you. Fixing.

> --
> https://code.launchpad.net/~smspillaz/compiz-core/compiz-core.work_923683/+merge/94683
> You are the owner of lp:~smspillaz/compiz-core/compiz-core.work_923683.
>

Mikkel Kamstrup Erlandsen (kamstrup) wrote : Posted in a previous version of this proposal

> > #5 is a regression because it will make "--sync" be ignored. Line 375 is
> important and should not be deleted.
>
> Thank you. Fixing.

Be sure to add a comment there explaining why that call needs to be there - this review demonstrates that it should have been there in the first place :-)

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Comments are good. Though the string "synchronousX" is unique so its use should be quite clear already without a comment.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Looks like a mistake:

710 - if (x2 > priv->width)
711 - x2 = priv->width;
712 - if (y2 > priv->height)
713 - y2 = priv->height;
714 + if (x2 > priv->serverGeometry.width ())
715 + x2 = priv->serverGeometry.height (); <====== width?
716 + if (y2 > priv->serverGeometry.width ()) <====== height?
717 + y2 = priv->serverGeometry.height ();

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Also, there seems to be a HUGE performance regression when moving windows with this new branch. Try running under callgrind. With lp:compiz-core it's nice and fast. However with this branch it is painfully slow moving windows.

About 75% of the time is spent in:
  775,164,942 /home/dan/bzr/compiz-core/sam/plugins/move/src/move.cpp:moveHandleMotionEvent(CompScreen*, int, int) [/home/dan/sam/lib/compiz/libmove.so]
  772,734,309 /home/dan/bzr/compiz-core/sam/src/window.cpp:CompWindow::configureXWindow(unsigned int, XWindowChanges*) [/home/dan/sam/lib/libcompiz_core.so.0.9.7.0]
  771,062,144 /home/dan/bzr/compiz-core/sam/src/window.cpp:CompWindow::move(int, int, bool) [/home/dan/sam/lib/libcompiz_core.so.0.9.7.0]
  636,443,803 /home/dan/bzr/compiz-core/sam/src/window.cpp:CompWindow::moveNotify(int, int, bool) [/home/dan/sam/lib/libcompiz_core.so.0.9.7.0]
  636,266,731 /home/dan/bzr/compiz-core/sam/plugins/decor/src/decor.cpp:DecorWindow::moveNotify(int, int, bool) [/home/dan/sam/lib/compiz/libdecor.so]

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

The main paths causing this massive performance regression are:

70% of the time:
CompWindow::move
DecorWindow::moveNotify
DecorWindow::computeShadowRegion

18% of the time:
CompWindow::move
CompWindow::configureXWindow
PrivateWindow::reconfigureXWindow

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Hmm, I would imagine this is the throttling of motion events that we mentioned earlier. I think in lp:compiz-core we would have just spent all that time in CompWindow::move although I'll conceed that configureXWindow is a bit more of an ... involved function (although I haven't noticed any *noticable* performance problems).

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I also recommend "kcachegrind" to display callgrind output in a pretty graphical way.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Try using valgrind/callgrind to simulate a slow machine. You will see a monumental difference in performance when dragging windows. Even my i7 (running callgrind) can't keep up with dragging windows using this branch. But it is almost perfectly fluid without this branch.

Maybe it is the fact that all motion events are getting though now. But regardless, people with slow-to-regular machines will be noticeably impacted. We need a fix before accepting this.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

From what I can tell, the problem is that moveNotify is called much more often with this branch. However moveNotify is far too expensive to call so often, mostly due to DecorWindow::moveNotify.

Does DecorWindow::moveNotify really need to computeShadowRegion on EVERY window whenever a single window moves?

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

One small caveat is that I haven't merged lp:compiz-core into this one today, which includes the region fixes.

> Does DecorWindow::moveNotify really need to computeShadowRegion on EVERY window whenever a single window moves?

Yes it does. There are some optimizations we can do there to make it only compute regions on certain windows. I've done them before, so its not too hard. Not for this branch.

> From what I can tell, the problem is that moveNotify is called much more often with this branch. However moveNotify is far too expensive to call so often, mostly due to DecorWindow::moveNotify.

So I think there are three optimizations which can be applied here, all of which are quite involved, so I'll need to put them in separate branches.

Firstly, we need to throttle motion events, so they aren't dispatched spuriously. That's easy enough to do.

The second which is a bit more complicated is to also throttle dispatch of serverGeometry updates / moveNotify / XConfigureWindow as well. There are some plugins which need immediate move notify updates but probably not immediate move notify updates 1000 times a second.

Another optimization is to only call XConfigureWindow when we actually need to update the server side position and not necessarily all the time. This does mean that serverGeometry will be "ahead" of whats being sent to the server, but that's OK since we can just flush the changes on demand (and besides, its meant to be ahead, which is why its there).

Incidentally, I'm not able to get such high readings in callgrind for window movement, but I guess this is a case-by-case thing.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Window movement accounts for all my CPU because that's all I am testing since I noticed the problem;
  Start compiz
  Move windows around lots
  Stop compiz

With this branch I see movement account for 60-80% of compiz' time and is incredibly slow and stuttering. Without this branch, it only uses maximum 20% of compiz' time and is visually much smoother.

Daniel van Vugt (vanvugt) : Posted in a previous version of this proposal
review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

I merged lp:compiz-core from today. Could you give it another try and let me know how it goes ?

Also some thoughts on those optimizations would be nice :)

Currently I'm testing using the entire unity stack, but I can reduce it down to just compiz and a basic set of plugins.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I was already testing this branch merged with the latest lp:compiz-core (including yesterday's optimizations) all along. Which makes the regression from this branch more worrying.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

tOn Tue, 28 Feb 2012, Daniel van Vugt wrote:

> I was already testing this branch merged with the latest lp:compiz-core (including yesterday's optimizations) all along. Which makes the regression from this branch more worrying.
> --
> https://code.launchpad.net/~smspillaz/compiz-core/compiz-core.work_923683/+merge/94923
> You are the owner of lp:~smspillaz/compiz-core/compiz-core.work_923683.
>

OK, well, I know there are some code paths which can be slow, so lets look
at optimizing. Do you have any thoughts about the ideas I raised ?

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I don't have the encyclopaedic knowledge of CompWindow or the time to research your suggestions right now. So no comment.

But I'm happy to test/profile any further additions to this proposal... tomorrow.

(Daniel logs off)

review: Needs Fixing
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

I don't see anything obviously wrong, but would like to hear the results of Daniel's profiling.

review: Abstain
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Tested revision 2994. Moving windows is still so slow it's unusable (under valgrind). We should fix this because it's a good indication that the same would occur in the wild on a slow machine.

compiz is spending 70% of it's CPU in or below moveHandleMotionEvent. The two main CPU hogs are:

(73% of the 70%)
moveHandleMotionEvent
CompWindow::move
DecorWindow::moveNotify
DecorWindow::computeShadowRegion

(16% of the 70%)
moveHandleMotionEvent
CompWindow::move
CompWindow::configureXWindow
PrivateWindow::reconfigureXWindow

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

And no, combining this branch with lp:~smspillaz/compiz-core/compiz-core.optimization-inlining
does not solve or change the performance problem.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Indeed, that's not meant to completely fix it, but it does fix some hotspots and other inefficiencies I observed :)

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

I'm concerned that the code still looks "fragile" (to use Sam's word). For example:

50 + y1 = geom.height () + geom.border ();
...
59 + y2 = geom.height () - geom.border ();

It isn't explicit why border is added in one case and subtracted in the other. I suspect that there's an abstraction missing (or at least suitably named functions that derive the appropriate result from geom). Something like "internalHeight = internalHeight(geom)" is much easier to follow.

I've not tested the latest version enough to be confident in it. Will aim to do so on Thursday.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> I'm concerned that the code still looks "fragile" (to use Sam's word). For
> example:
>
> 50 + y1 = geom.height () + geom.border ();
> ...
> 59 + y2 = geom.height () - geom.border ();
>
> It isn't explicit why border is added in one case and subtracted in the other.
> I suspect that there's an abstraction missing (or at least suitably named
> functions that derive the appropriate result from geom). Something like
> "internalHeight = internalHeight(geom)" is much easier to follow.
>
> I've not tested the latest version enough to be confident in it. Will aim to
> do so on Thursday.

Ack, I'll add something like that to compiz::window::Geometry

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Tested this branch by itself and merged with lp:~smspillaz/compiz-core/compiz-core.fix_969108.2

By itself, this branch still makes window movement unacceptably slow. With the other branch designed to make movement more efficient, windows now often don't move at all when dragged.

Unfortunately performance is getting worse, not better.

review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Its probably a small typo during refactoring. Please don't panic

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I got this branch performing somewhat better by combining it with:
https://code.launchpad.net/~vanvugt/compiz-core/lastMotionTime/+merge/100742

However I would say still noticeably slower than lp:compiz-core. :(

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Confirmed the performance problems with this branch do seem to be fixed by:
https://code.launchpad.net/~smspillaz/compiz-core/compiz-core.fix_969101/+merge/100270

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Please resubmit with prerequisite:
lp:~smspillaz/compiz-core/compiz-core.fix_969101

review: Resubmit
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

This branch does appear to fix bug 862430.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I was so close to approving and merging this today. But in final testing I noticed it triggers window border/shadow artefacts when resizing. They are easiest to see in Normal resize mode, but still happen much less noticeably in Rectangle resize mode too.

Just put a Nautilus window in front of a large white window and resize the Nautilus window rapidly from its top-right corner. Ugly artefacts will be left on the window behind.

I actually suspect the resize plugin being to blame for this, because I have encountered similar bugs with it before. And read that the GLES branch seems to have too.

However right now, it's being triggered by this branch. So I can't approve it just yet.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I can't reproduce the same resize artefacts with my experimental branch, only with this one.

Perhaps we didn't notice the artefacts before because they are the result of the latest compiz-core commit r3086 combining with this branch...

review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Resubmitted again.

LP #923520 is also fixed in this branch. I'm not sure if the artefacts are fixed "for good" but I can't reproduce them anymore since fixing that one.

(I cannot remove that fix from this branch, since its actually dependent on the fact that we can update window regions before sending geometry to the server, which wouldn't be possible in core at the moment)

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> (I cannot remove that fix from this branch, since its actually dependent on
> the fact that we can update window regions before sending geometry to the
> server, which wouldn't be possible in core at the moment)

Clarifying ambiguous words: I can't separate out that fix.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Typo : bug 932520

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

The intent has always looked sensible. The latest code looks the tidiest. And I've been running it all morning without noticing anything untoward.

review: Approve
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Probably a reason not to merge, but running with "wobbly windows", and dragging a window across others there are repaint issues on the "behind" windows that don't resolve until the moved window is released.

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> Probably a reason not to merge, but running with "wobbly windows", and
> dragging a window across others there are repaint issues on the "behind"
> windows that don't resolve until the moved window is released.

That should be "Probably /not/ a reason not to merge"

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> Probably a reason not to merge, but running with "wobbly windows", and
> dragging a window across others there are repaint issues on the "behind"
> windows that don't resolve until the moved window is released.

I'll resolve this anyhow since it could impact other plugins.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Please remove the ABI changes (include/core/window.h at least). I agree they're nice changes, but we can't change the ABI.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Also, when I maximize and restore a window, it moves left by about 1 pixel each time. So I don't think we can declare this branch as having fixed bug 892012.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

And confirmed the regression with wobbly windows this branch introduces. Although not officially enabled by default, enough people do use wobbly windows for us to want to avoid introducing such a regression.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Confirmed the flicker bug 862430 is fixed. So that's some good news.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Both issues fixed, please re-review.

Will look into the 1px shift later.

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Confirm wobbly windows fixed. They are rather cute!

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I'm still testing the various bugs, and want to continue testing for tomorrow at least.

So far I can't see any regressions. And the 1px movement issue is actually not related to this branch, so forget that for now.

Once I'm happy it runs OK and further fixes are not required, then I'll start reviewing the code again in detail.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I sense a slight performance regression when moving windows compared to trunk. Trunk is slightly smoother. But it's only noticeable when running under callgrind and only slight.

I have confirmed 3 of the 4 bugs are fixed, and the other 1 I can't reproduce.

All good so far. But I won't review the rather large diff in detail tonight.

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Only problem I've seen today is that when I replace the graphics stack all windows end up in 1st workspace. I don't think that is this branch - but haven't got to the bottom of it yet.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

* priv->frameRegion -= infiniteRegion
  should be:
  priv->frameRegion = emptyRegion;

* Gererally speaking, x1 + width != x2
  That's an off-by-one mistake. It should usually be: x1 + width - 1 == x2
  However I can't prove that's causing any problems right now and it's not new in this branch.

* Regression: The resize artefacts reported on 5 April are still present. I thought they were meant to be fixed?

I really really don't want to see any more revisions of this branch. But the regression is kind of a problem.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Thanks, the regression is now fixed (or at least worked around by damageScreen).

And after 10 weeks(!) of revisions on this branch, I'm sure I'm not the only one who is fed up looking at it.

As far as I can tell, it fixes all the bugs linked to it. And there are no visible regressions now. Let's land it, and move on.

review: Approve
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

As above.

review: Approve
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

LGTM

review: Approve
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

REGRESSION:
When resizing a window's top or left edges, the opposite edge jitters about (in Normal resize move). I know I mentioned this bug yesterday but I only just realized it's a regression that's unique to this branch.

Sounds like that's the cause of the resize artefacts too. So if we fix the regression then we can remove the damageScreen workaround from the resize plugin.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

And please wait till Monday at least before proposing any new revisions. It would ruin my weekend to see this branch come up in weekend email :)

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Make that Tuesday. You're meant to have Monday off, I believe :)

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> And please wait till Monday at least before proposing any new revisions. It
> would ruin my weekend to see this branch come up in weekend email :)

Nobody is making you look at this ...........................................

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Okay.

Normal resize mode was not something I was planning on supporting in precise. Nevertheless, I've merged in some work I did a few weeks ago to essentially fix it up so that there's no tearing and windows don't appear to jump around when you resize them.

There is still a race condition in the window decorators where pixmaps can be freed server side before they are bound by the decorator. Getting around that race condition requires some synchronization protocol which I've prototyped and works fine with gtk-window-decorator (no fail to bind errors \o/). However, I don't want to push up the size of the diff anymore. So I've put that work in another branch (lp:~smspillaz/compiz-core/compiz-core.decor_synchronization).

The damageScreen call in DecorWindow::resizeNotify is, while unfortunate, necessary for now at least. There are some race conditions to do with bindPixmapToTexture where the returned size can differ from the actual texture size in the middle of a resize op. As such, damageScreen for now.

I hope this is the last revision we need to do of this.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Contains a trivial conflict in src/window.cpp, but simple to fix and carry on testing.

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Breaks with wobby windows - moving windows distorted, semi-maximized windows placed wrongly

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Regression: Vertically maximizing a window while wobbly is enabled causes it to over-shoot either the top or bottom of the screen, instead of fitting to the top and bottom.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Erm, I think we both just said the same thing :)

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> Erm, I think we both just said the same thing :)

Maybe we're both right?

;)

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Issues with the wobbly plugin fixed.

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

That being said, please keep in mind that for ubuntu we really don't care about plugins and options that we don't enable by default. All upgraders get their settings reset.

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

[Still using wobbly of course] largely fixed.

If I drag to LHS (say) the orange highlight looks fine, but the window first paints and wobbles a few pixels to left before jumping to the correct position.

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

The glitch with wobbly is minor (and now doesn't happen consistently) other issues appear fixed.

review: Approve
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Regression: Weirdly, this branch (r3017) causes a regression of bug 981703. So Alan's fix wasn't the root cause, just a trigger. But we knew that already.

Also contains conflicts.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Regression #2: This branch causes artefacts/gaps in the switcher window. Screenshot emailed to smspillaz.

review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Regressions fixed.

The big change in this branch is here:

 CompWindow::Geometry &
 CompWindow::serverGeometry () const
 {
- return priv->serverGeometry;
+ return priv->attrib.override_redirect ? priv->geometry : priv->serverGeometry;
 }

 CompWindow::Geometry &
 CompWindow::geometry () const
 {
- return priv->geometry;
+ return priv->attrib.override_redirect ? priv->geometry : priv->serverGeometry;
 }

We're now making all calls to both geometry () and serverGeometry () for managed windows return geometry last sent to server. The reason is that for managed windows, configureXWindow can never fail, so the geometry last sent is always the most up to date and the most accurate.

Override redirect windows cant be configured so we used the geometry last received from the server from that.

In my testing, this fixed practically all the flakiness.

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

I have no reason to believe it is doing the wrong thing, but expressions like the following don't parse easily:

2706 + return CompRect (geometry ().xMinusBorder () - priv->border.left,
2707 + geometry ().yMinusBorder () - priv->border.top,

why are we subtracting a border from "*MinusBorder"? why isn't that what "MinusBorder" does?

2708 + geometry ().widthIncBorders () +
2709 priv->border.left + priv->border.right,
2711 + geometry ().heightIncBorders () +
2712 priv->border.top + priv->border.bottom);

why are we adding borders to "*IncBorders"? why isn't that what "IncBorders" does?

(I suspect it's a naming thing, or a missing abstraction.)

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Regression: Window is offset from its decorations (vertically this time).
Test case : Open a terminal, minimize it, restore it using switcher.
Outcome : Window is offset vertically from its decorations.

I've emailed a screenshot to smpsillaz.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

The branch also contains more complex conflicts now that need fixing.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Regression #2: Shading is very broken. Windows shade/unshade without their decorations changing (until the window is moved). And often I can't unshade windows at all.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Lines 2537..2547: This is the same as Alan's branch and ideally shouldn't be in this one too. I will reintroduce that code to trunk soon, when my new fix for bug 981703 is merged.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

And I spy more pointless "-= infiniteRegion" statements.

review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Regressions fixed.

Alan - now that server* is effectively no longer necessary, we can proceed to bulk-rename things in the next series when we get all the code in one place. Wdyt ?

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Not seen any problems over the last couple of hours. Will have a look at the code tomorrow (unless there are more changes by then - in which case I might swear).

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Regression #1: Windows lose their borders (and most shadows) during shading animation. Try this with a Terminal so it's more visible.

Regression #2: "failed to bind pixmap to texture" warnings and flashing white decorations during resize are now much more common in this branch than with trunk. Annoyingly so.

Regression #3: Moving wobbly windows in expo (esp. between workspaces) jump a significant distance after the wobble.

Regression #4: Vertically maximized wobbly windows sometimes jump up/down by one pixel after the wobble, making the bottom border visible/invisible. Try Alt+dragging a vertically maximized window up a little, and sometimes it will move up ~1px. Normally the borders of semi-maximized windows overlap adjacent workspaces by 1px. That's a bug in trunk too, but this regression makes it worse (2px) and unpredictable.

I dare say it might be time to start again, using multiple smaller proposals rather than this one big one. I don't believe a single large proposal is the only way to solve the four related bugs.

review: Needs Fixing
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> Regression #1: Windows lose their borders (and most shadows) during shading
> animation. Try this with a Terminal so it's more visible.

Insignificant.

>
> Regression #2: "failed to bind pixmap to texture" warnings and flashing white
> decorations during resize are now much more common in this branch than with
> trunk. Annoyingly so.

I'm not supporting normal resize mode. See my previous comments as to the flashing white borders and the solution to that.

>
> Regression #3: Moving wobbly windows in expo (esp. between workspaces) jump a
> significant distance after the wobble.

This is the only one worth attention. I will look into it.

>
> Regression #4: Vertically maximized wobbly windows sometimes jump up/down by
> one pixel after the wobble, making the bottom border visible/invisible. Try
> Alt+dragging a vertically maximized window up a little, and sometimes it will
> move up ~1px. Normally the borders of semi-maximized windows overlap adjacent
> workspaces by 1px. That's a bug in trunk too, but this regression makes it
> worse (2px) and unpredictable.

Why is this a bad thing ? Why does this justify rejecting this branch. This feels very insignificant.

>
> I dare say it might be time to start again, using multiple smaller proposals
> rather than this one big one. I don't believe a single large proposal is the
> only way to solve the four related bugs.

Not possible.

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Please don't say something's impossible. It will only motivate me (or other people) to prove you wrong, and that would be a duplication of effort and waste of resources.

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Everyone is getting fed up with this branch.

IMO the prop-review cycle is getting in the way. This sort of problem is better addressed by a pairing session. (Not so easy when not co-located, but still possible.)

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

I'm resubmitting this into the development branch now.

Please Please Please.

We will not be supporting plugins like wobbly and friends in later versions of ubuntu. As such, minor regressions in those plugins are not a good reason to reject this branch.

Normal resize mode is another can of worms. Please don't talk about it either.

The only valid reasons to block this branch are
1) Bad code
2) A regression in the actual supported ubuntu usecases

Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I can imagine regressions #1, #2 and #4 being accepted and ignored indefinitely. But #3 is something I would not want to see in 0.9.8.0. It's a commonly used feature (albeit unofficial) that has worked perfectly until now. If you don't want to fix it then either myself or Alan will be motivated to, because it's annoying us personally.

Please try to fix regression #3 before we merge this branch.

Sam Spilsbury (smspillaz) wrote :

Regressions 1, 3 and 4 fixed (even if they were tiny)

If you want to fix regression 2 (even though its not really a regression, just a race condition that has always existed), then please check out lp:~smspillaz/compiz-core/compiz-core.decor_synchronization . That adds some synchronization primitives to the decoration protocol which fixes races where pixmaps were being bound after destruction.

I've also cleaned up the code a bit now that we don't need to use server* in client code, so the diff size should be smaller.

Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Can we rename this merge "Groundhog Day"?

Alan Griffiths (alan-griffiths) wrote :

Not seen any problems over the last few of hours of use (but not been running wobbly). Will have a look at the code tomorrow (unless there are more changes by then - in which case I might swear).

Daniel van Vugt (vanvugt) wrote :

Pointless use of abs(): All uses of the abs() function in the diff appear to be numerically pointless;
    if (abs (foo))
is the same as:
    if (foo)

Pointless temporary creation/destruction:
1345 + priv->region = priv->inputRegion = CompRegion ();
Should just assign emptyRegion I think.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote :

But the good news is that it's running nicely so far.

3032. By Sam Spilsbury on 2012-04-20

Fix logic errors

Daniel van Vugt (vanvugt) :
review: Approve
3033. By Sam Spilsbury on 2012-04-20

!= 0 not necessary

Alan Griffiths (alan-griffiths) wrote :

Since grabbing latest revision and switching to wobbly I'm seeing misplacement of half-maximized windows.

3034. By Sam Spilsbury on 2012-04-23

Merge lp:compiz-core

Daniel van Vugt (vanvugt) wrote :

Alan, can you elaborate?

Alan Griffiths (alan-griffiths) wrote :

> Alan, can you elaborate?

E.g. drag a window to RHS and get half max highlight. Release and the window goes to a position that is not at the side of the screen.

Daniel van Vugt (vanvugt) wrote :

Hmm, I can't reproduce any such regressions with wobbly+grid plugins and this branch.

Alan Griffiths (alan-griffiths) wrote :

> Hmm, I can't reproduce any such regressions with wobbly+grid plugins and this
> branch.

Odd. Am testing something else just now, but will retest shortly.

Alan Griffiths (alan-griffiths) wrote :

Looks good now. (Can't reproduce friday's problems.)

review: Approve
Daniel van Vugt (vanvugt) wrote :

Double-checked all the header (ABI) changes against plugins-main, plugins-extra and unity. Confirmed the affected classes are not used in any of the major plugin packages.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/composite/src/window.cpp'
2--- plugins/composite/src/window.cpp 2012-03-22 17:00:51 +0000
3+++ plugins/composite/src/window.cpp 2012-04-23 05:39:20 +0000
4@@ -128,6 +128,9 @@
5 /* We have to grab the server here to make sure that window
6 is mapped when getting the window pixmap */
7 XGrabServer (screen->dpy ());
8+
9+ /* Flush changes to the server and wait for it to process them */
10+ XSync (screen->dpy (), false);
11 XGetWindowAttributes (screen->dpy (),
12 ROOTPARENT (priv->window), &attr);
13 if (attr.map_state != IsViewable)
14@@ -250,7 +253,7 @@
15
16 if (x2 > x1 && y2 > y1)
17 {
18- CompWindow::Geometry geom = priv->window->geometry ();
19+ const CompWindow::Geometry &geom = priv->window->serverGeometry ();
20
21 x1 += geom.x () + geom.border ();
22 y1 += geom.y () + geom.border ();
23@@ -272,20 +275,20 @@
24 {
25 int x1, x2, y1, y2;
26
27- CompWindow::Geometry geom = priv->window->geometry ();
28- CompWindowExtents output = priv->window->output ();
29+ const CompWindow::Geometry &geom = priv->window->geometry ();
30+ const CompWindowExtents &output = priv->window->output ();
31
32 /* top */
33 x1 = -output.left - geom.border ();
34 y1 = -output.top - geom.border ();
35- x2 = priv->window->size ().width () + output.right - geom.border ();
36+ x2 = priv->window->size ().width () + output.right;
37 y2 = -geom.border ();
38
39 if (x1 < x2 && y1 < y2)
40 addDamageRect (CompRect (x1, y1, x2 - x1, y2 - y1));
41
42 /* bottom */
43- y1 = priv->window->size ().height () - geom.border ();
44+ y1 = priv->window->size ().height ();
45 y2 = y1 + output.bottom - geom.border ();
46
47 if (x1 < x2 && y1 < y2)
48@@ -295,13 +298,13 @@
49 x1 = -output.left - geom.border ();
50 y1 = -geom.border ();
51 x2 = -geom.border ();
52- y2 = priv->window->size ().height () - geom.border ();
53+ y2 = priv->window->size ().height ();
54
55 if (x1 < x2 && y1 < y2)
56 addDamageRect (CompRect (x1, y1, x2 - x1, y2 - y1));
57
58 /* right */
59- x1 = priv->window->size ().width () - geom.border ();
60+ x1 = priv->window->size ().width ();
61 x2 = x1 + output.right - geom.border ();
62
63 if (x1 < x2 && y1 < y2)
64@@ -322,7 +325,7 @@
65 x = rect.x ();
66 y = rect.y ();
67
68- CompWindow::Geometry geom = priv->window->geometry ();
69+ const CompWindow::Geometry &geom = priv->window->geometry ();
70 x += geom.x () + geom.border ();
71 y += geom.y () + geom.border ();
72
73@@ -341,7 +344,7 @@
74 if (priv->window->shaded () || force ||
75 (priv->window->isViewable ()))
76 {
77- int border = priv->window->geometry ().border ();
78+ int border = priv->window->serverGeometry ().border ();
79
80 int x1 = -MAX (priv->window->output ().left,
81 priv->window->input ().left) - border;
82@@ -410,7 +413,7 @@
83
84 if (!w->damageRect (initial, CompRect (x, y, width, height)))
85 {
86- CompWindow::Geometry geom = w->priv->window->geometry ();
87+ const CompWindow::Geometry &geom = w->priv->window->geometry ();
88
89 x += geom.x () + geom.border ();
90 y += geom.y () + geom.border ();
91@@ -557,10 +560,6 @@
92 {
93 window->resizeNotify (dx, dy, dwidth, dheight);
94
95- Pixmap pixmap = None;
96- CompSize size = CompSize ();
97-
98-
99 if (window->shaded () || (window->isViewable ()))
100 {
101 int x, y, x1, x2, y1, y2;
102@@ -578,25 +577,6 @@
103 cScreen->damageRegion (CompRegion (CompRect (x1, y1, x2 - x1, y2 - y1)));
104 }
105
106- if (window->mapNum () && redirected)
107- {
108- unsigned int actualWidth, actualHeight, ui;
109- Window root;
110- Status result;
111- int i;
112-
113- pixmap = XCompositeNameWindowPixmap (screen->dpy (), ROOTPARENT (window));
114- result = XGetGeometry (screen->dpy (), pixmap, &root, &i, &i,
115- &actualWidth, &actualHeight, &ui, &ui);
116- size = CompSize (actualWidth, actualHeight);
117- if (!result || actualWidth != (unsigned int) window->size ().width () ||
118- actualHeight != (unsigned int) window->size ().height ())
119- {
120- XFreePixmap (screen->dpy (), pixmap);
121- return;
122- }
123- }
124-
125 if (((!window->mapNum () && window->isViewable ()) ||
126 window->state () & CompWindowStateHiddenMask) && window->hasUnmapReference ())
127 {
128@@ -627,9 +607,9 @@
129
130 x1 = x - window->output ().left - dx;
131 y1 = y - window->output ().top - dy;
132- x2 = x + window->size ().width () +
133+ x2 = x + window->geometry ().width () +
134 window->output ().right - dx;
135- y2 = y + window->size ().height () +
136+ y2 = y + window->geometry ().height () +
137 window->output ().bottom - dy;
138
139 cScreen->damageRegion (CompRegion (CompRect (x1, y1, x2 - x1, y2 - y1)));
140
141=== modified file 'plugins/decor/src/decor.cpp'
142--- plugins/decor/src/decor.cpp 2012-04-20 10:40:23 +0000
143+++ plugins/decor/src/decor.cpp 2012-04-23 05:39:20 +0000
144@@ -223,30 +223,38 @@
145
146 const CompRegion *preg = NULL;
147
148- if ((mask & (PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK |
149- PAINT_WINDOW_WITH_OFFSET_MASK)))
150- preg = &region;
151- else if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
152- preg = &infiniteRegion;
153- else
154+ if (mClipGroup)
155 {
156- tmpRegion = mOutputRegion;
157- tmpRegion &= region;
158-
159- if (tmpRegion.isEmpty ())
160+ if ((mask & (PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK |
161+ PAINT_WINDOW_WITH_OFFSET_MASK)))
162 preg = &region;
163+ else if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
164+ preg = &infiniteRegion;
165 else
166- preg = &shadowRegion;
167+ {
168+ tmpRegion = mOutputRegion;
169+ tmpRegion &= region;
170+
171+ if (tmpRegion.isEmpty ())
172+ preg = &region;
173+ else
174+ preg = &shadowRegion;
175+ }
176+
177+ /* In case some plugin needs to paint us with an offset region */
178+ if (preg->isEmpty ())
179+ preg = &region;
180 }
181-
182- /* In case some plugin needs to paint us with an offset region */
183- if (preg->isEmpty ())
184+ else
185 preg = &region;
186
187 const CompRegion &reg (*preg);
188
189 gWindow->geometry ().reset ();
190
191+ if (updateMatrix)
192+ updateDecorationScale ();
193+
194 for (int i = 0; i < wd->nQuad; i++)
195 {
196 box.setGeometry (wd->quad[i].box.x1,
197@@ -275,6 +283,9 @@
198 if (gWindow->textures ().empty ())
199 return;
200
201+ if (updateMatrix)
202+ updateDecorationScale ();
203+
204 if (gWindow->textures ().size () == 1)
205 {
206 ml[0] = gWindow->matrices ()[0];
207@@ -1017,6 +1028,8 @@
208 wd->quad[i].box.y1 * wd->quad[i].matrix.yy +
209 wd->quad[i].box.x1 * wd->quad[i].matrix.yx;
210 }
211+
212+ updateMatrix = false;
213 }
214
215 /*
216@@ -1047,7 +1060,16 @@
217 unsigned int height = window->size ().height ();
218
219 if (window->shaded ())
220- height = 0;
221+ {
222+ if (dScreen->cScreen &&
223+ dScreen->cScreen->compositingActive ())
224+ {
225+ if (!cWindow->pixmap ())
226+ height = 0;
227+ }
228+ else
229+ height = 0;
230+ }
231
232 computeQuadBox (&wd->decor->quad[i], width, height,
233 &x1, &y1, &x2, &y2, &sx, &sy);
234@@ -1060,6 +1082,7 @@
235 wd->quad[i].box.y1 = y1 + y;
236 wd->quad[i].box.x2 = x2 + x;
237 wd->quad[i].box.y2 = y2 + y;
238+
239 wd->quad[i].sx = sx;
240 wd->quad[i].sy = sy;
241 }
242@@ -1083,7 +1106,7 @@
243 DecorWindow::checkSize (const Decoration::Ptr &decoration)
244 {
245 return (decoration->minWidth <= (int) window->size ().width () &&
246- decoration->minHeight <= (int) window->size ().height ());
247+ decoration->minHeight <= (int) window->size ().height ());
248 }
249
250 /*
251@@ -1523,6 +1546,9 @@
252 if (decorate)
253 updateFrame ();
254 window->updateWindowOutputExtents ();
255+
256+ updateReg = true;
257+ updateMatrix = true;
258 mOutputRegion = CompRegion (window->outputRect ());
259 updateGroupShadows ();
260 if (dScreen->cmActive)
261@@ -1686,7 +1712,6 @@
262 XRectangle rects[4];
263 int x, y, width, height;
264 CompWindow::Geometry server = window->serverGeometry ();
265- int bw = server.border () * 2;
266 CompWindowExtents input;
267 CompWindowExtents border;
268 Window parent;
269@@ -1713,8 +1738,8 @@
270
271 x = window->border ().left - border.left;
272 y = window->border ().top - border.top;
273- width = server.width () + input.left + input.right + bw;
274- height = server.height ()+ input.top + input.bottom + bw;
275+ width = server.widthIncBorders () + input.left + input.right;
276+ height = server.heightIncBorders ()+ input.top + input.bottom ;
277
278 /* Non switcher windows are rooted relative to the frame window of the client
279 * and switchers need to be offset by the window geometry of the client */
280@@ -1853,7 +1878,6 @@
281 XRectangle rects[4];
282 int x, y, width, height;
283 CompWindow::Geometry server = window->serverGeometry ();
284- int bw = server.border () * 2;
285 CompWindowExtents input;
286
287 /* Determine frame extents */
288@@ -1864,8 +1888,8 @@
289
290 x = window->input ().left - input.left;
291 y = window->input ().top - input.top;
292- width = server.width () + input.left + input.right + bw;
293- height = server.height ()+ input.top + input.bottom + bw;
294+ width = server.widthIncBorders () + input.left + input.right;
295+ height = server.heightIncBorders ()+ input.top + input.bottom;
296
297 if (window->shaded ())
298 height = input.top + input.bottom;
299@@ -2107,7 +2131,9 @@
300 region += infiniteRegion;
301 }
302 }
303+
304 updateReg = true;
305+ updateMatrix = true;
306 }
307
308 /*
309@@ -2129,6 +2155,7 @@
310 regions[i].translate (input.x (), input.y ());
311 regions[i] &= window->frameRegion ();
312 }
313+
314 updateReg = false;
315 }
316
317@@ -2159,6 +2186,7 @@
318 * anyways, since the window is unmapped. Also need to
319 * update the shadow clip regions for panels and other windows */
320 update (true);
321+ updateDecorationScale ();
322 if (dScreen->mMenusClipGroup.pushClippable (this))
323 updateGroupShadows ();
324
325@@ -2180,7 +2208,7 @@
326 * anyways, since the window is unmapped. Also need to
327 * update the shadow clip regions for panels and other windows */
328 update (true);
329-
330+ updateDecorationScale ();
331 /* Preserve the group shadow update ptr */
332 DecorClipGroupInterface *clipGroup = mClipGroup;
333
334@@ -2367,6 +2395,7 @@
335 if (w)
336 {
337 DECOR_WINDOW (w);
338+
339 dw->updateDecoration ();
340
341 dw->update (true);
342@@ -2702,10 +2731,10 @@
343 wd->quad[i].box.x2 += dx;
344 wd->quad[i].box.y2 += dy;
345 }
346-
347- setDecorationMatrices ();
348 }
349+
350 updateReg = true;
351+ updateMatrix = true;
352
353 mInputRegion.translate (dx, dy);
354 mOutputRegion.translate (dx, dy);
355@@ -2717,32 +2746,6 @@
356 }
357
358 /*
359- * DecorWindow::resizeTimeout
360- *
361- * Called from the timeout on ::resizeNotify,
362- * set the shading and unshading bits and also
363- * updates the decoration. See the comment
364- * in ::resizeNotify as to why the timeout
365- * is necessary here
366- *
367- */
368-bool
369-DecorWindow::resizeTimeout ()
370-{
371- if (shading || unshading)
372- {
373- shading = false;
374- unshading = false;
375-
376- updateDecoration ();
377- }
378-
379- if (!window->hasUnmapReference ())
380- update (true);
381- return false;
382-}
383-
384-/*
385 * DecorWindow::resizeNotify
386 *
387 * Called whenever a window is resized. Update scaled quads and
388@@ -2753,6 +2756,11 @@
389 void
390 DecorWindow::resizeNotify (int dx, int dy, int dwidth, int dheight)
391 {
392+ if (shading || unshading)
393+ {
394+ shading = false;
395+ unshading = false;
396+ }
397 /* FIXME: we should not need a timer for calling decorWindowUpdate,
398 and only call updateWindowDecorationScale if decorWindowUpdate
399 returns false. Unfortunately, decorWindowUpdate may call
400@@ -2760,8 +2768,7 @@
401 we never should call a wrapped function that's currently
402 processed, we need the timer for the moment. updateWindowOutputExtents
403 should be fixed so that it does not emit a resize notification. */
404- resizeUpdate.start (boost::bind (&DecorWindow::resizeTimeout, this), 0);
405- updateDecorationScale ();
406+ updateMatrix = true;
407 updateReg = true;
408
409 mInputRegion = CompRegion (window->inputRect ());
410@@ -2769,7 +2776,12 @@
411 if (dScreen->cmActive && mClipGroup)
412 updateGroupShadows ();
413
414+ updateReg = true;
415+
416 window->resizeNotify (dx, dy, dwidth, dheight);
417+
418+ /* FIXME: remove */
419+ CompositeScreen::get (screen)->damageScreen ();
420 }
421
422
423@@ -3007,6 +3019,7 @@
424 pixmapFailed (false),
425 regions (),
426 updateReg (true),
427+ updateMatrix (true),
428 unshading (false),
429 shading (false),
430 isSwitcher (false),
431
432=== modified file 'plugins/decor/src/decor.h'
433--- plugins/decor/src/decor.h 2012-04-20 10:09:00 +0000
434+++ plugins/decor/src/decor.h 2012-04-23 05:39:20 +0000
435@@ -159,7 +159,7 @@
436
437 class WindowDecoration {
438 public:
439- static WindowDecoration * create (const Decoration::Ptr &);
440+ static WindowDecoration * create (const Decoration::Ptr &d);
441 static void destroy (WindowDecoration *);
442
443 public:
444@@ -250,8 +250,6 @@
445
446 bool damageRect (bool, const CompRect &);
447
448- void computeShadowRegion ();
449-
450 bool glDraw (const GLMatrix &, GLFragment::Attrib &,
451 const CompRegion &, unsigned int);
452 void glDecorate (const GLMatrix &, GLFragment::Attrib &,
453@@ -322,6 +320,7 @@
454
455 CompRegion::Vector regions;
456 bool updateReg;
457+ bool updateMatrix;
458
459 CompTimer resizeUpdate;
460 CompTimer moveUpdate;
461
462=== modified file 'plugins/move/src/move.cpp'
463--- plugins/move/src/move.cpp 2012-02-16 05:31:28 +0000
464+++ plugins/move/src/move.cpp 2012-04-23 05:39:20 +0000
465@@ -316,10 +316,8 @@
466
467 wX = w->geometry ().x ();
468 wY = w->geometry ().y ();
469- wWidth = w->geometry ().width () +
470- w->geometry ().border () * 2;
471- wHeight = w->geometry ().height () +
472- w->geometry ().border () * 2;
473+ wWidth = w->geometry ().widthIncBorders ();
474+ wHeight = w->geometry ().heightIncBorders ();
475
476 ms->x += xRoot - lastPointerX;
477 ms->y += yRoot - lastPointerY;
478
479=== modified file 'plugins/opengl/src/paint.cpp'
480--- plugins/opengl/src/paint.cpp 2012-03-19 09:19:04 +0000
481+++ plugins/opengl/src/paint.cpp 2012-04-23 05:39:20 +0000
482@@ -1194,7 +1194,7 @@
483 !priv->cWindow->damaged ())
484 return true;
485
486- if (priv->textures.empty () && !bind ())
487+ if (textures ().empty () && !bind ())
488 return false;
489
490 if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
491@@ -1210,26 +1210,19 @@
492 //
493 priv->gScreen->setTexEnvMode (GL_REPLACE);
494
495- if (priv->textures.size () == 1)
496+ if (priv->updateState & PrivateGLWindow::UpdateMatrix)
497+ priv->setWindowMatrix ();
498+
499+ if (priv->updateState & PrivateGLWindow::UpdateRegion)
500+ priv->updateWindowRegions ();
501+
502+ for (unsigned int i = 0; i < textures ().size (); i++)
503 {
504- ml[0] = priv->matrices[0];
505+ ml[0] = priv->matrices[i];
506 priv->geometry.reset ();
507- glAddGeometry (ml, priv->window->region (), reg);
508+ glAddGeometry (ml, priv->regions[i], reg);
509 if (priv->geometry.vCount)
510- glDrawTexture (priv->textures[0], fragment, mask);
511- }
512- else
513- {
514- if (priv->updateReg)
515- priv->updateWindowRegions ();
516- for (unsigned int i = 0; i < priv->textures.size (); i++)
517- {
518- ml[0] = priv->matrices[i];
519- priv->geometry.reset ();
520- glAddGeometry (ml, priv->regions[i], reg);
521- if (priv->geometry.vCount)
522- glDrawTexture (priv->textures[i], fragment, mask);
523- }
524+ glDrawTexture (textures ()[i], fragment, mask);
525 }
526
527 return true;
528
529=== modified file 'plugins/opengl/src/privates.h'
530--- plugins/opengl/src/privates.h 2012-04-20 07:35:20 +0000
531+++ plugins/opengl/src/privates.h 2012-04-23 05:39:20 +0000
532@@ -132,6 +132,11 @@
533 public CompositeWindowInterface
534 {
535 public:
536+
537+ static const unsigned int UpdateRegion = 1 << 0;
538+ static const unsigned int UpdateMatrix = 1 << 1;
539+
540+ public:
541 PrivateGLWindow (CompWindow *w, GLWindow *gw);
542 ~PrivateGLWindow ();
543
544@@ -151,7 +156,8 @@
545 GLTexture::List textures;
546 GLTexture::MatrixList matrices;
547 CompRegion::Vector regions;
548- bool updateReg;
549+ unsigned int updateState;
550+ bool needsRebind;
551
552 CompRegion clip;
553
554
555=== modified file 'plugins/opengl/src/window.cpp'
556--- plugins/opengl/src/window.cpp 2012-03-22 17:00:51 +0000
557+++ plugins/opengl/src/window.cpp 2012-04-23 05:39:20 +0000
558@@ -54,7 +54,8 @@
559 gScreen (GLScreen::get (screen)),
560 textures (),
561 regions (),
562- updateReg (true),
563+ updateState (UpdateRegion | UpdateMatrix),
564+ needsRebind (true),
565 clip (),
566 bindFailed (false),
567 geometry (),
568@@ -87,28 +88,41 @@
569 matrices[i].x0 -= (input.x () * matrices[i].xx);
570 matrices[i].y0 -= (input.y () * matrices[i].yy);
571 }
572+
573+ updateState &= ~(UpdateMatrix);
574 }
575
576 bool
577 GLWindow::bind ()
578 {
579 if ((!priv->cWindow->pixmap () && !priv->cWindow->bind ()))
580- return false;
581+ {
582+ if (!priv->textures.empty ())
583+ {
584+ /* Getting a new pixmap failed, recycle the old texture */
585+ priv->needsRebind = false;
586+ return true;
587+ }
588+ }
589
590- priv->textures =
591+ GLTexture::List textures =
592 GLTexture::bindPixmapToTexture (priv->cWindow->pixmap (),
593 priv->cWindow->size ().width (),
594 priv->cWindow->size ().height (),
595 priv->window->depth ());
596- if (priv->textures.empty ())
597+ if (textures.empty ())
598 {
599 compLogMessage ("opengl", CompLogLevelInfo,
600 "Couldn't bind redirected window 0x%x to "
601 "texture\n", (int) priv->window->id ());
602 }
603+ else
604+ {
605+ priv->textures = textures;
606+ priv->needsRebind = false;
607+ }
608
609- priv->setWindowMatrix ();
610- priv->updateReg = true;
611+ priv->updateState |= PrivateGLWindow::UpdateRegion | PrivateGLWindow::UpdateMatrix;
612
613 return true;
614 }
615@@ -116,12 +130,12 @@
616 void
617 GLWindow::release ()
618 {
619- priv->textures.clear ();
620-
621+ /* Release the pixmap but don't release
622+ * the texture (yet) */
623 if (priv->cWindow->pixmap ())
624- {
625 priv->cWindow->release ();
626- }
627+
628+ priv->needsRebind = true;
629 }
630
631 bool
632@@ -180,8 +194,7 @@
633 PrivateGLWindow::resizeNotify (int dx, int dy, int dwidth, int dheight)
634 {
635 window->resizeNotify (dx, dy, dwidth, dheight);
636- setWindowMatrix ();
637- updateReg = true;
638+ updateState |= PrivateGLWindow::UpdateMatrix | PrivateGLWindow::UpdateRegion;
639 if (!window->hasUnmapReference ())
640 gWindow->release ();
641 }
642@@ -190,8 +203,10 @@
643 PrivateGLWindow::moveNotify (int dx, int dy, bool now)
644 {
645 window->moveNotify (dx, dy, now);
646- updateReg = true;
647- setWindowMatrix ();
648+ updateState |= PrivateGLWindow::UpdateMatrix;
649+
650+ foreach (CompRegion &r, regions)
651+ r.translate (dx, dy);
652 }
653
654 void
655@@ -298,6 +313,13 @@
656 const GLTexture::List &
657 GLWindow::textures () const
658 {
659+ static const GLTexture::List emptyList;
660+
661+ /* No pixmap backs this window, let
662+ * users know that the window needs rebinding */
663+ if (priv->needsRebind)
664+ return emptyList;
665+
666 return priv->textures;
667 }
668
669@@ -338,13 +360,13 @@
670 PrivateGLWindow::updateFrameRegion (CompRegion &region)
671 {
672 window->updateFrameRegion (region);
673- updateReg = true;
674+ updateState |= PrivateGLWindow::UpdateRegion;
675 }
676
677 void
678 PrivateGLWindow::updateWindowRegions ()
679 {
680- CompRect input (window->inputRect ());
681+ CompRect input (window->serverInputRect ());
682
683 if (regions.size () != textures.size ())
684 regions.resize (textures.size ());
685@@ -354,7 +376,7 @@
686 regions[i].translate (input.x (), input.y ());
687 regions[i] &= window->region ();
688 }
689- updateReg = false;
690+ updateState &= ~(UpdateRegion);
691 }
692
693 unsigned int
694
695=== modified file 'plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp'
696--- plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp 2012-01-20 06:13:07 +0000
697+++ plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp 2012-04-23 05:39:20 +0000
698@@ -61,13 +61,11 @@
699 }
700
701 left = x - border.left;
702- right = left + g.width () + (border.left +
703- border.right +
704- 2 * g.border ());
705+ right = left + g.widthIncBorders () + (border.left +
706+ border.right);
707 top = y - border.top;
708- bottom = top + g.height () + (border.top +
709- border.bottom +
710- 2 * g.border ());
711+ bottom = top + g.heightIncBorders () + (border.top +
712+ border.bottom);
713
714 if ((right - left) > workArea.width ())
715 {
716
717=== modified file 'plugins/place/src/place.cpp'
718--- plugins/place/src/place.cpp 2012-02-02 17:01:15 +0000
719+++ plugins/place/src/place.cpp 2012-04-23 05:39:20 +0000
720@@ -343,37 +343,36 @@
721 CompWindow::Geometry geom;
722 int output;
723
724+ geom.set (xwc->x, xwc->y, xwc->width, xwc->height,
725+ window->serverGeometry ().border ());
726+
727 if (clampToViewport)
728 {
729 /* left, right, top, bottom target coordinates, clamed to viewport
730 * sizes as we don't need to validate movements to other viewports;
731 * we are only interested in inner-viewport movements */
732
733- x = xwc->x % screen->width ();
734- if ((x + xwc->width) < 0)
735+ x = geom.x () % screen->width ();
736+ if ((geom.x2 ()) < 0)
737 x += screen->width ();
738
739- y = xwc->y % screen->height ();
740- if ((y + xwc->height) < 0)
741+ y = geom.y () % screen->height ();
742+ if ((geom.y2 ()) < 0)
743 y += screen->height ();
744 }
745 else
746 {
747- x = xwc->x;
748- y = xwc->y;
749+ x = geom.x ();
750+ y = geom.y ();
751 }
752
753 left = x - window->border ().left;
754- right = left + xwc->width + (window->border ().left +
755- window->border ().right +
756- 2 * window->serverGeometry ().border ());
757+ right = left + geom.widthIncBorders () + (window->border ().left +
758+ window->border ().right);
759 top = y - window->border ().top;
760- bottom = top + xwc->height + (window->border ().top +
761- window->border ().bottom +
762- 2 * window->serverGeometry ().border ());
763+ bottom = top + geom.heightIncBorders () + (window->border ().top +
764+ window->border ().bottom);
765
766- geom.set (xwc->x, xwc->y, xwc->width, xwc->height,
767- window->serverGeometry ().border ());
768 output = screen->outputDeviceForGeometry (geom);
769 workArea = screen->getWorkareaForOutput (output);
770
771@@ -746,10 +745,8 @@
772 {
773 if (PlaceScreen::get (screen)->getPointerPosition (pos))
774 {
775- unsigned int dx = (window->serverGeometry ().width () / 2) -
776- window->serverGeometry ().border ();
777- unsigned int dy = (window->serverGeometry ().height () / 2) -
778- window->serverGeometry ().border ();
779+ unsigned int dx = (window->serverGeometry ().widthIncBorders () / 2);
780+ unsigned int dy = (window->serverGeometry ().heightIncBorders () / 2);
781 pos -= CompPoint (dx, dy);
782 }
783 else
784@@ -1200,14 +1197,12 @@
785
786 extents.left = pos.x () - window->border ().left;
787 extents.top = pos.y () - window->border ().top;
788- extents.right = extents.left + window->serverWidth () +
789+ extents.right = extents.left + window->serverGeometry ().heightIncBorders () +
790 (window->border ().left +
791- window->border ().right +
792- 2 * window->serverGeometry ().border ());
793- extents.bottom = extents.top + window->serverHeight () +
794+ window->border ().right);
795+ extents.bottom = extents.top + window->serverGeometry ().widthIncBorders () +
796 (window->border ().top +
797- window->border ().bottom +
798- 2 * window->serverGeometry ().border ());
799+ window->border ().bottom);
800
801 delta = workArea.right () - extents.right;
802 if (delta < 0)
803
804=== modified file 'plugins/resize/src/resize.cpp'
805--- plugins/resize/src/resize.cpp 2012-02-16 05:31:28 +0000
806+++ plugins/resize/src/resize.cpp 2012-04-23 05:39:20 +0000
807@@ -642,8 +642,7 @@
808 w->configureXWindow (mask, &xwc);
809 }
810
811- if (!(mask & (CWWidth | CWHeight)))
812- rs->finishResizing ();
813+ rs->finishResizing ();
814
815 if (rs->grabIndex)
816 {
817@@ -1510,15 +1509,6 @@
818 }
819
820 void
821-ResizeWindow::resizeNotify (int dx, int dy, int dwidth, int dheight)
822-{
823- window->resizeNotify (dx, dy, dwidth, dheight);
824-
825- if (rScreen->w == window && !rScreen->grabIndex)
826- rScreen->finishResizing ();
827-}
828-
829-void
830 ResizeScreen::glPaintRectangle (const GLScreenPaintAttrib &sAttrib,
831 const GLMatrix &transform,
832 CompOutput *output,
833
834=== modified file 'plugins/resize/src/resize.h'
835--- plugins/resize/src/resize.h 2012-02-09 07:48:57 +0000
836+++ plugins/resize/src/resize.h 2012-04-23 05:39:20 +0000
837@@ -162,8 +162,6 @@
838 ResizeWindow (CompWindow *w);
839 ~ResizeWindow ();
840
841- void resizeNotify (int, int, int, int);
842-
843 bool damageRect (bool, const CompRect &);
844
845 bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
846
847=== modified file 'plugins/wobbly/src/wobbly.cpp'
848--- plugins/wobbly/src/wobbly.cpp 2011-03-14 16:12:45 +0000
849+++ plugins/wobbly/src/wobbly.cpp 2012-04-23 05:39:20 +0000
850@@ -1772,7 +1772,7 @@
851
852 if (ww->isWobblyWin () && ww->ensureModel ())
853 {
854- CompRect outRect (w->outputRect ());
855+ CompRect outRect (w->serverOutputRect ());
856
857 ww->model->setMiddleAnchor (outRect.x (), outRect.y (),
858 outRect.width (), outRect.height ());
859@@ -1901,7 +1901,7 @@
860 switch (focusEffect) {
861 case WobblyOptions::FocusEffectShiver:
862 {
863- CompRect outRect (w->outputRect ());
864+ CompRect outRect (w->serverOutputRect ());
865
866 ww->model->adjustObjectsForShiver (outRect.x (),
867 outRect.y (),
868@@ -2131,7 +2131,8 @@
869 }
870 wScreen->moveWindow = false;
871
872- if ((mask & CompWindowGrabButtonMask) &&
873+ if (mask & (CompWindowGrabButtonMask) &&
874+ mask & (CompWindowGrabMoveMask) &&
875 wScreen->optionGetMoveWindowMatch ().evaluate (window) &&
876 isWobblyWin ())
877 {
878@@ -2192,7 +2193,7 @@
879 if (wScreen->yConstrained)
880 {
881 int output =
882- ::screen->outputDeviceForGeometry (window->geometry ());
883+ ::screen->outputDeviceForGeometry (window->serverGeometry ());
884 wScreen->constraintBox =
885 &::screen->outputDevs ()[output].workArea ();
886 }
887
888=== modified file 'src/event.cpp'
889--- src/event.cpp 2012-04-05 16:25:37 +0000
890+++ src/event.cpp 2012-04-23 05:39:20 +0000
891@@ -1251,7 +1251,7 @@
892 }
893
894 /* been shaded */
895- if (w->priv->height == 0)
896+ if (w->shaded ())
897 {
898 if (w->id () == priv->activeWindow)
899 w->moveInputFocusTo ();
900
901=== modified file 'src/privatewindow.h'
902--- src/privatewindow.h 2012-03-02 18:02:07 +0000
903+++ src/privatewindow.h 2012-04-23 05:39:20 +0000
904@@ -34,7 +34,6 @@
905 #include <core/timer.h>
906 #include "privatescreen.h"
907
908-
909 typedef CompWindowExtents CompFullscreenMonitorSet;
910
911 class PrivateWindow {
912@@ -167,6 +166,11 @@
913
914 bool handleSyncAlarm ();
915
916+ void move (int dx, int dy, bool sync);
917+ bool resize (int dx, int dy, int dwidth, int dheight, int dborder);
918+ bool resize (const CompWindow::Geometry &g);
919+ bool resize (const XWindowAttributes &attrib);
920+
921 void configure (XConfigureEvent *ce);
922
923 void configureFrame (XConfigureEvent *ce);
924@@ -241,13 +245,8 @@
925 XSizeHints sizeHints;
926 XWMHints *hints;
927
928- struct timeval lastGeometryUpdate;
929- struct timeval lastConfigureRequest;
930-
931 bool inputHint;
932 bool alpha;
933- int width;
934- int height;
935 CompRegion region;
936 CompRegion inputRegion;
937 CompRegion frameRegion;
938@@ -290,8 +289,6 @@
939 typedef std::pair <XWindowChanges, unsigned int> XWCValueMask;
940
941 compiz::X11::PendingEventQueue pendingConfigures;
942- CompTimer mClearCheckTimeout;
943- bool pendingPositionUpdates;
944
945 char *startupId;
946 char *resName;
947@@ -327,6 +324,8 @@
948
949 bool closeRequests;
950 Time lastCloseRequestTime;
951+
952+ bool nextMoveImmediate;
953 };
954
955 #endif
956
957=== modified file 'src/screen.cpp'
958--- src/screen.cpp 2012-04-20 09:58:29 +0000
959+++ src/screen.cpp 2012-04-23 05:39:20 +0000
960@@ -4071,8 +4071,8 @@
961 CompRect rect (gm);
962 int offset;
963
964- rect.setWidth (rect.width () + (gm.border () * 2));
965- rect.setHeight (rect.height () + (gm.border () * 2));
966+ rect.setWidth (gm.widthIncBorders ());
967+ rect.setHeight (gm.heightIncBorders ());
968
969 offset = rect.centerX () < 0 ? -1 : 0;
970 viewport.setX (priv->vp.x () + ((rect.centerX () / width ()) + offset) %
971@@ -4681,6 +4681,8 @@
972 return false;
973 }
974
975+ /* Use synchronous behaviour when running with --sync, useful
976+ * for getting stacktraces when X Errors occurr */
977 XSynchronize (dpy, synchronousX ? True : False);
978
979 snprintf (displayString_, 255, "DISPLAY=%s",
980
981=== modified file 'src/window.cpp'
982--- src/window.cpp 2012-04-20 08:27:16 +0000
983+++ src/window.cpp 2012-04-23 05:39:20 +0000
984@@ -77,8 +77,8 @@
985 PrivateWindow::isInvisible() const
986 {
987 return attrib.map_state != IsViewable ||
988- attrib.x + width + output.right <= 0 ||
989- attrib.y + height + output.bottom <= 0 ||
990+ attrib.x + geometry.width () + output.right <= 0 ||
991+ attrib.y + geometry.height () + output.bottom <= 0 ||
992 attrib.x - output.left >= (int) screen->width () ||
993 attrib.y - output.top >= (int) screen->height ();
994 }
995@@ -813,292 +813,14 @@
996 if (!serverFrame)
997 return;
998
999-
1000- gettimeofday (&lastConfigureRequest, NULL);
1001- /* Flush any changes made to serverFrameGeometry or serverGeometry to the server
1002- * since there is a race condition where geometries will go out-of-sync with
1003- * window movement */
1004-
1005- window->syncPosition ();
1006-
1007- if (serverInput.left || serverInput.right || serverInput.top || serverInput.bottom)
1008- {
1009- int bw = serverGeometry.border () * 2;
1010-
1011- xwc.x = serverGeometry.x () - serverInput.left;
1012- xwc.y = serverGeometry.y () - serverInput.top;
1013- xwc.width = serverGeometry.width () + serverInput.left + serverInput.right + bw;
1014- if (shaded)
1015- xwc.height = serverInput.top + serverInput.bottom + bw;
1016- else
1017- xwc.height = serverGeometry.height () + serverInput.top + serverInput.bottom + bw;
1018-
1019- if (shaded)
1020- height = serverInput.top + serverInput.bottom;
1021-
1022- if (serverFrameGeometry.x () == xwc.x)
1023- valueMask &= ~(CWX);
1024- else
1025- serverFrameGeometry.setX (xwc.x);
1026-
1027- if (serverFrameGeometry.y () == xwc.y)
1028- valueMask &= ~(CWY);
1029- else
1030- serverFrameGeometry.setY (xwc.y);
1031-
1032- if (serverFrameGeometry.width () == xwc.width)
1033- valueMask &= ~(CWWidth);
1034- else
1035- serverFrameGeometry.setWidth (xwc.width);
1036-
1037- if (serverFrameGeometry.height () == xwc.height)
1038- valueMask &= ~(CWHeight);
1039- else
1040- serverFrameGeometry.setHeight (xwc.height);
1041-
1042- /* Geometry is the same, so we're not going to get a ConfigureNotify
1043- * event when the window is configured, which means that other plugins
1044- * won't know that the client, frame and wrapper windows got shifted
1045- * around (and might result in display corruption, eg in OpenGL */
1046- if (valueMask == 0)
1047- {
1048- XConfigureEvent xev;
1049- XWindowAttributes attrib;
1050- unsigned int nchildren = 0;
1051- Window rootRet = 0, parentRet = 0;
1052- Window *children = NULL;
1053-
1054- xev.type = ConfigureNotify;
1055- xev.event = screen->root ();
1056- xev.window = priv->serverFrame;
1057-
1058- XGrabServer (screen->dpy ());
1059-
1060- if (XGetWindowAttributes (screen->dpy (), priv->serverFrame, &attrib))
1061- {
1062- xev.x = attrib.x;
1063- xev.y = attrib.y;
1064- xev.width = attrib.width;
1065- xev.height = attrib.height;
1066- xev.border_width = attrib.border_width;
1067- xev.above = None;
1068-
1069- /* We need to ensure that the stacking order is
1070- * based on the current server stacking order so
1071- * find the sibling to this window's frame in the
1072- * server side stack and stack above that */
1073- XQueryTree (screen->dpy (), screen->root (), &rootRet, &parentRet, &children, &nchildren);
1074-
1075- if (nchildren)
1076- {
1077- for (unsigned int i = 0; i < nchildren; i++)
1078- {
1079- if (i + 1 == nchildren ||
1080- children[i + 1] == ROOTPARENT (window))
1081- {
1082- xev.above = children[i];
1083- break;
1084- }
1085- }
1086- }
1087-
1088- if (children)
1089- XFree (children);
1090-
1091- if (!xev.above)
1092- xev.above = (window->serverPrev) ? ROOTPARENT (window->serverPrev) : None;
1093-
1094- xev.override_redirect = priv->attrib.override_redirect;
1095-
1096- }
1097-
1098- compiz::X11::PendingEvent::Ptr pc =
1099- boost::shared_static_cast<compiz::X11::PendingEvent> (compiz::X11::PendingConfigureEvent::Ptr (
1100- new compiz::X11::PendingConfigureEvent (
1101- screen->dpy (), serverFrame, valueMask, &xwc)));
1102-
1103- pendingConfigures.add (pc);
1104- if (priv->mClearCheckTimeout.active ())
1105- priv->mClearCheckTimeout.stop ();
1106- priv->mClearCheckTimeout.start (boost::bind (&PrivateWindow::checkClear, priv),
1107- 2000, 2500);
1108-
1109- XSendEvent (screen->dpy (), screen->root (), false,
1110- SubstructureNotifyMask, (XEvent *) &xev);
1111-
1112- XUngrabServer (screen->dpy ());
1113- XSync (screen->dpy (), false);
1114- }
1115- else
1116- {
1117- compiz::X11::PendingEvent::Ptr pc =
1118- boost::shared_static_cast<compiz::X11::PendingEvent> (compiz::X11::PendingConfigureEvent::Ptr (
1119- new compiz::X11::PendingConfigureEvent (
1120- screen->dpy (), serverFrame, valueMask, &xwc)));
1121-
1122- pendingConfigures.add (pc);
1123- if (priv->mClearCheckTimeout.active ())
1124- priv->mClearCheckTimeout.stop ();
1125- priv->mClearCheckTimeout.start (boost::bind (&PrivateWindow::checkClear, priv),
1126- 2000, 2500);
1127- XConfigureWindow (screen->dpy (), serverFrame, valueMask, &xwc);
1128- }
1129-
1130- if (shaded)
1131- {
1132- XUnmapWindow (screen->dpy (), wrapper);
1133- }
1134- else
1135- {
1136- XMapWindow (screen->dpy (), wrapper);
1137- XMoveResizeWindow (screen->dpy (), wrapper, serverInput.left, serverInput.top,
1138- serverGeometry.width (), serverGeometry.height ());
1139- }
1140- XMoveResizeWindow (screen->dpy (), id, 0, 0,
1141- serverGeometry.width (), serverGeometry.height ());
1142- window->sendConfigureNotify ();
1143- window->windowNotify (CompWindowNotifyFrameUpdate);
1144- }
1145- else
1146- {
1147- int bw = serverGeometry.border () * 2;
1148-
1149- xwc.x = serverGeometry.x ();
1150- xwc.y = serverGeometry.y ();
1151- xwc.width = serverGeometry.width () + bw;
1152-
1153- /* FIXME: It doesn't make much sense to allow undecorated windows to be
1154- * shaded */
1155- if (shaded)
1156- xwc.height = bw;
1157- else
1158- xwc.height = serverGeometry.height () + bw;
1159-
1160- if (serverFrameGeometry.x () == xwc.x)
1161- valueMask &= ~(CWX);
1162- else
1163- serverFrameGeometry.setX (xwc.x);
1164-
1165- if (serverFrameGeometry.y () == xwc.y)
1166- valueMask &= ~(CWY);
1167- else
1168- serverFrameGeometry.setY (xwc.y);
1169-
1170- if (serverFrameGeometry.width () == xwc.width)
1171- valueMask &= ~(CWWidth);
1172- else
1173- serverFrameGeometry.setWidth (xwc.width);
1174-
1175- if (serverFrameGeometry.height () == xwc.height)
1176- valueMask &= ~(CWHeight);
1177- else
1178- serverFrameGeometry.setHeight (xwc.height);
1179-
1180- /* Geometry is the same, so we're not going to get a ConfigureNotify
1181- * event when the window is configured, which means that other plugins
1182- * won't know that the client, frame and wrapper windows got shifted
1183- * around (and might result in display corruption, eg in OpenGL */
1184- if (valueMask == 0)
1185- {
1186- XConfigureEvent xev;
1187- XWindowAttributes attrib;
1188- unsigned int nchildren = 0;
1189- Window rootRet = 0, parentRet = 0;
1190- Window *children = NULL;
1191-
1192- xev.type = ConfigureNotify;
1193- xev.event = screen->root ();
1194- xev.window = priv->serverFrame;
1195-
1196- XGrabServer (screen->dpy ());
1197-
1198- if (XGetWindowAttributes (screen->dpy (), priv->serverFrame, &attrib))
1199- {
1200- xev.x = attrib.x;
1201- xev.y = attrib.y;
1202- xev.width = attrib.width;
1203- xev.height = attrib.height;
1204- xev.border_width = attrib.border_width;
1205- xev.above = None;
1206-
1207- /* We need to ensure that the stacking order is
1208- * based on the current server stacking order so
1209- * find the sibling to this window's frame in the
1210- * server side stack and stack above that */
1211- XQueryTree (screen->dpy (), screen->root (), &rootRet, &parentRet, &children, &nchildren);
1212-
1213- if (nchildren)
1214- {
1215- for (unsigned int i = 0; i < nchildren; i++)
1216- {
1217- if (i + 1 == nchildren ||
1218- children[i + 1] == ROOTPARENT (window))
1219- {
1220- xev.above = children[i];
1221- break;
1222- }
1223- }
1224- }
1225-
1226- if (children)
1227- XFree (children);
1228-
1229- if (!xev.above)
1230- xev.above = (window->serverPrev) ? ROOTPARENT (window->serverPrev) : None;
1231-
1232- xev.override_redirect = priv->attrib.override_redirect;
1233-
1234- }
1235-
1236- compiz::X11::PendingEvent::Ptr pc =
1237- boost::shared_static_cast<compiz::X11::PendingEvent> (compiz::X11::PendingConfigureEvent::Ptr (
1238- new compiz::X11::PendingConfigureEvent (
1239- screen->dpy (), serverFrame, valueMask, &xwc)));
1240-
1241- pendingConfigures.add (pc);
1242- if (priv->mClearCheckTimeout.active ())
1243- priv->mClearCheckTimeout.stop ();
1244- priv->mClearCheckTimeout.start (boost::bind (&PrivateWindow::checkClear, priv),
1245- 2000, 2500);
1246-
1247- XSendEvent (screen->dpy (), screen->root (), false,
1248- SubstructureNotifyMask, (XEvent *) &xev);
1249-
1250- XUngrabServer (screen->dpy ());
1251- XSync (screen->dpy (), false);
1252- }
1253- else
1254- {
1255- compiz::X11::PendingEvent::Ptr pc =
1256- boost::shared_static_cast<compiz::X11::PendingEvent> (compiz::X11::PendingConfigureEvent::Ptr (
1257- new compiz::X11::PendingConfigureEvent (
1258- screen->dpy (), serverFrame, valueMask, &xwc)));
1259-
1260- pendingConfigures.add (pc);
1261- if (priv->mClearCheckTimeout.active ())
1262- priv->mClearCheckTimeout.stop ();
1263- priv->mClearCheckTimeout.start (boost::bind (&PrivateWindow::checkClear, priv),
1264- 2000, 2500);
1265-
1266- XConfigureWindow (screen->dpy (), serverFrame, valueMask, &xwc);
1267- }
1268-
1269- if (shaded)
1270- {
1271- XUnmapWindow (screen->dpy (), wrapper);
1272- }
1273- else
1274- {
1275- XMapWindow (screen->dpy (), wrapper);
1276- XMoveResizeWindow (screen->dpy (), wrapper, 0, 0,
1277- serverGeometry.width (), serverGeometry.height ());
1278- }
1279-
1280- XMoveResizeWindow (screen->dpy (), id, 0, 0,
1281- serverGeometry.width (), serverGeometry.height ());
1282- window->sendConfigureNotify ();
1283- window->windowNotify (CompWindowNotifyFrameUpdate);
1284- }
1285+ xwc.x = serverGeometry.x ();
1286+ xwc.y = serverGeometry.y ();
1287+ xwc.width = serverGeometry.width ();
1288+ xwc.height = serverGeometry.height ();
1289+ xwc.border_width = serverGeometry.border ();
1290+
1291+ window->configureXWindow (valueMask, &xwc);
1292+ window->windowNotify (CompWindowNotifyFrameUpdate);
1293 window->recalcActions ();
1294 }
1295
1296@@ -1138,11 +860,12 @@
1297 {
1298 CompRegion ret;
1299 int x1, x2, y1, y2;
1300+ const CompWindow::Geometry &geom = attrib.override_redirect ? priv->geometry : priv->serverGeometry;
1301
1302 for (unsigned int i = 0; i < n; i++)
1303 {
1304- x1 = rects[i].x + priv->geometry.border ();
1305- y1 = rects[i].y + priv->geometry.border ();
1306+ x1 = rects[i].x + geom.border ();
1307+ y1 = rects[i].y + geom.border ();
1308 x2 = x1 + rects[i].width;
1309 y2 = y1 + rects[i].height;
1310
1311@@ -1150,17 +873,17 @@
1312 x1 = 0;
1313 if (y1 < 0)
1314 y1 = 0;
1315- if (x2 > priv->width)
1316- x2 = priv->width;
1317- if (y2 > priv->height)
1318- y2 = priv->height;
1319+ if (x2 > geom.width ())
1320+ x2 = geom.width ();
1321+ if (y2 > geom.height ())
1322+ y2 = geom.height ();
1323
1324 if (y1 < y2 && x1 < x2)
1325 {
1326- x1 += priv->geometry.x ();
1327- y1 += priv->geometry.y ();
1328- x2 += priv->geometry.x ();
1329- y2 += priv->geometry.y ();
1330+ x1 += geom.x ();
1331+ y1 += geom.y ();
1332+ x2 += geom.x ();
1333+ y2 += geom.y ();
1334
1335 ret += CompRect (x1, y1, x2 - x1, y2 - y1);
1336 }
1337@@ -1180,25 +903,27 @@
1338 XRectangle r, *boundingShapeRects = NULL;
1339 XRectangle *inputShapeRects = NULL;
1340 int nBounding = 0, nInput = 0;
1341+ const CompWindow::Geometry &geom = attrib.override_redirect ? priv->geometry : priv->serverGeometry;
1342
1343- priv->region = CompRegion ();
1344- priv->inputRegion = CompRegion ();
1345+ priv->region = priv->inputRegion = emptyRegion;
1346
1347 if (screen->XShape ())
1348 {
1349 int order;
1350
1351+ /* We should update the server here */
1352+ XSync (screen->dpy (), false);
1353+
1354 boundingShapeRects = XShapeGetRectangles (screen->dpy (), priv->id,
1355 ShapeBounding, &nBounding, &order);
1356 inputShapeRects = XShapeGetRectangles (screen->dpy (), priv->id,
1357 ShapeInput, &nInput, &order);
1358-
1359 }
1360
1361- r.x = -priv->geometry.border ();
1362- r.y = -priv->geometry.border ();
1363- r.width = priv->width + priv->geometry.border ();
1364- r.height = priv->height + priv->geometry.border ();
1365+ r.x = -geom.border ();
1366+ r.y = -geom.border ();
1367+ r.width = geom.widthIncBorders ();
1368+ r.height = geom.heightIncBorders ();
1369
1370 if (nBounding < 1)
1371 {
1372@@ -1664,6 +1389,9 @@
1373 }
1374
1375 windowNotify (CompWindowNotifyMap);
1376+ /* Send a resizeNotify to plugins to indicate
1377+ * that the map is complete */
1378+ resizeNotify (0, 0, 0, 0);
1379 }
1380
1381 void
1382@@ -1732,7 +1460,7 @@
1383 priv->attrib.map_state = IsUnmapped;
1384 priv->invisible = true;
1385
1386- if (priv->shaded && priv->height)
1387+ if (priv->shaded)
1388 {
1389 priv->updateFrameWindow ();
1390 }
1391@@ -1817,7 +1545,7 @@
1392 }
1393
1394 bool
1395-CompWindow::resize (CompWindow::Geometry gm)
1396+PrivateWindow::resize (const CompWindow::Geometry &gm)
1397 {
1398 /* Input extents are now the last thing sent
1399 * from the server. This might not work in some
1400@@ -1834,12 +1562,8 @@
1401 priv->geometry.height () != gm.height () ||
1402 priv->geometry.border () != gm.border ())
1403 {
1404- int pw, ph;
1405 int dx, dy, dwidth, dheight;
1406
1407- pw = gm.width () + gm.border () * 2;
1408- ph = gm.height () + gm.border () * 2;
1409-
1410 dx = gm.x () - priv->geometry.x ();
1411 dy = gm.y () - priv->geometry.y ();
1412 dwidth = gm.width () - priv->geometry.width ();
1413@@ -1849,37 +1573,58 @@
1414 gm.width (), gm.height (),
1415 gm.border ());
1416
1417- priv->width = pw;
1418- priv->height = ph;
1419-
1420- if (priv->mapNum)
1421- priv->updateRegion ();
1422-
1423- resizeNotify (dx, dy, dwidth, dheight);
1424-
1425 priv->invisible = priv->isInvisible ();
1426+
1427+ if (priv->attrib.override_redirect)
1428+ {
1429+ priv->serverGeometry = priv->geometry;
1430+ priv->serverFrameGeometry = priv->frameGeometry;
1431+
1432+ if (priv->mapNum)
1433+ priv->updateRegion ();
1434+
1435+ window->resizeNotify (dx, dy, dwidth, dheight);
1436+ }
1437 }
1438 else if (priv->geometry.x () != gm.x () || priv->geometry.y () != gm.y ())
1439 {
1440- int dx, dy;
1441-
1442- dx = gm.x () - priv->geometry.x ();
1443- dy = gm.y () - priv->geometry.y ();
1444-
1445- priv->geometry.setX (gm.x ());
1446- priv->geometry.setY (gm.y ());
1447-
1448- priv->region.translate (dx, dy);
1449- priv->inputRegion.translate (dx, dy);
1450- if (!priv->frameRegion.isEmpty ())
1451- priv->frameRegion.translate (dx, dy);
1452-
1453- priv->invisible = priv->isInvisible ();
1454-
1455- moveNotify (dx, dy, true);
1456+ move (gm.x () - priv->geometry.x (),
1457+ gm.y () - priv->geometry.y (), true);
1458 }
1459
1460- updateFrameRegion ();
1461+ return true;
1462+}
1463+
1464+bool
1465+PrivateWindow::resize (const XWindowAttributes &attr)
1466+{
1467+ return resize (CompWindow::Geometry (attr.x, attr.y, attr.width, attr.height,
1468+ attr.border_width));
1469+}
1470+
1471+bool
1472+PrivateWindow::resize (int x,
1473+ int y,
1474+ int width,
1475+ int height,
1476+ int border)
1477+{
1478+ return resize (CompWindow::Geometry (x, y, width, height, border));
1479+}
1480+
1481+bool
1482+CompWindow::resize (CompWindow::Geometry gm)
1483+{
1484+ XWindowChanges xwc = XWINDOWCHANGES_INIT;
1485+ unsigned int valueMask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth;
1486+
1487+ xwc.x = gm.x ();
1488+ xwc.y = gm.y ();
1489+ xwc.width = gm.width ();
1490+ xwc.height = gm.height ();
1491+ xwc.border_width = gm.border ();
1492+
1493+ configureXWindow (valueMask, &xwc);
1494
1495 return true;
1496 }
1497@@ -2047,13 +1792,7 @@
1498 ce->border_width);
1499 else
1500 {
1501- if (ce->override_redirect)
1502- {
1503- priv->serverGeometry.set (ce->x, ce->y, ce->width, ce->height,
1504- ce->border_width);
1505- }
1506-
1507- window->resize (ce->x, ce->y, ce->width, ce->height, ce->border_width);
1508+ resize (ce->x, ce->y, ce->width, ce->height, ce->border_width);
1509 }
1510
1511 if (ce->event == screen->root ())
1512@@ -2123,9 +1862,9 @@
1513 * windows since we didn't resize them
1514 * on configureXWindow */
1515 if (priv->shaded)
1516- height = priv->serverGeometry.height () - priv->serverGeometry.border () * 2 - priv->serverInput.top - priv->serverInput.bottom;
1517+ height = priv->serverGeometry.heightIncBorders () - priv->serverInput.top - priv->serverInput.bottom;
1518 else
1519- height = ce->height - priv->serverGeometry.border () * 2 - priv->serverInput.top - priv->serverInput.bottom;
1520+ height = ce->height + priv->serverGeometry.border () * 2 - priv->serverInput.top - priv->serverInput.bottom;
1521
1522 /* set the frame geometry */
1523 priv->frameGeometry.set (ce->x, ce->y, ce->width, ce->height, ce->border_width);
1524@@ -2134,7 +1873,7 @@
1525 if (priv->syncWait)
1526 priv->syncGeometry.set (x, y, width, height, ce->border_width);
1527 else
1528- window->resize (x, y, width, height, ce->border_width);
1529+ resize (x, y, width, height, ce->border_width);
1530
1531 if (priv->restack (ce->above))
1532 priv->updatePassiveButtonGrabs ();
1533@@ -2143,27 +1882,6 @@
1534
1535 if (above)
1536 above->priv->updatePassiveButtonGrabs ();
1537-
1538- if (!pendingConfigures.pending ())
1539- {
1540- /* Tell plugins its ok to start doing stupid things again but
1541- * obviously FIXME */
1542- CompOption::Vector options;
1543- CompOption::Value v;
1544-
1545- options.push_back (CompOption ("window", CompOption::TypeInt));
1546- v.set ((int) id);
1547- options.back ().set (v);
1548- options.push_back (CompOption ("active", CompOption::TypeInt));
1549- v.set ((int) 0);
1550- options.back ().set (v);
1551-
1552- /* Notify other plugins that it is unsafe to change geometry or serverGeometry
1553- * FIXME: That API should not be accessible to plugins, this is a hack to avoid
1554- * breaking ABI */
1555-
1556- screen->handleCompizEvent ("core", "lock_position", options);
1557- }
1558 }
1559
1560 void
1561@@ -2186,23 +1904,34 @@
1562 {
1563 if (dx || dy)
1564 {
1565- gettimeofday (&priv->lastGeometryUpdate, NULL);
1566-
1567- /* Don't allow window movement to overwrite working geometries
1568- * last received from the server if we know there are pending
1569- * ConfigureNotify events on this window. That's a clunky workaround
1570- * and a FIXME in any case, however, until we can break the API
1571- * and remove CompWindow::move, this will need to be the case */
1572-
1573- if (!priv->pendingConfigures.pending ())
1574+ XWindowChanges xwc = XWINDOWCHANGES_INIT;
1575+ unsigned int valueMask = CWX | CWY;
1576+
1577+ xwc.x = priv->serverGeometry.x () + dx;
1578+ xwc.y = priv->serverGeometry.y () + dy;
1579+
1580+ priv->nextMoveImmediate = immediate;
1581+
1582+ configureXWindow (valueMask, &xwc);
1583+ }
1584+}
1585+
1586+void
1587+PrivateWindow::move (int dx,
1588+ int dy,
1589+ bool immediate)
1590+{
1591+ if (dx || dy)
1592+ {
1593+ priv->geometry.setX (priv->geometry.x () + dx);
1594+ priv->geometry.setY (priv->geometry.y () + dy);
1595+ priv->frameGeometry.setX (priv->frameGeometry.x () + dx);
1596+ priv->frameGeometry.setY (priv->frameGeometry.y () + dy);
1597+
1598+ if (priv->attrib.override_redirect)
1599 {
1600- priv->geometry.setX (priv->geometry.x () + dx);
1601- priv->geometry.setY (priv->geometry.y () + dy);
1602- priv->frameGeometry.setX (priv->frameGeometry.x () + dx);
1603- priv->frameGeometry.setY (priv->frameGeometry.y () + dy);
1604-
1605- priv->pendingPositionUpdates = true;
1606-
1607+ priv->serverGeometry = priv->geometry;
1608+ priv->serverFrameGeometry = priv->frameGeometry;
1609 priv->region.translate (dx, dy);
1610 priv->inputRegion.translate (dx, dy);
1611 if (!priv->frameRegion.isEmpty ())
1612@@ -2210,19 +1939,7 @@
1613
1614 priv->invisible = priv->isInvisible ();
1615
1616- moveNotify (dx, dy, immediate);
1617- }
1618- else
1619- {
1620- XWindowChanges xwc = XWINDOWCHANGES_INIT;
1621- unsigned int valueMask = CWX | CWY;
1622- compLogMessage ("core", CompLogLevelDebug, "pending configure notifies on 0x%x, "\
1623- "moving window asyncrhonously!", (unsigned int) priv->serverId);
1624-
1625- xwc.x = priv->serverGeometry.x () + dx;
1626- xwc.y = priv->serverGeometry.y () + dy;
1627-
1628- configureXWindow (valueMask, &xwc);
1629+ window->moveNotify (dx, dy, true);
1630 }
1631 }
1632 }
1633@@ -2233,22 +1950,6 @@
1634 return !mEvents.empty ();
1635 }
1636
1637-bool
1638-PrivateWindow::checkClear ()
1639-{
1640- if (pendingConfigures.pending ())
1641- {
1642- /* FIXME: This is a hack to avoid performance regressions
1643- * and must be removed in 0.9.6 */
1644- compLogMessage ("core", CompLogLevelWarn, "failed to receive ConfigureNotify event on 0x%x\n",
1645- id);
1646- pendingConfigures.dump ();
1647- pendingConfigures.clear ();
1648- }
1649-
1650- return false;
1651-}
1652-
1653 void
1654 compiz::X11::PendingEventQueue::add (PendingEvent::Ptr p)
1655 {
1656@@ -2470,21 +2171,6 @@
1657 mValueMask (valueMask),
1658 mXwc (*xwc)
1659 {
1660- CompOption::Vector options;
1661- CompOption::Value v;
1662-
1663- options.push_back (CompOption ("window", CompOption::TypeInt));
1664- v.set ((int) w);
1665- options.back ().set (v);
1666- options.push_back (CompOption ("active", CompOption::TypeInt));
1667- v.set ((int) 1);
1668- options.back ().set (v);
1669-
1670- /* Notify other plugins that it is unsafe to change geometry or serverGeometry
1671- * FIXME: That API should not be accessible to plugins, this is a hack to avoid
1672- * breaking ABI */
1673-
1674- screen->handleCompizEvent ("core", "lock_position", options);
1675 }
1676
1677 compiz::X11::PendingConfigureEvent::~PendingConfigureEvent ()
1678@@ -2494,57 +2180,6 @@
1679 void
1680 CompWindow::syncPosition ()
1681 {
1682- gettimeofday (&priv->lastConfigureRequest, NULL);
1683-
1684- unsigned int valueMask = CWX | CWY;
1685- XWindowChanges xwc = XWINDOWCHANGES_INIT;
1686-
1687- if (priv->pendingPositionUpdates && !priv->pendingConfigures.pending ())
1688- {
1689- if (priv->serverFrameGeometry.x () == priv->frameGeometry.x ())
1690- valueMask &= ~(CWX);
1691- if (priv->serverFrameGeometry.y () == priv->frameGeometry.y ())
1692- valueMask &= ~(CWY);
1693-
1694- /* Because CompWindow::move can update the geometry last
1695- * received from the server, we must indicate that no values
1696- * changed, because when the ConfigureNotify comes around
1697- * the values are going to be the same. That's obviously
1698- * broken behaviour and worthy of a FIXME, but requires
1699- * larger changes to the window movement system. */
1700- if (valueMask)
1701- {
1702- priv->serverGeometry.setX (priv->geometry.x ());
1703- priv->serverGeometry.setY (priv->geometry.y ());
1704- priv->serverFrameGeometry.setX (priv->frameGeometry.x ());
1705- priv->serverFrameGeometry.setY (priv->frameGeometry.y ());
1706-
1707- xwc.x = priv->serverFrameGeometry.x ();
1708- xwc.y = priv->serverFrameGeometry.y ();
1709-
1710- compiz::X11::PendingEvent::Ptr pc =
1711- boost::shared_static_cast<compiz::X11::PendingEvent> (compiz::X11::PendingConfigureEvent::Ptr (
1712- new compiz::X11::PendingConfigureEvent (
1713- screen->dpy (), priv->serverFrame, 0, &xwc)));
1714-
1715- priv->pendingConfigures.add (pc);
1716-
1717- /* Got 3 seconds to get its stuff together */
1718- if (priv->mClearCheckTimeout.active ())
1719- priv->mClearCheckTimeout.stop ();
1720- priv->mClearCheckTimeout.start (boost::bind (&PrivateWindow::checkClear, priv),
1721- 2000, 2500);
1722- XConfigureWindow (screen->dpy (), ROOTPARENT (this), valueMask, &xwc);
1723-
1724- if (priv->serverFrame)
1725- {
1726- XMoveWindow (screen->dpy (), priv->wrapper,
1727- priv->serverInput.left, priv->serverInput.top);
1728- sendConfigureNotify ();
1729- }
1730- }
1731- priv->pendingPositionUpdates = false;
1732- }
1733 }
1734
1735 bool
1736@@ -3345,14 +2980,41 @@
1737 {
1738 unsigned int frameValueMask = 0;
1739
1740- /* Immediately sync window position
1741- * if plugins were updating w->geometry () directly
1742- * in order to avoid a race condition */
1743-
1744- window->syncPosition ();
1745+ if (id == screen->root ())
1746+ {
1747+ compLogMessage ("core", CompLogLevelWarn, "attempted to reconfigure root window");
1748+ return;
1749+ }
1750
1751 /* Remove redundant bits */
1752
1753+ xwc->x = valueMask & CWX ? xwc->x : serverGeometry.x ();
1754+ xwc->y = valueMask & CWY ? xwc->y : serverGeometry.y ();
1755+ xwc->width = valueMask & CWWidth ? xwc->width : serverGeometry.width ();
1756+ xwc->height = valueMask & CWHeight ? xwc->height : serverGeometry.height ();
1757+ xwc->border_width = valueMask & CWBorderWidth ? xwc->border_width : serverGeometry.border ();
1758+
1759+ /* Don't allow anything that might generate a BadValue */
1760+ if (valueMask & CWWidth && !xwc->width)
1761+ {
1762+ compLogMessage ("core", CompLogLevelWarn, "Attempted to set < 1 width on a window");
1763+ xwc->width = 1;
1764+ }
1765+
1766+ if (valueMask & CWHeight && !xwc->height)
1767+ {
1768+ compLogMessage ("core", CompLogLevelWarn, "Attempted to set < 1 height on a window");
1769+ xwc->height = 1;
1770+ }
1771+
1772+ int dx = valueMask & CWX ? xwc->x - serverGeometry.x () : 0;
1773+ int dy = valueMask & CWY ? xwc->y - serverGeometry.y () : 0;
1774+ int dwidth = valueMask & CWWidth ? xwc->width - serverGeometry.width () : 0;
1775+ int dheight = valueMask & CWHeight ? xwc->height - serverGeometry.height () : 0;
1776+
1777+ /* FIXME: This is a total fallacy for the reparenting case
1778+ * at least since the client doesn't actually move here, it only
1779+ * moves within the frame */
1780 if (valueMask & CWX && serverGeometry.x () == xwc->x)
1781 valueMask &= ~(CWX);
1782
1783@@ -3419,18 +3081,15 @@
1784 compLogMessage ("core", CompLogLevelWarn, "restack_mode not Above");
1785 }
1786
1787- frameValueMask = valueMask;
1788+ frameValueMask = CWX | CWY | CWWidth | CWHeight | (valueMask & (CWStackMode | CWSibling));
1789
1790- if (frameValueMask & CWX &&
1791- serverFrameGeometry.x () == xwc->x - serverGeometry.border () - serverInput.left)
1792+ if (serverFrameGeometry.x () == xwc->x - serverGeometry.border () - serverInput.left)
1793 frameValueMask &= ~(CWX);
1794
1795- if (frameValueMask & CWY &&
1796- serverFrameGeometry.y () == xwc->y - serverGeometry.border () - serverInput.top)
1797+ if (serverFrameGeometry.y () == xwc->y - serverGeometry.border () - serverInput.top)
1798 frameValueMask &= ~(CWY);
1799
1800- if (frameValueMask & CWWidth &&
1801- serverFrameGeometry.width () == xwc->width + serverGeometry.border () * 2
1802+ if (serverFrameGeometry.width () == xwc->width + serverGeometry.border () * 2
1803 + serverInput.left + serverInput.right)
1804 frameValueMask &= ~(CWWidth);
1805
1806@@ -3440,19 +3099,64 @@
1807
1808 if (shaded)
1809 {
1810- if (frameValueMask & CWHeight &&
1811- serverFrameGeometry.height () == serverGeometry.border () * 2
1812+ if (serverFrameGeometry.height () == serverGeometry.border () * 2
1813 + serverInput.top + serverInput.bottom)
1814 frameValueMask &= ~(CWHeight);
1815 }
1816 else
1817 {
1818- if (frameValueMask & CWHeight &&
1819- serverFrameGeometry.height () == xwc->height + serverGeometry.border () * 2
1820+ if (serverFrameGeometry.height () == xwc->height + serverGeometry.border () * 2
1821 + serverInput.top + serverInput.bottom)
1822 frameValueMask &= ~(CWHeight);
1823 }
1824
1825+
1826+ if (valueMask & CWStackMode &&
1827+ ((xwc->stack_mode != TopIf) && (xwc->stack_mode != BottomIf) && (xwc->stack_mode != Opposite) &&
1828+ (xwc->stack_mode != Above) && (xwc->stack_mode != Below)))
1829+ {
1830+ compLogMessage ("core", CompLogLevelWarn, "Invalid stack mode %i", xwc->stack_mode);
1831+ valueMask &= ~(CWStackMode | CWSibling);
1832+ }
1833+
1834+ /* Don't allow anything that might cause a BadMatch error */
1835+
1836+ if (valueMask & CWSibling && !(valueMask & CWStackMode))
1837+ {
1838+ compLogMessage ("core", CompLogLevelWarn, "Didn't specify a CWStackMode for CWSibling");
1839+ valueMask &= ~CWSibling;
1840+ }
1841+
1842+ if (valueMask & CWSibling && xwc->sibling == (serverFrame ? serverFrame : id))
1843+ {
1844+ compLogMessage ("core", CompLogLevelWarn, "Can't restack a window relative to itself");
1845+ valueMask &= ~CWSibling;
1846+ }
1847+
1848+ if (valueMask & CWBorderWidth && attrib.c_class == InputOnly)
1849+ {
1850+ compLogMessage ("core", CompLogLevelWarn, "Cannot set border_width of an input_only window");
1851+ valueMask &= ~CWBorderWidth;
1852+ }
1853+
1854+ if (valueMask & CWSibling)
1855+ {
1856+ CompWindow *sibling = screen->findTopLevelWindow (xwc->sibling);
1857+
1858+ if (!sibling)
1859+ {
1860+ compLogMessage ("core", CompLogLevelWarn, "Attempted to restack relative to 0x%x which is "\
1861+ "not a child of the root window or a window compiz owns", static_cast <unsigned int> (xwc->sibling));
1862+ valueMask &= ~(CWSibling | CWStackMode);
1863+ }
1864+ else if (sibling->frame () && xwc->sibling != sibling->frame ())
1865+ {
1866+ compLogMessage ("core", CompLogLevelWarn, "Attempted to restack relative to 0x%x which is "\
1867+ "not a child of the root window", static_cast <unsigned int> (xwc->sibling));
1868+ valueMask &= ~(CWSibling | CWStackMode);
1869+ }
1870+ }
1871+
1872 /* Can't set the border width of frame windows */
1873 frameValueMask &= ~(CWBorderWidth);
1874
1875@@ -3479,11 +3183,8 @@
1876 + serverInput.top + serverInput.bottom);
1877 }
1878
1879-
1880 if (serverFrame)
1881 {
1882- gettimeofday (&lastConfigureRequest, NULL);
1883-
1884 if (frameValueMask)
1885 {
1886 XWindowChanges wc = *xwc;
1887@@ -3499,13 +3200,10 @@
1888 screen->dpy (), priv->serverFrame, frameValueMask, &wc)));
1889
1890 pendingConfigures.add (pc);
1891- if (priv->mClearCheckTimeout.active ())
1892- priv->mClearCheckTimeout.stop ();
1893- priv->mClearCheckTimeout.start (boost::bind (&PrivateWindow::checkClear, priv),
1894- 2000, 2500);
1895
1896 XConfigureWindow (screen->dpy (), serverFrame, frameValueMask, &wc);
1897 }
1898+
1899 valueMask &= ~(CWSibling | CWStackMode);
1900
1901 /* If the frame has changed position (eg, serverInput.top
1902@@ -3531,6 +3229,39 @@
1903
1904 if (valueMask)
1905 XConfigureWindow (screen->dpy (), id, valueMask, xwc);
1906+
1907+ /* When updating plugins we care about
1908+ * the absolute position */
1909+ if (dx)
1910+ valueMask |= CWX;
1911+ if (dy)
1912+ valueMask |= CWY;
1913+ if (dwidth)
1914+ valueMask |= CWWidth;
1915+ if (dheight)
1916+ valueMask |= CWHeight;
1917+
1918+ if (!attrib.override_redirect)
1919+ {
1920+ if (valueMask & (CWWidth | CWHeight))
1921+ {
1922+ updateRegion ();
1923+ window->resizeNotify (dx, dy, dwidth, dheight);
1924+ }
1925+ else if (valueMask & (CWX | CWY))
1926+ {
1927+ region.translate (dx, dy);
1928+ inputRegion.translate (dx, dy);
1929+ if (!frameRegion.isEmpty ())
1930+ frameRegion.translate (dx, dy);
1931+
1932+ if (dx || dy)
1933+ {
1934+ window->moveNotify (dx, dy, priv->nextMoveImmediate);
1935+ priv->nextMoveImmediate = true;
1936+ }
1937+ }
1938+ }
1939 }
1940
1941 bool
1942@@ -4308,10 +4039,6 @@
1943 screen->dpy (), serverFrame, valueMask, &lxwc)));
1944
1945 pendingConfigures.add (pc);
1946- if (priv->mClearCheckTimeout.active ())
1947- priv->mClearCheckTimeout.stop ();
1948- priv->mClearCheckTimeout.start (boost::bind (&PrivateWindow::checkClear, priv),
1949- 2000, 2500);
1950 }
1951
1952 /* Below with no sibling puts the window at the bottom
1953@@ -4615,8 +4342,8 @@
1954 PrivateWindow::ensureWindowVisibility ()
1955 {
1956 int x1, y1, x2, y2;
1957- int width = serverGeometry.width () + serverGeometry.border () * 2;
1958- int height = serverGeometry.height () + serverGeometry.border () * 2;
1959+ int width = serverGeometry.widthIncBorders ();
1960+ int height = serverGeometry.heightIncBorders ();
1961 int dx = 0;
1962 int dy = 0;
1963
1964@@ -5476,10 +5203,10 @@
1965 }
1966 else
1967 {
1968- m = priv->geometry.x () + offX;
1969- if (m - priv->input.left < (int) s->width () - vWidth)
1970+ m = priv->serverGeometry.x () + offX;
1971+ if (m - priv->serverInput.left < (int) s->width () - vWidth)
1972 rv.setX (offX + vWidth);
1973- else if (m + priv->width + priv->input.right > vWidth)
1974+ else if (m + priv->serverGeometry.width () + priv->serverInput.right > vWidth)
1975 rv.setX (offX - vWidth);
1976 else
1977 rv.setX (offX);
1978@@ -5491,10 +5218,10 @@
1979 }
1980 else
1981 {
1982- m = priv->geometry.y () + offY;
1983- if (m - priv->input.top < (int) s->height () - vHeight)
1984+ m = priv->serverGeometry.y () + offY;
1985+ if (m - priv->serverInput.top < (int) s->height () - vHeight)
1986 rv.setY (offY + vHeight);
1987- else if (m + priv->height + priv->input.bottom > vHeight)
1988+ else if (m + priv->serverGeometry.height () + priv->serverInput.bottom > vHeight)
1989 rv.setY (offY - vHeight);
1990 else
1991 rv.setY (offY);
1992@@ -6017,8 +5744,8 @@
1993 y -= screen->vp ().y () * screen->height ();
1994 }
1995
1996- tx = x - priv->geometry.x ();
1997- ty = y - priv->geometry.y ();
1998+ tx = x - priv->serverGeometry.x ();
1999+ ty = y - priv->serverGeometry.y ();
2000
2001 if (tx || ty)
2002 {
2003@@ -6040,21 +5767,21 @@
2004
2005 if (screen->vpSize ().width ()!= 1)
2006 {
2007- m = priv->geometry.x () + tx;
2008+ m = priv->serverGeometry.x () + tx;
2009
2010 if (m - priv->output.left < (int) screen->width () - vWidth)
2011 wx = tx + vWidth;
2012- else if (m + priv->width + priv->output.right > vWidth)
2013+ else if (m + priv->serverGeometry.width () + priv->output.right > vWidth)
2014 wx = tx - vWidth;
2015 }
2016
2017 if (screen->vpSize ().height () != 1)
2018 {
2019- m = priv->geometry.y () + ty;
2020+ m = priv->serverGeometry.y () + ty;
2021
2022 if (m - priv->output.top < (int) screen->height () - vHeight)
2023 wy = ty + vHeight;
2024- else if (m + priv->height + priv->output.bottom > vHeight)
2025+ else if (m + priv->serverGeometry.height () + priv->output.bottom > vHeight)
2026 wy = ty - vHeight;
2027 }
2028
2029@@ -6209,8 +5936,8 @@
2030 svp = screen->vp ();
2031 size = *screen;
2032
2033- x = window->geometry ().x () + (svp.x () - vp.x ()) * size.width ();
2034- y = window->geometry ().y () + (svp.y () - vp.y ()) * size.height ();
2035+ x = window->serverGeometry ().x () + (svp.x () - vp.x ()) * size.width ();
2036+ y = window->serverGeometry ().y () + (svp.y () - vp.y ()) * size.height ();
2037 window->moveToViewportPosition (x, y, true);
2038
2039 if (allowWindowFocus (0, timestamp))
2040@@ -6279,9 +6006,6 @@
2041 priv->serverFrameGeometry = priv->frameGeometry = priv->syncGeometry
2042 = priv->geometry = priv->serverGeometry;
2043
2044- priv->width = priv->attrib.width + priv->attrib.border_width * 2;
2045- priv->height = priv->attrib.height + priv->attrib.border_width * 2;
2046-
2047 priv->sizeHints.flags = 0;
2048
2049 priv->recalcNormalHints ();
2050@@ -6303,8 +6027,7 @@
2051
2052 if (priv->attrib.c_class != InputOnly)
2053 {
2054- priv->region = CompRegion (priv->attrib.x, priv->attrib.y,
2055- priv->width, priv->height);
2056+ priv->region = CompRegion (priv->serverGeometry);
2057 priv->inputRegion = priv->region;
2058
2059 /* need to check for DisplayModal state on all windows */
2060@@ -6534,8 +6257,6 @@
2061 hints (NULL),
2062 inputHint (true),
2063 alpha (false),
2064- width (0),
2065- height (0),
2066 region (),
2067 wmType (0),
2068 type (CompWindowTypeUnknownMask),
2069@@ -6570,7 +6291,6 @@
2070 pendingUnmaps (0),
2071 pendingMaps (0),
2072 pendingConfigures (screen->dpy ()),
2073- pendingPositionUpdates (false),
2074
2075 startupId (0),
2076 resName (0),
2077@@ -6748,14 +6468,12 @@
2078 void
2079 CompWindow::updateFrameRegion ()
2080 {
2081- if (priv->serverFrame &&
2082- priv->serverGeometry.width () == priv->geometry.width () &&
2083- priv->serverGeometry.height () == priv->geometry.height ())
2084+ if (priv->serverFrame)
2085 {
2086 CompRect r;
2087 int x, y;
2088
2089- priv->frameRegion = CompRegion ();
2090+ priv->frameRegion = emptyRegion;
2091
2092 updateFrameRegion (priv->frameRegion);
2093
2094@@ -6764,16 +6482,16 @@
2095 r = priv->region.boundingRect ();
2096 priv->frameRegion -= r;
2097
2098- r.setGeometry (r.x1 () - priv->input.left,
2099- r.y1 () - priv->input.top,
2100- r.width () + priv->input.right + priv->input.left,
2101- r.height () + priv->input.bottom + priv->input.top);
2102+ r.setGeometry (r.x1 () - priv->serverInput.left,
2103+ r.y1 () - priv->serverInput.top,
2104+ r.width () + priv->serverInput.right + priv->serverInput.left,
2105+ r.height () + priv->serverInput.bottom + priv->serverInput.top);
2106
2107 priv->frameRegion &= CompRegion (r);
2108 }
2109
2110- x = priv->geometry.x () - priv->input.left;
2111- y = priv->geometry.y () - priv->input.top;
2112+ x = priv->serverGeometry.x () - priv->serverInput.left;
2113+ y = priv->serverGeometry.y () - priv->serverInput.top;
2114
2115 XShapeCombineRegion (screen->dpy (), priv->serverFrame,
2116 ShapeBounding, -x, -y,
2117@@ -6791,6 +6509,10 @@
2118 CompWindow::setWindowFrameExtents (CompWindowExtents *b,
2119 CompWindowExtents *i)
2120 {
2121+ /* override redirect windows can't have frame extents */
2122+ if (priv->attrib.override_redirect)
2123+ return;
2124+
2125 /* Input extents are used for frame size,
2126 * Border extents used for placement.
2127 */
2128@@ -6814,6 +6536,11 @@
2129
2130 priv->updateSize ();
2131 priv->updateFrameWindow ();
2132+
2133+ /* Always send a moveNotify
2134+ * whenever the frame extents update
2135+ * so that plugins can re-position appropriately */
2136+ moveNotify (0, 0, true);
2137 }
2138
2139 /* Use b for _NET_WM_FRAME_EXTENTS here because
2140@@ -7097,10 +6824,10 @@
2141 /* Wait for the reparent to finish */
2142 XSync (dpy, false);
2143
2144- xwc.x = serverGeometry.x () - serverGeometry.border ();
2145- xwc.y = serverGeometry.y () - serverGeometry.border ();
2146- xwc.width = serverGeometry.width () + serverGeometry.border () * 2;
2147- xwc.height = serverGeometry.height () + serverGeometry.border () * 2;
2148+ xwc.x = serverGeometry.xMinusBorder ();
2149+ xwc.y = serverGeometry.yMinusBorder ();
2150+ xwc.width = serverGeometry.widthIncBorders ();
2151+ xwc.height = serverGeometry.heightIncBorders ();
2152
2153 XConfigureWindow (dpy, serverFrame, CWX | CWY | CWWidth | CWHeight, &xwc);
2154
2155
2156=== modified file 'src/window/geometry/include/core/windowgeometry.h'
2157--- src/window/geometry/include/core/windowgeometry.h 2012-01-19 20:08:32 +0000
2158+++ src/window/geometry/include/core/windowgeometry.h 2012-04-23 05:39:20 +0000
2159@@ -64,6 +64,12 @@
2160 compiz::window::Geometry change (const compiz::window::Geometry &g, unsigned int mask) const;
2161 void applyChange (const compiz::window::Geometry &g, unsigned int mask);
2162
2163+ int xMinusBorder () const { return x () - mBorder; }
2164+ int yMinusBorder () const { return y () - mBorder; }
2165+
2166+ unsigned int widthIncBorders () const { return width () + mBorder * 2; }
2167+ unsigned int heightIncBorders () const { return height () + mBorder * 2; }
2168+
2169 private:
2170 int mBorder;
2171 };
2172
2173=== modified file 'src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp'
2174--- src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp 2012-03-30 16:30:13 +0000
2175+++ src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp 2012-04-23 05:39:20 +0000
2176@@ -87,3 +87,13 @@
2177 EXPECT_EQ (rg, compiz::window::Geometry (49, 99, 199, 299, 5));
2178 EXPECT_EQ (mask, CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT);
2179 }
2180+
2181+TEST_F(CompWindowGeometryTestGeometry, TestBorders)
2182+{
2183+ compiz::window::Geometry g (1, 1, 1, 1, 1);
2184+
2185+ EXPECT_EQ (g.xMinusBorder (), 0);
2186+ EXPECT_EQ (g.yMinusBorder (), 0);
2187+ EXPECT_EQ (g.widthIncBorders (), 3);
2188+ EXPECT_EQ (g.heightIncBorders (), 3);
2189+}
2190
2191=== modified file 'src/windowgeometry.cpp'
2192--- src/windowgeometry.cpp 2012-01-23 05:44:19 +0000
2193+++ src/windowgeometry.cpp 2012-04-23 05:39:20 +0000
2194@@ -30,160 +30,153 @@
2195 CompWindow::Geometry &
2196 CompWindow::serverGeometry () const
2197 {
2198- return priv->serverGeometry;
2199+ return priv->attrib.override_redirect ? priv->geometry : priv->serverGeometry;
2200 }
2201
2202 CompWindow::Geometry &
2203 CompWindow::geometry () const
2204 {
2205- return priv->geometry;
2206+ return priv->attrib.override_redirect ? priv->geometry : priv->serverGeometry;
2207 }
2208
2209 int
2210 CompWindow::x () const
2211 {
2212- return priv->geometry.x ();
2213+ return geometry ().x ();
2214 }
2215
2216 int
2217 CompWindow::y () const
2218 {
2219- return priv->geometry.y ();
2220+ return geometry ().y ();
2221 }
2222
2223 CompPoint
2224 CompWindow::pos () const
2225 {
2226- return CompPoint (priv->geometry.x (), priv->geometry.y ());
2227+ return CompPoint (geometry ().x (), geometry ().y ());
2228 }
2229
2230 /* With border */
2231 int
2232 CompWindow::width () const
2233 {
2234- return priv->width +
2235- priv->geometry.border () * 2;
2236+ return geometry ().widthIncBorders ();
2237 }
2238
2239 int
2240 CompWindow::height () const
2241 {
2242- return priv->height +
2243- priv->geometry.border () * 2;;
2244+ return geometry ().heightIncBorders ();
2245 }
2246
2247 CompSize
2248 CompWindow::size () const
2249 {
2250- return CompSize (priv->width + priv->geometry.border () * 2,
2251- priv->height + priv->geometry.border () * 2);
2252+ return CompSize (width (), height ());
2253 }
2254
2255 int
2256 CompWindow::serverX () const
2257 {
2258- return priv->serverGeometry.x ();
2259+ return serverGeometry ().x ();
2260 }
2261
2262 int
2263 CompWindow::serverY () const
2264 {
2265- return priv->serverGeometry.y ();
2266+ return serverGeometry ().y ();
2267 }
2268
2269 CompPoint
2270 CompWindow::serverPos () const
2271 {
2272- return CompPoint (priv->serverGeometry.x (),
2273- priv->serverGeometry.y ());
2274+ return CompPoint (serverGeometry ().x (),
2275+ serverGeometry ().y ());
2276 }
2277
2278 /* With border */
2279 int
2280 CompWindow::serverWidth () const
2281 {
2282- return priv->serverGeometry.width () +
2283- 2 * priv->serverGeometry.border ();
2284+ return serverGeometry ().widthIncBorders ();
2285 }
2286
2287 int
2288 CompWindow::serverHeight () const
2289 {
2290- return priv->serverGeometry.height () +
2291- 2 * priv->serverGeometry.border ();
2292+ return serverGeometry ().heightIncBorders ();
2293 }
2294
2295 const CompSize
2296 CompWindow::serverSize () const
2297 {
2298- return CompSize (priv->serverGeometry.width () +
2299- 2 * priv->serverGeometry.border (),
2300- priv->serverGeometry.height () +
2301- 2 * priv->serverGeometry.border ());
2302+ return CompSize (serverGeometry ().widthIncBorders (),
2303+ serverGeometry ().heightIncBorders ());
2304 }
2305
2306 CompRect
2307 CompWindow::borderRect () const
2308 {
2309- return CompRect (priv->geometry.x () - priv->geometry.border () - priv->border.left,
2310- priv->geometry.y () - priv->geometry.border () - priv->border.top,
2311- priv->geometry.width () + priv->geometry.border () * 2 +
2312+ return CompRect (geometry ().xMinusBorder () - priv->border.left,
2313+ geometry ().yMinusBorder () - priv->border.top,
2314+ geometry ().widthIncBorders () +
2315 priv->border.left + priv->border.right,
2316- priv->geometry.height () + priv->geometry.border () * 2 +
2317+ geometry ().heightIncBorders () +
2318 priv->border.top + priv->border.bottom);
2319 }
2320
2321 CompRect
2322 CompWindow::serverBorderRect () const
2323 {
2324- return CompRect (priv->serverGeometry.x () - priv->geometry.border () - priv->border.left,
2325- priv->serverGeometry.y () - priv->geometry.border () - priv->border.top,
2326- priv->serverGeometry.width () + priv->geometry.border () * 2 +
2327+ return CompRect (serverGeometry ().xMinusBorder () - priv->border.left,
2328+ serverGeometry ().yMinusBorder () - priv->border.top,
2329+ serverGeometry ().widthIncBorders () +
2330 priv->border.left + priv->border.right,
2331- priv->serverGeometry.height () + priv->geometry.border () * 2 +
2332+ serverGeometry ().heightIncBorders() +
2333 priv->border.top + priv->border.bottom);
2334 }
2335
2336 CompRect
2337 CompWindow::inputRect () const
2338 {
2339- return CompRect (priv->geometry.x () - priv->geometry.border () - priv->serverInput.left,
2340- priv->geometry.y () - priv->geometry.border () - priv->serverInput.top,
2341- priv->geometry.width () + priv->geometry.border () * 2 +
2342+ return CompRect (geometry ().xMinusBorder () - priv->serverInput.left,
2343+ geometry ().yMinusBorder () - priv->serverInput.top,
2344+ geometry ().widthIncBorders () +
2345 priv->serverInput.left + priv->serverInput.right,
2346- priv->geometry.height () +priv->geometry.border () * 2 +
2347+ geometry ().heightIncBorders () +
2348 priv->serverInput.top + priv->serverInput.bottom);
2349 }
2350
2351 CompRect
2352 CompWindow::serverInputRect () const
2353 {
2354- return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->serverInput.left,
2355- priv->serverGeometry.y () - priv->serverGeometry.border () - priv->serverInput.top,
2356- priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
2357+ return CompRect (serverGeometry ().xMinusBorder () - priv->serverInput.left,
2358+ serverGeometry ().yMinusBorder () - priv->serverInput.top,
2359+ serverGeometry ().widthIncBorders () +
2360 priv->serverInput.left + priv->serverInput.right,
2361- priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
2362+ serverGeometry ().heightIncBorders () +
2363 priv->serverInput.top + priv->serverInput.bottom);
2364 }
2365
2366 CompRect
2367 CompWindow::outputRect () const
2368 {
2369- return CompRect (priv->geometry.x () - priv->serverGeometry.border ()- priv->output.left,
2370- priv->geometry.y () - priv->serverGeometry.border () - priv->output.top,
2371- priv->geometry.width () + priv->serverGeometry.border () * 2 +
2372+ return CompRect (geometry ().xMinusBorder ()- priv->output.left,
2373+ geometry ().yMinusBorder () - priv->output.top,
2374+ geometry ().widthIncBorders () +
2375 priv->output.left + priv->output.right,
2376- priv->geometry.height () + priv->serverGeometry.border () * 2 +
2377+ geometry ().heightIncBorders () +
2378 priv->output.top + priv->output.bottom);
2379 }
2380
2381 CompRect
2382 CompWindow::serverOutputRect () const
2383 {
2384- return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->output.left,
2385- priv->serverGeometry.y () - priv->serverGeometry.border () - priv->output.top,
2386- priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
2387+ return CompRect (serverGeometry ().xMinusBorder () - priv->output.left,
2388+ serverGeometry ().yMinusBorder () - priv->output.top,
2389+ serverGeometry ().widthIncBorders () +
2390 priv->output.left + priv->output.right,
2391- priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
2392+ serverGeometry ().heightIncBorders () +
2393 priv->output.top + priv->output.bottom);
2394 }

Subscribers

People subscribed via source and target branches