Merge lp:~smspillaz/compiz-core/compiz-core.cleanup-modifierhandler-propertywriter into lp:compiz-core/0.9.5
- compiz-core.cleanup-modifierhandler-propertywriter
- Merge into 0.9.5
Status: | Superseded |
---|---|
Proposed branch: | lp:~smspillaz/compiz-core/compiz-core.cleanup-modifierhandler-propertywriter |
Merge into: | lp:compiz-core/0.9.5 |
Prerequisite: | lp:~smspillaz/compiz-core/compiz-core.break-option-screen-dep |
Diff against target: |
801 lines (+193/-124) (has conflicts) 16 files modified
include/core/abiversion.h (+18/-0) include/core/action.h (+1/-19) include/core/core.h (+0/-24) include/core/modifierhandler.h (+32/-10) include/core/propertywriter.h (+3/-1) include/core/screen.h (+13/-0) plugins/inotify/src/inotify.cpp (+2/-0) plugins/regex/src/regexplugin.h (+2/-0) src/event.cpp (+17/-12) src/main.cpp (+0/-6) src/modifierhandler.cpp (+50/-32) src/privatescreen.h (+2/-0) src/propertywriter.cpp (+27/-7) src/screen.cpp (+21/-10) src/session.cpp (+1/-0) src/window.cpp (+4/-3) Text conflict in include/core/screen.h |
To merge this branch: | bzr merge lp:~smspillaz/compiz-core/compiz-core.cleanup-modifierhandler-propertywriter |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel van Vugt | Needs Resubmitting | ||
Alan Griffiths | Needs Fixing | ||
Review via email:
|
This proposal supersedes a proposal from 2012-01-24.
Commit message
Description of the change
Remove header dependencies, make objects into singletons, cleanup
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sam Spilsbury (smspillaz) wrote : | # |
> The description is wrong - I don't see a singleton (there can be more than one
> ModifierHandler).
ModifierHandler
>
> screen.h doesn't need the the includes:
>
> 208 +#include <boost/
> 209 +#include <boost/bind.hpp>
> 210 +#include <boost/foreach.hpp>
> 211 +#define foreach BOOST_FOREACH
> 212 +
> 213 +#include <core/abiversion.h>
>
> (There are some .cpp files that need some of this though - but they shoud
> include what they need, not a header used elsewhere.)
>
> The diff shows a merge error with:
>
> 221 +<<<<<<< TREE
> 222 +=======
> 223 +#include <core/actionbin
> 224 +#include <core/plugin.h>
> 225 +
> 226 +#include <X11/extensions
> 227 +>>>>>>> MERGE-SOURCE
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
> > The description is wrong - I don't see a singleton (there can be more than
> one
> > ModifierHandler).
>
> ModifierHandler
What are you saying? I still don't see Singleton (which BTW is good). modMap() isn't a global accessor method - it's a member function that accesses a member variable. (XModifierKeymap doesn't prevent multiple instances either.)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel van Vugt (vanvugt) wrote : | # |
Please resubmit for target branch lp:compiz-core (0.9.7)
Unmerged revisions
- 2951. By Sam Spilsbury
-
Assorted cleanups - remove header dependencies from ModifierHandler and PropertyWriter
Preview Diff
1 | === modified file 'include/core/abiversion.h' |
2 | --- include/core/abiversion.h 2012-01-24 08:24:18 +0000 |
3 | +++ include/core/abiversion.h 2012-01-24 08:28:10 +0000 |
4 | @@ -7,4 +7,22 @@ |
5 | |
6 | #define CORE_ABIVERSION 20120123 |
7 | |
8 | +/* |
9 | + * WORDS_BIGENDIAN should be defined before including this file for |
10 | + * IMAGE_BYTE_ORDER and BITMAP_BIT_ORDER to be set correctly. |
11 | + */ |
12 | +#define LSBFirst 0 |
13 | +#define MSBFirst 1 |
14 | + |
15 | +#ifdef WORDS_BIGENDIAN |
16 | +# define IMAGE_BYTE_ORDER MSBFirst |
17 | +# define BITMAP_BIT_ORDER MSBFirst |
18 | +#else |
19 | +# define IMAGE_BYTE_ORDER LSBFirst |
20 | +# define BITMAP_BIT_ORDER LSBFirst |
21 | +#endif |
22 | + |
23 | +#define STRINGIFY(x) #x |
24 | +#define TOSTRING(x) STRINGIFY (x) |
25 | + |
26 | #endif // COMPIZ_ABIVERSION_H |
27 | |
28 | === modified file 'include/core/action.h' |
29 | --- include/core/action.h 2012-01-24 08:24:18 +0000 |
30 | +++ include/core/action.h 2012-01-24 08:28:10 +0000 |
31 | @@ -29,6 +29,7 @@ |
32 | #define _COMPACTION_H |
33 | |
34 | #include <core/option.h> |
35 | +#include <core/modifierhandler.h> |
36 | |
37 | #include <boost/function.hpp> |
38 | |
39 | @@ -37,25 +38,6 @@ |
40 | |
41 | class PrivateAction; |
42 | |
43 | -#define CompModAlt 0 |
44 | -#define CompModMeta 1 |
45 | -#define CompModSuper 2 |
46 | -#define CompModHyper 3 |
47 | -#define CompModModeSwitch 4 |
48 | -#define CompModNumLock 5 |
49 | -#define CompModScrollLock 6 |
50 | -#define CompModNum 7 |
51 | - |
52 | -#define CompAltMask (1 << 16) |
53 | -#define CompMetaMask (1 << 17) |
54 | -#define CompSuperMask (1 << 18) |
55 | -#define CompHyperMask (1 << 19) |
56 | -#define CompModeSwitchMask (1 << 20) |
57 | -#define CompNumLockMask (1 << 21) |
58 | -#define CompScrollLockMask (1 << 22) |
59 | - |
60 | -#define CompNoMask (1 << 25) |
61 | - |
62 | /** |
63 | * Context of an event occuring. |
64 | */ |
65 | |
66 | === modified file 'include/core/core.h' |
67 | --- include/core/core.h 2012-01-24 08:24:18 +0000 |
68 | +++ include/core/core.h 2012-01-24 08:28:10 +0000 |
69 | @@ -51,30 +51,6 @@ |
70 | typedef XBool Bool; |
71 | #endif |
72 | |
73 | -#include <boost/function.hpp> |
74 | -#include <boost/bind.hpp> |
75 | -#include <boost/foreach.hpp> |
76 | -#define foreach BOOST_FOREACH |
77 | - |
78 | - |
79 | -/* |
80 | - * WORDS_BIGENDIAN should be defined before including this file for |
81 | - * IMAGE_BYTE_ORDER and BITMAP_BIT_ORDER to be set correctly. |
82 | - */ |
83 | -#define LSBFirst 0 |
84 | -#define MSBFirst 1 |
85 | - |
86 | -#ifdef WORDS_BIGENDIAN |
87 | -# define IMAGE_BYTE_ORDER MSBFirst |
88 | -# define BITMAP_BIT_ORDER MSBFirst |
89 | -#else |
90 | -# define IMAGE_BYTE_ORDER LSBFirst |
91 | -# define BITMAP_BIT_ORDER LSBFirst |
92 | -#endif |
93 | - |
94 | -#define STRINGIFY(x) #x |
95 | -#define TOSTRING(x) STRINGIFY (x) |
96 | - |
97 | #include <core/global.h> |
98 | |
99 | #include <core/pluginclasses.h> |
100 | |
101 | === modified file 'include/core/modifierhandler.h' |
102 | --- include/core/modifierhandler.h 2010-03-24 09:37:19 +0000 |
103 | +++ include/core/modifierhandler.h 2012-01-24 08:28:10 +0000 |
104 | @@ -26,7 +26,28 @@ |
105 | * Sam Spilsbury <smspillaz@gmail.com> |
106 | */ |
107 | |
108 | -#include <core/core.h> |
109 | +#ifndef _COMPIZ_MODIFIERHANDLER_H |
110 | +#define _COMPIZ_MODIFIERHANDLER_H |
111 | + |
112 | +#include <X11/Xlib-xcb.h> |
113 | + |
114 | +const unsigned int CompModAlt = 0; |
115 | +const unsigned int CompModMeta = 1; |
116 | +const unsigned int CompModSuper = 2; |
117 | +const unsigned int CompModHyper = 3; |
118 | +const unsigned int CompModModeSwitch = 4; |
119 | +const unsigned int CompModNumLock = 5; |
120 | +const unsigned int CompModScrollLock = 6; |
121 | +const unsigned int CompModNum = 7; |
122 | + |
123 | +const unsigned int CompAltMask = (1 << 16); |
124 | +const unsigned int CompMetaMask = (1 << 17); |
125 | +const unsigned int CompSuperMask = (1 << 18); |
126 | +const unsigned int CompHyperMask = (1 << 19); |
127 | +const unsigned int CompModeSwitchMask = (1 << 20); |
128 | +const unsigned int CompNumLockMask = (1 << 21); |
129 | +const unsigned int CompScrollLockMask = (1 << 22); |
130 | +const unsigned int CompNoMask = (1 << 25); |
131 | |
132 | /** |
133 | * Toplevel class which provides access to display |
134 | @@ -36,7 +57,7 @@ |
135 | { |
136 | public: |
137 | |
138 | - ModifierHandler (); |
139 | + ModifierHandler (Display *); |
140 | ~ModifierHandler (); |
141 | |
142 | typedef enum |
143 | @@ -75,7 +96,7 @@ |
144 | /** |
145 | * Updates X11 Modifier mappings |
146 | */ |
147 | - void updateModifierMappings (); |
148 | + bool updateModifierMappings (); |
149 | |
150 | /** |
151 | * Takes a virtual modMask and returns a real modifier mask |
152 | @@ -98,17 +119,18 @@ |
153 | */ |
154 | const XModifierKeymap * modMap (); |
155 | |
156 | - friend class CompScreen; |
157 | + static ModifierHandler * |
158 | + Default (); |
159 | |
160 | + static void |
161 | + SetDefault (ModifierHandler *); |
162 | private: |
163 | |
164 | - static const unsigned int virtualModMask[7]; |
165 | - |
166 | - static const int maskTable[8]; |
167 | - |
168 | - static const int maskTableSize = 8; |
169 | - |
170 | ModMask mModMask[ModNum]; |
171 | unsigned int mIgnoredModMask; |
172 | XModifierKeymap *mModMap; |
173 | + |
174 | + Display *mDisplay; |
175 | }; |
176 | + |
177 | +#endif |
178 | |
179 | === modified file 'include/core/propertywriter.h' |
180 | --- include/core/propertywriter.h 2012-01-18 16:26:45 +0000 |
181 | +++ include/core/propertywriter.h 2012-01-24 08:28:10 +0000 |
182 | @@ -30,7 +30,7 @@ |
183 | #include "core/string.h" |
184 | |
185 | #include <X11/Xatom.h> |
186 | -#include <X11/X.h> |
187 | +#include <X11/Xlib-xcb.h> |
188 | |
189 | static const CompOption::Vector nilValues; |
190 | |
191 | @@ -48,6 +48,8 @@ |
192 | void setReadTemplate (const CompOption::Vector &); |
193 | const CompOption::Vector & getReadTemplate (); |
194 | |
195 | + static void connect (Display *); |
196 | + |
197 | private: |
198 | |
199 | CompOption::Vector mPropertyValues; |
200 | |
201 | === modified file 'include/core/screen.h' |
202 | --- include/core/screen.h 2012-01-24 08:24:18 +0000 |
203 | +++ include/core/screen.h 2012-01-24 08:28:10 +0000 |
204 | @@ -28,6 +28,12 @@ |
205 | #ifndef _COMPSCREEN_H |
206 | #define _COMPSCREEN_H |
207 | |
208 | +#include <boost/function.hpp> |
209 | +#include <boost/bind.hpp> |
210 | +#include <boost/foreach.hpp> |
211 | +#define foreach BOOST_FOREACH |
212 | + |
213 | +#include <core/abiversion.h> |
214 | #include <core/window.h> |
215 | #include <core/output.h> |
216 | #include <core/session.h> |
217 | @@ -37,6 +43,13 @@ |
218 | #include <core/region.h> |
219 | #include <core/modifierhandler.h> |
220 | #include <core/valueholder.h> |
221 | +<<<<<<< TREE |
222 | +======= |
223 | +#include <core/actionbindings.h> |
224 | +#include <core/plugin.h> |
225 | + |
226 | +#include <X11/extensions/Xinerama.h> |
227 | +>>>>>>> MERGE-SOURCE |
228 | |
229 | class CompScreen; |
230 | class PrivateScreen; |
231 | |
232 | === modified file 'plugins/inotify/src/inotify.cpp' |
233 | --- plugins/inotify/src/inotify.cpp 2012-01-18 16:26:45 +0000 |
234 | +++ plugins/inotify/src/inotify.cpp 2012-01-24 08:28:10 +0000 |
235 | @@ -30,6 +30,8 @@ |
236 | #include <poll.h> |
237 | #include <sys/inotify.h> |
238 | |
239 | +#include <cstdio> |
240 | +#include <boost/bind.hpp> |
241 | |
242 | COMPIZ_PLUGIN_20090315 (inotify, InotifyPluginVTable) |
243 | |
244 | |
245 | === modified file 'plugins/regex/src/regexplugin.h' |
246 | --- plugins/regex/src/regexplugin.h 2012-01-18 16:26:45 +0000 |
247 | +++ plugins/regex/src/regexplugin.h 2012-01-24 08:28:10 +0000 |
248 | @@ -26,8 +26,10 @@ |
249 | #ifndef COMPIZ_REGEXPLUGIN_H |
250 | #define COMPIZ_REGEXPLUGIN_H |
251 | |
252 | +#include <core/core.h> |
253 | #include <core/screen.h> |
254 | #include <core/pluginclasshandler.h> |
255 | +#include <core/timer.h> |
256 | |
257 | #include <X11/Xatom.h> |
258 | |
259 | |
260 | === modified file 'src/event.cpp' |
261 | --- src/event.cpp 2012-01-19 18:12:31 +0000 |
262 | +++ src/event.cpp 2012-01-24 08:28:10 +0000 |
263 | @@ -141,7 +141,7 @@ |
264 | { |
265 | CompAction::State state = CompAction::StateInitButton; |
266 | CompAction *action; |
267 | - unsigned int ignored = modHandler->ignoredModMask (); |
268 | + unsigned int ignored = ModifierHandler::Default ()->ignoredModMask (); |
269 | unsigned int modMask = REAL_MOD_MASK & ~ignored; |
270 | unsigned int bindMods; |
271 | unsigned int edge = 0; |
272 | @@ -177,7 +177,7 @@ |
273 | { |
274 | if (action->button ().button () == (int) event->button) |
275 | { |
276 | - bindMods = modHandler->virtualToRealModMask ( |
277 | + bindMods = ModifierHandler::Default ()->virtualToRealModMask ( |
278 | action->button ().modifiers ()); |
279 | |
280 | if ((bindMods & modMask) == (event->state & modMask)) |
281 | @@ -196,7 +196,7 @@ |
282 | if ((action->button ().button () == (int) event->button) && |
283 | (action->edgeMask () & edge)) |
284 | { |
285 | - bindMods = modHandler->virtualToRealModMask ( |
286 | + bindMods = ModifierHandler::Default ()->virtualToRealModMask ( |
287 | action->button ().modifiers ()); |
288 | |
289 | if ((bindMods & modMask) == (event->state & modMask)) |
290 | @@ -244,7 +244,7 @@ |
291 | { |
292 | CompAction::State state = 0; |
293 | CompAction *action; |
294 | - unsigned int modMask = REAL_MOD_MASK & ~modHandler->ignoredModMask (); |
295 | + unsigned int modMask = REAL_MOD_MASK & ~ModifierHandler::Default ()->ignoredModMask (); |
296 | unsigned int bindMods; |
297 | |
298 | if (event->keycode == escapeKeyCode) |
299 | @@ -274,7 +274,7 @@ |
300 | if (isInitiateBinding (option, CompAction::BindingTypeKey, |
301 | state, &action)) |
302 | { |
303 | - bindMods = modHandler->virtualToRealModMask ( |
304 | + bindMods = ModifierHandler::Default ()->virtualToRealModMask ( |
305 | action->key ().modifiers ()); |
306 | |
307 | if (action->key ().keycode () == (int) event->keycode) |
308 | @@ -302,12 +302,12 @@ |
309 | { |
310 | CompAction::State state = CompAction::StateTermKey; |
311 | CompAction *action; |
312 | - unsigned int ignored = modHandler->ignoredModMask (); |
313 | + unsigned int ignored = ModifierHandler::Default ()->ignoredModMask (); |
314 | unsigned int modMask = REAL_MOD_MASK & ~ignored; |
315 | unsigned int bindMods; |
316 | unsigned int mods; |
317 | |
318 | - mods = modHandler->keycodeToModifiers (event->keycode); |
319 | + mods = ModifierHandler::Default ()->keycodeToModifiers (event->keycode); |
320 | if (!xkbEvent && !mods) |
321 | return false; |
322 | |
323 | @@ -316,7 +316,7 @@ |
324 | if (isTerminateBinding (option, CompAction::BindingTypeKey, |
325 | state, &action)) |
326 | { |
327 | - bindMods = modHandler->virtualToRealModMask (action->key ().modifiers ()); |
328 | + bindMods = ModifierHandler::Default ()->virtualToRealModMask (action->key ().modifiers ()); |
329 | |
330 | if ((bindMods & modMask) == 0) |
331 | { |
332 | @@ -345,7 +345,7 @@ |
333 | { |
334 | CompAction::State state; |
335 | CompAction *action; |
336 | - unsigned int ignored = modHandler->ignoredModMask (); |
337 | + unsigned int ignored = ModifierHandler::Default ()->ignoredModMask (); |
338 | unsigned int modMask = REAL_MOD_MASK & ~ignored; |
339 | unsigned int bindMods; |
340 | |
341 | @@ -361,7 +361,7 @@ |
342 | if (action->key ().keycode () == 0) |
343 | { |
344 | bindMods = |
345 | - modHandler->virtualToRealModMask (action->key ().modifiers ()); |
346 | + ModifierHandler::Default ()->virtualToRealModMask (action->key ().modifiers ()); |
347 | |
348 | if ((event->mods & modMask & bindMods) == bindMods) |
349 | { |
350 | @@ -381,7 +381,7 @@ |
351 | if (isTerminateBinding (option, CompAction::BindingTypeKey, |
352 | state, &action)) |
353 | { |
354 | - bindMods = modHandler->virtualToRealModMask (action->key ().modifiers ()); |
355 | + bindMods = ModifierHandler::Default ()->virtualToRealModMask (action->key ().modifiers ()); |
356 | |
357 | if ((event->mods & modMask & bindMods) != bindMods) |
358 | { |
359 | @@ -1709,7 +1709,12 @@ |
360 | } |
361 | break; |
362 | case MappingNotify: |
363 | - modHandler->updateModifierMappings (); |
364 | + if (ModifierHandler::Default ()->updateModifierMappings ()) |
365 | + { |
366 | + priv->updatePassiveKeyGrabs (); |
367 | + foreach (CompWindow *w, screen->windows ()) |
368 | + w->priv->updatePassiveButtonGrabs (); |
369 | + } |
370 | break; |
371 | case MapRequest: |
372 | w = screen->findWindow (event->xmaprequest.window); |
373 | |
374 | === modified file 'src/main.cpp' |
375 | --- src/main.cpp 2012-01-23 17:45:39 +0000 |
376 | +++ src/main.cpp 2012-01-24 08:28:10 +0000 |
377 | @@ -172,11 +172,6 @@ |
378 | return false; |
379 | } |
380 | |
381 | - modHandler = new ModifierHandler (); |
382 | - |
383 | - if (!modHandler) |
384 | - return false; |
385 | - |
386 | if (!plugins.empty ()) |
387 | { |
388 | CompOption::Value::Vector list; |
389 | @@ -239,7 +234,6 @@ |
390 | StackDebugger::SetDefault (NULL); |
391 | |
392 | delete screen; |
393 | - delete modHandler; |
394 | } |
395 | |
396 | |
397 | |
398 | === modified file 'src/modifierhandler.cpp' |
399 | --- src/modifierhandler.cpp 2011-01-07 20:06:40 +0000 |
400 | +++ src/modifierhandler.cpp 2012-01-24 08:28:10 +0000 |
401 | @@ -26,19 +26,25 @@ |
402 | * Sam Spilsbury <smspillaz@gmail.com> |
403 | */ |
404 | |
405 | -#include <core/screen.h> |
406 | -#include "privatescreen.h" |
407 | -#include "privatewindow.h" |
408 | - |
409 | -const unsigned int ModifierHandler::virtualModMask[7] = { |
410 | - CompAltMask, CompMetaMask, CompSuperMask, CompHyperMask, |
411 | - CompModeSwitchMask, CompNumLockMask, CompScrollLockMask |
412 | -}; |
413 | - |
414 | -const int ModifierHandler::maskTable[8] = { |
415 | - ShiftMask, LockMask, ControlMask, Mod1Mask, |
416 | - Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask |
417 | -}; |
418 | +#include <core/modifierhandler.h> |
419 | +#include <assert.h> |
420 | +#include <X11/keysym.h> |
421 | +#include <cstring> |
422 | + |
423 | +namespace |
424 | +{ |
425 | +const unsigned int virtualModMask[7] = { |
426 | + CompAltMask, CompMetaMask, CompSuperMask, CompHyperMask, |
427 | + CompModeSwitchMask, CompNumLockMask, CompScrollLockMask |
428 | +}; |
429 | +const int maskTable[8] = { |
430 | + ShiftMask, LockMask, ControlMask, Mod1Mask, |
431 | + Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask |
432 | +}; |
433 | +const int maskTableSize = 8; |
434 | + |
435 | +ModifierHandler *gDefault = NULL; |
436 | +} |
437 | |
438 | unsigned int |
439 | ModifierHandler::ignoredModMask () |
440 | @@ -52,25 +58,25 @@ |
441 | return mModMap; |
442 | } |
443 | |
444 | -void |
445 | +bool |
446 | ModifierHandler::updateModifierMappings () |
447 | { |
448 | unsigned int modMask[CompModNum]; |
449 | - int i, minKeycode, maxKeycode, keysymsPerKeycode = 0; |
450 | + int minKeycode, maxKeycode, keysymsPerKeycode = 0; |
451 | KeySym* key; |
452 | |
453 | - for (i = 0; i < CompModNum; i++) |
454 | + for (unsigned int i = 0; i < CompModNum; i++) |
455 | modMask[i] = 0; |
456 | |
457 | - XDisplayKeycodes (screen->dpy (), &minKeycode, &maxKeycode); |
458 | - key = XGetKeyboardMapping (screen->dpy (), |
459 | + XDisplayKeycodes (mDisplay, &minKeycode, &maxKeycode); |
460 | + key = XGetKeyboardMapping (mDisplay, |
461 | minKeycode, (maxKeycode - minKeycode + 1), |
462 | &keysymsPerKeycode); |
463 | |
464 | if (mModMap) |
465 | XFreeModifiermap (mModMap); |
466 | |
467 | - mModMap = XGetModifierMapping (screen->dpy ()); |
468 | + mModMap = XGetModifierMapping (mDisplay); |
469 | if (mModMap && mModMap->max_keypermod > 0) |
470 | { |
471 | KeySym keysym; |
472 | @@ -78,7 +84,7 @@ |
473 | |
474 | size = maskTableSize * mModMap->max_keypermod; |
475 | |
476 | - for (i = 0; i < size; i++) |
477 | + for (int i = 0; i < size; i++) |
478 | { |
479 | if (!mModMap->modifiermap[i]) |
480 | continue; |
481 | @@ -86,7 +92,7 @@ |
482 | index = 0; |
483 | do |
484 | { |
485 | - keysym = XKeycodeToKeysym (screen->dpy (), |
486 | + keysym = XKeycodeToKeysym (mDisplay, |
487 | mModMap->modifiermap[i], |
488 | index++); |
489 | } while (!keysym && index < keysymsPerKeycode); |
490 | @@ -130,7 +136,7 @@ |
491 | } |
492 | } |
493 | |
494 | - for (i = 0; i < CompModNum; i++) |
495 | + for (unsigned int i = 0; i < CompModNum; i++) |
496 | { |
497 | if (!modMask[i]) |
498 | modMask[i] = CompNoMask; |
499 | @@ -144,22 +150,20 @@ |
500 | (modMask[CompModNumLock] & ~CompNoMask) | |
501 | (modMask[CompModScrollLock] & ~CompNoMask); |
502 | |
503 | - screen->priv->updatePassiveKeyGrabs (); |
504 | - foreach (CompWindow *w, screen->windows ()) |
505 | - w->priv->updatePassiveButtonGrabs (); |
506 | + if (key) |
507 | + XFree (key); |
508 | + |
509 | + return true; |
510 | } |
511 | } |
512 | |
513 | - if (key) |
514 | - XFree (key); |
515 | + return false; |
516 | } |
517 | |
518 | unsigned int |
519 | ModifierHandler::virtualToRealModMask (unsigned int modMask) |
520 | { |
521 | - int i; |
522 | - |
523 | - for (i = 0; i < CompModNum; i++) |
524 | + for (unsigned int i = 0; i < CompModNum; i++) |
525 | { |
526 | if (modMask & virtualModMask[i]) |
527 | { |
528 | @@ -190,9 +194,23 @@ |
529 | return mods; |
530 | } |
531 | |
532 | -ModifierHandler::ModifierHandler () : |
533 | +ModifierHandler * |
534 | +ModifierHandler::Default () |
535 | +{ |
536 | + return gDefault; |
537 | +} |
538 | + |
539 | +void |
540 | +ModifierHandler::SetDefault (ModifierHandler *m) |
541 | +{ |
542 | + assert (!gDefault); |
543 | + gDefault = m; |
544 | +} |
545 | + |
546 | +ModifierHandler::ModifierHandler (Display *display) : |
547 | mIgnoredModMask (LockMask), |
548 | - mModMap (0) |
549 | + mModMap (0), |
550 | + mDisplay (display) |
551 | { |
552 | for (int i = 0; i < ModNum; i++) |
553 | mModMask[i] = NoMask; |
554 | |
555 | === modified file 'src/privatescreen.h' |
556 | --- src/privatescreen.h 2012-01-21 13:34:31 +0000 |
557 | +++ src/privatescreen.h 2012-01-24 08:28:10 +0000 |
558 | @@ -407,6 +407,8 @@ |
559 | std::list< CompWatchFd * > watchFds; |
560 | CompWatchFdHandle lastWatchFdHandle; |
561 | |
562 | + ModifierHandler *modHandler; |
563 | + |
564 | std::map<CompString, CompPrivate> valueMap; |
565 | |
566 | xcb_connection_t *connection; |
567 | |
568 | === modified file 'src/propertywriter.cpp' |
569 | --- src/propertywriter.cpp 2012-01-18 16:26:45 +0000 |
570 | +++ src/propertywriter.cpp 2012-01-24 08:28:10 +0000 |
571 | @@ -23,8 +23,28 @@ |
572 | * Authors: Sam Spilsbury <smspillaz@gmail.com> |
573 | */ |
574 | |
575 | +#include <core/match.h> |
576 | +#include <core/action.h> |
577 | #include <core/propertywriter.h> |
578 | -#include <core/screen.h> |
579 | +#include <boost/foreach.hpp> |
580 | +#include <X11/Xlib-xcb.h> |
581 | +#include <X11/Xutil.h> |
582 | + |
583 | +#ifndef foreach |
584 | +#define foreach BOOST_FOREACH |
585 | +#endif |
586 | + |
587 | +namespace |
588 | +{ |
589 | + Display *connection = NULL; |
590 | +} |
591 | + |
592 | +void |
593 | +PropertyWriter::connect (Display *display) |
594 | +{ |
595 | + assert (!connection); |
596 | + connection = display; |
597 | +} |
598 | |
599 | PropertyWriter::PropertyWriter () |
600 | { |
601 | @@ -34,7 +54,7 @@ |
602 | CompOption::Vector &readTemplate) |
603 | { |
604 | mPropertyValues = readTemplate; |
605 | - mAtom = XInternAtom (screen->dpy (), propName.c_str (), 0); |
606 | + mAtom = XInternAtom (connection, propName.c_str (), 0); |
607 | } |
608 | |
609 | void |
610 | @@ -79,7 +99,7 @@ |
611 | count++; |
612 | } |
613 | |
614 | - XChangeProperty (screen->dpy (), id, |
615 | + XChangeProperty (connection, id, |
616 | mAtom, type, 32, |
617 | PropModeReplace, (unsigned char *)data, |
618 | propertyData.size ()); |
619 | @@ -117,7 +137,7 @@ |
620 | { |
621 | if (XStringListToTextProperty (data, count, &prop)) |
622 | { |
623 | - XSetTextProperty (screen->dpy (), id, &prop, mAtom); |
624 | + XSetTextProperty (connection, id, &prop, mAtom); |
625 | XFree (prop.value); |
626 | } |
627 | } |
628 | @@ -129,7 +149,7 @@ |
629 | void |
630 | PropertyWriter::deleteProperty (Window id) |
631 | { |
632 | - XDeleteProperty (screen->dpy (), id, mAtom); |
633 | + XDeleteProperty (connection, id, mAtom); |
634 | } |
635 | |
636 | const CompOption::Vector & |
637 | @@ -143,7 +163,7 @@ |
638 | if (mPropertyValues.empty ()) |
639 | return mPropertyValues; |
640 | |
641 | - retval = XGetWindowProperty (screen->dpy (), id, mAtom, 0, |
642 | + retval = XGetWindowProperty (connection, id, mAtom, 0, |
643 | mPropertyValues.size (), False, XA_CARDINAL, |
644 | &type, &fmt, &nitems, &exbyte, |
645 | (unsigned char **)&data); |
646 | @@ -184,7 +204,7 @@ |
647 | else if (type == XA_STRING && fmt == 8) |
648 | { |
649 | XTextProperty tProp; |
650 | - retval = XGetTextProperty (screen->dpy (), id, &tProp, mAtom); |
651 | + retval = XGetTextProperty (connection, id, &tProp, mAtom); |
652 | |
653 | if (tProp.value) |
654 | { |
655 | |
656 | === modified file 'src/screen.cpp' |
657 | --- src/screen.cpp 2012-01-24 08:24:18 +0000 |
658 | +++ src/screen.cpp 2012-01-24 08:28:10 +0000 |
659 | @@ -55,6 +55,7 @@ |
660 | #include <core/screen.h> |
661 | #include <core/icon.h> |
662 | #include <core/atoms.h> |
663 | +#include <core/propertywriter.h> |
664 | #include "privatescreen.h" |
665 | #include "privatewindow.h" |
666 | #include "privateaction.h" |
667 | @@ -87,7 +88,6 @@ |
668 | |
669 | |
670 | CompScreen *screen; |
671 | -ModifierHandler *modHandler; |
672 | |
673 | PluginClassStorage::Indices screenPluginClassIndices (0); |
674 | |
675 | @@ -3010,9 +3010,9 @@ |
676 | |
677 | CompScreen::checkForError (dpy); |
678 | |
679 | - for (ignore = 0; ignore <= modHandler->ignoredModMask (); ignore++) |
680 | + for (ignore = 0; ignore <= ModifierHandler::Default ()->ignoredModMask (); ignore++) |
681 | { |
682 | - if (ignore & ~modHandler->ignoredModMask ()) |
683 | + if (ignore & ~ModifierHandler::Default ()->ignoredModMask ()) |
684 | continue; |
685 | |
686 | if (keycode != 0) |
687 | @@ -3025,15 +3025,15 @@ |
688 | { |
689 | if (modifiers & (1 << mod)) |
690 | { |
691 | - for (k = mod * modHandler->modMap ()->max_keypermod; |
692 | - k < (mod + 1) * modHandler->modMap ()->max_keypermod; |
693 | + for (k = mod * ModifierHandler::Default ()->modMap ()->max_keypermod; |
694 | + k < (mod + 1) * ModifierHandler::Default ()->modMap ()->max_keypermod; |
695 | k++) |
696 | { |
697 | - if (modHandler->modMap ()->modifiermap[k]) |
698 | + if (ModifierHandler::Default ()->modMap ()->modifiermap[k]) |
699 | { |
700 | grabUngrabOneKey ((modifiers & ~(1 << mod)) | |
701 | ignore, |
702 | - modHandler->modMap ()->modifiermap[k], |
703 | + ModifierHandler::Default ()->modMap ()->modifiermap[k], |
704 | grab); |
705 | } |
706 | } |
707 | @@ -3055,7 +3055,7 @@ |
708 | unsigned int mask; |
709 | std::list<KeyGrab>::iterator it; |
710 | |
711 | - mask = modHandler->virtualToRealModMask (key.modifiers ()); |
712 | + mask = ModifierHandler::Default ()->virtualToRealModMask (key.modifiers ()); |
713 | |
714 | for (it = keyGrabs.begin (); it != keyGrabs.end (); it++) |
715 | { |
716 | @@ -3090,7 +3090,7 @@ |
717 | unsigned int mask; |
718 | std::list<KeyGrab>::iterator it; |
719 | |
720 | - mask = modHandler->virtualToRealModMask (key.modifiers ()); |
721 | + mask = ModifierHandler::Default ()->virtualToRealModMask (key.modifiers ()); |
722 | |
723 | for (it = keyGrabs.begin (); it != keyGrabs.end (); it++) |
724 | { |
725 | @@ -4398,6 +4398,11 @@ |
726 | return false; |
727 | } |
728 | |
729 | + priv->modHandler = new ModifierHandler (priv->dpy); |
730 | + |
731 | + PropertyWriter::connect (priv->dpy); |
732 | + ModifierHandler::SetDefault (priv->modHandler); |
733 | + |
734 | XSynchronize (dpy, TRUE); |
735 | |
736 | // priv->connection = XGetXCBConnection (priv->dpy); |
737 | @@ -4535,7 +4540,12 @@ |
738 | } while (event.type != DestroyNotify); |
739 | } |
740 | |
741 | - modHandler->updateModifierMappings (); |
742 | + if (ModifierHandler::Default ()->updateModifierMappings ()) |
743 | + { |
744 | + priv->updatePassiveKeyGrabs (); |
745 | + foreach (CompWindow *w, screen->windows ()) |
746 | + w->priv->updatePassiveButtonGrabs (); |
747 | + } |
748 | |
749 | CompScreen::checkForError (dpy); |
750 | |
751 | @@ -4963,6 +4973,7 @@ |
752 | { |
753 | delete timeout; |
754 | delete source; |
755 | + delete modHandler; |
756 | |
757 | foreach (CompWatchFd *fd, watchFds) |
758 | delete fd; |
759 | |
760 | === modified file 'src/session.cpp' |
761 | --- src/session.cpp 2012-01-19 18:12:31 +0000 |
762 | +++ src/session.cpp 2012-01-24 08:28:10 +0000 |
763 | @@ -26,6 +26,7 @@ |
764 | |
765 | #include "core/session.h" |
766 | #include "core/screen.h" |
767 | +#include "core/global.h" |
768 | |
769 | #ifdef HAVE_CONFIG_H |
770 | # include <config.h> |
771 | |
772 | === modified file 'src/window.cpp' |
773 | --- src/window.cpp 2012-01-21 18:31:07 +0000 |
774 | +++ src/window.cpp 2012-01-24 08:28:10 +0000 |
775 | @@ -41,6 +41,7 @@ |
776 | #include <core/icon.h> |
777 | #include <core/atoms.h> |
778 | #include "core/windowconstrainment.h" |
779 | +#include "core/modifierhandler.h" |
780 | #include "privatewindow.h" |
781 | #include "privatescreen.h" |
782 | #include "privatestackdebugger.h" |
783 | @@ -5869,15 +5870,15 @@ |
784 | /* Grab only we have bindings on */ |
785 | foreach (PrivateScreen::ButtonGrab &bind, screen->priv->buttonGrabs) |
786 | { |
787 | - unsigned int mods = modHandler->virtualToRealModMask (bind.modifiers); |
788 | + unsigned int mods = ModifierHandler::Default ()->virtualToRealModMask (bind.modifiers); |
789 | |
790 | if (mods & CompNoMask) |
791 | continue; |
792 | |
793 | for (unsigned int ignore = 0; |
794 | - ignore <= modHandler->ignoredModMask (); ignore++) |
795 | + ignore <= ModifierHandler::Default ()->ignoredModMask (); ignore++) |
796 | { |
797 | - if (ignore & ~modHandler->ignoredModMask ()) |
798 | + if (ignore & ~ModifierHandler::Default ()->ignoredModMask ()) |
799 | continue; |
800 | |
801 | XGrabButton (screen->priv->dpy, |
The description is wrong - I don't see a singleton (there can be more than one ModifierHandler).
screen.h doesn't need the the includes:
208 +#include <boost/ function. hpp>
209 +#include <boost/bind.hpp>
210 +#include <boost/foreach.hpp>
211 +#define foreach BOOST_FOREACH
212 +
213 +#include <core/abiversion.h>
(There are some .cpp files that need some of this though - but they shoud include what they need, not a header used elsewhere.)
The diff shows a merge error with:
221 +<<<<<<< TREE dings.h> /Xinerama. h>
222 +=======
223 +#include <core/actionbin
224 +#include <core/plugin.h>
225 +
226 +#include <X11/extensions
227 +>>>>>>> MERGE-SOURCE