Merge lp:~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces into lp:compiz/0.9.10

Proposed by MC Return
Status: Merged
Approved by: Sam Spilsbury
Approved revision: no longer in the revision history of the source branch.
Merged at revision: 3650
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces
Merge into: lp:compiz/0.9.10
Diff against target: 739 lines (+219/-88)
4 files modified
plugins/expo/src/expo.cpp (+6/-0)
plugins/grid/grid.xml.in (+31/-26)
plugins/grid/src/grid.cpp (+180/-61)
plugins/grid/src/grid.h (+2/-1)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Sami Jaktholm (community) Approve
Sam Spilsbury Approve
MC Return Pending
Review via email: mp+157817@code.launchpad.net

This proposal supersedes a proposal from 2013-04-08.

Commit message

*Grid code:

Prevent center and corner gridded windows from jumping viewports.
(Thanks and credits for this go to Sami Jaktholm)

Prevent top and bottom gridded windows from jumping viewports by
making those semi-maximize horizontally.

As those are actually semi-maximized horizontally, we will treat
them as such and let core handle the restoring, just like we
already do for vertically semi-maximized grid windows (left/right).

Now "Strg+Super+Down" will restore top and bottom gridded windows
correctly as well.

Also multiple gridding to top, bottom, left or right will not
overwrite the stored original size anymore.

Restore windows also when workspace switcher (expo) is active.
(Thanks and credits for this go to Sami Jaktholm)

Allow cycling for all gridded windows if explicitly specified by the
user in CCSM.

Forbid cycling through different sizes for corner and center-gridded
windows also per default, now fully fixing bug #878820 and following
the design specification by Ayatana Design there, making behaviour
consistent.

Introduced 3 new bools:
horzMaximizedGridPosition,
vertMaximizedGridPosition,
anyMaximizedGridPosition

Used these bools inside the if condition checks.
Simplified complicated if condition by removing redundant additional
size check.

Cleanup all around.

*Grid xml:

Added cycle_sizes bool option, which allows the user to choose the
prefered behaviour (fixed versus flexible sizes on multiple presses
on the same grid keyboard shortcut).
Default of this option is off, cycling disabled as specified by design.

Added punctuation where missing and removed it where usually is none.
Fixed typos, improved description and titles.

*Expo code:
Tell grid when viewport change is in progress.
(Thanks and credits for this go to Sami Jaktholm)

(fixes: LP: #878820, LP: #879218, LP: #882754 and LP: #1082001,
 partially fixes: #1116538, #1164332)

To post a comment you must log in.
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Ping ?

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

Hey, I'm pretty busy at the moment. I'll get on to this ASAP.

On Thu, Apr 4, 2013 at 12:11 PM, MC Return <email address hidden> wrote:
> Ping ?
> --
> https://code.launchpad.net/~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces/+merge/156663
> Your team Compiz Maintainers is requested to review the proposed merge of lp:~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces into lp:compiz.

--
Sam Spilsbury

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> Hey, I'm pretty busy at the moment. I'll get on to this ASAP.
>
Please take your time. I am honestly sorry for stressing.
I am just so excited that this MP already fixes 3 IMHO important
Grid usability bugs and so I was curious about your opinion... ;)

I will continue to work on it in the meantime, because I am
confident now that I am able to fully fix the bugs linked here...

Once all the bugs are fixed, I want to continue with optimization
of the logic and splitting out the various codeparts into separate
functions... - but this should probably be made in a separate MP
as this diff is already large enough, which complicates your review
effort (I am sorry for that)...

I can only ensure you that all changes are tested well and extensively
and manually by myself, which reduces the risk of errors or regressions
slipping through undetected ->
http://bazaar.launchpad.net/~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces/revision/3648
is an example for this ;)

Hope that I have all Grid bugs fixed, once you get to the review ;)

Revision history for this message
Sami Jaktholm (sjakthol) wrote : Posted in a previous version of this proposal

Some thoughts:
1) Top or bottom gridded windows can't be restored by dragging. The window does move up and down but doesn't snap off without pressing restore button/key (seems to be the default behavior for horizontally maximized windows).
2) Code duplication for GridTop || GridBottom case in initiateCommon. This could go like:
    if Top || Bottom || Left || Right
      *restore original geometry and change sizeHints*
      Resized = false

      if Top || Bottom
         maximize(HorzMask)
         HorzMaximized = true
         VertMaximized = false
      else
         maximize(VertMask)
         HorzMaximized = false
         VertMaximized = true

3) The easiest solution to fix bug 1082001 is to make expo send start/end_viewport_switch event at the start/end of viewport switch. Grid listens for those events and knows not to block the window movement while viewport switch is in progress. Currently only wall and rotate are emitting those events although expo and cube are also triggering viewport switches (so cube might need the change too).

The first point definitely needs fixing, the second one is just an opinion...

review: Needs Fixing
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Hey sampo555 :)
Thanks a lot 4 your review, it is very appreciated.

> Some thoughts:
> 1) Top or bottom gridded windows can't be restored by dragging. The window
> does move up and down but doesn't snap off without pressing restore button/key
> (seems to be the default behavior for horizontally maximized windows).
>

I did not notice that problem, because on multimonitor systems it snaps off, once
your pointer crosses monitors when dragging.
I also have "Rotate Cube"->"Edge Flip DnD" enabled, which makes the top/bottom
gridded window restore as well.

But of course this should be no excuse. I'll try to find the problem and fix it.

> 2) Code duplication for GridTop || GridBottom case in initiateCommon. This
> could go like:
> if Top || Bottom || Left || Right
> *restore original geometry and change sizeHints*
> Resized = false
>
> if Top || Bottom
> maximize(HorzMask)
> HorzMaximized = true
> VertMaximized = false
> else
> maximize(VertMask)
> HorzMaximized = false
> VertMaximized = true
>

Yes. Will fix that also (was already on the TODO list).

> 3) The easiest solution to fix bug 1082001 is to make expo send
> start/end_viewport_switch event at the start/end of viewport switch. Grid
> listens for those events and knows not to block the window movement while
> viewport switch is in progress. Currently only wall and rotate are emitting
> those events although expo and cube are also triggering viewport switches (so
> cube might need the change too).
>

Very good observation. Actually awesome, sounds like the key to the solution. \o/
I still was unsure about the best way to approach the problem...
I think I'll have to conduct some experiments with that...

> The first point definitely needs fixing, the second one is just an opinion...
>

All of your points are valid and your review is very welcome.
They'll all get fixed ;).

sampo555, thanks for your involvement with Compiz.
I hope to see some new MPs from you soon...

P.S.: I'll change the status of this MP to "WIP", but additional comments are
always welcome...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

@sampo55:
Did some experiments with making expo send the start/end_viewport_switch event at the start/end of viewport switch, but I was not able to get it right :(
The main new problem I got by doing that, was that Expo drag-and-dropping windows failed to work once Expo announces start_viewport_switch...
I am quite clueless @ the moment, so if you have a working solution or did experiments yourself, please propose a MP, so we can test it...

Revision history for this message
Sami Jaktholm (sjakthol) wrote : Posted in a previous version of this proposal

I don't have any code to show as I just checked what wall did but expo didn't. As DnD fails, I assume you're emitting those events right when expo starts/quits(?). If you emit the events only when expo calls moveViewport, it shouldn't affect DnD windows (emitting those events equals to situation without grid). So something like this could work:
  screen->handleCompizEvent ("expo","start_viewport_switch", CompOption::Vector());
  screen->moveViewport(...)
  screen->handleCompizEvent ("expo","end_viewport_switch", CompOption::Vector());

I don't have time to test it right now, but I can try it later...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> I don't have any code to show as I just checked what wall did but expo didn't.
> As DnD fails, I assume you're emitting those events right when expo
> starts/quits(?). If you emit the events only when expo calls moveViewport, it
> shouldn't affect DnD windows (emitting those events equals to situation
> without grid). So something like this could work:
> screen->handleCompizEvent ("expo","start_viewport_switch",
> CompOption::Vector());
> screen->moveViewport(...)
> screen->handleCompizEvent ("expo","end_viewport_switch",
> CompOption::Vector());
>
> I don't have time to test it right now, but I can try it later...

Yeah - that might indeed be the problem. I'll try that and will report here...
Thanks 4 your involvement, sampo555 - and sorry for spelling your synonym
incorrectly before ;)

Revision history for this message
Sami Jaktholm (sjakthol) wrote : Posted in a previous version of this proposal

That seems to work, but there's still a problem as gridded windows (corners) can't be dragged anywhere in expo (also present in the current trunk). That's because grid ignores the fact that window is dragged in expo (for valid reasons) but still stops the window from moving.

Seems a bit tricky to get this one right :)

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> That seems to work, but there's still a problem as gridded windows (corners)
> can't be dragged anywhere in expo (also present in the current trunk). That's
> because grid ignores the fact that window is dragged in expo (for valid
> reasons) but still stops the window from moving.
>
> Seems a bit tricky to get this one right :)

Hehe, tricky describes it perfectly ;)
It would really be nice if you could propose the expo/cube code, as I did just get
to the point, where gridded corner windows do not jump viewports anymore, but I am
not able to drag any window in expo mode currently, which is ofc inacceptable...

Other observations:
In trunk it is currently possible to drag and drop corner-gridded windows in expo,
just dragging itself is not animated and the window disappears in one viewport and
suddenly pops up in the viewport it is dragged to once you release the mousebutton...

But on multimonitor systems it is not possible to drag the same windows from one
screen to the other, just from viewport to viewport...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

One other point:
Seems the cube does not need any changes, as just rotate cube seems to be responsible
for moving windows...
If you unfold the cube (which is a cube option) and change workspace corner-gridded
windows stay in their position, so it seems no fix is needed here...

Revision history for this message
Sami Jaktholm (sjakthol) wrote : Posted in a previous version of this proposal

It seems to be very tricky to restore the gridded window inside expo. We can't use pointer location to calculate the restored position as it's absolute to the screen, not relative to expo viewport. We also can't restore it to original location as it might jump anywhere.

So there's pretty much two solutions:
1) Restore the window in place. Problem: the restored window might detach from the pointer, if the it's smaller than the gridded window (depending on where user grabs the window). This can't be easily solved as we don't know where the pointer is relative to the window.
2) Don't restore the window. If the window is moved inside expo, just forgot that it's gridded. This is less likely to cause any issues but it's not consistent with rest of grid behavior or nice thing to do to the user (I wouldn't like it).

Personally I like the first one more as it has a chance to get it right at least some times. The second option just feels a little broken. Anyways, an implementation of the first option can be found from lp:~sjakthol/compiz/grid-expo-interaction. Please test it, and if you think it's good, you can merge it to your branch and start debugging those horizontally maximized windows.

(I'm still the same guy - just did some profile reconfiguration)

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> It seems to be very tricky to restore the gridded window inside expo. We can't
> use pointer location to calculate the restored position as it's absolute to
> the screen, not relative to expo viewport. We also can't restore it to
> original location as it might jump anywhere.
>
> So there's pretty much two solutions:
> 1) Restore the window in place. Problem: the restored window might detach from
> the pointer, if the it's smaller than the gridded window (depending on where
> user grabs the window). This can't be easily solved as we don't know where the
> pointer is relative to the window.
> 2) Don't restore the window. If the window is moved inside expo, just forgot
> that it's gridded. This is less likely to cause any issues but it's not
> consistent with rest of grid behavior or nice thing to do to the user (I
> wouldn't like it).
>
> Personally I like the first one more as it has a chance to get it right at
> least some times. The second option just feels a little broken. Anyways, an
> implementation of the first option can be found from lp:~sjakthol/compiz/grid-
> expo-interaction. Please test it, and if you think it's good, you can merge it
> to your branch and start debugging those horizontally maximized windows.
>
> (I'm still the same guy - just did some profile reconfiguration)

Hi, Sami Jaktholm :)

I've tested your branch now and this looks like another big improvement to me.
Everything works exactly like you described. Top job !

I also think that the solution you found is our best bet at the moment and it
will still affect just corner- and center-gridded windows to restore to original
size when dragged inside expo.

This solution is just slightly inconsistent, compared to the behaviour of grid-
semi-maximized and maximized windows, which will keep their size when dragged to
a new viewport - but it is 100 times better than the version we have in trunk now,
which also acts inconsistent and makes gridded windows jump around and follow the
user's moves in expo...

Restoring the window to original size is always the best solution, because gridding
it back requires just one shortcut, while it can be nerving to have to manually resize
to get back to original size.
Btw, there is still a working workaround for users, who want to move a corner- or center-
gridded window from one workspace to another (rotate to cube face with window) - this
one works perfectly for gridded windows as well...

I still have to apply your other improvements here, and still have to find a solution
for snapping off horizontally maximized windows correctly and easily...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> Some thoughts:
> 1) Top or bottom gridded windows can't be restored by dragging. The window
> does move up and down but doesn't snap off without pressing restore button/key
> (seems to be the default behavior for horizontally maximized windows).

Yes. The problem is actually hidden in the move plugin. The option SnapoffMaximized ()
does not take care of & CompWindowStateMaximizedHorzMask windows.

You can easily check this wrong behaviour by horizontally maximizing a window by
right-mousebutton clicking the maximize button and you'll get the same behaviour
like for top and bottom gridded windows with this branch here...

Actually I should file another bug and fix that in another branch I guess, but I
do not know, maybe I'll simply attach another bug report here...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

I have now filed bug #1165198 about "Horizontally semi-maximized windows do not snap off easily"...

@Sami Jaktholm: Can you confirm ?

Revision history for this message
Sami Jaktholm (sjakthol) wrote : Posted in a previous version of this proposal

A second branch might be a better solution. Let's keep this as a fix for grid&expo problem only. Once the other fix lands, I'm ok with this (although I'm probably not the best judge as I have very narrow understanding of how this stuff actually works).

review: Approve
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> A second branch might be a better solution. Let's keep this as a fix for
> grid&expo problem only. Once the other fix lands, I'm ok with this (although
> I'm probably not the best judge as I have very narrow understanding of how
> this stuff actually works).

Okay. The fix for the move snapoff problem should be relatively easy. I already
got a working solution (just a quick hack), but I am confident I can fix this
correctly soonish...

If you are interested: the problem is hidden in static void moveHandleMotionEvent (...)

There:
if (ms->optionGetSnapoffMaximized ())
does not check:
if (w->state () & CompWindowStateMaximizedHorzMask)

and thus Compiz has no strategy to snap off a horizontally semi-maximized window...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> A second branch might be a better solution. Let's keep this as a fix for
> grid&expo problem only. Once the other fix lands, I'm ok with this (although
> I'm probably not the best judge as I have very narrow understanding of how
> this stuff actually works).

I've uploaded the fix for bug #1165198 to this branch now anyway as it is somehow
related and is very separated fromthe rest (as the fix is in the move plugin).

Re-review and re-test needed ;)

Revision history for this message
Sami Jaktholm (sjakthol) wrote : Posted in a previous version of this proposal

The change to move code might cause a change in behavior in a corner case. If the window is HorzMaximized but not VertMaximized, the code will never enter the next else if clause (where it would remaximize the window) as it returns in the new else if block. However I haven't found a way to trigger this case so it shouldn't be a problem.

I still think you should split these changes up as the move changes have nothing to do with the original problem.

Other than that, it looks good and works fine.

review: Approve
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Hey Sami :)

Thanks for the review and testing.
I have tested the changes extensively as well and could find no regressions.

/offtopic on
But during testing I found a new bug unfortunately... it seems to have nothing to do with this MP and can be reproduced in trunk as well, but a multimonitor system is needed:

1.Semi-maximize horizontally or maximize a window on monitor 2
2.Change the viewport
3.Switch back to your window with a switcher, or via click on its icon in a dock/launcher

Result: The viewport will change correctly, but the window will move to the main monitor and maximize/semi-maximize horizontally there

Can you reproduce this also (without this branch) ?
/offtopic off

Regarding move: Sure, I can make a new MP for that - my only personal problem is that my SSD is 96,8% full and each
MP with a compiled/tested Compiz build takes another 400MB away ;) - so I am quite handicapped with available space @ the moment...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

I've changed the partial fixes in the commit message to numbers, but I might have to remove the linked bug reports, so launchpad won't auto-track them and change them to "Fix Committed" when committing this to trunk, but I'll better adjust the status of those manually after the merge...

Revision history for this message
Sami Jaktholm (sjakthol) wrote : Posted in a previous version of this proposal

I don't have a second monitor to test that.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> I don't have a second monitor to test that.
No problem, seems to be completely unrelated anyway... will check that one @ a later stage...

We are now bailing out if we are repeating the same action:
Probably this would have been enough:

if (gw->lastTarget == where &&
    gw->isGridResized)
    return false

but it works now also (with a little bit of redundancy in the condition check) ;)

I'll have to optimize that a bit...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Okay, behaviour is configurable now (at least for corner and center gridded windows), so we won't regress for noone...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Made the behaviour now fully configurable for all gridded windows.

Revision history for this message
Sami Jaktholm (sjakthol) wrote : Posted in a previous version of this proposal

This has way too much going on. Please split these changes up (one fix per MP).

review: Needs Fixing
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> This has way too much going on. Please split these changes up (one fix per
> MP).

I will explain first what happened after r3652, which is the last revision
you approved...
Btw, there are subcommits, which all have their own diff - making it easier
to follow development:

In
http://bazaar.launchpad.net/~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces/revision/3653
I forbid cycling through different sizes for corner and center-gridded
windows also, now fully fixing bug #878820 and following the design
specification for now.

In
http://bazaar.launchpad.net/~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces/revision/3654
I simplified the condition check to bail out if the last target was the
same like the current one to prevent corner and centered windows from
cycling through sizes, so that it looked like this:

if (gw->lastTarget == where &&
    gw->isGridResized)
    return false;

That means we bail out if the last target is the same as current one and
the window is already grid-resized, so we won't resize a corner/center
gridded window again.

In
http://bazaar.launchpad.net/~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces/revision/3655
I added a cycle_sizes bool option, which allows the user to choose the
prefered behaviour (fixed versus flexible sizes on multiple presses
 on the same grid keyboard shortcut).
Default of this option is off, cycling disabled as specified by design.
This is the relevant part in the xml, the rest are just minor punctuation/
wording fixes:
<option name="cycle_sizes" type="bool">
    <_short>Cycle Through Multiple Sizes</_short>
    <_long>Cycle through multiple different sizes by using the same keyboard shortcut multiple times in a row.</_long>
    <default>false</default>
</option>

The only code change in this revision is this:
/* We do not want to allow cycling through sizes,
 * unless the user explicitely specified that in CCSM */
if (gw->lastTarget == where &&
    gw->isGridResized &&
    !optionGetCycleSizes ())
    return false;

That means we allow to cycle center and corner gridded
windows now, if the user specifies explicitly in CCSM.

In the final revision
http://bazaar.launchpad.net/~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces/revision/3656
I had to implement the same choice for the rest of the
grid windows, namely left/right/top/bottom, which will
act like normal grid windows, if the user selects the
"want to cycle through sizes" option in CCSM

Voila, everything works perfectly :)

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal
Download full text (3.5 KiB)

Hey MCR1. Excellent work, here's some comments so far.

8 + CompOption::Vector o(0);
9 dndWindow->ungrabNotify ();
10
11 + screen->handleCompizEvent ("expo", "start_viewport_switch", o);

I believe there is a constant somewhere, either as a static member of CompOption or just as a global called "noOptions". I'd suggest using that.

43 - <_long>Warp and resize windows to fit an imaginary grid.</_long>
44 + <_long>Warp and resize windows to fit an imaginary grid</_long>
45 <category>Window Management</category>
46 <deps>
47 <requirement>
48 @@ -83,7 +83,7 @@
49 <_long>Window resize action</_long>
50 <option name="top_left_corner_action" type="int">
51 <_short>Upper Left Corner</_short>
52 - <_long>Action to be performed when window is dropped on the top left corner</_long>
53 + <_long>Action to be performed when window is dropped on the top left corner.</_long>

Try to avoid mixing formatting changes with substantive changes.

319 - * computing what the 33% and 66% offsets would be
320 - */
321 + * computing what the 33% and 66% offsets would be
322 + */

I think that's probably an undesired formatting change.

Statements like this:

377 + if (where & GridLeft || where & GridRight ||
378 + where & GridTop || where & GridBottom)

And this:

308 + (where & ~(GridMaximize) ||
309 + (where & ~(GridLeft | GridRight | GridTop | GridBottom) &&

Can be combined, eg

unsigned int VerticalGrid = GridLeft | GridRight;
unsigned int HorizontalGrid = GridTop | GridBottom;
unsigned int ConstrainedGrid = VerticalGrid | HorizontalGrid | GridMaximize;

if (where & ~ConstrinedGrid)

...

if (where & VerticalGrid)
{
}
else if (where & HorizontalGrid)
{
}

530 + else if (!gw->isGridResized &&
531 + gw->isGridHorzMaximized &&
532 + !gw->isGridVertMaximized)
533 + {
534 + /* Window has been horizontally maximized by grid. We only need
535 + * to restore Y and height - core handles X and width. */
536 + if (gw->sizeHintsFlags)
537 + gw->window->sizeHints ().flags |= gw->sizeHintsFlags;
538 + xwcm |= CWY | CWHeight;
539 + }
540 + else if (!gw->isGridResized &&
541 + !gw->isGridHorzMaximized &&
542 + gw->isGridVertMaximized)
543 {
544 /* Window has been vertically maximized by grid. We only need
545 - * to restore the X and width - core handles Y and height. */
546 + * to restore X and width - core handles Y and height. */
547 if (gw->sizeHintsFlags)
548 gw->window->sizeHints ().flags |= gw->sizeHintsFlags;
549 xwcm |= CWX | CWWidth;
550 }
551 -
552 - else if (gw->isGridResized && !gw->isGridSemiMaximized)
553 - /* Window is just gridded (top, bottom, center, corners). We
554 - * need to handle everything. */
555 + else if (gw->isGridResized &&
556 + !gw->isGridHorzMaximized &&
557 + !gw->isGridVertMaximized)
558 + /* Window is just gridded (center, corners).
559 + * We need to handle everything. */

It might make sense to nest these blocks.

if (!isGridResized)
{
    assert (isGridHorzMaximized != isGridVertMaximized);

    if (isGridHorzMaximized)
    {
        ...
    }
    else if (isGridVertMaximized)
   ...

Read more...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal
Download full text (4.9 KiB)

> Hey MCR1. Excellent work, here's some comments so far.
>
Hi Sam. First of all thanks for the review. It is very appreciated.

> 8 + CompOption::Vector o(0);
> 9 dndWindow->ungrabNotify ();
> 10
> 11 + screen->handleCompizEvent ("expo", "start_viewport_switch", o);
>
> I believe there is a constant somewhere, either as a static member of
> CompOption or just as a global called "noOptions". I'd suggest using that.
>
I am not sure where to find that, but I'll search...

> 43 - <_long>Warp and resize windows to fit an imaginary
> grid.</_long>
> 44 + <_long>Warp and resize windows to fit an imaginary
> grid</_long>
> 45 <category>Window Management</category>
> 46 <deps>
> 47 <requirement>
> 48 @@ -83,7 +83,7 @@
> 49 <_long>Window resize action</_long>
> 50 <option name="top_left_corner_action"
> type="int">
> 51 <_short>Upper Left Corner</_short>
> 52 - <_long>Action to be performed when window
> is dropped on the top left corner</_long>
> 53 + <_long>Action to be performed when window
> is dropped on the top left corner.</_long>
>
> Try to avoid mixing formatting changes with substantive changes.
>
I am sorry - I just can't help myself. I want to harmonize how plugins and their
tooltips look & feel, so if I am fixing stuff in the xml - I automatically just
have to fix those also...

> 319 - * computing what the 33% and 66% offsets would be
> 320 - */
> 321 + * computing what the 33% and 66% offsets would be
> 322 + */
>
> I think that's probably an undesired formatting change.
>
Not sure, have to check...

> Statements like this:
>
> 377 + if (where & GridLeft || where & GridRight ||
> 378 + where & GridTop || where & GridBottom)
>
> And this:
>
> 308 + (where & ~(GridMaximize) ||
> 309 + (where & ~(GridLeft | GridRight | GridTop | GridBottom)
> &&
>
> Can be combined, eg
>
> unsigned int VerticalGrid = GridLeft | GridRight;
> unsigned int HorizontalGrid = GridTop | GridBottom;
> unsigned int ConstrainedGrid = VerticalGrid | HorizontalGrid | GridMaximize;
>
> if (where & ~ConstrinedGrid)
>
> ...
>
> if (where & VerticalGrid)
> {
> }
> else if (where & HorizontalGrid)
> {
> }
>
Yeah, I did not touch that any further for the sake of the diffs' size and
readability, but if you want me to fix it in this MP, I'll do it...

> 530 + else if (!gw->isGridResized &&
> 531 + gw->isGridHorzMaximized &&
> 532 + !gw->isGridVertMaximized)
> 533 + {
> 534 + /* Window has been horizontally maximized by grid. We only
> need
> 535 + * to restore Y and height - core handles X and width. */
> 536 + if (gw->sizeHintsFlags)
> 537 + gw->window->sizeHints ().flags |= gw->sizeHintsFlags;
> 538 + xwcm |= CWY | CWHeight;
> 539 + }
> 540 + else if...

Read more...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> Hey MCR1. Excellent work, here's some comments so far.
>
> 8 + CompOption::Vector o(0);
> 9 dndWindow->ungrabNotify ();
> 10
> 11 + screen->handleCompizEvent ("expo", "start_viewport_switch", o);
>
> I believe there is a constant somewhere, either as a static member of
> CompOption or just as a global called "noOptions". I'd suggest using that.
>

Hmm, I do not know exactly what to change here, as searching through the code
shows it is almost always used like that, if there are no options - this is from
wall.cpp for example:

    CompOption::Vector o(0);
...
...
    screen->handleCompizEvent ("wall", "start_viewport_switch", o);

I am quite clueless here, but the version we use seems correct...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> > 319 - * computing what the 33% and 66% offsets would be
> > 320 - */
> > 321 + * computing what the 33% and 66% offsets would
> be
> > 322 + */
> >
> > I think that's probably an undesired formatting change.
> >

Fixed (not yet pushed).

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Sam, it would really be cool if we could merge this at current stage as it is a quasi Grid milestone.

Also I got another branch I stacked on this one:
https://code.launchpad.net/~mc-return/compiz/compiz.merge-fix1116538-isgridresized-windows-do-not-react-to-strg-super-down/+merge/157759

and making too many changes here will complicate further merging :(

I can assure you this here fully works, but I am somehow too lazy to make a video proving that all those bugs are fixed... ;)

Sam, I can assure you I will get to all of your points in a later follow-up MP, but please give this one here a green light first ;)

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

Sure, before that, can you:

1. Look into merging some of the bitflags (at the very least, doing if
(where & ~(GridLeft | GridRight | GridTop | GridBottom) is much better
than doing where & ~(GridLeft) || where &~(GridRight) etc
2. Look into whether or not an enum can replace those bools, as they
seem to be mutually exclusive.

On Tue, Apr 9, 2013 at 5:59 AM, MC Return <email address hidden> wrote:
> Sam, it would really be cool if we could merge this at current stage as it is a quasi Grid milestone.
>
> Also I got another branch I stacked on this one:
> https://code.launchpad.net/~mc-return/compiz/compiz.merge-fix1116538-isgridresized-windows-do-not-react-to-strg-super-down/+merge/157759
>
> and making too many changes here will complicate further merging :(
>
> I can assure you this here fully works, but I am somehow too lazy to make a video proving that all those bugs are fixed... ;)
>
> Sam, I can assure you I will get to all of your points in a later follow-up MP, but please give this one here a green light first ;)
> --
> https://code.launchpad.net/~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces/+merge/157760
> Your team Compiz Maintainers is requested to review the proposed merge of lp:~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces into lp:compiz.

--
Sam Spilsbury

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> Sure, before that, can you:
>
> 1. Look into merging some of the bitflags (at the very least, doing if
> (where & ~(GridLeft | GridRight | GridTop | GridBottom) is much better
> than doing where & ~(GridLeft) || where &~(GridRight) etc
> 2. Look into whether or not an enum can replace those bools, as they
> seem to be mutually exclusive.
>
1 & 2: Done. Even simplified one complicated if condition check additionally.
       I used 3 new bools, like you suggested before - it is much nicer already.
       I think an enum is not necessary here, the bools seem to be enough to
       clean that mess up.

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

Coolio, you don't need to resubmit this, I can just reack it when I have
time to look over it next ..

Revision history for this message
MC Return (mc-return) wrote :

> Coolio, you don't need to resubmit this, I can just reack it when I have
> time to look over it next ..

I was not sure... I think Daniel once asked me to always resumbmit, or he won't notice it - so I am using this workflow now - I would prefer it to not always have to resubmit, but do not care, if it is prefered to be done this way either...

/offtopic on

I want to create a blueprint on launchpad, where I want to throw in all bugs that are still valid and reproducable.
The bugtracker is a bit of a mess, so I think something like a blueprint combining the most important of them would be
nice...
I want to sort them by: Feature-Requests/Wishlist / Multimonitor only / Regressions / Window-management / Other

Maybe some other categories as well - we'll see...

How do you like that idea ?

/offtopic off

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

> /offtopic on
>
> I want to create a blueprint on launchpad, where I want to throw in all bugs
> that are still valid and reproducable.
> The bugtracker is a bit of a mess, so I think something like a blueprint
> combining the most important of them would be
> nice...
> I want to sort them by: Feature-Requests/Wishlist / Multimonitor only /
> Regressions / Window-management / Other
>
> Maybe some other categories as well - we'll see...
>
> How do you like that idea ?
>
> /offtopic off

The best thing to do would be to add them to the 0.9.10.0 milestone. Dunno if that exists yet - I will create it if need be.

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

I'm fine with this as is. Sami, what are your thoughts?

review: Approve
Revision history for this message
MC Return (mc-return) wrote :

>
> The best thing to do would be to add them to the 0.9.10.0 milestone. Dunno if
> that exists yet - I will create it if need be.

The problem here is that I am not a member of the Compiz team
- so I am not able to change bug priority levels and also cannot add bugs to milestones.

BTW, milestone 0.9.10 already exists:
https://launchpad.net/compiz/+milestone/0.9.10.0

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

On Tue, Apr 9, 2013 at 6:04 PM, MC Return <email address hidden> wrote:
>>
>> The best thing to do would be to add them to the 0.9.10.0 milestone. Dunno if
>> that exists yet - I will create it if need be.
>
> The problem here is that I am not a member of the Compiz team
> - so I am not able to change bug priority levels and also cannot add bugs to milestones.
>
> BTW, milestone 0.9.10 already exists:
> https://launchpad.net/compiz/+milestone/0.9.10.0

Okay, we'll need to fix that.

>
> --
> https://code.launchpad.net/~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces/+merge/157817
> You are reviewing the proposed merge of lp:~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces into lp:compiz.

--
Sam Spilsbury

3659. By MC Return

Grid xml:
Improved tooltip for the "put_restore_key" reflecting it's enhanced
functionality.

Revision history for this message
Sami Jaktholm (sjakthol) wrote :

Looks good and works fine.

review: Approve
Revision history for this message
MC Return (mc-return) wrote :

> Looks good and works fine.

Thanks :)

Really time to get this thingy merged ;)

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/expo/src/expo.cpp'
2--- plugins/expo/src/expo.cpp 2013-03-26 22:02:39 +0000
3+++ plugins/expo/src/expo.cpp 2013-04-09 08:47:24 +0000
4@@ -247,10 +247,13 @@
5 void
6 ExpoScreen::finishWindowMovement ()
7 {
8+ CompOption::Vector o(0);
9 dndWindow->ungrabNotify ();
10
11+ screen->handleCompizEvent ("expo", "start_viewport_switch", o);
12 screen->moveViewport (screen->vp ().x () - selectedVp.x (),
13 screen->vp ().y () - selectedVp.y (), true);
14+ screen->handleCompizEvent ("expo", "end_viewport_switch", o);
15
16 /* update saved window attributes in case we moved the
17 window to a new viewport */
18@@ -486,6 +489,8 @@
19 void
20 ExpoScreen::donePaint ()
21 {
22+ CompOption::Vector o(0);
23+ screen->handleCompizEvent ("expo", "start_viewport_switch", o);
24 switch (vpUpdateMode) {
25 case VPUpdateMouseOver:
26 screen->moveViewport (screen->vp ().x () - selectedVp.x (),
27@@ -504,6 +509,7 @@
28 default:
29 break;
30 }
31+ screen->handleCompizEvent ("expo", "end_viewport_switch", o);
32
33 if ((expoCam > 0.0f && expoCam < 1.0f) || dndState != DnDNone)
34 cScreen->damageScreen ();
35
36=== modified file 'plugins/grid/grid.xml.in'
37--- plugins/grid/grid.xml.in 2013-01-16 23:12:46 +0000
38+++ plugins/grid/grid.xml.in 2013-04-09 08:47:24 +0000
39@@ -2,7 +2,7 @@
40 <compiz>
41 <plugin name="grid" useBcop="true">
42 <_short>Grid</_short>
43- <_long>Warp and resize windows to fit an imaginary grid.</_long>
44+ <_long>Warp and resize windows to fit an imaginary grid</_long>
45 <category>Window Management</category>
46 <deps>
47 <requirement>
48@@ -83,7 +83,7 @@
49 <_long>Window resize action</_long>
50 <option name="top_left_corner_action" type="int">
51 <_short>Upper Left Corner</_short>
52- <_long>Action to be performed when window is dropped on the top left corner</_long>
53+ <_long>Action to be performed when window is dropped on the top left corner.</_long>
54 <default>4</default>
55 <min>0</min>
56 <max>10</max>
57@@ -134,7 +134,7 @@
58 </option>
59 <option name="top_edge_action" type="int">
60 <_short>Top Edge</_short>
61- <_long>Action to be performed when window is dropped on the top edge</_long>
62+ <_long>Action to be performed when window is dropped on the top edge.</_long>
63 <default>10</default>
64 <min>0</min>
65 <max>10</max>
66@@ -185,7 +185,7 @@
67 </option>
68 <option name="top_right_corner_action" type="int">
69 <_short>Upper Right Corner</_short>
70- <_long>Action to be performed when window is dropped on the top right corner</_long>
71+ <_long>Action to be performed when window is dropped on the top right corner.</_long>
72 <default>6</default>
73 <min>0</min>
74 <max>10</max>
75@@ -236,7 +236,7 @@
76 </option>
77 <option name="left_edge_action" type="int">
78 <_short>Left Edge</_short>
79- <_long>Action to be performed when window is dropped on the left edge</_long>
80+ <_long>Action to be performed when window is dropped on the left edge.</_long>
81 <default>4</default>
82 <min>0</min>
83 <max>10</max>
84@@ -287,7 +287,7 @@
85 </option>
86 <option name="right_edge_action" type="int">
87 <_short>Right Edge</_short>
88- <_long>Action to be performed when window is dropped on the right edge</_long>
89+ <_long>Action to be performed when window is dropped on the right edge.</_long>
90 <default>6</default>
91 <min>0</min>
92 <max>10</max>
93@@ -338,7 +338,7 @@
94 </option>
95 <option name="bottom_left_corner_action" type="int">
96 <_short>Bottom Left Corner</_short>
97- <_long>Action to be performed when window is dropped on the bottom left corner</_long>
98+ <_long>Action to be performed when window is dropped on the bottom left corner.</_long>
99 <default>4</default>
100 <min>0</min>
101 <max>10</max>
102@@ -389,7 +389,7 @@
103 </option>
104 <option name="bottom_edge_action" type="int">
105 <_short>Bottom Edge</_short>
106- <_long>Action to be performed when window is dropped on the bottom edge</_long>
107+ <_long>Action to be performed when window is dropped on the bottom edge.</_long>
108 <default>0</default>
109 <min>0</min>
110 <max>10</max>
111@@ -440,7 +440,7 @@
112 </option>
113 <option name="bottom_right_corner_action" type="int">
114 <_short>Bottom Right Corner</_short>
115- <_long>Action to be performed when window is dropped on the bottom right corner</_long>
116+ <_long>Action to be performed when window is dropped on the bottom right corner.</_long>
117 <default>6</default>
118 <min>0</min>
119 <max>10</max>
120@@ -490,42 +490,47 @@
121 </desc>
122 </option>
123 <option name="snapoff_maximized" type="bool">
124- <_short>Snapoff maximized windows</_short>
125- <_long>Snapoff maximized windows when pulling to edge.</_long>
126+ <_short>Snapoff Maximized/Semi-maximized Windows</_short>
127+ <_long>Snapoff maximized and vertically maximized windows by dragging them up or down and horizontally maximized ones by dragging them left or right.</_long>
128 <default>false</default>
129 </option>
130 <option name="snapback_windows" type="bool">
131- <_short>Snap windows back to original size</_short>
132+ <_short>Snap Windows Back To Original Size</_short>
133 <_long>Snaps windows back to their original size if dragged away from their gridded position.</_long>
134 <default>true</default>
135 </option>
136+ <option name="cycle_sizes" type="bool">
137+ <_short>Cycle Through Multiple Sizes</_short>
138+ <_long>Cycle through multiple different sizes by using the same keyboard shortcut multiple times in a row.</_long>
139+ <default>false</default>
140+ </option>
141 </subgroup>
142 <subgroup>
143 <_short>Thresholds</_short>
144 <option name="left_edge_threshold" type="int">
145 <_short>Left Edge</_short>
146- <_long>Maximum number of pixels from the left edge a window can be dropped</_long>
147+ <_long>Maximum number of pixels from the left edge a window can be dropped.</_long>
148 <default>15</default>
149 <min>0</min>
150 <max>500</max>
151 </option>
152 <option name="right_edge_threshold" type="int">
153 <_short>Right Edge</_short>
154- <_long>Maximum number of pixels from the right edge a window can be dropped</_long>
155+ <_long>Maximum number of pixels from the right edge a window can be dropped.</_long>
156 <default>15</default>
157 <min>0</min>
158 <max>500</max>
159 </option>
160 <option name="top_edge_threshold" type="int">
161 <_short>Top Edge</_short>
162- <_long>Maximum number of pixels from the top edge a window can be dropped</_long>
163+ <_long>Maximum number of pixels from the top edge a window can be dropped.</_long>
164 <default>20</default>
165 <min>0</min>
166 <max>500</max>
167 </option>
168 <option name="bottom_edge_threshold" type="int">
169 <_short>Bottom Edge</_short>
170- <_long>Maximum number of pixels from the Bottom edge a window can be dropped</_long>
171+ <_long>Maximum number of pixels from the bottom edge a window can be dropped.</_long>
172 <default>5</default>
173 <min>0</min>
174 <max>500</max>
175@@ -535,24 +540,24 @@
176 <group>
177 <_short>Appearance</_short>
178 <option name="draw_indicator" type="bool">
179- <_short>Draw Indicator</_short>
180- <_long>Draw Window Resize Indicator</_long>
181+ <_short>Preview Indicator</_short>
182+ <_long>Draw a window resize indicator preview.</_long>
183 <default>true</default>
184 </option>
185 <option name="draw_stretched_window" type="bool">
186- <_short>Draw Stretched Window</_short>
187- <_long>Draw stretched window animation</_long>
188+ <_short>Stretched Live Window Preview</_short>
189+ <_long>Draw a stretched live window content animation.</_long>
190 <default>true</default>
191 </option>
192 <option name="animation_duration" type="int">
193- <_short>Animation Duration</_short>
194- <_long>Grid animation duration (in ms)</_long>
195+ <_short>Preview Animation Duration</_short>
196+ <_long>Preview animation duration (in ms).</_long>
197 <default>350</default>
198 <min>0</min>
199 </option>
200 <option name="outline_color" type="color">
201- <_short>Outline Color</_short>
202- <_long>Color of the resize indicator outline</_long>
203+ <_short>Preview Outline Color</_short>
204+ <_long>Color and opacity of the resize indicator preview outline.</_long>
205 <default>
206 <red>0xfbfb</red>
207 <green>0x8b8b</green>
208@@ -561,8 +566,8 @@
209 </default>
210 </option>
211 <option name="fill_color" type="color">
212- <_short>Fill Color</_short>
213- <_long>Fill color of the resize indicator</_long>
214+ <_short>Preview Fill Color</_short>
215+ <_long>Fill color and opacity of the resize indicator preview.</_long>
216 <default>
217 <red>0xfbfb</red>
218 <green>0x8b8b</green>
219
220=== modified file 'plugins/grid/src/grid.cpp'
221--- plugins/grid/src/grid.cpp 2013-03-22 11:58:33 +0000
222+++ plugins/grid/src/grid.cpp 2013-04-09 08:47:24 +0000
223@@ -63,7 +63,6 @@
224 const CompRect& slot)
225 {
226 int cw, ch;
227-
228 CompRect result = slotToRect (w, slot);
229
230 if (w->constrainNewWindowSize (result.width (), result.height (), &cw, &ch))
231@@ -137,6 +136,12 @@
232 bool maximizeH = where & (GridBottom | GridTop | GridMaximize);
233 bool maximizeV = where & (GridLeft | GridRight | GridMaximize);
234
235+ bool horzMaximizedGridPosition = where & (GridTop | GridBottom);
236+ bool vertMaximizedGridPosition = where & (GridLeft | GridRight);
237+ bool anyMaximizedGridPosition = horzMaximizedGridPosition ||
238+ vertMaximizedGridPosition ||
239+ where & GridMaximize;
240+
241 if (!(cw->actions () & CompWindowActionResizeMask))
242 return false;
243
244@@ -169,23 +174,23 @@
245 if (props.numCellsX == 1)
246 centerCheck = true;
247
248- if (!gw->isGridResized)
249+ /* Do not overwrite the original size if we already have been gridded */
250+ if (!gw->isGridResized && !gw->isGridHorzMaximized && !gw->isGridVertMaximized)
251 /* Store size not including borders when using a keybinding */
252 gw->originalSize = slotToRect(cw, cw->serverBorderRect ());
253 }
254
255 if ((cw->state () & MAXIMIZE_STATE) &&
256 (resize || optionGetSnapoffMaximized ()))
257- {
258 /* maximized state interferes with us, clear it */
259 cw->maximize (0);
260- }
261
262 if ((where & GridMaximize) && resize)
263 {
264 /* move the window to the correct output */
265 if (cw == mGrabWindow)
266 {
267+ /* TODO: Remove these magic numbers */
268 xwc.x = workarea.x () + 50;
269 xwc.y = workarea.y () + 50;
270 xwc.width = workarea.width ();
271@@ -198,7 +203,9 @@
272 * gridded one.
273 */
274 gw->isGridResized = false;
275- gw->isGridSemiMaximized = false;
276+ gw->isGridHorzMaximized = false;
277+ gw->isGridVertMaximized = false;
278+
279 for (unsigned int i = 0; i < animations.size (); i++)
280 animations.at (i).fadingOut = true;
281 return true;
282@@ -219,20 +226,43 @@
283 (workarea.width () / props.numCellsX));
284 desiredSlot.setWidth (workarea.width () / props.numCellsX);
285
286- /* Adjust for constraints and decorations */
287- if (where & ~(GridMaximize | GridLeft | GridRight))
288- desiredRect = constrainSize (cw, desiredSlot);
289- else
290- desiredRect = slotToRect (cw, desiredSlot);
291+ if (!optionGetCycleSizes ())
292+ {
293+ /* Adjust for constraints and decorations */
294+ if (!anyMaximizedGridPosition)
295+ desiredRect = constrainSize (cw, desiredSlot);
296+ else
297+ desiredRect = slotToRect (cw, desiredSlot);
298+ }
299+ else /* (optionGetCycleSizes ()) */
300+ {
301+ /* Adjust for constraints and decorations */
302+ if (where & ~GridMaximize)
303+ desiredRect = constrainSize (cw, desiredSlot);
304+ else
305+ desiredRect = slotToRect (cw, desiredSlot);
306+ }
307
308 /* Get current rect not including decorations */
309 currentRect.setGeometry (cw->serverX (), cw->serverY (),
310 cw->serverWidth (),
311 cw->serverHeight ());
312
313- if (desiredRect.y () == currentRect.y () &&
314- desiredRect.height () == currentRect.height () &&
315- where & ~(GridMaximize | GridLeft | GridRight) && gw->lastTarget & where)
316+ /* We do not want to allow cycling through sizes,
317+ * unless the user explicitely specified that in CCSM
318+ */
319+ if (gw->lastTarget == where &&
320+ gw->isGridResized &&
321+ !optionGetCycleSizes ())
322+ return false;
323+
324+ /* !(Grid Left/Right/Top/Bottom) are only valid here, if
325+ * cycling through sizes is disabled also
326+ */
327+ if ((where & ~(GridMaximize) ||
328+ ((!horzMaximizedGridPosition || !vertMaximizedGridPosition) &&
329+ !optionGetCycleSizes ())) &&
330+ gw->lastTarget & where)
331 {
332 int slotWidth25 = workarea.width () / 4;
333 int slotWidth33 = (workarea.width () / 3) + cw->border ().left;
334@@ -258,34 +288,38 @@
335 props.gravityRight * slotWidth33);
336 gw->resizeCount++;
337 break;
338+
339 case 2:
340 gw->resizeCount++;
341 break;
342+
343 case 3:
344 desiredSlot.setWidth (slotWidth33);
345 desiredSlot.setX (workarea.x () +
346 props.gravityRight * slotWidth66);
347 gw->resizeCount++;
348 break;
349+
350 case 4:
351 desiredSlot.setWidth (slotWidth25);
352 desiredSlot.setX (workarea.x () +
353 props.gravityRight * slotWidth75);
354 gw->resizeCount++;
355 break;
356+
357 case 5:
358 desiredSlot.setWidth (slotWidth75);
359 desiredSlot.setX (workarea.x () +
360 props.gravityRight * slotWidth25);
361 gw->resizeCount++;
362 break;
363+
364 default:
365 break;
366 }
367 }
368 else /* keys (2, 5, 8) */
369 {
370-
371 if ((currentRect.width () == desiredRect.width () &&
372 currentRect.x () == desiredRect.x ()) ||
373 (gw->resizeCount < 1) || (gw->resizeCount > 5))
374@@ -299,6 +333,7 @@
375 desiredSlot.setX (workarea.x () + slotWidth17);
376 gw->resizeCount++;
377 break;
378+
379 case 2:
380 desiredSlot.setWidth ((slotWidth25 * 2) +
381 (slotWidth17 * 2));
382@@ -306,20 +341,25 @@
383 (slotWidth25 - slotWidth17));
384 gw->resizeCount++;
385 break;
386+
387 case 3:
388 desiredSlot.setWidth ((slotWidth25 * 2));
389 desiredSlot.setX (workarea.x () + slotWidth25);
390 gw->resizeCount++;
391 break;
392+
393 case 4:
394 desiredSlot.setWidth (slotWidth33 -
395- (cw->border ().left + cw->border ().right));
396+ (cw->border ().left +
397+ cw->border ().right));
398 desiredSlot.setX (workarea.x () + slotWidth33);
399 gw->resizeCount++;
400 break;
401+
402 case 5:
403 gw->resizeCount++;
404 break;
405+
406 default:
407 break;
408 }
409@@ -352,37 +392,63 @@
410
411 gw->sizeHintsFlags = 0;
412
413- /* Special case for left and right, actually vertically maximize
414- * the window */
415- if (where & GridLeft || where & GridRight)
416+ if (!optionGetCycleSizes ())
417 {
418- /* First restore the window to its original size */
419- XWindowChanges rwc;
420-
421- rwc.x = gw->originalSize.x ();
422- rwc.y = gw->originalSize.y ();
423- rwc.width = gw->originalSize.width ();
424- rwc.height = gw->originalSize.height ();
425-
426- cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &rwc);
427-
428- gw->isGridSemiMaximized = true;
429- gw->isGridResized = false;
430-
431- /* Maximize the window */
432- cw->maximize (CompWindowStateMaximizedVertMask);
433-
434- /* Be evil */
435- if (cw->sizeHints ().flags & PResizeInc)
436- {
437- gw->sizeHintsFlags |= PResizeInc;
438- gw->window->sizeHints ().flags &= ~(PResizeInc);
439+ /* Special cases for left/right and top/bottom gridded windows, where we
440+ * actually vertically respective horizontally semi-maximize the window
441+ */
442+ if (horzMaximizedGridPosition || vertMaximizedGridPosition)
443+ {
444+ /* First restore the window to its original size */
445+ XWindowChanges rwc;
446+
447+ rwc.x = gw->originalSize.x ();
448+ rwc.y = gw->originalSize.y ();
449+ rwc.width = gw->originalSize.width ();
450+ rwc.height = gw->originalSize.height ();
451+
452+ cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &rwc);
453+
454+ /* GridLeft || GridRight */
455+ if (vertMaximizedGridPosition)
456+ {
457+ gw->isGridVertMaximized = true;
458+ gw->isGridHorzMaximized = false;
459+ gw->isGridResized = false;
460+
461+ /* Semi-maximize the window vertically */
462+ cw->maximize (CompWindowStateMaximizedVertMask);
463+ }
464+ /* GridTop || GridBottom */
465+ else /* (horzMaximizedGridPosition) */
466+ {
467+ gw->isGridHorzMaximized = true;
468+ gw->isGridVertMaximized = false;
469+ gw->isGridResized = false;
470+
471+ /* Semi-maximize the window horizontally */
472+ cw->maximize (CompWindowStateMaximizedHorzMask);
473+ }
474+
475+ /* Be evil */
476+ if (cw->sizeHints ().flags & PResizeInc)
477+ {
478+ gw->sizeHintsFlags |= PResizeInc;
479+ gw->window->sizeHints ().flags &= ~(PResizeInc);
480+ }
481+ }
482+ else /* GridCorners || GridCenter */
483+ {
484+ gw->isGridResized = true;
485+ gw->isGridHorzMaximized = false;
486+ gw->isGridVertMaximized = false;
487 }
488 }
489- else
490+ else /* if (optionGetCycleSizes ()) */
491 {
492 gw->isGridResized = true;
493- gw->isGridSemiMaximized = false;
494+ gw->isGridHorzMaximized = false;
495+ gw->isGridVertMaximized = false;
496 }
497
498 int dw = (lastBorder.left + lastBorder.right) -
499@@ -657,31 +723,40 @@
500 {
501 int ret;
502
503- switch (edge) {
504+ switch (edge)
505+ {
506 case Left:
507 ret = (int) optionGetLeftEdgeAction ();
508 break;
509+
510 case Right:
511 ret = (int) optionGetRightEdgeAction ();
512 break;
513+
514 case Top:
515 ret = (int) optionGetTopEdgeAction ();
516 break;
517+
518 case Bottom:
519 ret = (int) optionGetBottomEdgeAction ();
520 break;
521+
522 case TopLeft:
523 ret = (int) optionGetTopLeftCornerAction ();
524 break;
525+
526 case TopRight:
527 ret = (int) optionGetTopRightCornerAction ();
528 break;
529+
530 case BottomLeft:
531 ret = (int) optionGetBottomLeftCornerAction ();
532 break;
533+
534 case BottomRight:
535 ret = (int) optionGetBottomRightCornerAction ();
536 break;
537+
538 case NoEdge:
539 default:
540 ret = -1;
541@@ -694,7 +769,6 @@
542 void
543 GridScreen::handleEvent (XEvent *event)
544 {
545- CompOutput out;
546 CompWindow *w;
547
548 screen->handleEvent (event);
549@@ -706,6 +780,7 @@
550
551 currentWorkarea = screen->getWorkareaForOutput
552 (screen->outputDeviceForPoint (pointerX, pointerY));
553+
554 if (lastWorkarea != currentWorkarea)
555 {
556 lastWorkarea = currentWorkarea;
557@@ -719,7 +794,7 @@
558 cScreen->damageRegion (desiredSlot);
559 }
560
561- out = screen->outputDevs ().at (
562+ CompOutput out = screen->outputDevs ().at (
563 screen->outputDeviceForPoint (CompPoint (pointerX, pointerY)));
564
565 /* Detect corners first */
566@@ -843,8 +918,8 @@
567
568 /* Don't allow non-pagers to change
569 * the size of the window, the user
570- * specified this size, thank-you */
571- if (isGridSemiMaximized)
572+ * specified this size */
573+ if (isGridHorzMaximized || isGridVertMaximized)
574 if (source != ClientTypePager)
575 xwcm = 0;
576 }
577@@ -868,7 +943,10 @@
578 pointerBufDx = pointerBufDy = 0;
579 grabMask = mask;
580
581- if (!isGridResized && !isGridSemiMaximized && gScreen->optionGetSnapbackWindows ())
582+ if (!isGridResized &&
583+ !isGridHorzMaximized &&
584+ !isGridVertMaximized &&
585+ gScreen->optionGetSnapbackWindows ())
586 /* Store size not including borders when grabbing with cursor */
587 originalSize = gScreen->slotToRect(window,
588 window->serverBorderRect ());
589@@ -909,8 +987,18 @@
590 {
591 window->moveNotify (dx, dy, immediate);
592
593- if (isGridResized && !isGridSemiMaximized && !GridScreen::get (screen)->mSwitchingVp)
594+ if (isGridResized &&
595+ !isGridHorzMaximized &&
596+ !isGridVertMaximized &&
597+ !GridScreen::get (screen)->mSwitchingVp)
598 {
599+ if (window->grabbed () && screen->grabExist ("expo"))
600+ {
601+ /* Window is being dragged in expo. Restore the original geometry
602+ * right away to avoid any confusion. */
603+ gScreen->restoreWindow (0, 0, gScreen->o);
604+ return;
605+ }
606 if (window->grabbed () && (grabMask & CompWindowGrabMoveMask))
607 {
608 pointerBufDx += dx;
609@@ -933,7 +1021,10 @@
610 !(window->state () & MAXIMIZE_STATE))
611 {
612 lastTarget = GridUnknown;
613- if (isGridSemiMaximized && (lastState & MAXIMIZE_STATE) == CompWindowStateMaximizedVertMask)
614+ if ((isGridHorzMaximized &&
615+ (lastState & MAXIMIZE_STATE) == CompWindowStateMaximizedHorzMask) ||
616+ (isGridVertMaximized &&
617+ (lastState & MAXIMIZE_STATE) == CompWindowStateMaximizedVertMask))
618 gScreen->restoreWindow(0, 0, gScreen->o);
619 }
620 else if (!(lastState & MAXIMIZE_STATE) &&
621@@ -969,7 +1060,9 @@
622
623 GRID_WINDOW (cw);
624
625- if (!gw->isGridResized && !gw->isGridSemiMaximized)
626+ if (!gw->isGridResized &&
627+ !gw->isGridHorzMaximized &&
628+ !gw->isGridVertMaximized)
629 {
630 /* Grid hasn't touched this window or has maximized it. If it's
631 * maximized, unmaximize it and get out. */
632@@ -977,25 +1070,38 @@
633 cw->maximize(0);
634 return true;
635 }
636-
637- else if (!gw->isGridResized && gw->isGridSemiMaximized)
638+ else if (!gw->isGridResized &&
639+ gw->isGridHorzMaximized &&
640+ !gw->isGridVertMaximized)
641+ {
642+ /* Window has been horizontally maximized by grid. We only need
643+ * to restore Y and height - core handles X and width. */
644+ if (gw->sizeHintsFlags)
645+ gw->window->sizeHints ().flags |= gw->sizeHintsFlags;
646+ xwcm |= CWY | CWHeight;
647+ }
648+ else if (!gw->isGridResized &&
649+ !gw->isGridHorzMaximized &&
650+ gw->isGridVertMaximized)
651 {
652 /* Window has been vertically maximized by grid. We only need
653- * to restore the X and width - core handles Y and height. */
654+ * to restore X and width - core handles Y and height. */
655 if (gw->sizeHintsFlags)
656 gw->window->sizeHints ().flags |= gw->sizeHintsFlags;
657 xwcm |= CWX | CWWidth;
658 }
659-
660- else if (gw->isGridResized && !gw->isGridSemiMaximized)
661- /* Window is just gridded (top, bottom, center, corners). We
662- * need to handle everything. */
663+ else if (gw->isGridResized &&
664+ !gw->isGridHorzMaximized &&
665+ !gw->isGridVertMaximized)
666+ /* Window is just gridded (center, corners).
667+ * We need to handle everything. */
668 xwcm |= CWX | CWY | CWWidth | CWHeight;
669 else
670 {
671 /* This should never happen. But if it does, just bail out
672 * gracefully. */
673- assert (gw->isGridResized && gw->isGridSemiMaximized);
674+ assert (gw->isGridResized &&
675+ (gw->isGridHorzMaximized || gw->isGridVertMaximized));
676 return false;
677 }
678
679@@ -1004,6 +1110,16 @@
680 xwc.x = pointerX - (gw->originalSize.width () / 2);
681 xwc.y = pointerY + (cw->border ().top / 2);
682 }
683+ else if (cw->grabbed () && screen->grabExist ("expo"))
684+ {
685+ /* We're restoring a window inside expo by dragging. This is a bit
686+ * tricky. Pointer location is absolute to the screen, not relative
687+ * to expo viewport. So we can't use pointer location to calculate
688+ * the position of the restore window.
689+ *
690+ * The best solution is to resize it in place. */
691+ xwcm = CWWidth | CWHeight;
692+ }
693 else
694 {
695 xwc.x = gw->originalSize.x ();
696@@ -1018,7 +1134,8 @@
697 gw->currentSize = CompRect ();
698 gw->pointerBufDx = 0;
699 gw->pointerBufDy = 0;
700- gw->isGridSemiMaximized = false;
701+ gw->isGridHorzMaximized = false;
702+ gw->isGridVertMaximized = false;
703 gw->isGridResized = false;
704 if (cw->state () & MAXIMIZE_STATE)
705 cw->maximize(0);
706@@ -1035,7 +1152,8 @@
707 GRID_WINDOW (screen->findWindow
708 (CompOption::getIntOptionNamed (o, "window")));
709 gw->isGridResized = false;
710- gw->isGridSemiMaximized = false;
711+ gw->isGridHorzMaximized = false;
712+ gw->isGridVertMaximized = false;
713 gw->resizeCount = 0;
714 }
715
716@@ -1197,7 +1315,8 @@
717 gWindow (GLWindow::get(window)),
718 gScreen (GridScreen::get (screen)),
719 isGridResized (false),
720- isGridSemiMaximized (false),
721+ isGridHorzMaximized (false),
722+ isGridVertMaximized (false),
723 grabMask (0),
724 pointerBufDx (0),
725 pointerBufDy (0),
726
727=== modified file 'plugins/grid/src/grid.h'
728--- plugins/grid/src/grid.h 2013-01-21 15:17:50 +0000
729+++ plugins/grid/src/grid.h 2013-04-09 08:47:24 +0000
730@@ -182,7 +182,8 @@
731 GridScreen *gScreen;
732
733 bool isGridResized;
734- bool isGridSemiMaximized;
735+ bool isGridHorzMaximized;
736+ bool isGridVertMaximized;
737 unsigned int grabMask;
738 int pointerBufDx;
739 int pointerBufDy;

Subscribers

People subscribed via source and target branches