Merge lp:~bitshifternz/unity/fix-for-bug-769781 into lp:unity

Proposed by Cameron Hart
Status: Merged
Merged at revision: 1195
Proposed branch: lp:~bitshifternz/unity/fix-for-bug-769781
Merge into: lp:unity
Diff against target: 44 lines (+6/-7)
1 file modified
src/PluginAdapter.cpp (+6/-7)
To merge this branch: bzr merge lp:~bitshifternz/unity/fix-for-bug-769781
Reviewer Review Type Date Requested Status
Sam Spilsbury (community) Approve
Review via email: mp+58893@code.launchpad.net

Description of the change

Checks the max size hint on the window before attempting to maximize. Also fixes memory leak.

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

> Checks the max size hint on the window before attempting to maximize.

Looks reasonable to me, but I don't hold any weight just now :-)

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

Approve, however being pedantic here, line 18 has weird indentation, you might want to fix that :)

Also, just for super-super-correctness, you might want to do the check against the window size minus the decorations geometry. So for that you'd have (screen_width - window->border ().left () - window->border ().right () > size_hints.max_width) ... if that makes any sense.

review: Approve
Revision history for this message
Cameron Hart (bitshifternz) wrote :

Cheers, I don't know what happened with that indentation. I'll fold in your other suggestion.

> Approve, however being pedantic here, line 18 has weird indentation, you might
> want to fix that :)
>
> Also, just for super-super-correctness, you might want to do the check against
> the window size minus the decorations geometry. So for that you'd have
> (screen_width - window->border ().left () - window->border ().right () >
> size_hints.max_width) ... if that makes any sense.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/PluginAdapter.cpp'
2--- src/PluginAdapter.cpp 2011-04-18 17:56:31 +0000
3+++ src/PluginAdapter.cpp 2011-04-24 08:41:02 +0000
4@@ -580,7 +580,7 @@
5 {
6 XClassHint classHint;
7 Status status;
8- char* win_wmclass = NULL;
9+ std::string win_wmclass;
10 int num_monitor;
11 CompOutput screen;
12 int screen_width;
13@@ -597,7 +597,7 @@
14 status = XGetClassHint (m_Screen->dpy (), window->id (), &classHint);
15 if (status && classHint.res_class)
16 {
17- win_wmclass = strdup (classHint.res_class);
18+ win_wmclass = classHint.res_class;
19 XFree (classHint.res_class);
20 }
21 else
22@@ -617,18 +617,17 @@
23
24 // use server<parameter> because the window won't show the real parameter as
25 // not mapped yet
26+ const XSizeHints& hints = window->sizeHints ();
27 covering_part = (float)(window->serverWidth () * window->serverHeight ()) / (float)(screen_width * screen_height);
28- if ((covering_part < COVERAGE_AREA_BEFORE_AUTOMAXIMIZE) || (covering_part > 1.0))
29+ if ((covering_part < COVERAGE_AREA_BEFORE_AUTOMAXIMIZE) || (covering_part > 1.0) ||
30+ (hints.flags & PMaxSize && (screen_width > hints.max_width || screen_height > hints.max_height)))
31 {
32- g_debug ("MaximizeIfBigEnough: %s window size doesn't fit", win_wmclass);
33+ g_debug ("MaximizeIfBigEnough: %s window size doesn't fit", win_wmclass.c_str());
34 return;
35 }
36
37 Undecorate (window->id ());
38 window->maximize (MAXIMIZE_STATE);
39-
40- if (win_wmclass)
41- free (win_wmclass);
42 }
43
44 void