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

Proposed by Sam Spilsbury
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: 2548 lines (+537/-822) (has conflicts)
20 files modified
plugins/composite/src/window.cpp (+19/-39)
plugins/decor/src/decor.cpp (+86/-73)
plugins/decor/src/decor.h (+3/-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 (+12/-12)
src/actions.cpp (+2/-2)
src/event.cpp (+1/-1)
src/privatewindow.h (+7/-8)
src/screen.cpp (+4/-2)
src/window.cpp (+257/-545)
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 src/window.cpp
To merge this branch: bzr merge lp:~smspillaz/compiz-core/compiz-core.work_923683
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Fixing
Alan Griffiths Approve
Sam Spilsbury Pending
Review via email: mp+101690@code.launchpad.net

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

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

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.
Revision history for this message
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...

Revision history for this message
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

Revision history for this message
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
Revision history for this message
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...

Revision history for this message
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 ()"; }"

Revision history for this message
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
Revision history for this message
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; }

Revision history for this message
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

Revision history for this message
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.

Revision history for this message
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)

Revision history for this message
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.

Revision history for this message
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: Needs Resubmitting
Revision history for this message
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
Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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".

Revision history for this message
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.

Revision history for this message
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 ?

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

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

Revision history for this message
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 :(

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

    //XSynchronize (dpy, TRUE);

:) Haven't merged your other branch

Revision history for this message
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);

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

Perhaps remember to pull from trunk more often.

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

where trunk == lp:compiz-core

Revision history for this message
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?

Revision history for this message
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.

Revision history for this message
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);

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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).

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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 ?

Revision history for this message
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

Revision history for this message
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 ?

Revision history for this message
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.

Revision history for this message
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 ?

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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.
>

Revision history for this message
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.
>

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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"

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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)

Revision history for this message
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
Revision history for this message
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

Revision history for this message
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
Revision history for this message
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.
>

Revision history for this message
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 :-)

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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
Revision history for this message
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

Revision history for this message
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).

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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?

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
Daniel van Vugt (vanvugt) : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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 ?

Revision history for this message
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
Revision history for this message
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
Revision history for this message
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
Revision history for this message
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.

Revision history for this message
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 :)

Revision history for this message
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.

Revision history for this message
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

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal
Revision history for this message
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
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

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

Revision history for this message
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. :(

Revision history for this message
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

Revision history for this message
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: Needs Resubmitting
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

This branch does appear to fix bug 862430.

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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)

Revision history for this message
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.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Typo : bug 932520

Revision history for this message
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
Revision history for this message
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.

Revision history for this message
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"

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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.

Revision history for this message
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.

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

Confirm wobbly windows fixed. They are rather cute!

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

As above.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

LGTM

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

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
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

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

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

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

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

> 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 ...........................................

3009. By Sam Spilsbury

Merged trunk and fixed a number of problems with resize synchronization

3010. By Sam Spilsbury

Send resize notification immediately for windows that aren't override redirect

3011. By Sam Spilsbury

Fix jumping around on resize because we were rebinding way too much at the wrong time.

Only rebind on paints.

3012. By Sam Spilsbury

Don't not update decorations when we're grabbed for resizing

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

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.

3013. By Sam Spilsbury

Null check

3014. By Sam Spilsbury

resize: unconditionally finish the resize operation when releasing the button

3015. By Sam Spilsbury

Merge trunk

3016. By Sam Spilsbury

Don't send a moveNotify and resizeNotify if the window was moved and resized

3017. By Sam Spilsbury

Cleanup wobbly model update code

3018. By Sam Spilsbury

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

3019. By Sam Spilsbury

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

Clean some cruft

3021. By Sam Spilsbury

Update decoration matrix of shaded windows

3022. By Sam Spilsbury

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

3023. By Sam Spilsbury

Merge lp:compiz-core

3024. By Sam Spilsbury

Don't notify plugins of unreparent in the right place

3025. By Sam Spilsbury

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

3026. By Sam Spilsbury

updateState is bitwise, so never clobber it

3027. By Sam Spilsbury

Base decision to send notifications to plugins on absolute position
changes

3028. By Sam Spilsbury

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

3029. By Sam Spilsbury

Remove some unnecessary cahgnes in the wobbly plugin

3030. By Sam Spilsbury

Merge lp:compiz-core

3031. By Sam Spilsbury

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

Fix logic errors

3033. By Sam Spilsbury

!= 0 not necessary

3034. By Sam Spilsbury

Merge lp:compiz-core

Unmerged revisions

3034. By Sam Spilsbury

Merge lp:compiz-core

3033. By Sam Spilsbury

!= 0 not necessary

3032. By Sam Spilsbury

Fix logic errors

3031. By Sam Spilsbury

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

Merge lp:compiz-core

3029. By Sam Spilsbury

Remove some unnecessary cahgnes in the wobbly plugin

3028. By Sam Spilsbury

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

3027. By Sam Spilsbury

Base decision to send notifications to plugins on absolute position
changes

3026. By Sam Spilsbury

updateState is bitwise, so never clobber it

3025. By Sam Spilsbury

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

Subscribers

People subscribed via source and target branches