Merge lp:~unity-team/unity/mt-fixes into lp:unity

Proposed by Neil J. Patel
Status: Merged
Merged at revision: 500
Proposed branch: lp:~unity-team/unity/mt-fixes
Merge into: lp:unity
Diff against target: 306 lines (+139/-47)
1 file modified
targets/mutter/plugin.vala (+139/-47)
To merge this branch: bzr merge lp:~unity-team/unity/mt-fixes
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Review via email: mp+35398@code.launchpad.net

Description of the change

Some cleanup of MT stuff and a re-jig of some of the actions.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Code looks good and compiles even though I can't test it.

The primary thing that jumped to my eyes where in the last lines of the diff where you move a Gdk.Window - isn't that a bit like using wnck from inside a window manager?

If you know what you're doing - then go ahead :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'targets/mutter/plugin.vala'
2--- targets/mutter/plugin.vala 2010-08-26 15:34:34 +0000
3+++ targets/mutter/plugin.vala 2010-09-14 13:06:46 +0000
4@@ -163,9 +163,10 @@
5 private dynamic DBus.Object screensaver;
6
7 public Gesture.Dispatcher gesture_dispatcher;
8+ private Gesture.Type active_gesture_type = Gesture.Type.NONE;
9
10 /* Pinch info */
11- private float start_pinch_radius = 0.0f;
12+ /* private float start_pinch_radius = 0.0f; */
13 private unowned Mutter.Window? resize_window = null;
14 /*private float resize_last_x1 = 0.0f;
15 private float resize_last_y1 = 0.0f;
16@@ -804,22 +805,96 @@
17
18 private void on_gesture_received (Gesture.Event event)
19 {
20- if (event.type == Gesture.Type.TAP &&
21- expose_manager.expose_showing == false)
22- {
23- if (event.fingers == 3)
24- {
25- ;
26- }
27- else if (event.fingers == 4)
28- {
29- show_unity ();
30- }
31- }
32- else if (event.type == Gesture.Type.PINCH &&
33- places_showing == false)
34- {
35- if (event.fingers == 3)
36+ if (active_gesture_type != Gesture.Type.NONE
37+ && active_gesture_type != event.type
38+ && event.state != Gesture.State.ENDED)
39+ {
40+ /* A new gesture is beginning */
41+ if (event.state == Gesture.State.BEGAN)
42+ {
43+ active_gesture_type = event.type;
44+ }
45+ else
46+ {
47+ /* We don't want to handle it */
48+ return;
49+ }
50+ }
51+
52+ if (event.type == Gesture.Type.TAP
53+ && places_showing == false)
54+ {
55+ if (event.fingers == 3) /* Application-level window pick */
56+ {
57+ if (expose_manager.expose_showing == true)
58+ {
59+ expose_manager.end_expose ();
60+ return;
61+ }
62+
63+ Mutter.Window? window = null;
64+
65+ var actor = stage.get_actor_at_pos (Clutter.PickMode.ALL,
66+ (int)event.root_x,
67+ (int)event.root_y);
68+ if (actor is Mutter.Window == false)
69+ actor = actor.get_parent ();
70+
71+ if (actor is Mutter.Window)
72+ {
73+ window = actor as Mutter.Window;
74+
75+ if (start_pan_window.get_window_type () != Mutter.MetaCompWindowType.NORMAL &&
76+ start_pan_window.get_window_type () != Mutter.MetaCompWindowType.DIALOG &&
77+ start_pan_window.get_window_type () != Mutter.MetaCompWindowType.MODAL_DIALOG &&
78+ start_pan_window.get_window_type () != Mutter.MetaCompWindowType.UTILITY)
79+ window = null;
80+ }
81+
82+ if (window is Mutter.Window)
83+ {
84+ /* FIXME: bamf_matcher_get_application_for_xid () fails for
85+ * me in this case, so I had to use the slower method */
86+ var matcher = Bamf.Matcher.get_default ();
87+ var xwin = (uint32)Mutter.MetaWindow.get_xwindow (window.get_meta_window ());
88+
89+ foreach (Bamf.Application app in matcher.get_running_applications ())
90+ {
91+ Array<uint32> xids = app.get_xids ();
92+ for (int i = 0; i < xids.length; i++)
93+ {
94+ uint32 xid = xids.index (i);
95+ if (xwin == xid)
96+ {
97+ /* Found the right application, so pick it */
98+ expose_xids (xids);
99+ return;
100+ }
101+ }
102+ }
103+ }
104+ }
105+ else if (event.fingers == 4) /* System-level window picker */
106+ {
107+ if (expose_manager.expose_showing == false)
108+ {
109+ SList<Clutter.Actor> windows = new SList<Clutter.Actor> ();
110+ unowned GLib.List<Mutter.Window> mutter_windows = plugin.get_windows ();
111+ foreach (Mutter.Window w in mutter_windows)
112+ {
113+ windows.append (w);
114+ }
115+ expose_windows (windows, get_launcher_width_foobar () + 10);
116+ }
117+ else
118+ expose_manager.end_expose ();
119+ }
120+ }
121+ else if (event.type == Gesture.Type.PINCH)
122+ {
123+ if (event.fingers == 3
124+ && places_showing == false
125+ && expose_manager.expose_showing == false)
126 {
127 if (event.state == Gesture.State.ENDED)
128 {
129@@ -851,7 +926,6 @@
130 Mutter.MetaMaximizeFlags.HORIZONTAL |
131 Mutter.MetaMaximizeFlags.VERTICAL);
132 }
133-
134 }
135 else
136 {
137@@ -865,6 +939,8 @@
138 Mutter.MetaMaximizeFlags.HORIZONTAL | Mutter.MetaMaximizeFlags.VERTICAL);
139 }
140 }
141+
142+ Mutter.MetaWindow.activate (win, get_current_time ());
143 }
144 }
145
146@@ -937,8 +1013,16 @@
147 print (@"$event\n");
148 */
149 }
150- else if (event.fingers == 4)
151+ else if (event.fingers == 4
152+ && expose_manager.expose_showing == false
153+ && event.state == Gesture.State.BEGAN)
154 {
155+ if (places_showing == true)
156+ hide_unity ();
157+ else
158+ show_unity ();
159+
160+ /* FIXME: We'll come back to this awesomeness
161 if (event.state == Gesture.State.BEGAN)
162 {
163 if (expose_manager.expose_showing)
164@@ -973,7 +1057,7 @@
165 {
166 if (start_pinch_radius < 0)
167 {
168- /* We're moving backward */
169+ // We're moving backward
170 I_JUST_PULLED_THIS_FROM_MY_FOO *= -1;
171 }
172 }
173@@ -981,7 +1065,7 @@
174 {
175 if (start_pinch_radius >= 0)
176 {
177- /* We're moving backward */
178+ // We're moving backward
179 I_JUST_PULLED_THIS_FROM_MY_FOO *= -1;
180 }
181 }
182@@ -1051,6 +1135,7 @@
183 clone.queue_relayout ();
184 }
185 }
186+ */
187 }
188 }
189 else if (event.type == Gesture.Type.PAN)
190@@ -1094,7 +1179,7 @@
191 if (!Mutter.MetaWindow.is_maximized (win) && fullscreen == false)
192 {
193 if (start_pan_window.y == PANEL_HEIGHT
194- && event.pan_event.delta_y < 0.0f)
195+ && event.pan_event.delta_y <= 0.0f)
196 {
197 if (start_frame_rect is Clutter.Rectangle == false)
198 {
199@@ -1109,14 +1194,14 @@
200 start_pan_window.y);
201 frame.show ();
202
203- start_frame_rect = frame;
204+ start_frame_rect = frame;
205
206- last_pan_maximised_x_root = event.root_x;
207+ last_pan_maximised_x_root = start_pan_window.x;
208 }
209
210 maximize_type = MaximizeType.FULL;
211 var MAX_DELTA = 50.0f;
212- if (event.root_x < last_pan_maximised_x_root - MAX_DELTA)
213+ if (start_pan_window.x < last_pan_maximised_x_root - MAX_DELTA)
214 {
215 maximize_type = MaximizeType.LEFT;
216 start_frame_rect.animate (Clutter.AnimationMode.EASE_OUT_QUAD,
217@@ -1127,7 +1212,7 @@
218 "height", stage.height - PANEL_HEIGHT);
219
220 }
221- else if (event.root_x > last_pan_maximised_x_root + MAX_DELTA)
222+ else if (start_pan_window.x > last_pan_maximised_x_root + MAX_DELTA)
223 {
224 maximize_type = MaximizeType.RIGHT;
225 start_frame_rect.animate (Clutter.AnimationMode.EASE_OUT_QUAD,
226@@ -1150,11 +1235,6 @@
227 }
228 else
229 {
230- start_pan_window.x += Math.floorf (event.pan_event.delta_x + 0.5f);
231- start_pan_window.y += Math.floorf (event.pan_event.delta_y + 0.5f);
232- start_pan_window.x = float.max (start_pan_window.x, QUICKLAUNCHER_WIDTH);
233- start_pan_window.y = float.max (start_pan_window.y, PANEL_HEIGHT);
234-
235 if (start_frame_rect is Clutter.Rectangle)
236 {
237 if (start_frame_rect.opacity == 0)
238@@ -1175,6 +1255,10 @@
239 }
240 }
241 }
242+ start_pan_window.x += Math.floorf (event.pan_event.delta_x + 0.5f);
243+ start_pan_window.y += Math.floorf (event.pan_event.delta_y + 0.5f);
244+ start_pan_window.x = float.max (start_pan_window.x, QUICKLAUNCHER_WIDTH);
245+ start_pan_window.y = float.max (start_pan_window.y, PANEL_HEIGHT);
246 }
247 else
248 {
249@@ -1213,6 +1297,7 @@
250
251 Mutter.MetaWindow.maximize (win,
252 Mutter.MetaMaximizeFlags.HORIZONTAL | Mutter.MetaMaximizeFlags.VERTICAL);
253+ move_resize = false;
254 }
255 else if (maximize_type == MaximizeType.RIGHT)
256 {
257@@ -1235,27 +1320,34 @@
258 }
259 else
260 {
261- /* FIXME: We need to somehow convince Mutter to tell
262- * us the size of the frame. 27 = top + bottom frame
263- * 1 = left frame
264- * 24 = size of top frame
265- */
266 nx = start_pan_window.x;
267- ny = start_pan_window.y; /* Kittens are dying */
268- nwidth = start_pan_window.width;
269- nheight = start_pan_window.height;
270+ ny = start_pan_window.y;
271+ nwidth = 0.0f;
272+ nheight = 0.0f;
273 move_resize = true;
274-
275- print ("%d %d %d %d\n",wx, wy, rect.x, rect.y);
276 }
277
278- X.Window xwin = start_pan_window.get_x_window ();
279- unowned Gdk.Window w = Gdk.Window.foreign_new ((Gdk.NativeWindow)xwin);
280- if (w is Gdk.Window && move_resize)
281+ if (move_resize)
282 {
283- Mutter.MetaWindow.move_resize (win, false, ((int)nx),
284- ((int)ny),
285- (int)nwidth, (int)nheight);
286+ X.Window xwin = start_pan_window.get_x_window ();
287+ if (nwidth > 0.0f && nheight > 0.0f)
288+ {
289+ Mutter.MetaWindow.move_resize (win, false, ((int)nx),
290+ ((int)ny),
291+ (int)nwidth, (int)nheight);
292+ }
293+ else
294+ {
295+ /* We use gdk_window_move because we don't want
296+ * to send in the width and height if we dont
297+ * need to, as otherwise we'll cause a resize
298+ * for no reason, and most likely get it
299+ * wrong (you need to take into account frame
300+ * size inside Mutter
301+ */
302+ unowned Gdk.Window w = Gdk.Window.foreign_new ((Gdk.NativeWindow)xwin);
303+ w.move ((int)nx, (int)ny);
304+ }
305 }
306 }
307