Merge lp:~3v1n0/compiz/cursors-update-on-theme+size-changes into lp:compiz/0.9.12

Proposed by Marco Trevisan (Treviño)
Status: Superseded
Proposed branch: lp:~3v1n0/compiz/cursors-update-on-theme+size-changes
Merge into: lp:compiz/0.9.12
Prerequisite: lp:~3v1n0/compiz/resize-selective-grab
Diff against target: 1027 lines (+223/-166)
27 files modified
CMakeLists.txt (+1/-0)
debian/patches/ubuntu_super_p.patch.OTHER (+0/-27)
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 (+4/-6)
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 (+156/-24)
To merge this branch: bzr merge lp:~3v1n0/compiz/cursors-update-on-theme+size-changes
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Andrea Azzarone Approve
Review via email: mp+275057@code.launchpad.net

This proposal has been superseded by a proposal from 2015-10-22.

Commit message

Screen: monitor root RESOURCE_MANAGER and update cursors when Size or Theme changes

Also add cursorCache and updateCursors notify function

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM. Not sure what happend with that diff still around but should not be a problem.

Revision history for this message
Andrea Azzarone (azzar1) :
review: Approve
3953. By Marco Trevisan (Treviño)

Resize: add cursorCache definition to screen-interface

3954. By Marco Trevisan (Treviño)

CompScreen: add missing declaration for cursorCache method

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
3955. By Marco Trevisan (Treviño)

Screen: no need to update cursors on startup, we have none of them

Unmerged revisions

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

Subscribers

People subscribed via source and target branches