Merge lp:~3v1n0/compiz/wily-cursors-update-and-cache into lp:compiz/wily
- wily-cursors-update-and-cache
- Merge into wily
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Approved by: | Andrea Azzarone |
Approved revision: | 3984 |
Merged at revision: | 3983 |
Proposed branch: | lp:~3v1n0/compiz/wily-cursors-update-and-cache |
Merge into: | lp:compiz/wily |
Diff against target: |
966 lines (+209/-134) 26 files modified
CMakeLists.txt (+1/-0) include/core/abiversion.h (+1/-1) include/core/screen.h (+6/-1) plugins/expo/src/expo.cpp (+1/-8) plugins/expo/src/expo.h (+0/-3) plugins/freewins/src/action.cpp (+1/-5) plugins/freewins/src/events.cpp (+2/-4) plugins/freewins/src/freewins.h (+0/-2) plugins/move/src/move.cpp (+1/-5) plugins/move/src/move.h (+0/-2) plugins/resize/src/logic/include/resize-logic.h (+1/-11) plugins/resize/src/logic/include/screen-interface.h (+1/-0) plugins/resize/src/logic/src/resize-logic.cpp (+23/-12) plugins/resize/src/logic/tests/mock-screen.h (+1/-0) plugins/resize/src/resize.cpp (+0/-37) plugins/resize/src/screen-impl.h (+5/-0) plugins/shelf/src/shelf.cpp (+1/-7) plugins/shelf/src/shelf.h (+0/-1) plugins/shift/src/shift.cpp (+0/-3) plugins/shift/src/shift.h (+0/-2) plugins/widget/src/widget.cpp (+2/-6) plugins/widget/src/widget.h (+0/-1) src/event.cpp (+5/-0) src/privatescreen.h (+10/-3) src/privatescreen/tests/test-privatescreen.cpp (+2/-0) src/screen.cpp (+145/-20) |
To merge this branch: | bzr merge lp:~3v1n0/compiz/wily-cursors-update-and-cache |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrea Azzarone | Approve | ||
Review via email: mp+279304@code.launchpad.net |
Commit message
Screen: monitor root RESOURCE_MANAGER and update cursors when Size or Theme changes
Also add cursorCache to get a cursor caching its shape for future re-usage.
Description of the change
Backporting lp:~3v1n0/compiz/add-cursor-update-notify and lp:~3v1n0/compiz/cursors-update-on-theme+size-changes to wily
To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2015-07-30 20:12:45 +0000 |
3 | +++ CMakeLists.txt 2015-12-02 16:44:19 +0000 |
4 | @@ -101,6 +101,7 @@ |
5 | xext |
6 | xdamage |
7 | xcomposite |
8 | + xcursor |
9 | x11-xcb |
10 | xrandr |
11 | xinerama |
12 | |
13 | === modified file 'include/core/abiversion.h' |
14 | --- include/core/abiversion.h 2015-02-17 14:57:27 +0000 |
15 | +++ include/core/abiversion.h 2015-12-02 16:44:19 +0000 |
16 | @@ -5,6 +5,6 @@ |
17 | # error Conflicting definitions of CORE_ABIVERSION |
18 | #endif |
19 | |
20 | -#define CORE_ABIVERSION 20150217 |
21 | +#define CORE_ABIVERSION 20151010 |
22 | |
23 | #endif // COMPIZ_ABIVERSION_H |
24 | |
25 | === modified file 'include/core/screen.h' |
26 | --- include/core/screen.h 2012-12-03 10:36:42 +0000 |
27 | +++ include/core/screen.h 2015-12-02 16:44:19 +0000 |
28 | @@ -155,6 +155,7 @@ |
29 | virtual void outputChangeNotify (); |
30 | virtual void addSupportedAtoms (std::vector<Atom>& atoms); |
31 | |
32 | + virtual void cursorChangeNotify (const CompString& theme, int size); |
33 | }; |
34 | |
35 | namespace compiz { namespace private_screen { |
36 | @@ -217,7 +218,7 @@ |
37 | } |
38 | |
39 | class CompScreen : |
40 | - public WrapableHandler<ScreenInterface, 18>, |
41 | + public WrapableHandler<ScreenInterface, 19>, |
42 | public PluginClassStorage, // TODO should be an interface here |
43 | public CompSize, |
44 | public virtual ::compiz::DesktopWindowCount, |
45 | @@ -267,6 +268,8 @@ |
46 | WRAPABLE_HND (16, ScreenInterface, void, outputChangeNotify); |
47 | WRAPABLE_HND (17, ScreenInterface, void, addSupportedAtoms, |
48 | std::vector<Atom>& atoms); |
49 | + WRAPABLE_HND (18, ScreenInterface, void, cursorChangeNotify, |
50 | + const CompString&, int); |
51 | |
52 | unsigned int allocPluginClassIndex (); |
53 | void freePluginClassIndex (unsigned int index); |
54 | @@ -390,6 +393,7 @@ |
55 | virtual const char * displayString () = 0; |
56 | virtual CompRect getCurrentOutputExtents () = 0; |
57 | virtual Cursor normalCursor () = 0; |
58 | + virtual Cursor cursorCache (unsigned int cursorName) = 0; |
59 | virtual bool grabbed () = 0; |
60 | virtual SnDisplay * snDisplay () = 0; |
61 | |
62 | @@ -443,6 +447,7 @@ |
63 | virtual void _matchExpHandlerChanged() = 0; |
64 | virtual void _matchPropertyChanged(CompWindow *) = 0; |
65 | virtual void _outputChangeNotify() = 0; |
66 | + virtual void _cursorChangeNotify(const CompString&, int) = 0; |
67 | }; |
68 | |
69 | #endif |
70 | |
71 | === modified file 'plugins/expo/src/expo.cpp' |
72 | --- plugins/expo/src/expo.cpp 2015-04-10 21:55:21 +0000 |
73 | +++ plugins/expo/src/expo.cpp 2015-12-02 16:44:19 +0000 |
74 | @@ -610,7 +610,7 @@ |
75 | CompWindowGrabMoveMask | |
76 | CompWindowGrabButtonMask); |
77 | |
78 | - screen->updateGrab (grabIndex, dragCursor); |
79 | + screen->updateGrab (grabIndex, screen->cursorCache (XC_fleur)); |
80 | |
81 | w->raise (); |
82 | w->moveInputFocusTo (); |
83 | @@ -1578,8 +1578,6 @@ |
84 | upKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Up")); |
85 | downKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Down")); |
86 | |
87 | - dragCursor = XCreateFontCursor (screen->dpy (), XC_fleur); |
88 | - |
89 | EXPOINITBIND (ExpoKey, doExpo); |
90 | EXPOTERMBIND (ExpoKey, termExpo); |
91 | EXPOINITBIND (ExpoButton, doExpo); |
92 | @@ -1603,11 +1601,6 @@ |
93 | GL_RGBA, GL_UNSIGNED_BYTE); |
94 | } |
95 | |
96 | -ExpoScreen::~ExpoScreen () |
97 | -{ |
98 | - if (dragCursor != None) |
99 | - XFreeCursor (screen->dpy (), dragCursor); |
100 | -} |
101 | |
102 | ExpoWindow::ExpoWindow (CompWindow *w) : |
103 | PluginClassHandler<ExpoWindow, CompWindow> (w), |
104 | |
105 | === modified file 'plugins/expo/src/expo.h' |
106 | --- plugins/expo/src/expo.h 2013-07-14 10:38:09 +0000 |
107 | +++ plugins/expo/src/expo.h 2015-12-02 16:44:19 +0000 |
108 | @@ -42,7 +42,6 @@ |
109 | public: |
110 | |
111 | ExpoScreen (CompScreen *); |
112 | - ~ExpoScreen (); |
113 | |
114 | void handleEvent (XEvent *); |
115 | |
116 | @@ -153,8 +152,6 @@ |
117 | KeyCode rightKey; |
118 | KeyCode upKey; |
119 | KeyCode downKey; |
120 | - |
121 | - Cursor dragCursor; |
122 | }; |
123 | |
124 | class ExpoWindow : |
125 | |
126 | === modified file 'plugins/freewins/src/action.cpp' |
127 | --- plugins/freewins/src/action.cpp 2013-03-26 22:02:39 +0000 |
128 | +++ plugins/freewins/src/action.cpp 2015-12-02 16:44:19 +0000 |
129 | @@ -82,8 +82,6 @@ |
130 | useW = getRealWindow (w); |
131 | } |
132 | |
133 | - mRotateCursor = XCreateFontCursor (screen->dpy (), XC_fleur); |
134 | - |
135 | if (!screen->otherGrabExist ("freewins", 0)) |
136 | if (!mGrabIndex) |
137 | { |
138 | @@ -305,11 +303,9 @@ |
139 | useW = getRealWindow (w); |
140 | } |
141 | |
142 | - mRotateCursor = XCreateFontCursor (screen->dpy (), XC_fleur); |
143 | - |
144 | if (!screen->otherGrabExist ("freewins", 0)) |
145 | if (!mGrabIndex) |
146 | - mGrabIndex = screen->pushGrab (mRotateCursor, "freewins"); |
147 | + mGrabIndex = screen->pushGrab (screen->cursorCache(XC_fleur), "freewins"); |
148 | } |
149 | |
150 | if (useW) |
151 | |
152 | === modified file 'plugins/freewins/src/events.cpp' |
153 | --- plugins/freewins/src/events.cpp 2013-03-26 22:02:39 +0000 |
154 | +++ plugins/freewins/src/events.cpp 2015-12-02 16:44:19 +0000 |
155 | @@ -60,13 +60,12 @@ |
156 | |
157 | window->activate (); |
158 | mGrab = grabResize; |
159 | - fws->mRotateCursor = XCreateFontCursor (screen->dpy (), XC_plus); |
160 | if(!screen->otherGrabExist ("freewins", "resize", 0)) |
161 | if(!fws->mGrabIndex) |
162 | { |
163 | unsigned int mods = 0; |
164 | mods &= CompNoMask; |
165 | - fws->mGrabIndex = screen->pushGrab (fws->mRotateCursor, "resize"); |
166 | + fws->mGrabIndex = screen->pushGrab (screen->cursorCache (XC_plus), "resize"); |
167 | window->grabNotify (window->x () + (window->width () / 2), |
168 | window->y () + (window->height () / 2), mods, |
169 | CompWindowGrabMoveMask | CompWindowGrabButtonMask); |
170 | @@ -81,13 +80,12 @@ |
171 | |
172 | window->activate (); |
173 | mGrab = grabMove; |
174 | - fws->mRotateCursor = XCreateFontCursor (screen->dpy (), XC_fleur); |
175 | if(!screen->otherGrabExist ("freewins", "resize", 0)) |
176 | if(!fws->mGrabIndex) |
177 | { |
178 | unsigned int mods = 0; |
179 | mods &= CompNoMask; |
180 | - fws->mGrabIndex = screen->pushGrab (fws->mRotateCursor, "resize"); |
181 | + fws->mGrabIndex = screen->pushGrab (screen->cursorCache (XC_fleur), "resize"); |
182 | window->grabNotify (window->x () + (window->width () / 2), |
183 | window->y () + (window->height () / 2), mods, |
184 | CompWindowGrabResizeMask | CompWindowGrabButtonMask); |
185 | |
186 | === modified file 'plugins/freewins/src/freewins.h' |
187 | --- plugins/freewins/src/freewins.h 2013-02-20 14:24:30 +0000 |
188 | +++ plugins/freewins/src/freewins.h 2015-12-02 16:44:19 +0000 |
189 | @@ -281,8 +281,6 @@ |
190 | int mSnapMask; |
191 | int mInvertMask; |
192 | |
193 | - Cursor mRotateCursor; |
194 | - |
195 | CompScreen::GrabHandle mGrabIndex; |
196 | |
197 | void preparePaint (int); |
198 | |
199 | === modified file 'plugins/move/src/move.cpp' |
200 | --- plugins/move/src/move.cpp 2013-06-28 01:10:57 +0000 |
201 | +++ plugins/move/src/move.cpp 2015-12-02 16:44:19 +0000 |
202 | @@ -104,7 +104,7 @@ |
203 | ms->snapOffY = y - workArea.y (); |
204 | |
205 | if (!ms->grab) |
206 | - ms->grab = s->pushGrab (ms->moveCursor, "move"); |
207 | + ms->grab = s->pushGrab (screen->cursorCache (XC_fleur), "move"); |
208 | |
209 | if (ms->grab) |
210 | { |
211 | @@ -711,7 +711,6 @@ |
212 | key[i] = XKeysymToKeycode (screen->dpy (), |
213 | XStringToKeysym (mKeys[i].name)); |
214 | |
215 | - moveCursor = XCreateFontCursor (screen->dpy (), XC_fleur); |
216 | if (cScreen) |
217 | { |
218 | CompositeScreenInterface::setHandler (cScreen); |
219 | @@ -734,9 +733,6 @@ |
220 | { |
221 | if (region) |
222 | XDestroyRegion (region); |
223 | - |
224 | - if (moveCursor) |
225 | - XFreeCursor (screen->dpy (), moveCursor); |
226 | } |
227 | |
228 | bool |
229 | |
230 | === modified file 'plugins/move/src/move.h' |
231 | --- plugins/move/src/move.h 2013-04-13 21:59:11 +0000 |
232 | +++ plugins/move/src/move.h 2015-12-02 16:44:19 +0000 |
233 | @@ -82,8 +82,6 @@ |
234 | |
235 | CompScreen::GrabHandle grab; |
236 | |
237 | - Cursor moveCursor; |
238 | - |
239 | unsigned int origState; |
240 | |
241 | int snapOffX; |
242 | |
243 | === modified file 'plugins/resize/src/logic/include/resize-logic.h' |
244 | --- plugins/resize/src/logic/include/resize-logic.h 2014-05-28 07:08:10 +0000 |
245 | +++ plugins/resize/src/logic/include/resize-logic.h 2015-12-02 16:44:19 +0000 |
246 | @@ -113,20 +113,10 @@ |
247 | int pointerDx; |
248 | int pointerDy; |
249 | KeyCode key[NUM_KEYS]; |
250 | + unsigned int keyCursorNames[NUM_KEYS]; |
251 | |
252 | CompScreen::GrabHandle grabIndex; |
253 | |
254 | - Cursor leftCursor; |
255 | - Cursor rightCursor; |
256 | - Cursor upCursor; |
257 | - Cursor upLeftCursor; |
258 | - Cursor upRightCursor; |
259 | - Cursor downCursor; |
260 | - Cursor downLeftCursor; |
261 | - Cursor downRightCursor; |
262 | - Cursor middleCursor; |
263 | - Cursor cursor[NUM_KEYS]; |
264 | - |
265 | bool isConstrained; |
266 | CompRegion constraintRegion; |
267 | bool inRegionStatus; |
268 | |
269 | === modified file 'plugins/resize/src/logic/include/screen-interface.h' |
270 | --- plugins/resize/src/logic/include/screen-interface.h 2013-01-08 09:17:25 +0000 |
271 | +++ plugins/resize/src/logic/include/screen-interface.h 2015-12-02 16:44:19 +0000 |
272 | @@ -57,6 +57,7 @@ |
273 | virtual void updateGrab (CompScreen::GrabHandle handle, Cursor cursor) = 0; |
274 | virtual CompScreen::GrabHandle pushGrab (Cursor cursor, const char *name) = 0; |
275 | virtual void removeGrab (CompScreen::GrabHandle handle, CompPoint *restorePointer) = 0; |
276 | + virtual Cursor cursorCache (unsigned int cursorName) = 0; |
277 | |
278 | /* CompOption::Class */ |
279 | virtual CompOption * getOption (const CompString &name) = 0; |
280 | |
281 | === modified file 'plugins/resize/src/logic/src/resize-logic.cpp' |
282 | --- plugins/resize/src/logic/src/resize-logic.cpp 2015-03-19 15:14:55 +0000 |
283 | +++ plugins/resize/src/logic/src/resize-logic.cpp 2015-12-02 16:44:19 +0000 |
284 | @@ -27,6 +27,7 @@ |
285 | |
286 | #include <core/core.h> |
287 | #include <core/atoms.h> |
288 | +#include <X11/cursorfont.h> |
289 | |
290 | #include "resize-logic.h" |
291 | |
292 | @@ -48,6 +49,16 @@ |
293 | static const unsigned short TOUCH_TOP = 3; |
294 | static const unsigned short TOUCH_BOTTOM = 4; |
295 | |
296 | +#define LEFT_CURSOR XC_left_side |
297 | +#define RIGHT_CURSOR XC_right_side |
298 | +#define UP_CURSOR XC_top_side |
299 | +#define UP_LEFT_CURSOR XC_top_left_corner |
300 | +#define UP_RIGHT_CURSOR XC_top_right_corner |
301 | +#define DOWN_CURSOR XC_bottom_side |
302 | +#define DOWN_LEFT_CURSOR XC_bottom_left_corner |
303 | +#define DOWN_RIGHT_CURSOR XC_bottom_right_corner |
304 | +#define MIDDLE_CURSOR XC_fleur |
305 | + |
306 | using namespace resize; |
307 | |
308 | ResizeLogic::ResizeLogic() : |
309 | @@ -428,7 +439,7 @@ |
310 | lastMaskY = mask; |
311 | } |
312 | |
313 | - mScreen->updateGrab (grabIndex, cursor[i]); |
314 | + mScreen->updateGrab (grabIndex, screen->cursorCache (keyCursorNames[i])); |
315 | } |
316 | break; |
317 | } |
318 | @@ -652,36 +663,36 @@ |
319 | Cursor |
320 | ResizeLogic::cursorFromResizeMask (unsigned int mask) |
321 | { |
322 | - Cursor cursor; |
323 | + unsigned int cursor_name; |
324 | |
325 | if (mask & ResizeLeftMask) |
326 | { |
327 | if (mask & ResizeDownMask) |
328 | - cursor = downLeftCursor; |
329 | + cursor_name = DOWN_LEFT_CURSOR; |
330 | else if (mask & ResizeUpMask) |
331 | - cursor = upLeftCursor; |
332 | + cursor_name = UP_LEFT_CURSOR; |
333 | else |
334 | - cursor = leftCursor; |
335 | + cursor_name = LEFT_CURSOR; |
336 | } |
337 | else if (mask & ResizeRightMask) |
338 | { |
339 | if (mask & ResizeDownMask) |
340 | - cursor = downRightCursor; |
341 | + cursor_name = DOWN_RIGHT_CURSOR; |
342 | else if (mask & ResizeUpMask) |
343 | - cursor = upRightCursor; |
344 | + cursor_name = UP_RIGHT_CURSOR; |
345 | else |
346 | - cursor = rightCursor; |
347 | + cursor_name = RIGHT_CURSOR; |
348 | } |
349 | else if (mask & ResizeUpMask) |
350 | { |
351 | - cursor = upCursor; |
352 | + cursor_name = UP_CURSOR; |
353 | } |
354 | else |
355 | { |
356 | - cursor = downCursor; |
357 | + cursor_name = DOWN_CURSOR; |
358 | } |
359 | |
360 | - return cursor; |
361 | + return screen->cursorCache (cursor_name); |
362 | } |
363 | |
364 | void |
365 | @@ -1327,7 +1338,7 @@ |
366 | Cursor cursor; |
367 | |
368 | if (state & CompAction::StateInitKey) |
369 | - cursor = middleCursor; |
370 | + cursor = screen->cursorCache (MIDDLE_CURSOR); |
371 | else |
372 | cursor = cursorFromResizeMask (mask); |
373 | |
374 | |
375 | === modified file 'plugins/resize/src/logic/tests/mock-screen.h' |
376 | --- plugins/resize/src/logic/tests/mock-screen.h 2012-08-16 14:04:59 +0000 |
377 | +++ plugins/resize/src/logic/tests/mock-screen.h 2015-12-02 16:44:19 +0000 |
378 | @@ -52,6 +52,7 @@ |
379 | MOCK_METHOD2(updateGrab, void(CompScreen::GrabHandle handle, Cursor cursor)); |
380 | MOCK_METHOD2(pushGrab, CompScreen::GrabHandle(Cursor cursor, const char *name)); |
381 | MOCK_METHOD2(removeGrab, void(CompScreen::GrabHandle handle, CompPoint *restorePointer)); |
382 | + MOCK_METHOD1(cursorCache, Cursor (unsigned int)); |
383 | |
384 | MOCK_METHOD1(getOption, CompOption*(const CompString &name)); |
385 | |
386 | |
387 | === modified file 'plugins/resize/src/resize.cpp' |
388 | --- plugins/resize/src/resize.cpp 2013-05-15 10:23:30 +0000 |
389 | +++ plugins/resize/src/resize.cpp 2015-12-02 16:44:19 +0000 |
390 | @@ -380,7 +380,6 @@ |
391 | logic.options = this; |
392 | |
393 | CompOption::Vector atomTemplate; |
394 | - Display *dpy = s->dpy (); |
395 | ResizeOptions::ChangeNotify notify = |
396 | boost::bind (&ResizeScreen::optionChanged, this, _1, _2); |
397 | |
398 | @@ -404,21 +403,6 @@ |
399 | for (unsigned int i = 0; i < NUM_KEYS; i++) |
400 | logic.key[i] = XKeysymToKeycode (s->dpy (), XStringToKeysym (logic.rKeys[i].name)); |
401 | |
402 | - logic.leftCursor = XCreateFontCursor (dpy, XC_left_side); |
403 | - logic.rightCursor = XCreateFontCursor (dpy, XC_right_side); |
404 | - logic.upCursor = XCreateFontCursor (dpy, XC_top_side); |
405 | - logic.upLeftCursor = XCreateFontCursor (dpy, XC_top_left_corner); |
406 | - logic.upRightCursor = XCreateFontCursor (dpy, XC_top_right_corner); |
407 | - logic.downCursor = XCreateFontCursor (dpy, XC_bottom_side); |
408 | - logic.downLeftCursor = XCreateFontCursor (dpy, XC_bottom_left_corner); |
409 | - logic.downRightCursor = XCreateFontCursor (dpy, XC_bottom_right_corner); |
410 | - logic.middleCursor = XCreateFontCursor (dpy, XC_fleur); |
411 | - |
412 | - logic.cursor[0] = logic.leftCursor; |
413 | - logic.cursor[1] = logic.rightCursor; |
414 | - logic.cursor[2] = logic.upCursor; |
415 | - logic.cursor[3] = logic.downCursor; |
416 | - |
417 | optionSetInitiateKeyInitiate (resizeInitiateDefaultMode); |
418 | optionSetInitiateKeyTerminate (resizeTerminate); |
419 | optionSetInitiateButtonInitiate (resizeInitiateDefaultMode); |
420 | @@ -442,27 +426,6 @@ |
421 | |
422 | ResizeScreen::~ResizeScreen () |
423 | { |
424 | - Display *dpy = screen->dpy (); |
425 | - |
426 | - if (logic.leftCursor) |
427 | - XFreeCursor (dpy, logic.leftCursor); |
428 | - if (logic.rightCursor) |
429 | - XFreeCursor (dpy, logic.rightCursor); |
430 | - if (logic.upCursor) |
431 | - XFreeCursor (dpy, logic.upCursor); |
432 | - if (logic.downCursor) |
433 | - XFreeCursor (dpy, logic.downCursor); |
434 | - if (logic.middleCursor) |
435 | - XFreeCursor (dpy, logic.middleCursor); |
436 | - if (logic.upLeftCursor) |
437 | - XFreeCursor (dpy, logic.upLeftCursor); |
438 | - if (logic.upRightCursor) |
439 | - XFreeCursor (dpy, logic.upRightCursor); |
440 | - if (logic.downLeftCursor) |
441 | - XFreeCursor (dpy, logic.downLeftCursor); |
442 | - if (logic.downRightCursor) |
443 | - XFreeCursor (dpy, logic.downRightCursor); |
444 | - |
445 | delete logic.mScreen; |
446 | delete logic.cScreen; |
447 | delete logic.gScreen; |
448 | |
449 | === modified file 'plugins/resize/src/screen-impl.h' |
450 | --- plugins/resize/src/screen-impl.h 2013-01-08 09:17:25 +0000 |
451 | +++ plugins/resize/src/screen-impl.h 2015-12-02 16:44:19 +0000 |
452 | @@ -124,6 +124,11 @@ |
453 | return mImpl->height (); |
454 | } |
455 | |
456 | + virtual Cursor cursorCache (unsigned int cursorName) |
457 | + { |
458 | + return mImpl->cursorCache (cursorName); |
459 | + } |
460 | + |
461 | private: |
462 | CompScreen *mImpl; |
463 | }; |
464 | |
465 | === modified file 'plugins/shelf/src/shelf.cpp' |
466 | --- plugins/shelf/src/shelf.cpp 2013-05-09 13:43:07 +0000 |
467 | +++ plugins/shelf/src/shelf.cpp 2015-12-02 16:44:19 +0000 |
468 | @@ -509,7 +509,7 @@ |
469 | { |
470 | window->activate (); |
471 | ss->grabbedWindow = window->id (); |
472 | - ss->grabIndex = screen->pushGrab (ss->moveCursor, "shelf"); |
473 | + ss->grabIndex = screen->pushGrab (screen->cursorCache (XC_fleur), "shelf"); |
474 | |
475 | ss->lastPointerX = x; |
476 | ss->lastPointerY = y; |
477 | @@ -760,7 +760,6 @@ |
478 | gScreen (GLScreen::get (screen)), |
479 | grabIndex (0), |
480 | grabbedWindow (None), |
481 | - moveCursor (XCreateFontCursor (screen->dpy (), XC_fleur)), |
482 | lastPointerX (0), |
483 | lastPointerY (0) |
484 | { |
485 | @@ -780,11 +779,6 @@ |
486 | _3)); |
487 | } |
488 | |
489 | -ShelfScreen::~ShelfScreen () |
490 | -{ |
491 | - if (moveCursor) |
492 | - XFreeCursor (screen->dpy (), moveCursor); |
493 | -} |
494 | |
495 | ShelfWindow::ShelfWindow (CompWindow *window) : |
496 | PluginClassHandler <ShelfWindow, CompWindow> (window), |
497 | |
498 | === modified file 'plugins/shelf/src/shelf.h' |
499 | --- plugins/shelf/src/shelf.h 2012-09-07 23:29:42 +0000 |
500 | +++ plugins/shelf/src/shelf.h 2015-12-02 16:44:19 +0000 |
501 | @@ -145,7 +145,6 @@ |
502 | public: |
503 | |
504 | ShelfScreen (CompScreen *); |
505 | - ~ShelfScreen (); |
506 | |
507 | CompositeScreen *cScreen; |
508 | GLScreen *gScreen; |
509 | |
510 | === modified file 'plugins/shift/src/shift.cpp' |
511 | --- plugins/shift/src/shift.cpp 2013-05-11 09:30:49 +0000 |
512 | +++ plugins/shift/src/shift.cpp 2015-12-02 16:44:19 +0000 |
513 | @@ -1968,7 +1968,6 @@ |
514 | mMvTarget (0), |
515 | mMvVelocity (0), |
516 | mInvert (false), |
517 | - mCursor (XCreateFontCursor (screen->dpy (), XC_left_ptr)), |
518 | mWindows (NULL), |
519 | mNWindows (0), |
520 | mWindowsSize (0), |
521 | @@ -2059,8 +2058,6 @@ |
522 | { |
523 | freeWindowTitle (); |
524 | |
525 | - XFreeCursor (screen->dpy (), mCursor); |
526 | - |
527 | if (mWindows) |
528 | free (mWindows); |
529 | |
530 | |
531 | === modified file 'plugins/shift/src/shift.h' |
532 | --- plugins/shift/src/shift.h 2013-04-27 16:51:53 +0000 |
533 | +++ plugins/shift/src/shift.h 2015-12-02 16:44:19 +0000 |
534 | @@ -143,8 +143,6 @@ |
535 | float mMvVelocity; |
536 | bool mInvert; |
537 | |
538 | - Cursor mCursor; |
539 | - |
540 | /* only used for sorting */ |
541 | CompWindow **mWindows; |
542 | int mNWindows; |
543 | |
544 | === modified file 'plugins/widget/src/widget.cpp' |
545 | --- plugins/widget/src/widget.cpp 2013-05-28 21:31:18 +0000 |
546 | +++ plugins/widget/src/widget.cpp 2015-12-02 16:44:19 +0000 |
547 | @@ -312,7 +312,7 @@ |
548 | } |
549 | |
550 | if (!mGrabIndex) |
551 | - mGrabIndex = screen->pushGrab (mCursor, "widget"); |
552 | + mGrabIndex = screen->pushGrab (screen->cursorCache (XC_watch), "widget"); |
553 | |
554 | enableFunctions (this, true); |
555 | |
556 | @@ -672,8 +672,7 @@ |
557 | mLastActiveWindow (None), |
558 | mCompizWidgetAtom (XInternAtom (screen->dpy (), "_COMPIZ_WIDGET", false)), |
559 | mFadeTime (0), |
560 | - mGrabIndex (0), |
561 | - mCursor (XCreateFontCursor (screen->dpy (), XC_watch)) |
562 | + mGrabIndex (0) |
563 | { |
564 | CompAction::CallBack cb; |
565 | ChangeNotify notify; |
566 | @@ -706,9 +705,6 @@ |
567 | { |
568 | screen->matchExpHandlerChangedSetEnabled (this, false); |
569 | screen->matchExpHandlerChanged (); |
570 | - |
571 | - if (mCursor) |
572 | - XFreeCursor (screen->dpy (), mCursor); |
573 | } |
574 | |
575 | WidgetWindow::WidgetWindow (CompWindow *window) : |
576 | |
577 | === modified file 'plugins/widget/src/widget.h' |
578 | --- plugins/widget/src/widget.h 2013-05-28 21:31:18 +0000 |
579 | +++ plugins/widget/src/widget.h 2015-12-02 16:44:19 +0000 |
580 | @@ -107,7 +107,6 @@ |
581 | WidgetState mState; |
582 | int mFadeTime; |
583 | CompScreen::GrabHandle mGrabIndex; |
584 | - Cursor mCursor; |
585 | }; |
586 | |
587 | #define WIDGET_SCREEN(screen) \ |
588 | |
589 | === modified file 'src/event.cpp' |
590 | --- src/event.cpp 2015-08-05 11:26:30 +0000 |
591 | +++ src/event.cpp 2015-12-02 16:44:19 +0000 |
592 | @@ -1801,6 +1801,11 @@ |
593 | if (w) |
594 | w->priv->updateClassHints (); |
595 | } |
596 | + else if (event->xproperty.atom == XA_RESOURCE_MANAGER) |
597 | + { |
598 | + if (event->xproperty.window == privateScreen.rootWindow()) |
599 | + privateScreen.updateResources(); |
600 | + } |
601 | break; |
602 | case MotionNotify: |
603 | break; |
604 | |
605 | === modified file 'src/privatescreen.h' |
606 | --- src/privatescreen.h 2014-12-02 19:37:10 +0000 |
607 | +++ src/privatescreen.h 2015-12-02 16:44:19 +0000 |
608 | @@ -680,6 +680,8 @@ |
609 | |
610 | void updateScreenInfo (); |
611 | |
612 | + void updateResources (); |
613 | + |
614 | Window getActiveWindow (Window root); |
615 | |
616 | void setWindowState (unsigned int state, Window id); |
617 | @@ -700,6 +702,10 @@ |
618 | |
619 | void setDefaultWindowAttributes (XWindowAttributes *); |
620 | |
621 | + void updateCursors (const CompString& theme, int size); |
622 | + |
623 | + Cursor cursorCache (unsigned int cursorName); |
624 | + |
625 | static void compScreenSnEvent (SnMonitorEvent *event, |
626 | void *userData); |
627 | |
628 | @@ -763,9 +769,8 @@ |
629 | Window wmSnSelectionWindow; |
630 | |
631 | int clientPointerDeviceId; |
632 | - Cursor normalCursor; |
633 | - Cursor busyCursor; |
634 | Cursor invisibleCursor; |
635 | + std::vector<Cursor> cursors; |
636 | CompRect workArea; |
637 | |
638 | bool initialized; |
639 | @@ -802,6 +807,7 @@ |
640 | Window xdndWindow; |
641 | compiz::private_screen::PluginManager pluginManager; |
642 | compiz::private_screen::WindowManager& windowManager; |
643 | + CompOption::Vector resourceManager; |
644 | }; |
645 | |
646 | class CompManager |
647 | @@ -954,8 +960,8 @@ |
648 | void unhookServerWindow (CompWindow *w); |
649 | |
650 | Cursor normalCursor (); |
651 | - |
652 | Cursor invisibleCursor (); |
653 | + Cursor cursorCache (unsigned int cursorName); |
654 | |
655 | /* Adds an X Pointer and Keyboard grab to the stack. Since |
656 | * compiz as a client only need to grab once, multiple clients |
657 | @@ -1158,6 +1164,7 @@ |
658 | virtual void _matchExpHandlerChanged(); |
659 | virtual void _matchPropertyChanged(CompWindow *); |
660 | virtual void _outputChangeNotify(); |
661 | + virtual void _cursorChangeNotify(const CompString&, int); |
662 | |
663 | void grabServer (); |
664 | void ungrabServer (); |
665 | |
666 | === modified file 'src/privatescreen/tests/test-privatescreen.cpp' |
667 | --- src/privatescreen/tests/test-privatescreen.cpp 2015-09-23 23:17:54 +0000 |
668 | +++ src/privatescreen/tests/test-privatescreen.cpp 2015-12-02 16:44:19 +0000 |
669 | @@ -81,6 +81,7 @@ |
670 | MOCK_METHOD0(_matchExpHandlerChanged, void ()); |
671 | MOCK_METHOD1(_matchPropertyChanged, void (CompWindow *)); |
672 | MOCK_METHOD0(_outputChangeNotify, void ()); |
673 | + MOCK_METHOD2(_cursorChangeNotify, void (const CompString&, int)); |
674 | |
675 | MOCK_METHOD0(outputDevs, CompOutput::vector & ()); |
676 | MOCK_METHOD2(setWindowState, void (unsigned int state, Window id)); |
677 | @@ -175,6 +176,7 @@ |
678 | MOCK_METHOD0(displayString, const char * ()); |
679 | MOCK_METHOD0(getCurrentOutputExtents, CompRect ()); |
680 | MOCK_METHOD0(normalCursor, Cursor ()); |
681 | + MOCK_METHOD1(cursorCache, Cursor (unsigned int)); |
682 | MOCK_METHOD0(grabbed, bool ()); |
683 | MOCK_METHOD0(snDisplay, SnDisplay * ()); |
684 | MOCK_CONST_METHOD0(createFailed, bool ()); |
685 | |
686 | === modified file 'src/screen.cpp' |
687 | --- src/screen.cpp 2014-12-02 19:37:10 +0000 |
688 | +++ src/screen.cpp 2015-12-02 16:44:19 +0000 |
689 | @@ -44,6 +44,7 @@ |
690 | |
691 | #include <boost/bind.hpp> |
692 | #include <boost/foreach.hpp> |
693 | +#include <boost/algorithm/string.hpp> |
694 | #define foreach BOOST_FOREACH |
695 | |
696 | #include <X11/Xlib.h> |
697 | @@ -53,6 +54,7 @@ |
698 | #include <X11/extensions/shape.h> |
699 | #include <X11/cursorfont.h> |
700 | #include <X11/extensions/XInput2.h> |
701 | +#include <X11/Xcursor/Xcursor.h> |
702 | |
703 | #include <core/global.h> |
704 | #include <core/screen.h> |
705 | @@ -77,10 +79,12 @@ |
706 | namespace |
707 | { |
708 | bool inHandleEvent = false; |
709 | - |
710 | bool screenInitalized = false; |
711 | } |
712 | |
713 | +#define normalCursorName XC_left_ptr |
714 | +#define busyCursorName XC_watch |
715 | + |
716 | #define MwmHintsFunctions (1L << 0) |
717 | #define MwmHintsDecorations (1L << 1) |
718 | static const unsigned short PropMotifWmHintElements = 3; |
719 | @@ -101,6 +105,14 @@ |
720 | |
721 | PluginClassStorage::Indices screenPluginClassIndices (0); |
722 | |
723 | +namespace utils |
724 | +{ |
725 | +bool is_number (CompString const& s) |
726 | +{ |
727 | + return std::find_if (s.begin (), s.end (), [](char c) { return !std::isdigit (c); }) == s.end (); |
728 | +} |
729 | +} |
730 | + |
731 | void CompScreenImpl::sizePluginClasses(unsigned int size) |
732 | { |
733 | if(size != pluginClasses.size ()) |
734 | @@ -1271,8 +1283,8 @@ |
735 | eventManager.quit (); |
736 | } |
737 | |
738 | -static const std::string IMAGEDIR("images"); |
739 | -static const std::string HOMECOMPIZDIR(".compiz-1"); |
740 | +static const CompString IMAGEDIR("images"); |
741 | +static const CompString HOMECOMPIZDIR(".compiz-1"); |
742 | |
743 | bool |
744 | CompScreenImpl::readImageFromFile (CompString &name, |
745 | @@ -1353,6 +1365,68 @@ |
746 | return w; |
747 | } |
748 | |
749 | +void |
750 | +PrivateScreen::updateResources () |
751 | +{ |
752 | + Atom actual; |
753 | + int result, format; |
754 | + unsigned long n, left; |
755 | + unsigned char *data; |
756 | + |
757 | + result = XGetWindowProperty (dpy, root, |
758 | + XA_RESOURCE_MANAGER, 0L, 65536, False, |
759 | + XA_STRING, &actual, &format, |
760 | + &n, &left, &data); |
761 | + |
762 | + int oldCursorSize = CompOption::getIntOptionNamed (resourceManager, "Xcursor.size", -1); |
763 | + CompString oldCursorTheme = CompOption::getStringOptionNamed (resourceManager, "Xcursor.theme"); |
764 | + resourceManager.clear (); |
765 | + |
766 | + if (result == Success && data) |
767 | + { |
768 | + if (actual == XA_STRING) |
769 | + { |
770 | + std::vector<CompString> lines; |
771 | + CompString resources (reinterpret_cast<char *> (data)); |
772 | + boost::split (lines, resources, boost::is_any_of ("\n")); |
773 | + |
774 | + for (auto const& line : lines) |
775 | + { |
776 | + std::vector<CompString> pair; |
777 | + boost::split (pair, line, boost::is_any_of ("\t")); |
778 | + |
779 | + if (pair.size () == 2 && pair[0].back () == ':') |
780 | + { |
781 | + CompOption option; |
782 | + auto key = pair[0].substr (0, pair[0].size () - 1); |
783 | + auto const& value = pair[1]; |
784 | + |
785 | + if (utils::is_number (value)) |
786 | + { |
787 | + option.setName (key, CompOption::TypeInt); |
788 | + option.value ().set (std::atoi (value.c_str ())); |
789 | + } |
790 | + else |
791 | + { |
792 | + option.setName (key, CompOption::TypeString); |
793 | + option.value ().set (value); |
794 | + } |
795 | + |
796 | + resourceManager.push_back (option); |
797 | + } |
798 | + } |
799 | + } |
800 | + |
801 | + XFree (data); |
802 | + } |
803 | + |
804 | + int cursorSize = CompOption::getIntOptionNamed (resourceManager, "Xcursor.size", -1); |
805 | + CompString const& cursorTheme = CompOption::getStringOptionNamed (resourceManager, "Xcursor.theme"); |
806 | + |
807 | + if (cursorSize != oldCursorSize || cursorTheme != oldCursorTheme) |
808 | + screen->cursorChangeNotify (cursorTheme, cursorSize); |
809 | +} |
810 | + |
811 | bool |
812 | CompScreen::fileToImage (CompString &name, |
813 | CompSize &size, |
814 | @@ -2078,9 +2152,9 @@ |
815 | if (priv->initialized) |
816 | { |
817 | if (!emptySequence()) |
818 | - XIDefineCursor (priv->dpy, priv->clientPointerDeviceId, priv->rootWindow(), priv->busyCursor); |
819 | + XIDefineCursor (priv->dpy, priv->clientPointerDeviceId, priv->rootWindow(), priv->cursorCache (busyCursorName)); |
820 | else |
821 | - XIDefineCursor (priv->dpy, priv->clientPointerDeviceId, priv->rootWindow(), priv->normalCursor); |
822 | + XIDefineCursor (priv->dpy, priv->clientPointerDeviceId, priv->rootWindow(), priv->cursorCache (normalCursorName)); |
823 | } |
824 | } |
825 | |
826 | @@ -3012,7 +3086,7 @@ |
827 | Cursor |
828 | CompScreenImpl::normalCursor () |
829 | { |
830 | - return privateScreen.normalCursor; |
831 | + return privateScreen.cursorCache (normalCursorName); |
832 | } |
833 | |
834 | Cursor |
835 | @@ -3021,6 +3095,12 @@ |
836 | return privateScreen.invisibleCursor; |
837 | } |
838 | |
839 | +Cursor |
840 | +CompScreenImpl::cursorCache (unsigned int cursorName) |
841 | +{ |
842 | + return privateScreen.cursorCache (cursorName); |
843 | +} |
844 | + |
845 | #define POINTER_GRAB_MASK (ButtonReleaseMask | \ |
846 | ButtonPressMask | \ |
847 | PointerMotionMask) |
848 | @@ -3744,11 +3824,11 @@ |
849 | setsid (); |
850 | |
851 | pos = env.find (':'); |
852 | - if (pos != std::string::npos) |
853 | + if (pos != CompString::npos) |
854 | { |
855 | size_t pointPos = env.find ('.', pos); |
856 | |
857 | - if (pointPos != std::string::npos) |
858 | + if (pointPos != CompString::npos) |
859 | { |
860 | env.erase (pointPos); |
861 | } |
862 | @@ -4028,6 +4108,56 @@ |
863 | { |
864 | } |
865 | |
866 | +void |
867 | +CompScreen::cursorChangeNotify (const CompString& theme, int size) |
868 | +{ |
869 | + WRAPABLE_HND_FUNCTN (cursorChangeNotify, theme, size); |
870 | + _cursorChangeNotify (theme, size); |
871 | +} |
872 | + |
873 | +Cursor |
874 | +PrivateScreen::cursorCache (unsigned int cursorName) |
875 | +{ |
876 | + if (cursorName >= XC_num_glyphs) |
877 | + return 0; |
878 | + |
879 | + if (cursors.size() > cursorName && cursors[cursorName]) |
880 | + return cursors[cursorName]; |
881 | + |
882 | + cursors.resize(std::max<size_t>(cursorName + 1, cursors.size()), 0); |
883 | + cursors[cursorName] = XCreateFontCursor (dpy, cursorName); |
884 | + |
885 | + return cursors[cursorName]; |
886 | +} |
887 | + |
888 | +void |
889 | +PrivateScreen::updateCursors (const CompString& theme, int size) |
890 | +{ |
891 | + if (size > 0) |
892 | + XcursorSetDefaultSize (dpy, size); |
893 | + |
894 | + if (!theme.empty()) |
895 | + XcursorSetTheme (dpy, theme.c_str()); |
896 | + |
897 | + for (auto it = begin (cursors); it != end (cursors); ++it) |
898 | + { |
899 | + if (*it) |
900 | + { |
901 | + XFreeCursor (dpy, *it); |
902 | + *it = XCreateFontCursor (dpy, it - begin (cursors)); |
903 | + } |
904 | + } |
905 | + |
906 | + XIDefineCursor (dpy, clientPointerDeviceId, root, cursorCache (normalCursorName)); |
907 | + startupSequence.updateStartupFeedback (); |
908 | +} |
909 | + |
910 | +void |
911 | +CompScreenImpl::_cursorChangeNotify (const CompString& theme, int size) |
912 | +{ |
913 | + privateScreen.updateCursors (theme, size); |
914 | +} |
915 | + |
916 | /* Returns default viewport for some window geometry. If the window spans |
917 | * more than one viewport the most appropriate viewport is returned. How the |
918 | * most appropriate viewport is computed can be made optional if necessary. It |
919 | @@ -4170,6 +4300,9 @@ |
920 | ScreenInterface::addSupportedAtoms (std::vector<Atom>& atoms) |
921 | WRAPABLE_DEF (addSupportedAtoms, atoms) |
922 | |
923 | +void |
924 | +ScreenInterface::cursorChangeNotify (const CompString& theme, int size) |
925 | + WRAPABLE_DEF (cursorChangeNotify, theme, size) |
926 | |
927 | Window |
928 | CompScreenImpl::root () |
929 | @@ -5022,12 +5155,9 @@ |
930 | eventManager.setSupportingWmCheck (dpy, rootWindow()); |
931 | screen->updateSupportedWmHints (); |
932 | |
933 | + |
934 | XIGetClientPointer (dpy, None, &clientPointerDeviceId); |
935 | - |
936 | - normalCursor = XCreateFontCursor (dpy, XC_left_ptr); |
937 | - busyCursor = XCreateFontCursor (dpy, XC_watch); |
938 | - |
939 | - XIDefineCursor (dpy, clientPointerDeviceId, rootWindow(), normalCursor); |
940 | + updateResources (); |
941 | |
942 | /* Attempt to gain SubstructureRedirectMask */ |
943 | CompScreenImpl::checkForError (dpy); |
944 | @@ -5203,8 +5333,6 @@ |
945 | currentDesktop (0), |
946 | wmSnSelectionWindow (None), |
947 | clientPointerDeviceId (None), |
948 | - normalCursor (None), |
949 | - busyCursor (None), |
950 | invisibleCursor (None), |
951 | initialized (false), |
952 | screen(screen), |
953 | @@ -5325,11 +5453,8 @@ |
954 | |
955 | eventManager.destroyGrabWindow (dpy); |
956 | |
957 | - if (normalCursor != None) |
958 | - XFreeCursor (dpy, normalCursor); |
959 | - |
960 | - if (busyCursor != None) |
961 | - XFreeCursor (dpy, busyCursor); |
962 | + for (auto cursor : cursors) |
963 | + XFreeCursor (dpy, cursor); |
964 | |
965 | if (invisibleCursor != None) |
966 | XFreeCursor (dpy, invisibleCursor); |