On Mon, 31 Aug 2009, Carlos R. Mafra wrote:
> > > +#define WKBD_RAISELOWER 18
> > > +#define WKBD_MOVERESIZE 19
> > > +#define WKBD_SHADE 20
> > > /* window, menu */
> > > -#define WKBD_CLOSE 20
> > > +#define WKBD_CLOSE 21
> > >
> >
> >
> > this #define usage seems to be a ticking bomb ready to blow up if someone
> > forgets to correctly adjust all the numbers.
>
> Well, I guess it is hard to forget to adjust the others when you change
> them.
>
> > Why aren't we using an enum {} ?
>
> Do you think it would be cleaner? I am all for having cleaner (and
> easier to understand) code, so if you can cook up a patch that would
> be fine.
i had something to this end a while back, i s'pose things therein
haven't changed that much (or at least it should be painless to
adjust):
tree a891408e8ead
parent 4832f7b624e6
author Tamas TEVESZ <[email protected]> 1231143101 -3600
committer Tamas TEVESZ <[email protected]> 1231143101 -3600
revision 1616
branch default
Use enum instead of #ifdef maze for enumerating keybindings
diff --git a/src/keybind.h b/src/keybind.h
--- a/src/keybind.h
+++ b/src/keybind.h
@@ -20,81 +20,80 @@
*/
+enum {
+ /* anywhere */
+ WKBD_ROOTMENU,
+ WKBD_WINDOWMENU,
+ WKBD_WINDOWLIST,
-/* anywhere */
-#define WKBD_ROOTMENU 0
-#define WKBD_WINDOWMENU 1
-#define WKBD_WINDOWLIST 2
-/* window */
-#define WKBD_MINIATURIZE 3
-#define WKBD_HIDE 4
-#define WKBD_HIDE_OTHERS 5
-#define WKBD_MAXIMIZE 6
-#define WKBD_VMAXIMIZE 7
-#define WKBD_HMAXIMIZE 8
-#define WKBD_SELECT 9
-/* Clip */
-#define WKBD_CLIPLOWER 10
-#define WKBD_CLIPRAISE 11
-#define WKBD_CLIPRAISELOWER 12
-/* window */
-#define WKBD_RAISE 13
-#define WKBD_LOWER 14
-#define WKBD_RAISELOWER 15
-#define WKBD_MOVERESIZE 16
-#define WKBD_SHADE 17
-/* window, menu */
-#define WKBD_CLOSE 18
-/* window */
-#define WKBD_FOCUSNEXT 19
-#define WKBD_FOCUSPREV 20
+ /* window */
+ WKBD_MINIATURIZE,
+ WKBD_HIDE,
+ WKBD_HIDE_OTHERS,
+ WKBD_MAXIMIZE,
+ WKBD_VMAXIMIZE,
+ WKBD_HMAXIMIZE,
+ WKBD_SELECT,
+ WKBD_RAISE,
+ WKBD_LOWER,
+ WKBD_RAISELOWER,
+ WKBD_MOVERESIZE,
+ WKBD_SHADE,
+ WKBD_FOCUSNEXT,
+ WKBD_FOCUSPREV,
-#define WKBD_WORKSPACE1 21
-#define WKBD_WORKSPACE2 22
-#define WKBD_WORKSPACE3 23
-#define WKBD_WORKSPACE4 24
-#define WKBD_WORKSPACE5 25
-#define WKBD_WORKSPACE6 26
-#define WKBD_WORKSPACE7 27
-#define WKBD_WORKSPACE8 28
-#define WKBD_WORKSPACE9 29
-#define WKBD_WORKSPACE10 30
-#define WKBD_NEXTWORKSPACE 31
-#define WKBD_PREVWORKSPACE 32
-#define WKBD_NEXTWSLAYER 33
-#define WKBD_PREVWSLAYER 34
+ /* window, menu */
+ WKBD_CLOSE,
-/* window shortcuts */
-#define WKBD_WINDOW1 35
-#define WKBD_WINDOW2 36
-#define WKBD_WINDOW3 37
-#define WKBD_WINDOW4 38
-#define WKBD_WINDOW5 39
-#define WKBD_WINDOW6 40
-#define WKBD_WINDOW7 41
-#define WKBD_WINDOW8 42
-#define WKBD_WINDOW9 43
-#define WKBD_WINDOW10 44
+ /* Clip */
+ WKBD_CLIPLOWER,
+ WKBD_CLIPRAISE,
+ WKBD_CLIPRAISELOWER,
-#define WKBD_SWITCH_SCREEN 45
+ /* workspace */
+ WKBD_WORKSPACE1,
+ WKBD_WORKSPACE2,
+ WKBD_WORKSPACE3,
+ WKBD_WORKSPACE4,
+ WKBD_WORKSPACE5,
+ WKBD_WORKSPACE6,
+ WKBD_WORKSPACE7,
+ WKBD_WORKSPACE8,
+ WKBD_WORKSPACE9,
+ WKBD_WORKSPACE10,
+ WKBD_NEXTWORKSPACE,
+ WKBD_PREVWORKSPACE,
+ WKBD_NEXTWSLAYER,
+ WKBD_PREVWSLAYER,
+
+ /* window shortcuts */
+ WKBD_WINDOW1,
+ WKBD_WINDOW2,
+ WKBD_WINDOW3,
+ WKBD_WINDOW4,
+ WKBD_WINDOW5,
+ WKBD_WINDOW6,
+ WKBD_WINDOW7,
+ WKBD_WINDOW8,
+ WKBD_WINDOW9,
+ WKBD_WINDOW10,
+
+ /* screen */
+ WKBD_SWITCH_SCREEN,
#ifdef KEEP_XKB_LOCK_STATUS
-# define WKBD_TOGGLE 46
-# define WKBD_TMP 47
-#else
-# define WKBD_TMP 46
+ WKBD_TOGGLE,
#endif
#ifdef VIRTUAL_DESKTOP
-# define WKBD_VDESK_LEFT WKBD_TMP
-# define WKBD_VDESK_RIGHT (WKBD_TMP+1)
-# define WKBD_VDESK_UP (WKBD_TMP+2)
-# define WKBD_VDESK_DOWN (WKBD_TMP+3)
-# define WKBD_LAST (WKBD_TMP+4)
-#else
-# define WKBD_LAST WKBD_TMP
-#endif /* VIRTUAL_DESKTOP */
-
+ WKBD_VDESK_LEFT,
+ WKBD_VDESK_RIGHT,
+ WKBD_VDESK_UP,
+ WKBD_VDESK_DOWN,
+#endif
+ /* keep this last */
+ WKBD_LAST
+};
typedef struct WShortKey {
unsigned int modifier;
--
[-]
mkdir /nonexistent
--
To unsubscribe, send mail to [email protected].