Merge lp:~smspillaz/unity/unity.fix_857214 into lp:unity

Proposed by Sam Spilsbury
Status: Merged
Approved by: Jason Smith
Approved revision: no longer in the source branch.
Merged at revision: 1650
Proposed branch: lp:~smspillaz/unity/unity.fix_857214
Merge into: lp:unity
Diff against target: 159 lines (+84/-20)
4 files modified
plugins/unityshell/src/PanelController.cpp (+12/-0)
plugins/unityshell/src/PanelController.h (+1/-0)
plugins/unityshell/src/unityshell.cpp (+70/-19)
plugins/unityshell/src/unityshell.h (+1/-1)
To merge this branch: bzr merge lp:~smspillaz/unity/unity.fix_857214
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+77319@code.launchpad.net

Description of the change

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/PanelController.cpp'
2--- plugins/unityshell/src/PanelController.cpp 2011-09-07 21:00:32 +0000
3+++ plugins/unityshell/src/PanelController.cpp 2011-09-28 12:34:03 +0000
4@@ -60,6 +60,18 @@
5 return 0;
6 }
7
8+std::list <nux::Geometry> PanelController::GetGeometries ()
9+{
10+ std::list <nux::Geometry> geometries;
11+
12+ for (auto &window : _windows)
13+ {
14+ geometries.push_back (window->GetAbsoluteGeometry ());
15+ }
16+
17+ return geometries;
18+}
19+
20 void
21 PanelController::StartFirstMenuShow()
22 {
23
24=== modified file 'plugins/unityshell/src/PanelController.h'
25--- plugins/unityshell/src/PanelController.h 2011-09-07 21:00:32 +0000
26+++ plugins/unityshell/src/PanelController.h 2011-09-28 12:34:03 +0000
27@@ -38,6 +38,7 @@
28 void QueueRedraw();
29
30 unsigned int GetTrayXid ();
31+ std::list <nux::Geometry> GetGeometries ();
32
33 float opacity() const;
34
35
36=== modified file 'plugins/unityshell/src/unityshell.cpp'
37--- plugins/unityshell/src/unityshell.cpp 2011-09-28 01:43:32 +0000
38+++ plugins/unityshell/src/unityshell.cpp 2011-09-28 12:34:03 +0000
39@@ -1738,16 +1738,79 @@
40 window->resizeNotify(x, y, w, h);
41 }
42
43-CompPoint UnityWindow::tryNotIntersectLauncher(CompPoint& pos)
44+CompPoint UnityWindow::tryNotIntersectUI(CompPoint& pos)
45 {
46 UnityScreen* us = UnityScreen::get(screen);
47+ Launcher::LauncherHideMode hideMode = us->launcher->GetHideMode();
48 nux::Geometry geo = us->launcher->GetAbsoluteGeometry();
49+ CompRegion allowedWorkArea (screen->workArea ());
50 CompRect launcherGeo(geo.x, geo.y, geo.width, geo.height);
51-
52- if (launcherGeo.contains(pos))
53- {
54- if (screen->workArea().contains(CompRect(launcherGeo.right() + 1, pos.y(), window->width(), window->height())))
55- pos.setX(launcherGeo.right() + 1);
56+ CompRegion wRegion (window->borderRect ());
57+ CompRegion intRegion;
58+
59+ wRegion.translate (pos.x () - wRegion.boundingRect ().x (),
60+ pos.y () - wRegion.boundingRect ().y ());
61+
62+ /* subtract launcher and panel geometries from allowed workarea */
63+ if (!us->launcher->Hidden ())
64+ {
65+ switch (hideMode)
66+ {
67+ case Launcher::LAUNCHER_HIDE_DODGE_WINDOWS:
68+ case Launcher::LAUNCHER_HIDE_DODGE_ACTIVE_WINDOW:
69+ allowedWorkArea -= launcherGeo;
70+ break;
71+
72+ default:
73+ break;
74+ }
75+ }
76+
77+ for (nux::Geometry &g : us->panelController->GetGeometries ())
78+ {
79+ CompRect pg (g.x, g.y, g.width, g.height);
80+ allowedWorkArea -= pg;
81+ }
82+
83+ /* Invert allowed work area */
84+ allowedWorkArea = CompRegion (screen->workArea ()) - allowedWorkArea;
85+
86+ /* Now intersect the window region with the allowed work area
87+ * region, such that it splits up into a number of rects */
88+ intRegion = wRegion.intersected (allowedWorkArea);
89+
90+ if (intRegion.rects ().size () > 1)
91+ {
92+ /* Now find the largest rect, this will be the area that we want to move to */
93+ CompRect largest;
94+
95+ for (CompRect &r : intRegion.rects ())
96+ {
97+ if (r.area () > largest.area ())
98+ largest = r;
99+ }
100+
101+ /* Now pad the largest rect with the other rectangles that
102+ * were intersecting, padding the opposite side to the one
103+ * that they are currently on on the large rect
104+ */
105+
106+ intRegion -= largest;
107+
108+ for (CompRect &r : intRegion.rects ())
109+ {
110+ if (r.x1 () > largest.x2 ())
111+ largest.setX (largest.x () - r.width ());
112+ else if (r.x2 () < largest.x ())
113+ largest.setWidth (largest.width () + r.width ());
114+
115+ if (r.y1 () > largest.y2 ())
116+ largest.setY (largest.y () - r.height ());
117+ else if (r.y2 () < largest.y ())
118+ largest.setWidth (largest.height () + r.height ());
119+ }
120+
121+ pos = largest.pos ();
122 }
123
124 return pos;
125@@ -1755,21 +1818,9 @@
126
127 bool UnityWindow::place(CompPoint& pos)
128 {
129- UnityScreen* us = UnityScreen::get(screen);
130- Launcher::LauncherHideMode hideMode = us->launcher->GetHideMode();
131-
132 bool result = window->place(pos);
133
134- switch (hideMode)
135- {
136- case Launcher::LAUNCHER_HIDE_DODGE_WINDOWS:
137- case Launcher::LAUNCHER_HIDE_DODGE_ACTIVE_WINDOW:
138- pos = tryNotIntersectLauncher(pos);
139- break;
140-
141- default:
142- break;
143- }
144+ pos = tryNotIntersectUI(pos);
145
146 return result;
147 }
148
149=== modified file 'plugins/unityshell/src/unityshell.h'
150--- plugins/unityshell/src/unityshell.h 2011-09-21 03:40:33 +0000
151+++ plugins/unityshell/src/unityshell.h 2011-09-28 12:34:03 +0000
152@@ -382,7 +382,7 @@
153 void stateChangeNotify(unsigned int lastState);
154
155 bool place(CompPoint& pos);
156- CompPoint tryNotIntersectLauncher(CompPoint& pos);
157+ CompPoint tryNotIntersectUI(CompPoint& pos);
158
159 void paintThumbnail (nux::Geometry const& bounding, float alpha);
160