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

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~smspillaz/unity/unity.fix_881190v2
Merge into: lp:unity
Diff against target: 208 lines (+36/-29)
5 files modified
plugins/unityshell/src/compizminimizedwindowhandler.h (+14/-5)
plugins/unityshell/src/comptransientfor.cpp (+6/-1)
plugins/unityshell/src/transientfor.cpp (+11/-4)
plugins/unityshell/src/unityshell.cpp (+4/-18)
plugins/unityshell/src/unityshell.h (+1/-1)
To merge this branch: bzr merge lp:~smspillaz/unity/unity.fix_881190v2
Reviewer Review Type Date Requested Status
Tim Penhey (community) Needs Fixing
Review via email: mp+89397@code.launchpad.net

This proposal supersedes a proposal from 2012-01-19.

This proposal has been superseded by a proposal from 2012-02-07.

Description of the change

Fix LP #881190 #871801

    The transient for reader would report every window as a "transient" if it
    matched the w->transientFor () definition on the window - at destruction time
    this will be zero, so it will match every single window. That would cause
    all windows to be unminimized.

    However, it makes no sense to do the unminimize/minimize normally dance when
    the window has been destroyed.

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Conflicts with: https://code.launchpad.net/~vanvugt/unity/fix-918329-trunk/+merge/89391

Also, this proposal attempts to fix 2 separate bugs. I think you should remove the fix for 918360 which is redundant with my proposal and re-propose just a fix for bug 881190.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Fri, 20 Jan 2012, Daniel van Vugt wrote:

> Conflicts with: https://code.launchpad.net/~vanvugt/unity/fix-918329-trunk/+merge/89391
>
> Also, this proposal attempts to fix 2 separate bugs. I think you should remove the fix for 918360 which is redundant with my proposal and re-propose just a fix for bug 881190.

Ack, removing the cycle code and keeping the fix for the unminimize

> --
> https://code.launchpad.net/~smspillaz/unity/unity.fix_881190_918360/+merge/89181
> You are the owner of lp:~smspillaz/unity/unity.fix_881190_918360.
>

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

(Updated)

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

mMinimizeHandler should be a std::unique_ptr from <memory>.

Also there are places where you dereference a pointer without checking that it is non-null.

Also please use nullptr rather than NULL.

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

> mMinimizeHandler should be a std::unique_ptr from <memory>.

It can't be. It needs strong and weak references (eg, the static list of mMinimizeHandler is there because the minimize handlers need to know about other minimize handlers that are around in order to handle stuff like, eg, minimizing transient windows)

>
> Also there are places where you dereference a pointer without checking that it
> is non-null.

If you are talking about

167 if (actualType == XA_WINDOW && actualFormat == 32 && nLeft == 0 && nItems == 1)
168 {
169 - Window *data = (Window *) prop;
170 + Window *data = (Window *) prop;
171
172 - serverAncestor = *data;
173 + serverAncestor = *data;
174 }

data in this case is always guarunteed to be non-null, as because nItems tells you what is actually in data.

>
> Also please use nullptr rather than NULL.

ack

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

This has been updated, please re-review

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

To do with std::unique_ptr...

