Merge lp:~3v1n0/unity/panel-p-window-manager into lp:~3v1n0/unity/panel-p-tray

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merge reported by: Marco Trevisan (Treviño)
Merged at revision: not available
Proposed branch: lp:~3v1n0/unity/panel-p-window-manager
Merge into: lp:~3v1n0/unity/panel-p-tray
Diff against target: 559 lines (+220/-43)
4 files modified
plugins/unityshell/src/PluginAdapter.cpp (+158/-24)
plugins/unityshell/src/PluginAdapter.h (+12/-3)
plugins/unityshell/src/WindowManager.cpp (+38/-10)
plugins/unityshell/src/WindowManager.h (+12/-6)
To merge this branch: bzr merge lp:~3v1n0/unity/panel-p-window-manager
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Marco Trevisan (Treviño) Pending
Review via email: mp+100126@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

I first noticed the change in the behaviour in side

PluginAdapter::Minimize, where you removed
  && (window->actions() & CompWindowActionMinimizeMask)

What is the rationale for that?

Why have GetWorkAreaGeometry and GetWindowSavedGeometry return
constant rectanges of a fixed size and the method themselves are
non-const? (Two question there: non-const and why fixed size)

review: Needs Information
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> I first noticed the change in the behaviour in side
>
> PluginAdapter::Minimize, where you removed
> && (window->actions() & CompWindowActionMinimizeMask)
>
> What is the rationale for that?

Removed? I've added that... :o
Even if compiz should do the same, it was good to me to check if a window is minimizable before trying to do that.

> Why have GetWorkAreaGeometry and GetWindowSavedGeometry return
> constant rectanges of a fixed size and the method themselves are
> non-const? (Two question there: non-const and why fixed size)

Well, I've just been consistent with the already available GetGeometry* related methods in WindowManager, but now I've changed them to be const.

Revision history for this message
Tim Penhey (thumper) wrote :

Please don't use:
  g_debug("%s", G_STRFUNC);

I noticed that this is really just a copy and paste from the other methods. Why do we have this logging here? What value is it adding? Shall we change it to use new logging?

review: Needs Information
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> Please don't use:
> g_debug("%s", G_STRFUNC);
>
> I noticed that this is really just a copy and paste from the other methods.
> Why do we have this logging here? What value is it adding? Shall we change
> it to use new logging?

Mh, it's basically a place-holder and I used that since it has always been used in WindowManager.cpp by most of the functions. These functions are never called, since the class methods are mostly pure-virtual.

For sure, this should be fixed in some way, but I didn't this here not to go out of scope more than I already was for this branch :); so I've just been consistent with the others.

Revision history for this message
Tim Penhey (thumper) wrote :

