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

Proposed by MC Return
Status: Superseded
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces
Merge into: lp:compiz/0.9.10
Diff against target: 390 lines (+136/-35)
5 files modified
plugins/expo/src/expo.cpp (+6/-0)
plugins/grid/src/grid.cpp (+96/-34)
plugins/grid/src/grid.h (+2/-1)
plugins/move/src/move.cpp (+29/-0)
plugins/move/src/move.h (+3/-0)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix1082001-gridded-windows-jump-workspaces
Reviewer Review Type Date Requested Status
Sami Jaktholm (community) Approve
Compiz Maintainers Pending
Review via email: mp+156663@code.launchpad.net

This proposal has been superseded by a proposal from 2013-04-05.

Commit message

Grid:
Prevent top and bottom gridded windows from jumping viewports.

Those are actually semi-maximized horizontally, so we will treat
them as such and let core handle the restoring, just like we
already do for semi-maximized vertically 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 is active.
(Thanks and credits for this go to Sami Jaktholm)

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

Move:
Implemented strategy to snap off horizontally semi-maximized
windows by dragging the titlebar in direction of the x-axis.

(fixes: LP: #1082001, LP: #1165198)
(partially fixes: LP: #1116538, LP: #1164332)

Description of the change

Note: Problems unfortunately remain for corner- and center-gridded windows...

Any ideas ?

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

Ping ?

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

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 :

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

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 :

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 :

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

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 :

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

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 :

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

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 :

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 :

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

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

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 :

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 :

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

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

3653. By MC Return

Grid:
Forbid cycling through different sizes for corner and center-gridded
windows also, now fully fixing bug #878820 and following the design
specification for now

TODO: Make the behaviour configurable for the user as many prefer
cycling through different sizes

Added comment
Minor whitespace fixes
Declare CompOutput out and assign a value to it in one line

3654. By MC Return

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

3655. By MC Return

plugins/grid/grid.xml.in:

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

grid:

Allow cycling for corner/center gridded windows if specified by the
user

3656. By MC Return

Allow cycling through different sizes for top/bottom and left/right
gridded windows as well, if the user specified it in CCSM explicitely
(default is off)

3657. By MC Return

Reverted r3652 as this change to the move plugin is not tightly related
to this branch and thus will be proposed seperately to reduce diff size
here

3658. By MC Return

Grid:
We want to use the same functionality like the unmaximize_or_minimize_window
shortcut normally provides, so if our window has not been touched by grid, we
will do the same with that window that core would normally do
(see src/actions.cpp, unmaximizeOrMinimizeWin and
 launchpad bug LP: #1116538 for details)

Note: If we use the same shortcut for unmaximize_or_minimize_window_key (core)
and put_restore_key (grid) core will take over again, if grid gets disabled
If grid is enabled the unmaximize_or_minimize_window_key will be overridden,
because core always loads first and grid later

Also note that this commit did not change any shortcut yet, but just provides
the functionality for grid - Please use your grid restore keybinding like you
would use the unmaximize_or_minimize_window_key normally to test

3659. By MC Return

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

3660. By MC Return

Merged Grid from latest lp:compiz

Simplified bool GridScreen::restoreWindow (...):
If Grid has not touched the window we return false and let core do the
dirty work (Thanks go to Sam Spilsbury for suggesting this)

Improved the CCSM grid restore tooltip

3661. By MC Return

Merged latest lp:compiz

Unmerged revisions

3661. By MC Return

Merged latest lp:compiz

3660. By MC Return

Merged Grid from latest lp:compiz

Simplified bool GridScreen::restoreWindow (...):
If Grid has not touched the window we return false and let core do the
dirty work (Thanks go to Sam Spilsbury for suggesting this)

Improved the CCSM grid restore tooltip

3659. By MC Return

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

3658. By MC Return

Grid:
We want to use the same functionality like the unmaximize_or_minimize_window
shortcut normally provides, so if our window has not been touched by grid, we
will do the same with that window that core would normally do
(see src/actions.cpp, unmaximizeOrMinimizeWin and
 launchpad bug LP: #1116538 for details)

Note: If we use the same shortcut for unmaximize_or_minimize_window_key (core)
and put_restore_key (grid) core will take over again, if grid gets disabled
If grid is enabled the unmaximize_or_minimize_window_key will be overridden,
because core always loads first and grid later

Also note that this commit did not change any shortcut yet, but just provides
the functionality for grid - Please use your grid restore keybinding like you
would use the unmaximize_or_minimize_window_key normally to test

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-05 21:36:18 +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/src/grid.cpp'
37--- plugins/grid/src/grid.cpp 2013-03-22 11:58:33 +0000
38+++ plugins/grid/src/grid.cpp 2013-04-05 21:36:18 +0000
39@@ -63,7 +63,6 @@
40 const CompRect& slot)
41 {
42 int cw, ch;
43-
44 CompRect result = slotToRect (w, slot);
45
46 if (w->constrainNewWindowSize (result.width (), result.height (), &cw, &ch))
47@@ -169,17 +168,15 @@
48 if (props.numCellsX == 1)
49 centerCheck = true;
50
51- if (!gw->isGridResized)
52+ if (!gw->isGridResized && !gw->isGridHorzMaximized && !gw->isGridVertMaximized)
53 /* Store size not including borders when using a keybinding */
54 gw->originalSize = slotToRect(cw, cw->serverBorderRect ());
55 }
56
57 if ((cw->state () & MAXIMIZE_STATE) &&
58 (resize || optionGetSnapoffMaximized ()))
59- {
60 /* maximized state interferes with us, clear it */
61 cw->maximize (0);
62- }
63
64 if ((where & GridMaximize) && resize)
65 {
66@@ -198,7 +195,9 @@
67 * gridded one.
68 */
69 gw->isGridResized = false;
70- gw->isGridSemiMaximized = false;
71+ gw->isGridHorzMaximized = false;
72+ gw->isGridVertMaximized = false;
73+
74 for (unsigned int i = 0; i < animations.size (); i++)
75 animations.at (i).fadingOut = true;
76 return true;
77@@ -220,7 +219,8 @@
78 desiredSlot.setWidth (workarea.width () / props.numCellsX);
79
80 /* Adjust for constraints and decorations */
81- if (where & ~(GridMaximize | GridLeft | GridRight))
82+ if (where & ~(GridMaximize |
83+ GridLeft | GridRight | GridTop | GridBottom))
84 desiredRect = constrainSize (cw, desiredSlot);
85 else
86 desiredRect = slotToRect (cw, desiredSlot);
87@@ -232,7 +232,9 @@
88
89 if (desiredRect.y () == currentRect.y () &&
90 desiredRect.height () == currentRect.height () &&
91- where & ~(GridMaximize | GridLeft | GridRight) && gw->lastTarget & where)
92+ where & ~(GridMaximize |
93+ GridLeft | GridRight | GridTop | GridBottom) &&
94+ gw->lastTarget & where)
95 {
96 int slotWidth25 = workarea.width () / 4;
97 int slotWidth33 = (workarea.width () / 3) + cw->border ().left;
98@@ -352,9 +354,11 @@
99
100 gw->sizeHintsFlags = 0;
101
102- /* Special case for left and right, actually vertically maximize
103- * the window */
104- if (where & GridLeft || where & GridRight)
105+ /* Special cases for left/right and top/bottom gridded windows, where we
106+ * actually vertically respective horizontally semi-maximize the window
107+ */
108+ if (where & GridLeft || where & GridRight ||
109+ where & GridTop || where & GridBottom)
110 {
111 /* First restore the window to its original size */
112 XWindowChanges rwc;
113@@ -366,11 +370,24 @@
114
115 cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &rwc);
116
117- gw->isGridSemiMaximized = true;
118- gw->isGridResized = false;
119-
120- /* Maximize the window */
121- cw->maximize (CompWindowStateMaximizedVertMask);
122+ if (where & GridLeft || where & GridRight)
123+ {
124+ gw->isGridVertMaximized = true;
125+ gw->isGridHorzMaximized = false;
126+ gw->isGridResized = false;
127+
128+ /* Semi-maximize the window vertically */
129+ cw->maximize (CompWindowStateMaximizedVertMask);
130+ }
131+ else /* GridTop || GridBottom */
132+ {
133+ gw->isGridHorzMaximized = true;
134+ gw->isGridVertMaximized = false;
135+ gw->isGridResized = false;
136+
137+ /* Semi-maximize the window horizontally */
138+ cw->maximize (CompWindowStateMaximizedHorzMask);
139+ }
140
141 /* Be evil */
142 if (cw->sizeHints ().flags & PResizeInc)
143@@ -379,10 +396,11 @@
144 gw->window->sizeHints ().flags &= ~(PResizeInc);
145 }
146 }
147- else
148+ else /* GridCorners || GridCenter */
149 {
150 gw->isGridResized = true;
151- gw->isGridSemiMaximized = false;
152+ gw->isGridHorzMaximized = false;
153+ gw->isGridVertMaximized = false;
154 }
155
156 int dw = (lastBorder.left + lastBorder.right) -
157@@ -843,8 +861,8 @@
158
159 /* Don't allow non-pagers to change
160 * the size of the window, the user
161- * specified this size, thank-you */
162- if (isGridSemiMaximized)
163+ * specified this size */
164+ if (isGridHorzMaximized || isGridVertMaximized)
165 if (source != ClientTypePager)
166 xwcm = 0;
167 }
168@@ -868,7 +886,10 @@
169 pointerBufDx = pointerBufDy = 0;
170 grabMask = mask;
171
172- if (!isGridResized && !isGridSemiMaximized && gScreen->optionGetSnapbackWindows ())
173+ if (!isGridResized &&
174+ !isGridHorzMaximized &&
175+ !isGridVertMaximized &&
176+ gScreen->optionGetSnapbackWindows ())
177 /* Store size not including borders when grabbing with cursor */
178 originalSize = gScreen->slotToRect(window,
179 window->serverBorderRect ());
180@@ -909,8 +930,18 @@
181 {
182 window->moveNotify (dx, dy, immediate);
183
184- if (isGridResized && !isGridSemiMaximized && !GridScreen::get (screen)->mSwitchingVp)
185+ if (isGridResized &&
186+ !isGridHorzMaximized &&
187+ !isGridVertMaximized &&
188+ !GridScreen::get (screen)->mSwitchingVp)
189 {
190+ if (window->grabbed () && screen->grabExist ("expo"))
191+ {
192+ /* Window is being dragged in expo. Restore the original geometry
193+ * right away to avoid any confusion. */
194+ gScreen->restoreWindow (0, 0, gScreen->o);
195+ return;
196+ }
197 if (window->grabbed () && (grabMask & CompWindowGrabMoveMask))
198 {
199 pointerBufDx += dx;
200@@ -933,7 +964,10 @@
201 !(window->state () & MAXIMIZE_STATE))
202 {
203 lastTarget = GridUnknown;
204- if (isGridSemiMaximized && (lastState & MAXIMIZE_STATE) == CompWindowStateMaximizedVertMask)
205+ if ((isGridHorzMaximized &&
206+ (lastState & MAXIMIZE_STATE) == CompWindowStateMaximizedHorzMask) ||
207+ (isGridVertMaximized &&
208+ (lastState & MAXIMIZE_STATE) == CompWindowStateMaximizedVertMask))
209 gScreen->restoreWindow(0, 0, gScreen->o);
210 }
211 else if (!(lastState & MAXIMIZE_STATE) &&
212@@ -969,7 +1003,9 @@
213
214 GRID_WINDOW (cw);
215
216- if (!gw->isGridResized && !gw->isGridSemiMaximized)
217+ if (!gw->isGridResized &&
218+ !gw->isGridHorzMaximized &&
219+ !gw->isGridVertMaximized)
220 {
221 /* Grid hasn't touched this window or has maximized it. If it's
222 * maximized, unmaximize it and get out. */
223@@ -977,25 +1013,38 @@
224 cw->maximize(0);
225 return true;
226 }
227-
228- else if (!gw->isGridResized && gw->isGridSemiMaximized)
229+ else if (!gw->isGridResized &&
230+ gw->isGridHorzMaximized &&
231+ !gw->isGridVertMaximized)
232+ {
233+ /* Window has been horizontally maximized by grid. We only need
234+ * to restore Y and height - core handles X and width. */
235+ if (gw->sizeHintsFlags)
236+ gw->window->sizeHints ().flags |= gw->sizeHintsFlags;
237+ xwcm |= CWY | CWHeight;
238+ }
239+ else if (!gw->isGridResized &&
240+ !gw->isGridHorzMaximized &&
241+ gw->isGridVertMaximized)
242 {
243 /* Window has been vertically maximized by grid. We only need
244- * to restore the X and width - core handles Y and height. */
245+ * to restore X and width - core handles Y and height. */
246 if (gw->sizeHintsFlags)
247 gw->window->sizeHints ().flags |= gw->sizeHintsFlags;
248 xwcm |= CWX | CWWidth;
249 }
250-
251- else if (gw->isGridResized && !gw->isGridSemiMaximized)
252- /* Window is just gridded (top, bottom, center, corners). We
253- * need to handle everything. */
254+ else if (gw->isGridResized &&
255+ !gw->isGridHorzMaximized &&
256+ !gw->isGridVertMaximized)
257+ /* Window is just gridded (center, corners).
258+ * We need to handle everything. */
259 xwcm |= CWX | CWY | CWWidth | CWHeight;
260 else
261 {
262 /* This should never happen. But if it does, just bail out
263 * gracefully. */
264- assert (gw->isGridResized && gw->isGridSemiMaximized);
265+ assert (gw->isGridResized &&
266+ (gw->isGridHorzMaximized || gw->isGridVertMaximized));
267 return false;
268 }
269
270@@ -1004,6 +1053,16 @@
271 xwc.x = pointerX - (gw->originalSize.width () / 2);
272 xwc.y = pointerY + (cw->border ().top / 2);
273 }
274+ else if (cw->grabbed () && screen->grabExist ("expo"))
275+ {
276+ /* We're restoring a window inside expo by dragging. This is a bit
277+ * tricky. Pointer location is absolute to the screen, not relative
278+ * to expo viewport. So we can't use pointer location to calculate
279+ * the position of the restore window.
280+ *
281+ * The best solution is to resize it in place. */
282+ xwcm = CWWidth | CWHeight;
283+ }
284 else
285 {
286 xwc.x = gw->originalSize.x ();
287@@ -1018,7 +1077,8 @@
288 gw->currentSize = CompRect ();
289 gw->pointerBufDx = 0;
290 gw->pointerBufDy = 0;
291- gw->isGridSemiMaximized = false;
292+ gw->isGridHorzMaximized = false;
293+ gw->isGridVertMaximized = false;
294 gw->isGridResized = false;
295 if (cw->state () & MAXIMIZE_STATE)
296 cw->maximize(0);
297@@ -1035,7 +1095,8 @@
298 GRID_WINDOW (screen->findWindow
299 (CompOption::getIntOptionNamed (o, "window")));
300 gw->isGridResized = false;
301- gw->isGridSemiMaximized = false;
302+ gw->isGridHorzMaximized = false;
303+ gw->isGridVertMaximized = false;
304 gw->resizeCount = 0;
305 }
306
307@@ -1197,7 +1258,8 @@
308 gWindow (GLWindow::get(window)),
309 gScreen (GridScreen::get (screen)),
310 isGridResized (false),
311- isGridSemiMaximized (false),
312+ isGridHorzMaximized (false),
313+ isGridVertMaximized (false),
314 grabMask (0),
315 pointerBufDx (0),
316 pointerBufDy (0),
317
318=== modified file 'plugins/grid/src/grid.h'
319--- plugins/grid/src/grid.h 2013-01-21 15:17:50 +0000
320+++ plugins/grid/src/grid.h 2013-04-05 21:36:18 +0000
321@@ -182,7 +182,8 @@
322 GridScreen *gScreen;
323
324 bool isGridResized;
325- bool isGridSemiMaximized;
326+ bool isGridHorzMaximized;
327+ bool isGridVertMaximized;
328 unsigned int grabMask;
329 int pointerBufDx;
330 int pointerBufDy;
331
332=== modified file 'plugins/move/src/move.cpp'
333--- plugins/move/src/move.cpp 2013-03-26 22:02:39 +0000
334+++ plugins/move/src/move.cpp 2013-04-05 21:36:18 +0000
335@@ -112,6 +112,9 @@
336
337 workArea = s->getWorkareaForOutput (w->outputDevice ());
338
339+ ms->snapBackX = w->serverGeometry ().x () - workArea.x ();
340+ ms->snapOffX = x - workArea.x ();
341+
342 ms->snapBackY = w->serverGeometry ().y () - workArea.y ();
343 ms->snapOffY = y - workArea.y ();
344
345@@ -436,6 +439,32 @@
346 }
347 }
348 }
349+ else if (w->state () & CompWindowStateMaximizedHorzMask)
350+ {
351+ if (abs (xRoot - workArea.x () - ms->snapOffX) >= SNAP_OFF)
352+ {
353+ if (!s->otherGrabExist ("move", NULL))
354+ {
355+ int width = w->serverGeometry ().width ();
356+
357+ w->saveMask () |= CWX | CWY;
358+
359+ if (w->saveMask ()& CWWidth)
360+ width = w->saveWc ().width;
361+
362+ w->saveWc ().x = xRoot - (width >> 1);
363+ w->saveWc ().y = yRoot + (w->border ().top >> 1);
364+
365+ ms->x = ms->y = 0;
366+
367+ w->maximize (0);
368+
369+ ms->snapOffX = ms->snapBackX;
370+
371+ return;
372+ }
373+ }
374+ }
375 else if (ms->origState & CompWindowStateMaximizedVertMask)
376 {
377 if (abs (yRoot - workArea.y () - ms->snapBackY) < SNAP_BACK)
378
379=== modified file 'plugins/move/src/move.h'
380--- plugins/move/src/move.h 2013-01-03 16:05:26 +0000
381+++ plugins/move/src/move.h 2013-04-05 21:36:18 +0000
382@@ -89,6 +89,9 @@
383
384 unsigned int origState;
385
386+ int snapOffX;
387+ int snapBackX;
388+
389 int snapOffY;
390 int snapBackY;
391

Subscribers

People subscribed via source and target branches