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

Proposed by Sam Spilsbury on 2011-10-06
Status: Merged
Merged at revision: 1700
Proposed branch: lp:~smspillaz/unity/unity.fix_868930
Merge into: lp:unity
Diff against target: 107 lines (+22/-15)
3 files modified
plugins/unityshell/src/PluginAdapter.cpp (+9/-9)
plugins/unityshell/src/PluginAdapter.h (+1/-1)
plugins/unityshell/src/unityshell.cpp (+12/-5)
To merge this branch: bzr merge lp:~smspillaz/unity/unity.fix_868930
Reviewer Review Type Date Requested Status
Tim Penhey (community) conditional 2011-10-06 Approve on 2011-10-06
Review via email: mp+78358@code.launchpad.net

Description of the change

To post a comment you must log in.
Tim Penhey (thumper) wrote :

How about:

  bool maximized = PluginAdapter::Default()->MaximizeIfBigEnough(window);
  if (!maximized)

I find this easier to read, and the compiler will optimise the temporary out.

review: Approve (conditional)
lp:~smspillaz/unity/unity.fix_868930 updated on 2011-10-07
1694. By Sam Spilsbury on 2011-10-07

Use a temporary

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 2011-10-01 06:15:51 +0000
3+++ plugins/unityshell/src/PluginAdapter.cpp 2011-10-07 02:39:25 +0000
4@@ -190,9 +190,6 @@
5 case CompWindowNotifyUnmap:
6 WindowManager::window_unmapped.emit(window->id());
7 break;
8- case CompWindowNotifyReparent:
9- MaximizeIfBigEnough(window);
10- break;
11 case CompWindowNotifyFocusChange:
12 WindowManager::window_focus_changed.emit(window->id());
13 break;
14@@ -842,7 +839,8 @@
15 return _vp_switch_started;
16 }
17
18-void PluginAdapter::MaximizeIfBigEnough(CompWindow* window)
19+/* Returns true if the window was maximized */
20+bool PluginAdapter::MaximizeIfBigEnough(CompWindow* window)
21 {
22 XClassHint classHint;
23 Status status;
24@@ -854,14 +852,14 @@
25 float covering_part;
26
27 if (!window)
28- return;
29+ return false;
30
31 if ((window->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE)
32- return;
33+ return false;
34
35 if (window->type() != CompWindowTypeNormalMask
36 || (window->actions() & MAXIMIZABLE) != MAXIMIZABLE)
37- return;
38+ return false;
39
40 status = XGetClassHint(m_Screen->dpy(), window->id(), &classHint);
41 if (status && classHint.res_class)
42@@ -873,7 +871,7 @@
43 XFree(classHint.res_name);
44 }
45 else
46- return;
47+ return false;
48
49 num_monitor = window->outputDevice();
50 CompOutput &o = m_Screen->outputDevs().at(num_monitor);
51@@ -889,10 +887,12 @@
52 (hints.flags & PMaxSize && (screen_width > hints.max_width || screen_height > hints.max_height)))
53 {
54 LOG_DEBUG(logger) << win_wmclass << " window size doesn't fit";
55- return;
56+ return false;
57 }
58
59 window->maximize(MAXIMIZE_STATE);
60+
61+ return true;
62 }
63
64 void
65
66=== modified file 'plugins/unityshell/src/PluginAdapter.h'
67--- plugins/unityshell/src/PluginAdapter.h 2011-10-01 06:15:51 +0000
68+++ plugins/unityshell/src/PluginAdapter.h 2011-10-07 02:39:25 +0000
69@@ -135,7 +135,7 @@
70
71 unsigned long long GetWindowActiveNumber (guint32 xid);
72
73- void MaximizeIfBigEnough(CompWindow* window);
74+ bool MaximizeIfBigEnough(CompWindow* window);
75
76 nux::Geometry GetWindowGeometry(guint32 xid);
77 nux::Geometry GetScreenGeometry();
78
79=== modified file 'plugins/unityshell/src/unityshell.cpp'
80--- plugins/unityshell/src/unityshell.cpp 2011-10-05 09:03:44 +0000
81+++ plugins/unityshell/src/unityshell.cpp 2011-10-07 02:39:25 +0000
82@@ -1890,13 +1890,20 @@
83
84 bool UnityWindow::place(CompPoint& pos)
85 {
86- bool result = window->place(pos);
87-
88- if (window->type() & NO_FOCUS_MASK)
89+ bool was_maximized = PluginAdapter::Default ()->MaximizeIfBigEnough(window);
90+
91+ if (!was_maximized)
92+ {
93+ bool result = window->place(pos);
94+
95+ if (window->type() & NO_FOCUS_MASK)
96+ return result;
97+
98+ pos = tryNotIntersectUI(pos);
99 return result;
100+ }
101
102- pos = tryNotIntersectUI(pos);
103- return result;
104+ return true;
105 }
106
107 /* Configure callback for the launcher window */