Merge lp:~3v1n0/compiz/push-grab-types into lp:compiz/0.9.12
- push-grab-types
- Merge into 0.9.12
Status: | Merged |
---|---|
Approved by: | Andrea Azzarone |
Approved revision: | 3935 |
Merged at revision: | 3983 |
Proposed branch: | lp:~3v1n0/compiz/push-grab-types |
Merge into: | lp:compiz/0.9.12 |
Diff against target: |
467 lines (+189/-73) 5 files modified
include/core/abiversion.h (+1/-1) include/core/screen.h (+2/-0) src/privatescreen.h (+31/-15) src/privatescreen/tests/test-privatescreen.cpp (+2/-0) src/screen.cpp (+153/-57) |
To merge this branch: | bzr merge lp:~3v1n0/compiz/push-grab-types |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
MC Return | Approve | ||
Andrea Azzarone | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+271585@code.launchpad.net |
Commit message
Screen: add pushKeyboardGrab and pushPointerGrab methods to add different kinds of grabs
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
- 3932. By Marco Trevisan (Treviño)
-
debian/
patches/ ubuntu_ super_p. patch: refresh to fix merging
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3932
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 3933. By Marco Trevisan (Treviño)
-
Screen: use GrabType when calling removing or updating a Grab
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3933
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 3934. By Marco Trevisan (Treviño)
-
Screen: add missing space
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3934
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 3935. By Marco Trevisan (Treviño)
-
Screen: properly ungrab / change grab owners depending on the grab types
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3935
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 3936. By Marco Trevisan (Treviño)
-
PrivateScreen: fix typo in GrabType definition
- 3937. By Marco Trevisan (Treviño)
-
Merging with trunk
MC Return (mc-return) wrote : | # |
I'm late to the party, but wanted to express a:
Great job on that one, Marco. +1
Very useful separation indeed. Top Job.
Preview Diff
1 | === modified file 'include/core/abiversion.h' |
2 | --- include/core/abiversion.h 2015-02-17 14:57:27 +0000 |
3 | +++ include/core/abiversion.h 2015-10-26 17:12:40 +0000 |
4 | @@ -5,6 +5,6 @@ |
5 | # error Conflicting definitions of CORE_ABIVERSION |
6 | #endif |
7 | |
8 | -#define CORE_ABIVERSION 20150217 |
9 | +#define CORE_ABIVERSION 20150918 |
10 | |
11 | #endif // COMPIZ_ABIVERSION_H |
12 | |
13 | === modified file 'include/core/screen.h' |
14 | --- include/core/screen.h 2012-12-03 10:36:42 +0000 |
15 | +++ include/core/screen.h 2015-10-26 17:12:40 +0000 |
16 | @@ -364,6 +364,8 @@ |
17 | virtual CompIcon *defaultIcon () const = 0; |
18 | virtual bool otherGrabExist (const char *, ...) = 0; |
19 | virtual GrabHandle pushGrab (Cursor cursor, const char *name) = 0; |
20 | + virtual GrabHandle pushPointerGrab (Cursor cursor, const char *name) = 0; |
21 | + virtual GrabHandle pushKeyboardGrab (const char *name) = 0; |
22 | virtual void removeGrab (GrabHandle handle, CompPoint *restorePointer) = 0; |
23 | virtual bool writeImageToFile (CompString &path, |
24 | const char *format, |
25 | |
26 | === modified file 'src/privatescreen.h' |
27 | --- src/privatescreen.h 2014-12-02 19:37:10 +0000 |
28 | +++ src/privatescreen.h 2015-10-26 17:12:40 +0000 |
29 | @@ -239,6 +239,20 @@ |
30 | CompStringSet blacklist; |
31 | }; |
32 | |
33 | +enum GrabType { |
34 | + POINTER = 1 << 0, |
35 | + KEYBOARD = 1 << 1, |
36 | + ALL = POINTER|KEYBOARD |
37 | +}; |
38 | + |
39 | +struct Grab { |
40 | + Grab (GrabType type, Cursor cursor, const char *name) : type(type), cursor(cursor), name(name) {} |
41 | + Grab (Cursor cursor, const char *name) : Grab(GrabType::ALL, cursor, name) {} |
42 | + GrabType type; |
43 | + Cursor cursor; |
44 | + const char *name; |
45 | +}; |
46 | + |
47 | class GrabList |
48 | { |
49 | // TODO: std::list<Grab *> is almost certainly the wrong data |
50 | @@ -249,13 +263,14 @@ |
51 | public: |
52 | typedef GrabPtrList::iterator GrabIterator; |
53 | |
54 | - bool grabsEmpty() const { return grabs.empty(); } |
55 | - void grabsPush(Grab* grab) { grabs.push_back (grab); } |
56 | - GrabIterator grabsBegin() { return grabs.begin(); } |
57 | - GrabIterator grabsEnd() { return grabs.end(); } |
58 | - void grabsRemove(Grab* grab); |
59 | + bool grabsEmpty () const { return grabs.empty (); } |
60 | + void grabsPush (Grab* grab) { grabs.push_back (grab); } |
61 | + GrabIterator grabsBegin () { return begin (grabs); } |
62 | + GrabIterator grabsEnd () { return end (grabs); } |
63 | + void grabsRemove (Grab* grab); |
64 | bool grabExist (const char *grab); |
65 | - Grab* grabsBack() { return grabs.back (); } |
66 | + Grab* topGrab (GrabType t) { auto it = std::find_if (begin (grabs), end (grabs), [t] (Grab *g) { return (g->type & t); }); return (it != end (grabs)) ? *it : NULL; } |
67 | + Grab* grabsBack () { return grabs.back (); } |
68 | |
69 | private: |
70 | GrabPtrList grabs; |
71 | @@ -349,12 +364,6 @@ |
72 | int count; |
73 | }; |
74 | |
75 | -struct Grab { |
76 | - Grab(Cursor cursor, const char *name) : cursor(cursor), name(name) {} |
77 | - Cursor cursor; |
78 | - const char *name; |
79 | -}; |
80 | - |
81 | // data members that don't belong (these probably belong |
82 | // in CompScreenImpl as PrivateScreen doesn't use them) |
83 | struct OrphanData : boost::noncopyable |
84 | @@ -571,9 +580,6 @@ |
85 | Display* const& dpy; |
86 | }; |
87 | |
88 | - |
89 | - |
90 | - |
91 | unsigned int windowStateMask (Atom state); |
92 | |
93 | }} // namespace compiz::private_screen |
94 | @@ -703,6 +709,10 @@ |
95 | static void compScreenSnEvent (SnMonitorEvent *event, |
96 | void *userData); |
97 | |
98 | + CompScreen::GrabHandle pushGrabGeneric (::compiz::private_screen::GrabType type, |
99 | + Cursor cursor, |
100 | + const char *name); |
101 | + |
102 | int getXkbEvent() const { return xkbEvent.get(); } |
103 | std::vector<XineramaScreenInfo>& getScreenInfo () { return screenInfo; } |
104 | SnDisplay* getSnDisplay () const { return snDisplay; } |
105 | @@ -963,6 +973,12 @@ |
106 | * be grabbed once and the actual grab refcounted */ |
107 | GrabHandle pushGrab (Cursor cursor, const char *name); |
108 | |
109 | + /* Adds an X Pointer grab to the stack. */ |
110 | + GrabHandle pushPointerGrab (Cursor cursor, const char *name); |
111 | + |
112 | + /* Adds an X Keyboard grab to the stack. */ |
113 | + GrabHandle pushKeyboardGrab (const char *name); |
114 | + |
115 | /* Allows you to change the pointer of your grab */ |
116 | void updateGrab (GrabHandle handle, Cursor cursor); |
117 | |
118 | |
119 | === modified file 'src/privatescreen/tests/test-privatescreen.cpp' |
120 | --- src/privatescreen/tests/test-privatescreen.cpp 2015-09-23 23:17:54 +0000 |
121 | +++ src/privatescreen/tests/test-privatescreen.cpp 2015-10-26 17:12:40 +0000 |
122 | @@ -148,6 +148,8 @@ |
123 | MOCK_CONST_METHOD0(defaultIcon, CompIcon *()); |
124 | virtual bool otherGrabExist (const char *, ...) { return false; } // TODO How to mock? |
125 | MOCK_METHOD2(pushGrab, GrabHandle (Cursor cursor, const char *name)); |
126 | + MOCK_METHOD2(pushPointerGrab, GrabHandle (Cursor cursor, const char *name)); |
127 | + MOCK_METHOD1(pushKeyboardGrab, GrabHandle (const char *name)); |
128 | MOCK_METHOD2(removeGrab, void (GrabHandle handle, CompPoint *restorePointer)); |
129 | MOCK_METHOD4(writeImageToFile, bool (CompString &path, |
130 | const char *format, |
131 | |
132 | === modified file 'src/screen.cpp' |
133 | --- src/screen.cpp 2014-12-02 19:37:10 +0000 |
134 | +++ src/screen.cpp 2015-10-26 17:12:40 +0000 |
135 | @@ -104,7 +104,7 @@ |
136 | void CompScreenImpl::sizePluginClasses(unsigned int size) |
137 | { |
138 | if(size != pluginClasses.size ()) |
139 | - pluginClasses.resize (size); |
140 | + pluginClasses.resize (size); |
141 | } |
142 | |
143 | void CompScreenImpl::setWindowState (unsigned int state, Window id) |
144 | @@ -712,7 +712,7 @@ |
145 | return false; |
146 | |
147 | if (!CompOption::findOption (getOptions (), name, &index)) |
148 | - return false; |
149 | + return false; |
150 | |
151 | switch (index) { |
152 | case CoreOptions::ActivePlugins: |
153 | @@ -870,7 +870,7 @@ |
154 | break; |
155 | default: |
156 | break; |
157 | - } |
158 | + } |
159 | |
160 | sn_display_process_event (snDisplay, &event); |
161 | |
162 | @@ -1584,8 +1584,8 @@ |
163 | |
164 | i = compiz::window::fillStateData (state, data); |
165 | XChangeProperty (dpy, id, Atoms::winState, |
166 | - XA_ATOM, 32, PropModeReplace, |
167 | - (unsigned char *) data, i); |
168 | + XA_ATOM, 32, PropModeReplace, |
169 | + (unsigned char *) data, i); |
170 | } |
171 | |
172 | unsigned int |
173 | @@ -2760,10 +2760,10 @@ |
174 | } |
175 | else |
176 | { |
177 | - CompWindow::Map::const_iterator it = windowsMap.find (id); |
178 | + CompWindow::Map::const_iterator it = windowsMap.find (id); |
179 | |
180 | - if (it != windowsMap.end ()) |
181 | - return (lastFoundWindow = it->second); |
182 | + if (it != windowsMap.end ()) |
183 | + return (lastFoundWindow = it->second); |
184 | } |
185 | |
186 | return 0; |
187 | @@ -2933,7 +2933,7 @@ |
188 | cps::WindowManager::eraseWindowFromMap (Window id) |
189 | { |
190 | if (id != 1) |
191 | - windowsMap.erase (id); |
192 | + windowsMap.erase (id); |
193 | } |
194 | |
195 | void |
196 | @@ -3024,73 +3024,166 @@ |
197 | #define POINTER_GRAB_MASK (ButtonReleaseMask | \ |
198 | ButtonPressMask | \ |
199 | PointerMotionMask) |
200 | -CompScreenImpl::GrabHandle |
201 | -CompScreenImpl::pushGrab (Cursor cursor, const char *name) |
202 | + |
203 | +CompScreen::GrabHandle |
204 | +PrivateScreen::pushGrabGeneric (cps::GrabType type, |
205 | + Cursor cursor, |
206 | + const char *name) |
207 | { |
208 | - if (privateScreen.eventManager.grabsEmpty ()) |
209 | + int status = GrabSuccess; |
210 | + |
211 | + if (eventManager.grabsEmpty ()) |
212 | { |
213 | - int status; |
214 | - |
215 | - status = XGrabPointer (privateScreen.dpy, privateScreen.eventManager.getGrabWindow(), true, |
216 | - POINTER_GRAB_MASK, |
217 | - GrabModeAsync, GrabModeAsync, |
218 | - privateScreen.rootWindow(), cursor, |
219 | - CurrentTime); |
220 | + if (type & cps::GrabType::POINTER) |
221 | + { |
222 | + status = XGrabPointer (dpy, eventManager.getGrabWindow (), true, |
223 | + POINTER_GRAB_MASK, |
224 | + GrabModeAsync, GrabModeAsync, |
225 | + root, cursor, |
226 | + CurrentTime); |
227 | + } |
228 | |
229 | if (status == GrabSuccess) |
230 | { |
231 | - status = XGrabKeyboard (privateScreen.dpy, |
232 | - privateScreen.eventManager.getGrabWindow(), true, |
233 | + if (type & cps::GrabType::KEYBOARD) |
234 | + { |
235 | + status = XGrabKeyboard (dpy, |
236 | + eventManager.getGrabWindow (), true, |
237 | + GrabModeAsync, GrabModeAsync, |
238 | + CurrentTime); |
239 | + if (status != GrabSuccess) |
240 | + { |
241 | + if (type & cps::GrabType::POINTER) |
242 | + XUngrabPointer (dpy, CurrentTime); |
243 | + |
244 | + return NULL; |
245 | + } |
246 | + } |
247 | + } |
248 | + else |
249 | + return NULL; |
250 | + } |
251 | + else |
252 | + { |
253 | + if (type & cps::GrabType::POINTER) |
254 | + { |
255 | + if (eventManager.topGrab (cps::GrabType::POINTER)) |
256 | + { |
257 | + XChangeActivePointerGrab (dpy, POINTER_GRAB_MASK, |
258 | + cursor, CurrentTime); |
259 | + } |
260 | + else |
261 | + { |
262 | + status = XGrabPointer (dpy, eventManager.getGrabWindow (), true, |
263 | + POINTER_GRAB_MASK, |
264 | + GrabModeAsync, GrabModeAsync, |
265 | + root, cursor, |
266 | + CurrentTime); |
267 | + |
268 | + if (status != GrabSuccess) |
269 | + return NULL; |
270 | + } |
271 | + } |
272 | + |
273 | + if ((type & cps::GrabType::KEYBOARD) && |
274 | + !eventManager.topGrab (cps::GrabType::KEYBOARD)) |
275 | + { |
276 | + status = XGrabKeyboard (dpy, |
277 | + eventManager.getGrabWindow (), true, |
278 | GrabModeAsync, GrabModeAsync, |
279 | CurrentTime); |
280 | + |
281 | if (status != GrabSuccess) |
282 | { |
283 | - XUngrabPointer (privateScreen.dpy, CurrentTime); |
284 | + if (type & cps::GrabType::POINTER) |
285 | + { |
286 | + if (cps::Grab *lastPtrGrab = eventManager.topGrab (cps::GrabType::POINTER)) |
287 | + { |
288 | + XChangeActivePointerGrab (dpy, POINTER_GRAB_MASK, |
289 | + lastPtrGrab->cursor, CurrentTime); |
290 | + } |
291 | + else |
292 | + { |
293 | + XUngrabPointer (dpy, CurrentTime); |
294 | + } |
295 | + } |
296 | + |
297 | return NULL; |
298 | } |
299 | } |
300 | - else |
301 | - return NULL; |
302 | } |
303 | - else |
304 | + |
305 | + cps::Grab *grab = new cps::Grab (type, cursor, name); |
306 | + eventManager.grabsPush (grab); |
307 | + |
308 | + return grab; |
309 | +} |
310 | + |
311 | +CompScreenImpl::GrabHandle |
312 | +CompScreenImpl::pushGrab (Cursor cursor, const char *name) |
313 | +{ |
314 | + return privateScreen.pushGrabGeneric(cps::GrabType::ALL, cursor, name); |
315 | +} |
316 | + |
317 | +CompScreenImpl::GrabHandle |
318 | +CompScreenImpl::pushPointerGrab (Cursor cursor, const char *name) |
319 | +{ |
320 | + return privateScreen.pushGrabGeneric(cps::GrabType::POINTER, cursor, name); |
321 | +} |
322 | + |
323 | +CompScreenImpl::GrabHandle |
324 | +CompScreenImpl::pushKeyboardGrab (const char *name) |
325 | +{ |
326 | + return privateScreen.pushGrabGeneric(cps::GrabType::KEYBOARD, XC_X_cursor, name); |
327 | +} |
328 | + |
329 | +void |
330 | +CompScreenImpl::updateGrab (CompScreen::GrabHandle handle, Cursor cursor) |
331 | +{ |
332 | + if (!handle || !(handle->type & cps::GrabType::POINTER)) |
333 | + return; |
334 | + |
335 | + if (privateScreen.eventManager.topGrab (cps::GrabType::POINTER) == handle) |
336 | { |
337 | XChangeActivePointerGrab (privateScreen.dpy, POINTER_GRAB_MASK, |
338 | cursor, CurrentTime); |
339 | } |
340 | |
341 | - cps::Grab *grab = new cps::Grab (cursor, name); |
342 | - privateScreen.eventManager.grabsPush (grab); |
343 | - |
344 | - return grab; |
345 | -} |
346 | - |
347 | -void |
348 | -CompScreenImpl::updateGrab (CompScreen::GrabHandle handle, Cursor cursor) |
349 | -{ |
350 | - if (!handle) |
351 | - return; |
352 | - |
353 | - XChangeActivePointerGrab (privateScreen.dpy, POINTER_GRAB_MASK, |
354 | - cursor, CurrentTime); |
355 | - |
356 | handle->cursor = cursor; |
357 | } |
358 | |
359 | void |
360 | CompScreenImpl::removeGrab (CompScreen::GrabHandle handle, |
361 | - CompPoint *restorePointer) |
362 | + CompPoint *restorePointer) |
363 | { |
364 | if (!handle) |
365 | return; |
366 | |
367 | + cps::GrabType removedType = handle->type; |
368 | privateScreen.eventManager.grabsRemove(handle); |
369 | |
370 | if (!privateScreen.eventManager.grabsEmpty ()) |
371 | { |
372 | - XChangeActivePointerGrab (privateScreen.dpy, |
373 | - POINTER_GRAB_MASK, |
374 | - privateScreen.eventManager.grabsBack ()->cursor, |
375 | - CurrentTime); |
376 | + if (removedType & cps::GrabType::POINTER) |
377 | + { |
378 | + if (CompScreen::GrabHandle topPtrGrab = privateScreen.eventManager.topGrab (cps::GrabType::POINTER)) |
379 | + { |
380 | + XChangeActivePointerGrab (privateScreen.dpy, |
381 | + POINTER_GRAB_MASK, |
382 | + topPtrGrab->cursor, |
383 | + CurrentTime); |
384 | + } |
385 | + else |
386 | + { |
387 | + XUngrabPointer (privateScreen.dpy, CurrentTime); |
388 | + } |
389 | + } |
390 | + |
391 | + if (removedType & cps::GrabType::KEYBOARD) |
392 | + { |
393 | + if (!privateScreen.eventManager.topGrab (cps::GrabType::KEYBOARD)) |
394 | + XUngrabKeyboard (privateScreen.dpy, CurrentTime); |
395 | + } |
396 | } |
397 | else |
398 | { |
399 | @@ -3098,8 +3191,11 @@ |
400 | warpPointer (restorePointer->x () - pointerX, |
401 | restorePointer->y () - pointerY); |
402 | |
403 | - XUngrabPointer (privateScreen.dpy, CurrentTime); |
404 | - XUngrabKeyboard (privateScreen.dpy, CurrentTime); |
405 | + if (removedType & cps::GrabType::POINTER) |
406 | + XUngrabPointer (privateScreen.dpy, CurrentTime); |
407 | + |
408 | + if (removedType & cps::GrabType::KEYBOARD) |
409 | + XUngrabKeyboard (privateScreen.dpy, CurrentTime); |
410 | } |
411 | } |
412 | |
413 | @@ -3265,12 +3361,12 @@ |
414 | * keys, and know to cancel the tap if <modifier>+k is pressed. |
415 | */ |
416 | if (!(currentState & CompAction::StateIgnoreTap)) |
417 | - { |
418 | - int minCode, maxCode; |
419 | - XDisplayKeycodes (screen->dpy(), &minCode, &maxCode); |
420 | - for (k = minCode; k <= maxCode; k++) |
421 | - grabUngrabOneKey (modifiers | modifierForKeycode | ignore, k, grab); |
422 | - } |
423 | + { |
424 | + int minCode, maxCode; |
425 | + XDisplayKeycodes (screen->dpy(), &minCode, &maxCode); |
426 | + for (k = minCode; k <= maxCode; k++) |
427 | + grabUngrabOneKey (modifiers | modifierForKeycode | ignore, k, grab); |
428 | + } |
429 | } |
430 | |
431 | if (CompScreen::checkForError (screen->dpy())) |
432 | @@ -3517,7 +3613,7 @@ |
433 | CompScreenImpl::removeAction (CompAction *action) |
434 | { |
435 | if (!privateScreen.initialized || |
436 | - !action->active ()) |
437 | + !action->active ()) |
438 | return; |
439 | |
440 | grabManager.setCurrentState(action->state()); |
441 | @@ -3746,7 +3842,7 @@ |
442 | pos = env.find (':'); |
443 | if (pos != std::string::npos) |
444 | { |
445 | - size_t pointPos = env.find ('.', pos); |
446 | + size_t pointPos = env.find ('.', pos); |
447 | |
448 | if (pointPos != std::string::npos) |
449 | { |
450 | @@ -3754,7 +3850,7 @@ |
451 | } |
452 | else |
453 | { |
454 | - unsigned int displayNum = atoi (env.substr (pos + 1).c_str ()); |
455 | + unsigned int displayNum = atoi (env.substr (pos + 1).c_str ()); |
456 | env.erase (pos); |
457 | env.append (compPrintf (":%i", displayNum)); |
458 | } |
459 | @@ -5160,7 +5256,7 @@ |
460 | privateScreen.startupSequence.removeAllSequences (); |
461 | |
462 | while (!windowManager.getWindows().empty ()) |
463 | - delete windowManager.getWindows().front (); |
464 | + delete windowManager.getWindows().front (); |
465 | |
466 | while (CompPlugin* p = CompPlugin::pop ()) |
467 | CompPlugin::unload (p); |
FAILED: Continuous integration, rev:3931 jenkins. qa.ubuntu. com/job/ compiz- ci/80/ jenkins. qa.ubuntu. com/job/ compiz- wily-amd64- ci/25/console jenkins. qa.ubuntu. com/job/ compiz- wily-armhf- ci/25/console jenkins. qa.ubuntu. com/job/ compiz- wily-i386- ci/25/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/compiz- ci/80/rebuild
http://