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

Proposed by Sam Spilsbury
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 Approve
Review via email: mp+78358@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
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)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
--- plugins/unityshell/src/PluginAdapter.cpp 2011-10-01 06:15:51 +0000
+++ plugins/unityshell/src/PluginAdapter.cpp 2011-10-07 02:39:25 +0000
@@ -190,9 +190,6 @@
190 case CompWindowNotifyUnmap:190 case CompWindowNotifyUnmap:
191 WindowManager::window_unmapped.emit(window->id());191 WindowManager::window_unmapped.emit(window->id());
192 break;192 break;
193 case CompWindowNotifyReparent:
194 MaximizeIfBigEnough(window);
195 break;
196 case CompWindowNotifyFocusChange:193 case CompWindowNotifyFocusChange:
197 WindowManager::window_focus_changed.emit(window->id());194 WindowManager::window_focus_changed.emit(window->id());
198 break;195 break;
@@ -842,7 +839,8 @@
842 return _vp_switch_started;839 return _vp_switch_started;
843}840}
844841
845void PluginAdapter::MaximizeIfBigEnough(CompWindow* window)842/* Returns true if the window was maximized */
843bool PluginAdapter::MaximizeIfBigEnough(CompWindow* window)
846{844{
847 XClassHint classHint;845 XClassHint classHint;
848 Status status;846 Status status;
@@ -854,14 +852,14 @@
854 float covering_part;852 float covering_part;
855853
856 if (!window)854 if (!window)
857 return;855 return false;
858856
859 if ((window->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE)857 if ((window->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE)
860 return;858 return false;
861859
862 if (window->type() != CompWindowTypeNormalMask860 if (window->type() != CompWindowTypeNormalMask
863 || (window->actions() & MAXIMIZABLE) != MAXIMIZABLE)861 || (window->actions() & MAXIMIZABLE) != MAXIMIZABLE)
864 return;862 return false;
865863
866 status = XGetClassHint(m_Screen->dpy(), window->id(), &classHint);864 status = XGetClassHint(m_Screen->dpy(), window->id(), &classHint);
867 if (status && classHint.res_class)865 if (status && classHint.res_class)
@@ -873,7 +871,7 @@
873 XFree(classHint.res_name);871 XFree(classHint.res_name);
874 }872 }
875 else873 else
876 return;874 return false;
877875
878 num_monitor = window->outputDevice();876 num_monitor = window->outputDevice();
879 CompOutput &o = m_Screen->outputDevs().at(num_monitor);877 CompOutput &o = m_Screen->outputDevs().at(num_monitor);
@@ -889,10 +887,12 @@
889 (hints.flags & PMaxSize && (screen_width > hints.max_width || screen_height > hints.max_height)))887 (hints.flags & PMaxSize && (screen_width > hints.max_width || screen_height > hints.max_height)))
890 {888 {
891 LOG_DEBUG(logger) << win_wmclass << " window size doesn't fit";889 LOG_DEBUG(logger) << win_wmclass << " window size doesn't fit";
892 return;890 return false;
893 }891 }
894892
895 window->maximize(MAXIMIZE_STATE);893 window->maximize(MAXIMIZE_STATE);
894
895 return true;
896}896}
897897
898void898void
899899
=== modified file 'plugins/unityshell/src/PluginAdapter.h'
--- plugins/unityshell/src/PluginAdapter.h 2011-10-01 06:15:51 +0000
+++ plugins/unityshell/src/PluginAdapter.h 2011-10-07 02:39:25 +0000
@@ -135,7 +135,7 @@
135135
136 unsigned long long GetWindowActiveNumber (guint32 xid);136 unsigned long long GetWindowActiveNumber (guint32 xid);
137137
138 void MaximizeIfBigEnough(CompWindow* window);138 bool MaximizeIfBigEnough(CompWindow* window);
139139
140 nux::Geometry GetWindowGeometry(guint32 xid);140 nux::Geometry GetWindowGeometry(guint32 xid);
141 nux::Geometry GetScreenGeometry();141 nux::Geometry GetScreenGeometry();
142142
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2011-10-05 09:03:44 +0000
+++ plugins/unityshell/src/unityshell.cpp 2011-10-07 02:39:25 +0000
@@ -1890,13 +1890,20 @@
18901890
1891bool UnityWindow::place(CompPoint& pos)1891bool UnityWindow::place(CompPoint& pos)
1892{1892{
1893 bool result = window->place(pos);1893 bool was_maximized = PluginAdapter::Default ()->MaximizeIfBigEnough(window);
18941894
1895 if (window->type() & NO_FOCUS_MASK)1895 if (!was_maximized)
1896 {
1897 bool result = window->place(pos);
1898
1899 if (window->type() & NO_FOCUS_MASK)
1900 return result;
1901
1902 pos = tryNotIntersectUI(pos);
1896 return result;1903 return result;
1904 }
18971905
1898 pos = tryNotIntersectUI(pos);1906 return true;
1899 return result;
1900}1907}
19011908
1902/* Configure callback for the launcher window */1909/* Configure callback for the launcher window */