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

Proposed by Sam Spilsbury on 2012-04-16
Status: Superseded
Proposed branch: lp:~smspillaz/compiz-core/compiz-core.work_923683
Merge into: lp:compiz-core
Prerequisite: lp:~smspillaz/compiz-core/compiz-core.fix_969101
Diff against target: 2730 lines (+586/-827) (has conflicts)
21 files modified
plugins/composite/src/window.cpp (+19/-39)
plugins/decor/src/decor.cpp (+102/-49)
plugins/decor/src/decor.h (+4/-3)
plugins/move/src/move.cpp (+10/-12)
plugins/opengl/src/paint.cpp (+11/-18)
plugins/opengl/src/privates.h (+7/-1)
plugins/opengl/src/window.cpp (+40/-18)
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 (+8/-18)
plugins/resize/src/resize.h (+0/-2)
plugins/wobbly/src/wobbly.cpp (+37/-40)
plugins/wobbly/src/wobbly.h (+2/-0)
src/actions.cpp (+2/-2)
src/event.cpp (+1/-1)
src/privatewindow.h (+7/-8)
src/screen.cpp (+4/-2)
src/window.cpp (+262/-546)
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 (+31/-38)
Text conflict in plugins/decor/src/decor.cpp
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-16 Needs Fixing on 2012-04-17
Alan Griffiths 2012-04-16 Approve on 2012-04-16
Sam Spilsbury Pending
Review via email: mp+102098@code.launchpad.net

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

This proposal has been superseded by a proposal from 2012-04-18.

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

Note: you'll get funny behaviour around window edges unless you use lp:~smspillaz/compiz-snap-plugin/compiz-snap-plugin.work_923683 . The snap plugin was using the interfaces incorrectly.

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 is only ever called pre-request to the server 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
 * composite and opengl now use the geometry last sent to the server in order
   to compute display matrices and window positions as well as damage regions
 * decor now also does the above
 * const correctness in include/core/window.h
 * 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 about 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.

Caveats:

 0) There are no tests yet
 1) Window movement performance will regress with this branch. This is *probably* due to the fact that for every slight movement, we send a full ConfigureWindow request to the X Server and it has to post back to us a full ConfigureNotify, for pretty much every pixel the window moves. In the case that we're not doing compositing thats fine, but in every other case its *super* chatty and largely unnecessary. This can probably be optimized a lot, but that will require work to gather up requests that we want to send to the X server - combine them (eg, merging the stack of requests based on the change mask and using the latest values where appropriate). Thats a lot of work and probably not appropriate in this branch
 2) The diff is a little big
 3) No tests
 4) Window shading is more than likely going to break again, mostly because I haven't tested it yet, but also because shading does some strange things and manipulated geometry values in strange ways
 5) No tests

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 :

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 :

[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 :

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

review: Approve
Daniel van Vugt (vanvugt) wrote :

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 :

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

review: Needs Fixing
3018. By Sam Spilsbury on 2012-04-17

Ensure that override redirect windows get their regions set correctly.
Also they can't have input extents.

3019. By Sam Spilsbury on 2012-04-18

Force all override redirect windows to use geometry last received from
server. Force all managed windows to use geometry last sent.

The difference between geometry and server* is now moot and can be
removed in a future release

3020. By Sam Spilsbury on 2012-04-18

Clean some cruft

3021. By Sam Spilsbury on 2012-04-18

Update decoration matrix of shaded windows

3022. By Sam Spilsbury on 2012-04-18

Send a resizeNotify to indicate to plugins when map operations have completed

3023. By Sam Spilsbury on 2012-04-18

Merge lp:compiz-core

3024. By Sam Spilsbury on 2012-04-18

Don't notify plugins of unreparent in the right place

3025. By Sam Spilsbury on 2012-04-18

Merged lp:~vanvugt/compiz-core/compiz-core/fix-981703-properly

3026. By Sam Spilsbury on 2012-04-18

updateState is bitwise, so never clobber it

3027. By Sam Spilsbury on 2012-04-18

Base decision to send notifications to plugins on absolute position
changes

3028. By Sam Spilsbury on 2012-04-19

Don't set height = 0 if the window still has a pixmap

3029. By Sam Spilsbury on 2012-04-19

Remove some unnecessary cahgnes in the wobbly plugin

3030. By Sam Spilsbury on 2012-04-19

Merge lp:compiz-core

3031. By Sam Spilsbury on 2012-04-19

Now that geometry and serverGeometry both return the same thing, the changes
in client code don't make any sense to keep

3032. By Sam Spilsbury on 2012-04-20

Fix logic errors

3033. By Sam Spilsbury on 2012-04-20

!= 0 not necessary

3034. By Sam Spilsbury on 2012-04-23

Merge lp:compiz-core

Unmerged revisions

3034. By Sam Spilsbury on 2012-04-23

Merge lp:compiz-core

3033. By Sam Spilsbury on 2012-04-20

!= 0 not necessary

3032. By Sam Spilsbury on 2012-04-20

Fix logic errors

3031. By Sam Spilsbury on 2012-04-19

Now that geometry and serverGeometry both return the same thing, the changes
in client code don't make any sense to keep

3030. By Sam Spilsbury on 2012-04-19

Merge lp:compiz-core

3029. By Sam Spilsbury on 2012-04-19

Remove some unnecessary cahgnes in the wobbly plugin

3028. By Sam Spilsbury on 2012-04-19

Don't set height = 0 if the window still has a pixmap

3027. By Sam Spilsbury on 2012-04-18

Base decision to send notifications to plugins on absolute position
changes

3026. By Sam Spilsbury on 2012-04-18

updateState is bitwise, so never clobber it

3025. By Sam Spilsbury on 2012-04-18

Merged lp:~vanvugt/compiz-core/compiz-core/fix-981703-properly

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

Subscribers

People subscribed via source and target branches