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 | 101 | xext | 101 | xext |
6 | 102 | xdamage | 102 | xdamage |
7 | 103 | xcomposite | 103 | xcomposite |
8 | 104 | xcursor | ||
9 | 104 | x11-xcb | 105 | x11-xcb |
10 | 105 | xrandr | 106 | xrandr |
11 | 106 | xinerama | 107 | xinerama |
12 | 107 | 108 | ||
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 | 5 | # error Conflicting definitions of CORE_ABIVERSION | 5 | # error Conflicting definitions of CORE_ABIVERSION |
18 | 6 | #endif | 6 | #endif |
19 | 7 | 7 | ||
21 | 8 | #define CORE_ABIVERSION 20150217 | 8 | #define CORE_ABIVERSION 20151010 |
22 | 9 | 9 | ||
23 | 10 | #endif // COMPIZ_ABIVERSION_H | 10 | #endif // COMPIZ_ABIVERSION_H |
24 | 11 | 11 | ||
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 | 155 | virtual void outputChangeNotify (); | 155 | virtual void outputChangeNotify (); |
30 | 156 | virtual void addSupportedAtoms (std::vector<Atom>& atoms); | 156 | virtual void addSupportedAtoms (std::vector<Atom>& atoms); |
31 | 157 | 157 | ||
32 | 158 | virtual void cursorChangeNotify (const CompString& theme, int size); | ||
33 | 158 | }; | 159 | }; |
34 | 159 | 160 | ||
35 | 160 | namespace compiz { namespace private_screen { | 161 | namespace compiz { namespace private_screen { |
36 | @@ -217,7 +218,7 @@ | |||
37 | 217 | } | 218 | } |
38 | 218 | 219 | ||
39 | 219 | class CompScreen : | 220 | class CompScreen : |
41 | 220 | public WrapableHandler<ScreenInterface, 18>, | 221 | public WrapableHandler<ScreenInterface, 19>, |
42 | 221 | public PluginClassStorage, // TODO should be an interface here | 222 | public PluginClassStorage, // TODO should be an interface here |
43 | 222 | public CompSize, | 223 | public CompSize, |
44 | 223 | public virtual ::compiz::DesktopWindowCount, | 224 | public virtual ::compiz::DesktopWindowCount, |
45 | @@ -267,6 +268,8 @@ | |||
46 | 267 | WRAPABLE_HND (16, ScreenInterface, void, outputChangeNotify); | 268 | WRAPABLE_HND (16, ScreenInterface, void, outputChangeNotify); |
47 | 268 | WRAPABLE_HND (17, ScreenInterface, void, addSupportedAtoms, | 269 | WRAPABLE_HND (17, ScreenInterface, void, addSupportedAtoms, |
48 | 269 | std::vector<Atom>& atoms); | 270 | std::vector<Atom>& atoms); |
49 | 271 | WRAPABLE_HND (18, ScreenInterface, void, cursorChangeNotify, | ||
50 | 272 | const CompString&, int); | ||
51 | 270 | 273 | ||
52 | 271 | unsigned int allocPluginClassIndex (); | 274 | unsigned int allocPluginClassIndex (); |
53 | 272 | void freePluginClassIndex (unsigned int index); | 275 | void freePluginClassIndex (unsigned int index); |
54 | @@ -390,6 +393,7 @@ | |||
55 | 390 | virtual const char * displayString () = 0; | 393 | virtual const char * displayString () = 0; |
56 | 391 | virtual CompRect getCurrentOutputExtents () = 0; | 394 | virtual CompRect getCurrentOutputExtents () = 0; |
57 | 392 | virtual Cursor normalCursor () = 0; | 395 | virtual Cursor normalCursor () = 0; |
58 | 396 | virtual Cursor cursorCache (unsigned int cursorName) = 0; | ||
59 | 393 | virtual bool grabbed () = 0; | 397 | virtual bool grabbed () = 0; |
60 | 394 | virtual SnDisplay * snDisplay () = 0; | 398 | virtual SnDisplay * snDisplay () = 0; |
61 | 395 | 399 | ||
62 | @@ -443,6 +447,7 @@ | |||
63 | 443 | virtual void _matchExpHandlerChanged() = 0; | 447 | virtual void _matchExpHandlerChanged() = 0; |
64 | 444 | virtual void _matchPropertyChanged(CompWindow *) = 0; | 448 | virtual void _matchPropertyChanged(CompWindow *) = 0; |
65 | 445 | virtual void _outputChangeNotify() = 0; | 449 | virtual void _outputChangeNotify() = 0; |
66 | 450 | virtual void _cursorChangeNotify(const CompString&, int) = 0; | ||
67 | 446 | }; | 451 | }; |
68 | 447 | 452 | ||
69 | 448 | #endif | 453 | #endif |
70 | 449 | 454 | ||
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 | 610 | CompWindowGrabMoveMask | | 610 | CompWindowGrabMoveMask | |
76 | 611 | CompWindowGrabButtonMask); | 611 | CompWindowGrabButtonMask); |
77 | 612 | 612 | ||
79 | 613 | screen->updateGrab (grabIndex, dragCursor); | 613 | screen->updateGrab (grabIndex, screen->cursorCache (XC_fleur)); |
80 | 614 | 614 | ||
81 | 615 | w->raise (); | 615 | w->raise (); |
82 | 616 | w->moveInputFocusTo (); | 616 | w->moveInputFocusTo (); |
83 | @@ -1578,8 +1578,6 @@ | |||
84 | 1578 | upKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Up")); | 1578 | upKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Up")); |
85 | 1579 | downKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Down")); | 1579 | downKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Down")); |
86 | 1580 | 1580 | ||
87 | 1581 | dragCursor = XCreateFontCursor (screen->dpy (), XC_fleur); | ||
88 | 1582 | |||
89 | 1583 | EXPOINITBIND (ExpoKey, doExpo); | 1581 | EXPOINITBIND (ExpoKey, doExpo); |
90 | 1584 | EXPOTERMBIND (ExpoKey, termExpo); | 1582 | EXPOTERMBIND (ExpoKey, termExpo); |
91 | 1585 | EXPOINITBIND (ExpoButton, doExpo); | 1583 | EXPOINITBIND (ExpoButton, doExpo); |
92 | @@ -1603,11 +1601,6 @@ | |||
93 | 1603 | GL_RGBA, GL_UNSIGNED_BYTE); | 1601 | GL_RGBA, GL_UNSIGNED_BYTE); |
94 | 1604 | } | 1602 | } |
95 | 1605 | 1603 | ||
96 | 1606 | ExpoScreen::~ExpoScreen () | ||
97 | 1607 | { | ||
98 | 1608 | if (dragCursor != None) | ||
99 | 1609 | XFreeCursor (screen->dpy (), dragCursor); | ||
100 | 1610 | } | ||
101 | 1611 | 1604 | ||
102 | 1612 | ExpoWindow::ExpoWindow (CompWindow *w) : | 1605 | ExpoWindow::ExpoWindow (CompWindow *w) : |
103 | 1613 | PluginClassHandler<ExpoWindow, CompWindow> (w), | 1606 | PluginClassHandler<ExpoWindow, CompWindow> (w), |
104 | 1614 | 1607 | ||
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 | 42 | public: | 42 | public: |
110 | 43 | 43 | ||
111 | 44 | ExpoScreen (CompScreen *); | 44 | ExpoScreen (CompScreen *); |
112 | 45 | ~ExpoScreen (); | ||
113 | 46 | 45 | ||
114 | 47 | void handleEvent (XEvent *); | 46 | void handleEvent (XEvent *); |
115 | 48 | 47 | ||
116 | @@ -153,8 +152,6 @@ | |||
117 | 153 | KeyCode rightKey; | 152 | KeyCode rightKey; |
118 | 154 | KeyCode upKey; | 153 | KeyCode upKey; |
119 | 155 | KeyCode downKey; | 154 | KeyCode downKey; |
120 | 156 | |||
121 | 157 | Cursor dragCursor; | ||
122 | 158 | }; | 155 | }; |
123 | 159 | 156 | ||
124 | 160 | class ExpoWindow : | 157 | class ExpoWindow : |
125 | 161 | 158 | ||
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 | 82 | useW = getRealWindow (w); | 82 | useW = getRealWindow (w); |
131 | 83 | } | 83 | } |
132 | 84 | 84 | ||
133 | 85 | mRotateCursor = XCreateFontCursor (screen->dpy (), XC_fleur); | ||
134 | 86 | |||
135 | 87 | if (!screen->otherGrabExist ("freewins", 0)) | 85 | if (!screen->otherGrabExist ("freewins", 0)) |
136 | 88 | if (!mGrabIndex) | 86 | if (!mGrabIndex) |
137 | 89 | { | 87 | { |
138 | @@ -305,11 +303,9 @@ | |||
139 | 305 | useW = getRealWindow (w); | 303 | useW = getRealWindow (w); |
140 | 306 | } | 304 | } |
141 | 307 | 305 | ||
142 | 308 | mRotateCursor = XCreateFontCursor (screen->dpy (), XC_fleur); | ||
143 | 309 | |||
144 | 310 | if (!screen->otherGrabExist ("freewins", 0)) | 306 | if (!screen->otherGrabExist ("freewins", 0)) |
145 | 311 | if (!mGrabIndex) | 307 | if (!mGrabIndex) |
147 | 312 | mGrabIndex = screen->pushGrab (mRotateCursor, "freewins"); | 308 | mGrabIndex = screen->pushGrab (screen->cursorCache(XC_fleur), "freewins"); |
148 | 313 | } | 309 | } |
149 | 314 | 310 | ||
150 | 315 | if (useW) | 311 | if (useW) |
151 | 316 | 312 | ||
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 | 60 | 60 | ||
157 | 61 | window->activate (); | 61 | window->activate (); |
158 | 62 | mGrab = grabResize; | 62 | mGrab = grabResize; |
159 | 63 | fws->mRotateCursor = XCreateFontCursor (screen->dpy (), XC_plus); | ||
160 | 64 | if(!screen->otherGrabExist ("freewins", "resize", 0)) | 63 | if(!screen->otherGrabExist ("freewins", "resize", 0)) |
161 | 65 | if(!fws->mGrabIndex) | 64 | if(!fws->mGrabIndex) |
162 | 66 | { | 65 | { |
163 | 67 | unsigned int mods = 0; | 66 | unsigned int mods = 0; |
164 | 68 | mods &= CompNoMask; | 67 | mods &= CompNoMask; |
166 | 69 | fws->mGrabIndex = screen->pushGrab (fws->mRotateCursor, "resize"); | 68 | fws->mGrabIndex = screen->pushGrab (screen->cursorCache (XC_plus), "resize"); |
167 | 70 | window->grabNotify (window->x () + (window->width () / 2), | 69 | window->grabNotify (window->x () + (window->width () / 2), |
168 | 71 | window->y () + (window->height () / 2), mods, | 70 | window->y () + (window->height () / 2), mods, |
169 | 72 | CompWindowGrabMoveMask | CompWindowGrabButtonMask); | 71 | CompWindowGrabMoveMask | CompWindowGrabButtonMask); |
170 | @@ -81,13 +80,12 @@ | |||
171 | 81 | 80 | ||
172 | 82 | window->activate (); | 81 | window->activate (); |
173 | 83 | mGrab = grabMove; | 82 | mGrab = grabMove; |
174 | 84 | fws->mRotateCursor = XCreateFontCursor (screen->dpy (), XC_fleur); | ||
175 | 85 | if(!screen->otherGrabExist ("freewins", "resize", 0)) | 83 | if(!screen->otherGrabExist ("freewins", "resize", 0)) |
176 | 86 | if(!fws->mGrabIndex) | 84 | if(!fws->mGrabIndex) |
177 | 87 | { | 85 | { |
178 | 88 | unsigned int mods = 0; | 86 | unsigned int mods = 0; |
179 | 89 | mods &= CompNoMask; | 87 | mods &= CompNoMask; |
181 | 90 | fws->mGrabIndex = screen->pushGrab (fws->mRotateCursor, "resize"); | 88 | fws->mGrabIndex = screen->pushGrab (screen->cursorCache (XC_fleur), "resize"); |
182 | 91 | window->grabNotify (window->x () + (window->width () / 2), | 89 | window->grabNotify (window->x () + (window->width () / 2), |
183 | 92 | window->y () + (window->height () / 2), mods, | 90 | window->y () + (window->height () / 2), mods, |
184 | 93 | CompWindowGrabResizeMask | CompWindowGrabButtonMask); | 91 | CompWindowGrabResizeMask | CompWindowGrabButtonMask); |
185 | 94 | 92 | ||
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 | 281 | int mSnapMask; | 281 | int mSnapMask; |
191 | 282 | int mInvertMask; | 282 | int mInvertMask; |
192 | 283 | 283 | ||
193 | 284 | Cursor mRotateCursor; | ||
194 | 285 | |||
195 | 286 | CompScreen::GrabHandle mGrabIndex; | 284 | CompScreen::GrabHandle mGrabIndex; |
196 | 287 | 285 | ||
197 | 288 | void preparePaint (int); | 286 | void preparePaint (int); |
198 | 289 | 287 | ||
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 | 104 | ms->snapOffY = y - workArea.y (); | 104 | ms->snapOffY = y - workArea.y (); |
204 | 105 | 105 | ||
205 | 106 | if (!ms->grab) | 106 | if (!ms->grab) |
207 | 107 | ms->grab = s->pushGrab (ms->moveCursor, "move"); | 107 | ms->grab = s->pushGrab (screen->cursorCache (XC_fleur), "move"); |
208 | 108 | 108 | ||
209 | 109 | if (ms->grab) | 109 | if (ms->grab) |
210 | 110 | { | 110 | { |
211 | @@ -711,7 +711,6 @@ | |||
212 | 711 | key[i] = XKeysymToKeycode (screen->dpy (), | 711 | key[i] = XKeysymToKeycode (screen->dpy (), |
213 | 712 | XStringToKeysym (mKeys[i].name)); | 712 | XStringToKeysym (mKeys[i].name)); |
214 | 713 | 713 | ||
215 | 714 | moveCursor = XCreateFontCursor (screen->dpy (), XC_fleur); | ||
216 | 715 | if (cScreen) | 714 | if (cScreen) |
217 | 716 | { | 715 | { |
218 | 717 | CompositeScreenInterface::setHandler (cScreen); | 716 | CompositeScreenInterface::setHandler (cScreen); |
219 | @@ -734,9 +733,6 @@ | |||
220 | 734 | { | 733 | { |
221 | 735 | if (region) | 734 | if (region) |
222 | 736 | XDestroyRegion (region); | 735 | XDestroyRegion (region); |
223 | 737 | |||
224 | 738 | if (moveCursor) | ||
225 | 739 | XFreeCursor (screen->dpy (), moveCursor); | ||
226 | 740 | } | 736 | } |
227 | 741 | 737 | ||
228 | 742 | bool | 738 | bool |
229 | 743 | 739 | ||
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 | 82 | 82 | ||
235 | 83 | CompScreen::GrabHandle grab; | 83 | CompScreen::GrabHandle grab; |
236 | 84 | 84 | ||
237 | 85 | Cursor moveCursor; | ||
238 | 86 | |||
239 | 87 | unsigned int origState; | 85 | unsigned int origState; |
240 | 88 | 86 | ||
241 | 89 | int snapOffX; | 87 | int snapOffX; |
242 | 90 | 88 | ||
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 | 113 | int pointerDx; | 113 | int pointerDx; |
248 | 114 | int pointerDy; | 114 | int pointerDy; |
249 | 115 | KeyCode key[NUM_KEYS]; | 115 | KeyCode key[NUM_KEYS]; |
250 | 116 | unsigned int keyCursorNames[NUM_KEYS]; | ||
251 | 116 | 117 | ||
252 | 117 | CompScreen::GrabHandle grabIndex; | 118 | CompScreen::GrabHandle grabIndex; |
253 | 118 | 119 | ||
254 | 119 | Cursor leftCursor; | ||
255 | 120 | Cursor rightCursor; | ||
256 | 121 | Cursor upCursor; | ||
257 | 122 | Cursor upLeftCursor; | ||
258 | 123 | Cursor upRightCursor; | ||
259 | 124 | Cursor downCursor; | ||
260 | 125 | Cursor downLeftCursor; | ||
261 | 126 | Cursor downRightCursor; | ||
262 | 127 | Cursor middleCursor; | ||
263 | 128 | Cursor cursor[NUM_KEYS]; | ||
264 | 129 | |||
265 | 130 | bool isConstrained; | 120 | bool isConstrained; |
266 | 131 | CompRegion constraintRegion; | 121 | CompRegion constraintRegion; |
267 | 132 | bool inRegionStatus; | 122 | bool inRegionStatus; |
268 | 133 | 123 | ||
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 | 57 | virtual void updateGrab (CompScreen::GrabHandle handle, Cursor cursor) = 0; | 57 | virtual void updateGrab (CompScreen::GrabHandle handle, Cursor cursor) = 0; |
274 | 58 | virtual CompScreen::GrabHandle pushGrab (Cursor cursor, const char *name) = 0; | 58 | virtual CompScreen::GrabHandle pushGrab (Cursor cursor, const char *name) = 0; |
275 | 59 | virtual void removeGrab (CompScreen::GrabHandle handle, CompPoint *restorePointer) = 0; | 59 | virtual void removeGrab (CompScreen::GrabHandle handle, CompPoint *restorePointer) = 0; |
276 | 60 | virtual Cursor cursorCache (unsigned int cursorName) = 0; | ||
277 | 60 | 61 | ||
278 | 61 | /* CompOption::Class */ | 62 | /* CompOption::Class */ |
279 | 62 | virtual CompOption * getOption (const CompString &name) = 0; | 63 | virtual CompOption * getOption (const CompString &name) = 0; |
280 | 63 | 64 | ||
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 | 27 | 27 | ||
286 | 28 | #include <core/core.h> | 28 | #include <core/core.h> |
287 | 29 | #include <core/atoms.h> | 29 | #include <core/atoms.h> |
288 | 30 | #include <X11/cursorfont.h> | ||
289 | 30 | 31 | ||
290 | 31 | #include "resize-logic.h" | 32 | #include "resize-logic.h" |
291 | 32 | 33 | ||
292 | @@ -48,6 +49,16 @@ | |||
293 | 48 | static const unsigned short TOUCH_TOP = 3; | 49 | static const unsigned short TOUCH_TOP = 3; |
294 | 49 | static const unsigned short TOUCH_BOTTOM = 4; | 50 | static const unsigned short TOUCH_BOTTOM = 4; |
295 | 50 | 51 | ||
296 | 52 | #define LEFT_CURSOR XC_left_side | ||
297 | 53 | #define RIGHT_CURSOR XC_right_side | ||
298 | 54 | #define UP_CURSOR XC_top_side | ||
299 | 55 | #define UP_LEFT_CURSOR XC_top_left_corner | ||
300 | 56 | #define UP_RIGHT_CURSOR XC_top_right_corner | ||
301 | 57 | #define DOWN_CURSOR XC_bottom_side | ||
302 | 58 | #define DOWN_LEFT_CURSOR XC_bottom_left_corner | ||
303 | 59 | #define DOWN_RIGHT_CURSOR XC_bottom_right_corner | ||
304 | 60 | #define MIDDLE_CURSOR XC_fleur | ||
305 | 61 | |||
306 | 51 | using namespace resize; | 62 | using namespace resize; |
307 | 52 | 63 | ||
308 | 53 | ResizeLogic::ResizeLogic() : | 64 | ResizeLogic::ResizeLogic() : |
309 | @@ -428,7 +439,7 @@ | |||
310 | 428 | lastMaskY = mask; | 439 | lastMaskY = mask; |
311 | 429 | } | 440 | } |
312 | 430 | 441 | ||
314 | 431 | mScreen->updateGrab (grabIndex, cursor[i]); | 442 | mScreen->updateGrab (grabIndex, screen->cursorCache (keyCursorNames[i])); |
315 | 432 | } | 443 | } |
316 | 433 | break; | 444 | break; |
317 | 434 | } | 445 | } |
318 | @@ -652,36 +663,36 @@ | |||
319 | 652 | Cursor | 663 | Cursor |
320 | 653 | ResizeLogic::cursorFromResizeMask (unsigned int mask) | 664 | ResizeLogic::cursorFromResizeMask (unsigned int mask) |
321 | 654 | { | 665 | { |
323 | 655 | Cursor cursor; | 666 | unsigned int cursor_name; |
324 | 656 | 667 | ||
325 | 657 | if (mask & ResizeLeftMask) | 668 | if (mask & ResizeLeftMask) |
326 | 658 | { | 669 | { |
327 | 659 | if (mask & ResizeDownMask) | 670 | if (mask & ResizeDownMask) |
329 | 660 | cursor = downLeftCursor; | 671 | cursor_name = DOWN_LEFT_CURSOR; |
330 | 661 | else if (mask & ResizeUpMask) | 672 | else if (mask & ResizeUpMask) |
332 | 662 | cursor = upLeftCursor; | 673 | cursor_name = UP_LEFT_CURSOR; |
333 | 663 | else | 674 | else |
335 | 664 | cursor = leftCursor; | 675 | cursor_name = LEFT_CURSOR; |
336 | 665 | } | 676 | } |
337 | 666 | else if (mask & ResizeRightMask) | 677 | else if (mask & ResizeRightMask) |
338 | 667 | { | 678 | { |
339 | 668 | if (mask & ResizeDownMask) | 679 | if (mask & ResizeDownMask) |
341 | 669 | cursor = downRightCursor; | 680 | cursor_name = DOWN_RIGHT_CURSOR; |
342 | 670 | else if (mask & ResizeUpMask) | 681 | else if (mask & ResizeUpMask) |
344 | 671 | cursor = upRightCursor; | 682 | cursor_name = UP_RIGHT_CURSOR; |
345 | 672 | else | 683 | else |
347 | 673 | cursor = rightCursor; | 684 | cursor_name = RIGHT_CURSOR; |
348 | 674 | } | 685 | } |
349 | 675 | else if (mask & ResizeUpMask) | 686 | else if (mask & ResizeUpMask) |
350 | 676 | { | 687 | { |
352 | 677 | cursor = upCursor; | 688 | cursor_name = UP_CURSOR; |
353 | 678 | } | 689 | } |
354 | 679 | else | 690 | else |
355 | 680 | { | 691 | { |
357 | 681 | cursor = downCursor; | 692 | cursor_name = DOWN_CURSOR; |
358 | 682 | } | 693 | } |
359 | 683 | 694 | ||
361 | 684 | return cursor; | 695 | return screen->cursorCache (cursor_name); |
362 | 685 | } | 696 | } |
363 | 686 | 697 | ||
364 | 687 | void | 698 | void |
365 | @@ -1327,7 +1338,7 @@ | |||
366 | 1327 | Cursor cursor; | 1338 | Cursor cursor; |
367 | 1328 | 1339 | ||
368 | 1329 | if (state & CompAction::StateInitKey) | 1340 | if (state & CompAction::StateInitKey) |
370 | 1330 | cursor = middleCursor; | 1341 | cursor = screen->cursorCache (MIDDLE_CURSOR); |
371 | 1331 | else | 1342 | else |
372 | 1332 | cursor = cursorFromResizeMask (mask); | 1343 | cursor = cursorFromResizeMask (mask); |
373 | 1333 | 1344 | ||
374 | 1334 | 1345 | ||
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 | 52 | MOCK_METHOD2(updateGrab, void(CompScreen::GrabHandle handle, Cursor cursor)); | 52 | MOCK_METHOD2(updateGrab, void(CompScreen::GrabHandle handle, Cursor cursor)); |
380 | 53 | MOCK_METHOD2(pushGrab, CompScreen::GrabHandle(Cursor cursor, const char *name)); | 53 | MOCK_METHOD2(pushGrab, CompScreen::GrabHandle(Cursor cursor, const char *name)); |
381 | 54 | MOCK_METHOD2(removeGrab, void(CompScreen::GrabHandle handle, CompPoint *restorePointer)); | 54 | MOCK_METHOD2(removeGrab, void(CompScreen::GrabHandle handle, CompPoint *restorePointer)); |
382 | 55 | MOCK_METHOD1(cursorCache, Cursor (unsigned int)); | ||
383 | 55 | 56 | ||
384 | 56 | MOCK_METHOD1(getOption, CompOption*(const CompString &name)); | 57 | MOCK_METHOD1(getOption, CompOption*(const CompString &name)); |
385 | 57 | 58 | ||
386 | 58 | 59 | ||
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 | 380 | logic.options = this; | 380 | logic.options = this; |
392 | 381 | 381 | ||
393 | 382 | CompOption::Vector atomTemplate; | 382 | CompOption::Vector atomTemplate; |
394 | 383 | Display *dpy = s->dpy (); | ||
395 | 384 | ResizeOptions::ChangeNotify notify = | 383 | ResizeOptions::ChangeNotify notify = |
396 | 385 | boost::bind (&ResizeScreen::optionChanged, this, _1, _2); | 384 | boost::bind (&ResizeScreen::optionChanged, this, _1, _2); |
397 | 386 | 385 | ||
398 | @@ -404,21 +403,6 @@ | |||
399 | 404 | for (unsigned int i = 0; i < NUM_KEYS; i++) | 403 | for (unsigned int i = 0; i < NUM_KEYS; i++) |
400 | 405 | logic.key[i] = XKeysymToKeycode (s->dpy (), XStringToKeysym (logic.rKeys[i].name)); | 404 | logic.key[i] = XKeysymToKeycode (s->dpy (), XStringToKeysym (logic.rKeys[i].name)); |
401 | 406 | 405 | ||
402 | 407 | logic.leftCursor = XCreateFontCursor (dpy, XC_left_side); | ||
403 | 408 | logic.rightCursor = XCreateFontCursor (dpy, XC_right_side); | ||
404 | 409 | logic.upCursor = XCreateFontCursor (dpy, XC_top_side); | ||
405 | 410 | logic.upLeftCursor = XCreateFontCursor (dpy, XC_top_left_corner); | ||
406 | 411 | logic.upRightCursor = XCreateFontCursor (dpy, XC_top_right_corner); | ||
407 | 412 | logic.downCursor = XCreateFontCursor (dpy, XC_bottom_side); | ||
408 | 413 | logic.downLeftCursor = XCreateFontCursor (dpy, XC_bottom_left_corner); | ||
409 | 414 | logic.downRightCursor = XCreateFontCursor (dpy, XC_bottom_right_corner); | ||
410 | 415 | logic.middleCursor = XCreateFontCursor (dpy, XC_fleur); | ||
411 | 416 | |||
412 | 417 | logic.cursor[0] = logic.leftCursor; | ||
413 | 418 | logic.cursor[1] = logic.rightCursor; | ||
414 | 419 | logic.cursor[2] = logic.upCursor; | ||
415 | 420 | logic.cursor[3] = logic.downCursor; | ||
416 | 421 | |||
417 | 422 | optionSetInitiateKeyInitiate (resizeInitiateDefaultMode); | 406 | optionSetInitiateKeyInitiate (resizeInitiateDefaultMode); |
418 | 423 | optionSetInitiateKeyTerminate (resizeTerminate); | 407 | optionSetInitiateKeyTerminate (resizeTerminate); |
419 | 424 | optionSetInitiateButtonInitiate (resizeInitiateDefaultMode); | 408 | optionSetInitiateButtonInitiate (resizeInitiateDefaultMode); |
420 | @@ -442,27 +426,6 @@ | |||
421 | 442 | 426 | ||
422 | 443 | ResizeScreen::~ResizeScreen () | 427 | ResizeScreen::~ResizeScreen () |
423 | 444 | { | 428 | { |
424 | 445 | Display *dpy = screen->dpy (); | ||
425 | 446 | |||
426 | 447 | if (logic.leftCursor) | ||
427 | 448 | XFreeCursor (dpy, logic.leftCursor); | ||
428 | 449 | if (logic.rightCursor) | ||
429 | 450 | XFreeCursor (dpy, logic.rightCursor); | ||
430 | 451 | if (logic.upCursor) | ||
431 | 452 | XFreeCursor (dpy, logic.upCursor); | ||
432 | 453 | if (logic.downCursor) | ||
433 | 454 | XFreeCursor (dpy, logic.downCursor); | ||
434 | 455 | if (logic.middleCursor) | ||
435 | 456 | XFreeCursor (dpy, logic.middleCursor); | ||
436 | 457 | if (logic.upLeftCursor) | ||
437 | 458 | XFreeCursor (dpy, logic.upLeftCursor); | ||
438 | 459 | if (logic.upRightCursor) | ||
439 | 460 | XFreeCursor (dpy, logic.upRightCursor); | ||
440 | 461 | if (logic.downLeftCursor) | ||
441 | 462 | XFreeCursor (dpy, logic.downLeftCursor); | ||
442 | 463 | if (logic.downRightCursor) | ||
443 | 464 | XFreeCursor (dpy, logic.downRightCursor); | ||
444 | 465 | |||
445 | 466 | delete logic.mScreen; | 429 | delete logic.mScreen; |
446 | 467 | delete logic.cScreen; | 430 | delete logic.cScreen; |
447 | 468 | delete logic.gScreen; | 431 | delete logic.gScreen; |
448 | 469 | 432 | ||
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 | 124 | return mImpl->height (); | 124 | return mImpl->height (); |
454 | 125 | } | 125 | } |
455 | 126 | 126 | ||
456 | 127 | virtual Cursor cursorCache (unsigned int cursorName) | ||
457 | 128 | { | ||
458 | 129 | return mImpl->cursorCache (cursorName); | ||
459 | 130 | } | ||
460 | 131 | |||
461 | 127 | private: | 132 | private: |
462 | 128 | CompScreen *mImpl; | 133 | CompScreen *mImpl; |
463 | 129 | }; | 134 | }; |
464 | 130 | 135 | ||
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 | 509 | { | 509 | { |
470 | 510 | window->activate (); | 510 | window->activate (); |
471 | 511 | ss->grabbedWindow = window->id (); | 511 | ss->grabbedWindow = window->id (); |
473 | 512 | ss->grabIndex = screen->pushGrab (ss->moveCursor, "shelf"); | 512 | ss->grabIndex = screen->pushGrab (screen->cursorCache (XC_fleur), "shelf"); |
474 | 513 | 513 | ||
475 | 514 | ss->lastPointerX = x; | 514 | ss->lastPointerX = x; |
476 | 515 | ss->lastPointerY = y; | 515 | ss->lastPointerY = y; |
477 | @@ -760,7 +760,6 @@ | |||
478 | 760 | gScreen (GLScreen::get (screen)), | 760 | gScreen (GLScreen::get (screen)), |
479 | 761 | grabIndex (0), | 761 | grabIndex (0), |
480 | 762 | grabbedWindow (None), | 762 | grabbedWindow (None), |
481 | 763 | moveCursor (XCreateFontCursor (screen->dpy (), XC_fleur)), | ||
482 | 764 | lastPointerX (0), | 763 | lastPointerX (0), |
483 | 765 | lastPointerY (0) | 764 | lastPointerY (0) |
484 | 766 | { | 765 | { |
485 | @@ -780,11 +779,6 @@ | |||
486 | 780 | _3)); | 779 | _3)); |
487 | 781 | } | 780 | } |
488 | 782 | 781 | ||
489 | 783 | ShelfScreen::~ShelfScreen () | ||
490 | 784 | { | ||
491 | 785 | if (moveCursor) | ||
492 | 786 | XFreeCursor (screen->dpy (), moveCursor); | ||
493 | 787 | } | ||
494 | 788 | 782 | ||
495 | 789 | ShelfWindow::ShelfWindow (CompWindow *window) : | 783 | ShelfWindow::ShelfWindow (CompWindow *window) : |
496 | 790 | PluginClassHandler <ShelfWindow, CompWindow> (window), | 784 | PluginClassHandler <ShelfWindow, CompWindow> (window), |
497 | 791 | 785 | ||
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 | 145 | public: | 145 | public: |
503 | 146 | 146 | ||
504 | 147 | ShelfScreen (CompScreen *); | 147 | ShelfScreen (CompScreen *); |
505 | 148 | ~ShelfScreen (); | ||
506 | 149 | 148 | ||
507 | 150 | CompositeScreen *cScreen; | 149 | CompositeScreen *cScreen; |
508 | 151 | GLScreen *gScreen; | 150 | GLScreen *gScreen; |
509 | 152 | 151 | ||
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 | 1968 | mMvTarget (0), | 1968 | mMvTarget (0), |
515 | 1969 | mMvVelocity (0), | 1969 | mMvVelocity (0), |
516 | 1970 | mInvert (false), | 1970 | mInvert (false), |
517 | 1971 | mCursor (XCreateFontCursor (screen->dpy (), XC_left_ptr)), | ||
518 | 1972 | mWindows (NULL), | 1971 | mWindows (NULL), |
519 | 1973 | mNWindows (0), | 1972 | mNWindows (0), |
520 | 1974 | mWindowsSize (0), | 1973 | mWindowsSize (0), |
521 | @@ -2059,8 +2058,6 @@ | |||
522 | 2059 | { | 2058 | { |
523 | 2060 | freeWindowTitle (); | 2059 | freeWindowTitle (); |
524 | 2061 | 2060 | ||
525 | 2062 | XFreeCursor (screen->dpy (), mCursor); | ||
526 | 2063 | |||
527 | 2064 | if (mWindows) | 2061 | if (mWindows) |
528 | 2065 | free (mWindows); | 2062 | free (mWindows); |
529 | 2066 | 2063 | ||
530 | 2067 | 2064 | ||
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 | 143 | float mMvVelocity; | 143 | float mMvVelocity; |
536 | 144 | bool mInvert; | 144 | bool mInvert; |
537 | 145 | 145 | ||
538 | 146 | Cursor mCursor; | ||
539 | 147 | |||
540 | 148 | /* only used for sorting */ | 146 | /* only used for sorting */ |
541 | 149 | CompWindow **mWindows; | 147 | CompWindow **mWindows; |
542 | 150 | int mNWindows; | 148 | int mNWindows; |
543 | 151 | 149 | ||
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 | 312 | } | 312 | } |
549 | 313 | 313 | ||
550 | 314 | if (!mGrabIndex) | 314 | if (!mGrabIndex) |
552 | 315 | mGrabIndex = screen->pushGrab (mCursor, "widget"); | 315 | mGrabIndex = screen->pushGrab (screen->cursorCache (XC_watch), "widget"); |
553 | 316 | 316 | ||
554 | 317 | enableFunctions (this, true); | 317 | enableFunctions (this, true); |
555 | 318 | 318 | ||
556 | @@ -672,8 +672,7 @@ | |||
557 | 672 | mLastActiveWindow (None), | 672 | mLastActiveWindow (None), |
558 | 673 | mCompizWidgetAtom (XInternAtom (screen->dpy (), "_COMPIZ_WIDGET", false)), | 673 | mCompizWidgetAtom (XInternAtom (screen->dpy (), "_COMPIZ_WIDGET", false)), |
559 | 674 | mFadeTime (0), | 674 | mFadeTime (0), |
562 | 675 | mGrabIndex (0), | 675 | mGrabIndex (0) |
561 | 676 | mCursor (XCreateFontCursor (screen->dpy (), XC_watch)) | ||
563 | 677 | { | 676 | { |
564 | 678 | CompAction::CallBack cb; | 677 | CompAction::CallBack cb; |
565 | 679 | ChangeNotify notify; | 678 | ChangeNotify notify; |
566 | @@ -706,9 +705,6 @@ | |||
567 | 706 | { | 705 | { |
568 | 707 | screen->matchExpHandlerChangedSetEnabled (this, false); | 706 | screen->matchExpHandlerChangedSetEnabled (this, false); |
569 | 708 | screen->matchExpHandlerChanged (); | 707 | screen->matchExpHandlerChanged (); |
570 | 709 | |||
571 | 710 | if (mCursor) | ||
572 | 711 | XFreeCursor (screen->dpy (), mCursor); | ||
573 | 712 | } | 708 | } |
574 | 713 | 709 | ||
575 | 714 | WidgetWindow::WidgetWindow (CompWindow *window) : | 710 | WidgetWindow::WidgetWindow (CompWindow *window) : |
576 | 715 | 711 | ||
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 | 107 | WidgetState mState; | 107 | WidgetState mState; |
582 | 108 | int mFadeTime; | 108 | int mFadeTime; |
583 | 109 | CompScreen::GrabHandle mGrabIndex; | 109 | CompScreen::GrabHandle mGrabIndex; |
584 | 110 | Cursor mCursor; | ||
585 | 111 | }; | 110 | }; |
586 | 112 | 111 | ||
587 | 113 | #define WIDGET_SCREEN(screen) \ | 112 | #define WIDGET_SCREEN(screen) \ |
588 | 114 | 113 | ||
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 | 1801 | if (w) | 1801 | if (w) |
594 | 1802 | w->priv->updateClassHints (); | 1802 | w->priv->updateClassHints (); |
595 | 1803 | } | 1803 | } |
596 | 1804 | else if (event->xproperty.atom == XA_RESOURCE_MANAGER) | ||
597 | 1805 | { | ||
598 | 1806 | if (event->xproperty.window == privateScreen.rootWindow()) | ||
599 | 1807 | privateScreen.updateResources(); | ||
600 | 1808 | } | ||
601 | 1804 | break; | 1809 | break; |
602 | 1805 | case MotionNotify: | 1810 | case MotionNotify: |
603 | 1806 | break; | 1811 | break; |
604 | 1807 | 1812 | ||
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 | 680 | 680 | ||
610 | 681 | void updateScreenInfo (); | 681 | void updateScreenInfo (); |
611 | 682 | 682 | ||
612 | 683 | void updateResources (); | ||
613 | 684 | |||
614 | 683 | Window getActiveWindow (Window root); | 685 | Window getActiveWindow (Window root); |
615 | 684 | 686 | ||
616 | 685 | void setWindowState (unsigned int state, Window id); | 687 | void setWindowState (unsigned int state, Window id); |
617 | @@ -700,6 +702,10 @@ | |||
618 | 700 | 702 | ||
619 | 701 | void setDefaultWindowAttributes (XWindowAttributes *); | 703 | void setDefaultWindowAttributes (XWindowAttributes *); |
620 | 702 | 704 | ||
621 | 705 | void updateCursors (const CompString& theme, int size); | ||
622 | 706 | |||
623 | 707 | Cursor cursorCache (unsigned int cursorName); | ||
624 | 708 | |||
625 | 703 | static void compScreenSnEvent (SnMonitorEvent *event, | 709 | static void compScreenSnEvent (SnMonitorEvent *event, |
626 | 704 | void *userData); | 710 | void *userData); |
627 | 705 | 711 | ||
628 | @@ -763,9 +769,8 @@ | |||
629 | 763 | Window wmSnSelectionWindow; | 769 | Window wmSnSelectionWindow; |
630 | 764 | 770 | ||
631 | 765 | int clientPointerDeviceId; | 771 | int clientPointerDeviceId; |
632 | 766 | Cursor normalCursor; | ||
633 | 767 | Cursor busyCursor; | ||
634 | 768 | Cursor invisibleCursor; | 772 | Cursor invisibleCursor; |
635 | 773 | std::vector<Cursor> cursors; | ||
636 | 769 | CompRect workArea; | 774 | CompRect workArea; |
637 | 770 | 775 | ||
638 | 771 | bool initialized; | 776 | bool initialized; |
639 | @@ -802,6 +807,7 @@ | |||
640 | 802 | Window xdndWindow; | 807 | Window xdndWindow; |
641 | 803 | compiz::private_screen::PluginManager pluginManager; | 808 | compiz::private_screen::PluginManager pluginManager; |
642 | 804 | compiz::private_screen::WindowManager& windowManager; | 809 | compiz::private_screen::WindowManager& windowManager; |
643 | 810 | CompOption::Vector resourceManager; | ||
644 | 805 | }; | 811 | }; |
645 | 806 | 812 | ||
646 | 807 | class CompManager | 813 | class CompManager |
647 | @@ -954,8 +960,8 @@ | |||
648 | 954 | void unhookServerWindow (CompWindow *w); | 960 | void unhookServerWindow (CompWindow *w); |
649 | 955 | 961 | ||
650 | 956 | Cursor normalCursor (); | 962 | Cursor normalCursor (); |
651 | 957 | |||
652 | 958 | Cursor invisibleCursor (); | 963 | Cursor invisibleCursor (); |
653 | 964 | Cursor cursorCache (unsigned int cursorName); | ||
654 | 959 | 965 | ||
655 | 960 | /* Adds an X Pointer and Keyboard grab to the stack. Since | 966 | /* Adds an X Pointer and Keyboard grab to the stack. Since |
656 | 961 | * compiz as a client only need to grab once, multiple clients | 967 | * compiz as a client only need to grab once, multiple clients |
657 | @@ -1158,6 +1164,7 @@ | |||
658 | 1158 | virtual void _matchExpHandlerChanged(); | 1164 | virtual void _matchExpHandlerChanged(); |
659 | 1159 | virtual void _matchPropertyChanged(CompWindow *); | 1165 | virtual void _matchPropertyChanged(CompWindow *); |
660 | 1160 | virtual void _outputChangeNotify(); | 1166 | virtual void _outputChangeNotify(); |
661 | 1167 | virtual void _cursorChangeNotify(const CompString&, int); | ||
662 | 1161 | 1168 | ||
663 | 1162 | void grabServer (); | 1169 | void grabServer (); |
664 | 1163 | void ungrabServer (); | 1170 | void ungrabServer (); |
665 | 1164 | 1171 | ||
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 | 81 | MOCK_METHOD0(_matchExpHandlerChanged, void ()); | 81 | MOCK_METHOD0(_matchExpHandlerChanged, void ()); |
671 | 82 | MOCK_METHOD1(_matchPropertyChanged, void (CompWindow *)); | 82 | MOCK_METHOD1(_matchPropertyChanged, void (CompWindow *)); |
672 | 83 | MOCK_METHOD0(_outputChangeNotify, void ()); | 83 | MOCK_METHOD0(_outputChangeNotify, void ()); |
673 | 84 | MOCK_METHOD2(_cursorChangeNotify, void (const CompString&, int)); | ||
674 | 84 | 85 | ||
675 | 85 | MOCK_METHOD0(outputDevs, CompOutput::vector & ()); | 86 | MOCK_METHOD0(outputDevs, CompOutput::vector & ()); |
676 | 86 | MOCK_METHOD2(setWindowState, void (unsigned int state, Window id)); | 87 | MOCK_METHOD2(setWindowState, void (unsigned int state, Window id)); |
677 | @@ -175,6 +176,7 @@ | |||
678 | 175 | MOCK_METHOD0(displayString, const char * ()); | 176 | MOCK_METHOD0(displayString, const char * ()); |
679 | 176 | MOCK_METHOD0(getCurrentOutputExtents, CompRect ()); | 177 | MOCK_METHOD0(getCurrentOutputExtents, CompRect ()); |
680 | 177 | MOCK_METHOD0(normalCursor, Cursor ()); | 178 | MOCK_METHOD0(normalCursor, Cursor ()); |
681 | 179 | MOCK_METHOD1(cursorCache, Cursor (unsigned int)); | ||
682 | 178 | MOCK_METHOD0(grabbed, bool ()); | 180 | MOCK_METHOD0(grabbed, bool ()); |
683 | 179 | MOCK_METHOD0(snDisplay, SnDisplay * ()); | 181 | MOCK_METHOD0(snDisplay, SnDisplay * ()); |
684 | 180 | MOCK_CONST_METHOD0(createFailed, bool ()); | 182 | MOCK_CONST_METHOD0(createFailed, bool ()); |
685 | 181 | 183 | ||
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 | 44 | 44 | ||
691 | 45 | #include <boost/bind.hpp> | 45 | #include <boost/bind.hpp> |
692 | 46 | #include <boost/foreach.hpp> | 46 | #include <boost/foreach.hpp> |
693 | 47 | #include <boost/algorithm/string.hpp> | ||
694 | 47 | #define foreach BOOST_FOREACH | 48 | #define foreach BOOST_FOREACH |
695 | 48 | 49 | ||
696 | 49 | #include <X11/Xlib.h> | 50 | #include <X11/Xlib.h> |
697 | @@ -53,6 +54,7 @@ | |||
698 | 53 | #include <X11/extensions/shape.h> | 54 | #include <X11/extensions/shape.h> |
699 | 54 | #include <X11/cursorfont.h> | 55 | #include <X11/cursorfont.h> |
700 | 55 | #include <X11/extensions/XInput2.h> | 56 | #include <X11/extensions/XInput2.h> |
701 | 57 | #include <X11/Xcursor/Xcursor.h> | ||
702 | 56 | 58 | ||
703 | 57 | #include <core/global.h> | 59 | #include <core/global.h> |
704 | 58 | #include <core/screen.h> | 60 | #include <core/screen.h> |
705 | @@ -77,10 +79,12 @@ | |||
706 | 77 | namespace | 79 | namespace |
707 | 78 | { | 80 | { |
708 | 79 | bool inHandleEvent = false; | 81 | bool inHandleEvent = false; |
709 | 80 | |||
710 | 81 | bool screenInitalized = false; | 82 | bool screenInitalized = false; |
711 | 82 | } | 83 | } |
712 | 83 | 84 | ||
713 | 85 | #define normalCursorName XC_left_ptr | ||
714 | 86 | #define busyCursorName XC_watch | ||
715 | 87 | |||
716 | 84 | #define MwmHintsFunctions (1L << 0) | 88 | #define MwmHintsFunctions (1L << 0) |
717 | 85 | #define MwmHintsDecorations (1L << 1) | 89 | #define MwmHintsDecorations (1L << 1) |
718 | 86 | static const unsigned short PropMotifWmHintElements = 3; | 90 | static const unsigned short PropMotifWmHintElements = 3; |
719 | @@ -101,6 +105,14 @@ | |||
720 | 101 | 105 | ||
721 | 102 | PluginClassStorage::Indices screenPluginClassIndices (0); | 106 | PluginClassStorage::Indices screenPluginClassIndices (0); |
722 | 103 | 107 | ||
723 | 108 | namespace utils | ||
724 | 109 | { | ||
725 | 110 | bool is_number (CompString const& s) | ||
726 | 111 | { | ||
727 | 112 | return std::find_if (s.begin (), s.end (), [](char c) { return !std::isdigit (c); }) == s.end (); | ||
728 | 113 | } | ||
729 | 114 | } | ||
730 | 115 | |||
731 | 104 | void CompScreenImpl::sizePluginClasses(unsigned int size) | 116 | void CompScreenImpl::sizePluginClasses(unsigned int size) |
732 | 105 | { | 117 | { |
733 | 106 | if(size != pluginClasses.size ()) | 118 | if(size != pluginClasses.size ()) |
734 | @@ -1271,8 +1283,8 @@ | |||
735 | 1271 | eventManager.quit (); | 1283 | eventManager.quit (); |
736 | 1272 | } | 1284 | } |
737 | 1273 | 1285 | ||
740 | 1274 | static const std::string IMAGEDIR("images"); | 1286 | static const CompString IMAGEDIR("images"); |
741 | 1275 | static const std::string HOMECOMPIZDIR(".compiz-1"); | 1287 | static const CompString HOMECOMPIZDIR(".compiz-1"); |
742 | 1276 | 1288 | ||
743 | 1277 | bool | 1289 | bool |
744 | 1278 | CompScreenImpl::readImageFromFile (CompString &name, | 1290 | CompScreenImpl::readImageFromFile (CompString &name, |
745 | @@ -1353,6 +1365,68 @@ | |||
746 | 1353 | return w; | 1365 | return w; |
747 | 1354 | } | 1366 | } |
748 | 1355 | 1367 | ||
749 | 1368 | void | ||
750 | 1369 | PrivateScreen::updateResources () | ||
751 | 1370 | { | ||
752 | 1371 | Atom actual; | ||
753 | 1372 | int result, format; | ||
754 | 1373 | unsigned long n, left; | ||
755 | 1374 | unsigned char *data; | ||
756 | 1375 | |||
757 | 1376 | result = XGetWindowProperty (dpy, root, | ||
758 | 1377 | XA_RESOURCE_MANAGER, 0L, 65536, False, | ||
759 | 1378 | XA_STRING, &actual, &format, | ||
760 | 1379 | &n, &left, &data); | ||
761 | 1380 | |||
762 | 1381 | int oldCursorSize = CompOption::getIntOptionNamed (resourceManager, "Xcursor.size", -1); | ||
763 | 1382 | CompString oldCursorTheme = CompOption::getStringOptionNamed (resourceManager, "Xcursor.theme"); | ||
764 | 1383 | resourceManager.clear (); | ||
765 | 1384 | |||
766 | 1385 | if (result == Success && data) | ||
767 | 1386 | { | ||
768 | 1387 | if (actual == XA_STRING) | ||
769 | 1388 | { | ||
770 | 1389 | std::vector<CompString> lines; | ||
771 | 1390 | CompString resources (reinterpret_cast<char *> (data)); | ||
772 | 1391 | boost::split (lines, resources, boost::is_any_of ("\n")); | ||
773 | 1392 | |||
774 | 1393 | for (auto const& line : lines) | ||
775 | 1394 | { | ||
776 | 1395 | std::vector<CompString> pair; | ||
777 | 1396 | boost::split (pair, line, boost::is_any_of ("\t")); | ||
778 | 1397 | |||
779 | 1398 | if (pair.size () == 2 && pair[0].back () == ':') | ||
780 | 1399 | { | ||
781 | 1400 | CompOption option; | ||
782 | 1401 | auto key = pair[0].substr (0, pair[0].size () - 1); | ||
783 | 1402 | auto const& value = pair[1]; | ||
784 | 1403 | |||
785 | 1404 | if (utils::is_number (value)) | ||
786 | 1405 | { | ||
787 | 1406 | option.setName (key, CompOption::TypeInt); | ||
788 | 1407 | option.value ().set (std::atoi (value.c_str ())); | ||
789 | 1408 | } | ||
790 | 1409 | else | ||
791 | 1410 | { | ||
792 | 1411 | option.setName (key, CompOption::TypeString); | ||
793 | 1412 | option.value ().set (value); | ||
794 | 1413 | } | ||
795 | 1414 | |||
796 | 1415 | resourceManager.push_back (option); | ||
797 | 1416 | } | ||
798 | 1417 | } | ||
799 | 1418 | } | ||
800 | 1419 | |||
801 | 1420 | XFree (data); | ||
802 | 1421 | } | ||
803 | 1422 | |||
804 | 1423 | int cursorSize = CompOption::getIntOptionNamed (resourceManager, "Xcursor.size", -1); | ||
805 | 1424 | CompString const& cursorTheme = CompOption::getStringOptionNamed (resourceManager, "Xcursor.theme"); | ||
806 | 1425 | |||
807 | 1426 | if (cursorSize != oldCursorSize || cursorTheme != oldCursorTheme) | ||
808 | 1427 | screen->cursorChangeNotify (cursorTheme, cursorSize); | ||
809 | 1428 | } | ||
810 | 1429 | |||
811 | 1356 | bool | 1430 | bool |
812 | 1357 | CompScreen::fileToImage (CompString &name, | 1431 | CompScreen::fileToImage (CompString &name, |
813 | 1358 | CompSize &size, | 1432 | CompSize &size, |
814 | @@ -2078,9 +2152,9 @@ | |||
815 | 2078 | if (priv->initialized) | 2152 | if (priv->initialized) |
816 | 2079 | { | 2153 | { |
817 | 2080 | if (!emptySequence()) | 2154 | if (!emptySequence()) |
819 | 2081 | XIDefineCursor (priv->dpy, priv->clientPointerDeviceId, priv->rootWindow(), priv->busyCursor); | 2155 | XIDefineCursor (priv->dpy, priv->clientPointerDeviceId, priv->rootWindow(), priv->cursorCache (busyCursorName)); |
820 | 2082 | else | 2156 | else |
822 | 2083 | XIDefineCursor (priv->dpy, priv->clientPointerDeviceId, priv->rootWindow(), priv->normalCursor); | 2157 | XIDefineCursor (priv->dpy, priv->clientPointerDeviceId, priv->rootWindow(), priv->cursorCache (normalCursorName)); |
823 | 2084 | } | 2158 | } |
824 | 2085 | } | 2159 | } |
825 | 2086 | 2160 | ||
826 | @@ -3012,7 +3086,7 @@ | |||
827 | 3012 | Cursor | 3086 | Cursor |
828 | 3013 | CompScreenImpl::normalCursor () | 3087 | CompScreenImpl::normalCursor () |
829 | 3014 | { | 3088 | { |
831 | 3015 | return privateScreen.normalCursor; | 3089 | return privateScreen.cursorCache (normalCursorName); |
832 | 3016 | } | 3090 | } |
833 | 3017 | 3091 | ||
834 | 3018 | Cursor | 3092 | Cursor |
835 | @@ -3021,6 +3095,12 @@ | |||
836 | 3021 | return privateScreen.invisibleCursor; | 3095 | return privateScreen.invisibleCursor; |
837 | 3022 | } | 3096 | } |
838 | 3023 | 3097 | ||
839 | 3098 | Cursor | ||
840 | 3099 | CompScreenImpl::cursorCache (unsigned int cursorName) | ||
841 | 3100 | { | ||
842 | 3101 | return privateScreen.cursorCache (cursorName); | ||
843 | 3102 | } | ||
844 | 3103 | |||
845 | 3024 | #define POINTER_GRAB_MASK (ButtonReleaseMask | \ | 3104 | #define POINTER_GRAB_MASK (ButtonReleaseMask | \ |
846 | 3025 | ButtonPressMask | \ | 3105 | ButtonPressMask | \ |
847 | 3026 | PointerMotionMask) | 3106 | PointerMotionMask) |
848 | @@ -3744,11 +3824,11 @@ | |||
849 | 3744 | setsid (); | 3824 | setsid (); |
850 | 3745 | 3825 | ||
851 | 3746 | pos = env.find (':'); | 3826 | pos = env.find (':'); |
853 | 3747 | if (pos != std::string::npos) | 3827 | if (pos != CompString::npos) |
854 | 3748 | { | 3828 | { |
855 | 3749 | size_t pointPos = env.find ('.', pos); | 3829 | size_t pointPos = env.find ('.', pos); |
856 | 3750 | 3830 | ||
858 | 3751 | if (pointPos != std::string::npos) | 3831 | if (pointPos != CompString::npos) |
859 | 3752 | { | 3832 | { |
860 | 3753 | env.erase (pointPos); | 3833 | env.erase (pointPos); |
861 | 3754 | } | 3834 | } |
862 | @@ -4028,6 +4108,56 @@ | |||
863 | 4028 | { | 4108 | { |
864 | 4029 | } | 4109 | } |
865 | 4030 | 4110 | ||
866 | 4111 | void | ||
867 | 4112 | CompScreen::cursorChangeNotify (const CompString& theme, int size) | ||
868 | 4113 | { | ||
869 | 4114 | WRAPABLE_HND_FUNCTN (cursorChangeNotify, theme, size); | ||
870 | 4115 | _cursorChangeNotify (theme, size); | ||
871 | 4116 | } | ||
872 | 4117 | |||
873 | 4118 | Cursor | ||
874 | 4119 | PrivateScreen::cursorCache (unsigned int cursorName) | ||
875 | 4120 | { | ||
876 | 4121 | if (cursorName >= XC_num_glyphs) | ||
877 | 4122 | return 0; | ||
878 | 4123 | |||
879 | 4124 | if (cursors.size() > cursorName && cursors[cursorName]) | ||
880 | 4125 | return cursors[cursorName]; | ||
881 | 4126 | |||
882 | 4127 | cursors.resize(std::max<size_t>(cursorName + 1, cursors.size()), 0); | ||
883 | 4128 | cursors[cursorName] = XCreateFontCursor (dpy, cursorName); | ||
884 | 4129 | |||
885 | 4130 | return cursors[cursorName]; | ||
886 | 4131 | } | ||
887 | 4132 | |||
888 | 4133 | void | ||
889 | 4134 | PrivateScreen::updateCursors (const CompString& theme, int size) | ||
890 | 4135 | { | ||
891 | 4136 | if (size > 0) | ||
892 | 4137 | XcursorSetDefaultSize (dpy, size); | ||
893 | 4138 | |||
894 | 4139 | if (!theme.empty()) | ||
895 | 4140 | XcursorSetTheme (dpy, theme.c_str()); | ||
896 | 4141 | |||
897 | 4142 | for (auto it = begin (cursors); it != end (cursors); ++it) | ||
898 | 4143 | { | ||
899 | 4144 | if (*it) | ||
900 | 4145 | { | ||
901 | 4146 | XFreeCursor (dpy, *it); | ||
902 | 4147 | *it = XCreateFontCursor (dpy, it - begin (cursors)); | ||
903 | 4148 | } | ||
904 | 4149 | } | ||
905 | 4150 | |||
906 | 4151 | XIDefineCursor (dpy, clientPointerDeviceId, root, cursorCache (normalCursorName)); | ||
907 | 4152 | startupSequence.updateStartupFeedback (); | ||
908 | 4153 | } | ||
909 | 4154 | |||
910 | 4155 | void | ||
911 | 4156 | CompScreenImpl::_cursorChangeNotify (const CompString& theme, int size) | ||
912 | 4157 | { | ||
913 | 4158 | privateScreen.updateCursors (theme, size); | ||
914 | 4159 | } | ||
915 | 4160 | |||
916 | 4031 | /* Returns default viewport for some window geometry. If the window spans | 4161 | /* Returns default viewport for some window geometry. If the window spans |
917 | 4032 | * more than one viewport the most appropriate viewport is returned. How the | 4162 | * more than one viewport the most appropriate viewport is returned. How the |
918 | 4033 | * most appropriate viewport is computed can be made optional if necessary. It | 4163 | * most appropriate viewport is computed can be made optional if necessary. It |
919 | @@ -4170,6 +4300,9 @@ | |||
920 | 4170 | ScreenInterface::addSupportedAtoms (std::vector<Atom>& atoms) | 4300 | ScreenInterface::addSupportedAtoms (std::vector<Atom>& atoms) |
921 | 4171 | WRAPABLE_DEF (addSupportedAtoms, atoms) | 4301 | WRAPABLE_DEF (addSupportedAtoms, atoms) |
922 | 4172 | 4302 | ||
923 | 4303 | void | ||
924 | 4304 | ScreenInterface::cursorChangeNotify (const CompString& theme, int size) | ||
925 | 4305 | WRAPABLE_DEF (cursorChangeNotify, theme, size) | ||
926 | 4173 | 4306 | ||
927 | 4174 | Window | 4307 | Window |
928 | 4175 | CompScreenImpl::root () | 4308 | CompScreenImpl::root () |
929 | @@ -5022,12 +5155,9 @@ | |||
930 | 5022 | eventManager.setSupportingWmCheck (dpy, rootWindow()); | 5155 | eventManager.setSupportingWmCheck (dpy, rootWindow()); |
931 | 5023 | screen->updateSupportedWmHints (); | 5156 | screen->updateSupportedWmHints (); |
932 | 5024 | 5157 | ||
933 | 5158 | |||
934 | 5025 | XIGetClientPointer (dpy, None, &clientPointerDeviceId); | 5159 | XIGetClientPointer (dpy, None, &clientPointerDeviceId); |
940 | 5026 | 5160 | updateResources (); | |
936 | 5027 | normalCursor = XCreateFontCursor (dpy, XC_left_ptr); | ||
937 | 5028 | busyCursor = XCreateFontCursor (dpy, XC_watch); | ||
938 | 5029 | |||
939 | 5030 | XIDefineCursor (dpy, clientPointerDeviceId, rootWindow(), normalCursor); | ||
941 | 5031 | 5161 | ||
942 | 5032 | /* Attempt to gain SubstructureRedirectMask */ | 5162 | /* Attempt to gain SubstructureRedirectMask */ |
943 | 5033 | CompScreenImpl::checkForError (dpy); | 5163 | CompScreenImpl::checkForError (dpy); |
944 | @@ -5203,8 +5333,6 @@ | |||
945 | 5203 | currentDesktop (0), | 5333 | currentDesktop (0), |
946 | 5204 | wmSnSelectionWindow (None), | 5334 | wmSnSelectionWindow (None), |
947 | 5205 | clientPointerDeviceId (None), | 5335 | clientPointerDeviceId (None), |
948 | 5206 | normalCursor (None), | ||
949 | 5207 | busyCursor (None), | ||
950 | 5208 | invisibleCursor (None), | 5336 | invisibleCursor (None), |
951 | 5209 | initialized (false), | 5337 | initialized (false), |
952 | 5210 | screen(screen), | 5338 | screen(screen), |
953 | @@ -5325,11 +5453,8 @@ | |||
954 | 5325 | 5453 | ||
955 | 5326 | eventManager.destroyGrabWindow (dpy); | 5454 | eventManager.destroyGrabWindow (dpy); |
956 | 5327 | 5455 | ||
962 | 5328 | if (normalCursor != None) | 5456 | for (auto cursor : cursors) |
963 | 5329 | XFreeCursor (dpy, normalCursor); | 5457 | XFreeCursor (dpy, cursor); |
959 | 5330 | |||
960 | 5331 | if (busyCursor != None) | ||
961 | 5332 | XFreeCursor (dpy, busyCursor); | ||
964 | 5333 | 5458 | ||
965 | 5334 | if (invisibleCursor != None) | 5459 | if (invisibleCursor != None) |
966 | 5335 | XFreeCursor (dpy, invisibleCursor); | 5460 | XFreeCursor (dpy, invisibleCursor); |