Don't assign, please use reset:
> w->mMinimizeHandler = std::unique_ptr <Type> (new Type (win));

  w->mMinimizeHandler.reset(new Type(win);

Assignment only works with a temporary, as unique_ptr is non-copyable,
but has move semantics. Better to use the explicit reset.

Since you are not caring aroub the return type, use reset, not release.

 > w->mMinimizeHandler.release();

 w->mMinimizeHandler.reset();

 > return mMinimizeHandler.get () != nullptr;

Please use the class's operator bool.

  return mMinimizeHandler;

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/compizminimizedwindowhandler.h'
2--- plugins/unityshell/src/compizminimizedwindowhandler.h 2012-01-20 06:47:42 +0000
3+++ plugins/unityshell/src/compizminimizedwindowhandler.h 2012-02-02 01:53:21 +0000
4@@ -26,6 +26,7 @@
5 #include <core/core.h>
6 #include "minimizedwindowhandler.h"
7 #include "comptransientfor.h"
8+#include <memory>
9
10 // Will be merged back into compiz
11 namespace compiz {
12@@ -67,7 +68,7 @@
13 typedef std::list <Type *> List;
14 protected:
15
16- virtual std::vector<unsigned int> getTransients ();
17+ std::vector<unsigned int> getTransients ();
18
19 private:
20
21@@ -103,6 +104,15 @@
22 template <typename Screen, typename Window>
23 compiz::CompizMinimizedWindowHandler<Screen, Window>::~CompizMinimizedWindowHandler ()
24 {
25+ if (!priv->mWindow->destroyed ())
26+ {
27+ priv->mWindow->unminimize ();
28+ priv->mWindow->focusSetEnabled (Window::get (priv->mWindow), false);
29+ priv->mWindow->minimizeSetEnabled (Window::get (priv->mWindow), false);
30+ priv->mWindow->unminimizeSetEnabled (Window::get (priv->mWindow), false);
31+ priv->mWindow->minimize ();
32+ }
33+
34 minimizedWindows.remove (this);
35 }
36
37@@ -158,7 +168,7 @@
38 {
39 Window *w = Window::get (win);
40 if (!w->mMinimizeHandler)
41- w->mMinimizeHandler = new Type (win);
42+ w->mMinimizeHandler = std::unique_ptr <Type> (new Type (win));
43 w->mMinimizeHandler->minimize ();
44 }
45 }
46@@ -241,8 +251,7 @@
47 if (w && w->mMinimizeHandler)
48 {
49 w->mMinimizeHandler->unminimize ();
50- delete w->mMinimizeHandler;
51- w->mMinimizeHandler = NULL;
52+ w->mMinimizeHandler.release ();
53 }
54 }
55 }
56@@ -324,7 +333,7 @@
57 if (w)
58 {
59 Window *pw = Window::get (w);
60- Type *compizMinimizeHandler = pw->mMinimizeHandler;
61+ Type *compizMinimizeHandler = pw->mMinimizeHandler.get ();
62
63 /* Restore and re-save input shape and remove */
64 if (compizMinimizeHandler)
65
66=== modified file 'plugins/unityshell/src/comptransientfor.cpp'
67--- plugins/unityshell/src/comptransientfor.cpp 2011-08-23 14:47:38 +0000
68+++ plugins/unityshell/src/comptransientfor.cpp 2012-02-02 01:53:21 +0000
69@@ -55,13 +55,18 @@
70 bool
71 compiz::CompTransientForReader::isTransientFor (unsigned int ancestor)
72 {
73+ if (!ancestor ||
74+ !priv->mWindow->id ())
75+ return false;
76+
77 return priv->mWindow->transientFor () == ancestor;
78 }
79
80 bool
81 compiz::CompTransientForReader::isGroupTransientFor (unsigned int clientLeader)
82 {
83- if (!clientLeader)
84+ if (!clientLeader ||
85+ !priv->mWindow->id ())
86 return false;
87
88 if (priv->mWindow->transientFor () == None || priv->mWindow->transientFor () == screen->root ())
89
90=== modified file 'plugins/unityshell/src/transientfor.cpp'
91--- plugins/unityshell/src/transientfor.cpp 2011-08-26 10:37:35 +0000
92+++ plugins/unityshell/src/transientfor.cpp 2012-02-02 01:53:21 +0000
93@@ -51,9 +51,9 @@
94 {
95 if (actualType == XA_WINDOW && actualFormat == 32 && nLeft == 0 && nItems == 1)
96 {
97- Window *data = (Window *) prop;
98+ Window *data = (Window *) prop;
99
100- serverAncestor = *data;
101+ serverAncestor = *data;
102 }
103
104 XFree (prop);
105@@ -65,6 +65,10 @@
106 bool
107 compiz::X11TransientForReader::isTransientFor (unsigned int ancestor)
108 {
109+ if (!ancestor ||
110+ !priv->mXid)
111+ return false;
112+
113 return ancestor == getAncestor ();
114 }
115
116@@ -80,14 +84,17 @@
117 std::vector<std::string> strings;
118 std::list<Atom> atoms;
119
120+ if (!clientLeader ||
121+ !priv->mXid)
122+
123 if (XGetWindowProperty (priv->mDpy, priv->mXid, wmClientLeader, 0L, 2L, false,
124 XA_WINDOW, &actualType, &actualFormat, &nItems, &nLeft, (unsigned char **)&prop) == Success)
125 {
126 if (actualType == XA_WINDOW && actualFormat == 32 && nLeft == 0 && nItems == 1)
127 {
128- Window *data = (Window *) prop;
129+ Window *data = (Window *) prop;
130
131- serverClientLeader = *data;
132+ serverClientLeader = *data;
133 }
134
135 XFree (prop);
136
137=== modified file 'plugins/unityshell/src/unityshell.cpp'
138--- plugins/unityshell/src/unityshell.cpp 2012-02-01 00:06:29 +0000
139+++ plugins/unityshell/src/unityshell.cpp 2012-02-02 01:53:21 +0000
140@@ -1964,7 +1964,7 @@
141
142 if (!mMinimizeHandler)
143 {
144- mMinimizeHandler = new UnityMinimizedHandler (window);
145+ mMinimizeHandler = std::unique_ptr <UnityMinimizedHandler> (new UnityMinimizedHandler (window));
146 mMinimizeHandler->minimize ();
147 }
148 }
149@@ -1975,8 +1975,7 @@
150 if (mMinimizeHandler)
151 {
152 mMinimizeHandler->unminimize ();
153- delete mMinimizeHandler;
154- mMinimizeHandler = nullptr;
155+ mMinimizeHandler.release ();
156 }
157 }
158
159@@ -2015,7 +2014,7 @@
160 bool
161 UnityWindow::minimized ()
162 {
163- return mMinimizeHandler != nullptr;
164+ return mMinimizeHandler.get () != nullptr;
165 }
166
167 gboolean
168@@ -2571,7 +2570,7 @@
169 , PluginClassHandler<UnityWindow, CompWindow>(window)
170 , window(window)
171 , gWindow(GLWindow::get(window))
172- , mMinimizeHandler(nullptr)
173+ , mMinimizeHandler()
174 , mShowdesktopHandler(nullptr)
175 , focusdesktop_handle_(0)
176 {
177@@ -2629,19 +2628,6 @@
178
179 UnityShowdesktopHandler::animating_windows.remove (window);
180
181- if (mMinimizeHandler)
182- {
183- unminimize ();
184- window->focusSetEnabled (this, false);
185- window->minimizeSetEnabled (this, false);
186- window->unminimizeSetEnabled (this, false);
187- window->minimizedSetEnabled (this, false);
188- window->minimize ();
189-
190- delete mMinimizeHandler;
191- mMinimizeHandler = nullptr;
192- }
193-
194 if (mShowdesktopHandler)
195 delete mShowdesktopHandler;
196
197
198=== modified file 'plugins/unityshell/src/unityshell.h'
199--- plugins/unityshell/src/unityshell.h 2012-01-29 06:08:20 +0000
200+++ plugins/unityshell/src/unityshell.h 2012-02-02 01:53:21 +0000
201@@ -393,7 +393,7 @@
202
203 typedef compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>
204 UnityMinimizedHandler;
205- UnityMinimizedHandler *mMinimizeHandler;
206+ std::unique_ptr <UnityMinimizedHandler> mMinimizeHandler;
207
208 UnityShowdesktopHandler *mShowdesktopHandler;
209