Hmm... fair enough.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
2--- plugins/unityshell/src/PluginAdapter.cpp 2012-03-21 12:31:11 +0000
3+++ plugins/unityshell/src/PluginAdapter.cpp 2012-04-04 20:18:27 +0000
4@@ -66,6 +66,7 @@
5 _last_focused_window(nullptr)
6 {
7 _spread_state = false;
8+ _spread_windows_state = false;
9 _expo_state = false;
10 _vp_switch_started = false;
11
12@@ -105,6 +106,7 @@
13 if (_spread_state && !screen->grabExist("scale"))
14 {
15 _spread_state = false;
16+ _spread_windows_state = false;
17 terminate_spread.emit();
18 }
19
20@@ -296,7 +298,7 @@
21 unsigned long long
22 PluginAdapter::GetWindowActiveNumber (guint32 xid)
23 {
24- Window win = (Window)xid;
25+ Window win = xid;
26 CompWindow* window;
27
28 window = m_Screen->findWindow(win);
29@@ -370,6 +372,12 @@
30 }
31
32 bool
33+PluginAdapter::IsScaleActiveForGroup()
34+{
35+ return _spread_windows_state && m_Screen->grabExist("scale");
36+}
37+
38+bool
39 PluginAdapter::IsExpoActive()
40 {
41 return m_Screen->grabExist("expo");
42@@ -387,7 +395,7 @@
43 bool
44 PluginAdapter::IsWindowMaximized(guint xid)
45 {
46- Window win = (Window)xid;
47+ Window win = xid;
48 CompWindow* window;
49
50 window = m_Screen->findWindow(win);
51@@ -442,7 +450,7 @@
52 bool
53 PluginAdapter::IsWindowOnCurrentDesktop(guint32 xid)
54 {
55- Window win = (Window)xid;
56+ Window win = xid;
57 CompWindow* window;
58
59 window = m_Screen->findWindow(win);
60@@ -458,13 +466,18 @@
61 bool
62 PluginAdapter::IsWindowObscured(guint32 xid)
63 {
64- Window win = (Window)xid;
65+ Window win = xid;
66 CompWindow* window;
67
68 window = m_Screen->findWindow(win);
69+
70 if (window)
71 {
72+ if (window->inShowDesktopMode())
73+ return true;
74+
75 CompPoint window_vp = window->defaultViewport();
76+ nux::Geometry const& win_geo = GetWindowGeometry(window->id());
77 // Check if any windows above this one are blocking it
78 for (CompWindow* sibling = window->next; sibling != NULL; sibling = sibling->next)
79 {
80@@ -472,8 +485,11 @@
81 && !sibling->minimized()
82 && sibling->isMapped()
83 && sibling->isViewable()
84- && (sibling->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE)
85+ && (sibling->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE
86+ && !GetWindowGeometry(sibling->id()).Intersect(win_geo).IsNull())
87+ {
88 return true;
89+ }
90 }
91 }
92
93@@ -483,7 +499,7 @@
94 bool
95 PluginAdapter::IsWindowMapped(guint32 xid)
96 {
97- Window win = (Window) xid;
98+ Window win = xid;
99 CompWindow* window;
100
101 window = m_Screen->findWindow(win);
102@@ -495,20 +511,33 @@
103 bool
104 PluginAdapter::IsWindowVisible(guint32 xid)
105 {
106- Window win = (Window) xid;
107- CompWindow* window;
108-
109- window = m_Screen->findWindow(win);
110- if (window)
111- return !(window->state () & CompWindowStateHiddenMask);
112-
113- return true;
114+ Window win = xid;
115+ CompWindow* window;
116+
117+ window = m_Screen->findWindow(win);
118+ if (window)
119+ return !(window->state() & CompWindowStateHiddenMask) && !window->inShowDesktopMode();
120+
121+ return false;
122+}
123+
124+bool
125+PluginAdapter::IsWindowMinimizable(guint32 xid)
126+{
127+ Window win = xid;
128+ CompWindow* window;
129+
130+ window = m_Screen->findWindow(win);
131+ if (window)
132+ return (window->actions() & CompWindowActionMinimizeMask);
133+
134+ return false;
135 }
136
137 void
138 PluginAdapter::Restore(guint32 xid)
139 {
140- Window win = (Window)xid;
141+ Window win = xid;
142 CompWindow* window;
143
144 window = m_Screen->findWindow(win);
145@@ -517,20 +546,37 @@
146 }
147
148 void
149+PluginAdapter::RestoreAt(guint32 xid, int x, int y)
150+{
151+ Window win = xid;
152+ CompWindow* window;
153+
154+ window = m_Screen->findWindow(win);
155+ if (window && (window->state() & MAXIMIZE_STATE))
156+ {
157+ nux::Geometry new_geo(GetWindowSavedGeometry(xid));
158+ new_geo.x = x;
159+ new_geo.y = y;
160+ window->maximize(0);
161+ MoveResizeWindow(xid, new_geo);
162+ }
163+}
164+
165+void
166 PluginAdapter::Minimize(guint32 xid)
167 {
168- Window win = (Window)xid;
169+ Window win = xid;
170 CompWindow* window;
171
172 window = m_Screen->findWindow(win);
173- if (window)
174+ if (window && (window->actions() & CompWindowActionMinimizeMask))
175 window->minimize();
176 }
177
178 void
179 PluginAdapter::Close(guint32 xid)
180 {
181- Window win = (Window)xid;
182+ Window win = xid;
183 CompWindow* window;
184
185 window = m_Screen->findWindow(win);
186@@ -541,7 +587,7 @@
187 void
188 PluginAdapter::Activate(guint32 xid)
189 {
190- Window win = (Window)xid;
191+ Window win = xid;
192 CompWindow* window;
193
194 window = m_Screen->findWindow(win);
195@@ -552,7 +598,7 @@
196 void
197 PluginAdapter::Raise(guint32 xid)
198 {
199- Window win = (Window)xid;
200+ Window win = xid;
201 CompWindow* window;
202
203 window = m_Screen->findWindow(win);
204@@ -563,7 +609,7 @@
205 void
206 PluginAdapter::Lower(guint32 xid)
207 {
208- Window win = (Window)xid;
209+ Window win = xid;
210 CompWindow* window;
211
212 window = m_Screen->findWindow(win);
213@@ -664,9 +710,13 @@
214 }
215
216 if (monitor > 0 && top_window_on_monitor)
217+ {
218 top_window_on_monitor->activate();
219+ }
220 else if (top_window)
221+ {
222 top_window->activate();
223+ }
224 }
225
226 bool
227@@ -676,6 +726,7 @@
228 {
229 std::string match = MatchStringForXids(&windows);
230 InitiateScale(match, state);
231+ _spread_windows_state = true;
232 return true;
233 }
234 return false;
235@@ -718,9 +769,9 @@
236 }
237
238 nux::Geometry
239-PluginAdapter::GetWindowGeometry(guint32 xid)
240+PluginAdapter::GetWindowGeometry(guint32 xid) const
241 {
242- Window win = (Window)xid;
243+ Window win = xid;
244 CompWindow* window;
245 nux::Geometry geo(0, 0, 1, 1);
246
247@@ -735,8 +786,28 @@
248 return geo;
249 }
250
251+nux::Geometry
252+PluginAdapter::GetWindowSavedGeometry(guint32 xid) const
253+{
254+ Window win = xid;
255+ nux::Geometry geo(0, 0, 1, 1);
256+ CompWindow* window;
257+
258+ window = m_Screen->findWindow(win);
259+ if (window)
260+ {
261+ XWindowChanges &wc = window->saveWc();
262+ geo.x = wc.x;
263+ geo.y = wc.y;
264+ geo.width = wc.width;
265+ geo.height = wc.height;
266+ }
267+
268+ return geo;
269+}
270+
271 nux::Geometry
272-PluginAdapter::GetScreenGeometry()
273+PluginAdapter::GetScreenGeometry() const
274 {
275 nux::Geometry geo;
276
277@@ -748,6 +819,33 @@
278 return geo;
279 }
280
281+nux::Geometry
282+PluginAdapter::GetWorkAreaGeometry(guint32 xid) const
283+{
284+ CompWindow* window = nullptr;
285+ unsigned int output = 0;
286+
287+ if (xid != 0)
288+ {
289+ Window win = xid;
290+
291+ window = m_Screen->findWindow(win);
292+ if (window)
293+ {
294+ output = window->outputDevice();
295+ }
296+ }
297+
298+ if (xid == 0 || !window)
299+ {
300+ output = m_Screen->currentOutputDev().id();
301+ }
302+
303+ CompRect workarea = m_Screen->getWorkareaForOutput(output);
304+
305+ return nux::Geometry(workarea.x(), workarea.y(), workarea.width(), workarea.height());
306+}
307+
308 bool
309 PluginAdapter::CheckWindowIntersection(nux::Geometry const& region, CompWindow* window)
310 {
311@@ -1056,6 +1154,42 @@
312 }
313
314 void
315+PluginAdapter::MoveResizeWindow(guint32 xid, nux::Geometry geometry)
316+{
317+ int w, h;
318+ CompWindow* window = m_Screen->findWindow(xid);
319+
320+ if (!window)
321+ return;
322+
323+ if (window->constrainNewWindowSize(geometry.width, geometry.height, &w, &h))
324+ {
325+ CompRect workarea = m_Screen->getWorkareaForOutput(window->outputDevice());
326+ int dx = geometry.x + w - workarea.right() + window->border().right;
327+ int dy = geometry.y + h - workarea.bottom() + window->border().bottom;
328+
329+ if (dx > 0)
330+ geometry.x -= dx;
331+ if (dy > 0)
332+ geometry.y -= dy;
333+
334+ geometry.SetWidth(w);
335+ geometry.SetHeight(h);
336+ }
337+
338+ XWindowChanges xwc;
339+ xwc.x = geometry.x;
340+ xwc.y = geometry.y;
341+ xwc.width = geometry.width;
342+ xwc.height = geometry.height;
343+
344+ if (window->mapNum())
345+ window->sendSyncRequest();
346+
347+ window->configureXWindow(CWX | CWY | CWWidth | CWHeight, &xwc);
348+}
349+
350+void
351 PluginAdapter::OnWindowClosed(CompWindow *w)
352 {
353 if (_last_focused_window == w)
354
355=== modified file 'plugins/unityshell/src/PluginAdapter.h'
356--- plugins/unityshell/src/PluginAdapter.h 2012-03-21 12:31:11 +0000
357+++ plugins/unityshell/src/PluginAdapter.h 2012-04-04 20:18:27 +0000
358@@ -93,6 +93,7 @@
359
360 void TerminateScale();
361 bool IsScaleActive();
362+ bool IsScaleActiveForGroup();
363
364 void InitiateExpo();
365 bool IsExpoActive();
366@@ -118,7 +119,10 @@
367 bool IsWindowObscured(guint xid);
368 bool IsWindowMapped(guint xid);
369 bool IsWindowVisible(guint32 xid);
370+ bool IsWindowMinimizable(guint32 xid);
371+
372 void Restore(guint32 xid);
373+ void RestoreAt(guint32 xid, int x, int y);
374 void Minimize(guint32 xid);
375 void Close(guint32 xid);
376 void Activate(guint32 xid);
377@@ -138,9 +142,11 @@
378
379 bool MaximizeIfBigEnough(CompWindow* window);
380
381- nux::Geometry GetWindowGeometry(guint32 xid);
382- nux::Geometry GetScreenGeometry();
383-
384+ nux::Geometry GetWindowGeometry(guint32 xid) const;
385+ nux::Geometry GetWindowSavedGeometry(guint32 xid) const;
386+ nux::Geometry GetScreenGeometry() const;
387+ nux::Geometry GetWorkAreaGeometry(guint32 xid = 0) const;
388+
389 void CheckWindowIntersections(nux::Geometry const& region, bool &active, bool &any);
390
391 int WorkspaceCount();
392@@ -150,6 +156,8 @@
393 bool saveInputFocus ();
394 bool restoreInputFocus ();
395
396+ void MoveResizeWindow(guint32 xid, nux::Geometry geometry);
397+
398 protected:
399 PluginAdapter(CompScreen* screen);
400
401@@ -165,6 +173,7 @@
402 MultiActionList m_ScaleActionList;
403
404 bool _spread_state;
405+ bool _spread_windows_state;
406 bool _expo_state;
407 bool _vp_switch_started;
408
409
410=== modified file 'plugins/unityshell/src/WindowManager.cpp'
411--- plugins/unityshell/src/WindowManager.cpp 2012-03-21 12:31:11 +0000
412+++ plugins/unityshell/src/WindowManager.cpp 2012-04-04 20:18:27 +0000
413@@ -73,11 +73,21 @@
414 return true;
415 }
416
417+ bool IsWindowMinimizable(guint32 xid)
418+ {
419+ return true;
420+ }
421+
422 void Restore(guint32 xid)
423 {
424 g_debug("%s", G_STRFUNC);
425 }
426
427+ void RestoreAt(guint32 xid, int x, int y)
428+ {
429+ g_debug("%s", G_STRFUNC);
430+ }
431+
432 void Minimize(guint32 xid)
433 {
434 g_debug("%s", G_STRFUNC);
435@@ -114,14 +124,24 @@
436 return false;
437 }
438
439- nux::Geometry GetWindowGeometry(guint xid)
440+ nux::Geometry GetWindowGeometry(guint xid) const
441 {
442 int width = (guint32)xid >> 16;
443 int height = (guint32)xid & 0x0000FFFF;
444 return nux::Geometry(0, 0, width, height);
445 }
446
447- nux::Geometry GetScreenGeometry()
448+ nux::Geometry GetWindowSavedGeometry(guint xid) const
449+ {
450+ return nux::Geometry(0, 0, 1, 1);
451+ }
452+
453+ nux::Geometry GetScreenGeometry() const
454+ {
455+ return nux::Geometry(0, 0, 1, 1);
456+ }
457+
458+ nux::Geometry GetWorkAreaGeometry(guint32 xid) const
459 {
460 return nux::Geometry(0, 0, 1, 1);
461 }
462@@ -153,6 +173,12 @@
463 return false;
464 }
465
466+ bool IsScaleActiveForGroup()
467+ {
468+ g_debug("%s", G_STRFUNC);
469+ return false;
470+ }
471+
472 void InitiateExpo()
473 {
474 g_debug("%s", G_STRFUNC);
475@@ -164,6 +190,10 @@
476 return false;
477 }
478
479+ void MoveResizeWindow(guint32 xid, nux::Geometry geometry)
480+ {
481+ g_debug("%s", G_STRFUNC);
482+ }
483 };
484
485 WindowManager*
486@@ -183,9 +213,7 @@
487
488 #define NET_WM_MOVERESIZE_MOVE 8
489
490-
491-void
492-WindowManager::StartMove(guint32 xid, int x, int y)
493+void WindowManager::StartMove(guint32 xid, int x, int y)
494 {
495 if (x < 0 || y < 0)
496 return;
497@@ -229,11 +257,11 @@
498 ev.xclient.message_type = m_MoveResizeAtom;
499 ev.xclient.format = 32;
500
501- ev.xclient.data.l[0] = x;
502- ev.xclient.data.l[1] = y;
503- ev.xclient.data.l[2] = NET_WM_MOVERESIZE_MOVE;
504- ev.xclient.data.l[3] = 1;
505- ev.xclient.data.l[4] = 1;
506+ ev.xclient.data.l[0] = x; // x_root
507+ ev.xclient.data.l[1] = y; // y_root
508+ ev.xclient.data.l[2] = NET_WM_MOVERESIZE_MOVE; //direction
509+ ev.xclient.data.l[3] = 1; // button
510+ ev.xclient.data.l[4] = 2; // source
511
512 XSendEvent(d, DefaultRootWindow(d), FALSE,
513 SubstructureRedirectMask | SubstructureNotifyMask,
514
515=== modified file 'plugins/unityshell/src/WindowManager.h'
516--- plugins/unityshell/src/WindowManager.h 2012-03-21 12:31:11 +0000
517+++ plugins/unityshell/src/WindowManager.h 2012-04-04 20:18:27 +0000
518@@ -61,10 +61,12 @@
519 virtual bool IsWindowObscured(guint32 xid) = 0;
520 virtual bool IsWindowMapped(guint32 xid) = 0;
521 virtual bool IsWindowVisible(guint32 xid) = 0;
522+ virtual bool IsWindowMinimizable(guint32 xid) = 0;
523
524 virtual void ShowDesktop() = 0;
525
526 virtual void Restore(guint32 xid) = 0;
527+ virtual void RestoreAt(guint32 xid, int x, int y) = 0;
528 virtual void Minimize(guint32 xid) = 0;
529 virtual void Close(guint32 xid) = 0;
530
531@@ -74,6 +76,7 @@
532
533 virtual void TerminateScale() = 0;
534 virtual bool IsScaleActive() = 0;
535+ virtual bool IsScaleActiveForGroup() = 0;
536
537 virtual void InitiateExpo() = 0;
538 virtual bool IsExpoActive() = 0;
539@@ -87,12 +90,15 @@
540 virtual bool IsScreenGrabbed() = 0;
541 virtual bool IsViewPortSwitchStarted() = 0;
542
543- void StartMove(guint32 id, int, int);
544-
545- virtual nux::Geometry GetWindowGeometry(guint32 xid) = 0;
546- virtual nux::Geometry GetScreenGeometry() = 0;
547-
548- virtual unsigned long long GetWindowActiveNumber (guint32 xid) = 0;
549+ virtual void MoveResizeWindow(guint32 xid, nux::Geometry geometry) = 0;
550+ void StartMove(guint32 xid, int, int);
551+
552+ virtual nux::Geometry GetWindowGeometry(guint32 xid) const = 0;
553+ virtual nux::Geometry GetWindowSavedGeometry(guint32 xid) const = 0;
554+ virtual nux::Geometry GetScreenGeometry() const = 0;
555+ virtual nux::Geometry GetWorkAreaGeometry(guint32 xid = 0) const = 0;
556+
557+ virtual unsigned long long GetWindowActiveNumber(guint32 xid) = 0;
558
559 virtual void SetWindowIconGeometry(Window window, nux::Geometry const& geo) = 0;
560

Subscribers

People subscribed via source and target branches

to all changes: