Imagine my surprise when my Fedora 16 machine yum updated my
home-brewed Window Maker RPM with an "official" wmaker-crm build.
Good job whoever is responsible for that.
But imagine my dismay when I found I couldn't use the h/j/k/l keys
to select menu options any longer. The packager had not #defined
ARROWLESS_KBD, which is reasonable since no one except me ever uses it.
I thought the best solution would be to convert the #define into a
wPreferences option, which I called ViKeyMenus, and make it FALSE by
default so everyone else could carry on as normal.
Luckily it turned out to be easy. Unluckily it involved moving
buttons around in WPrefs. It looks OK in my font but I was never any
good at UI stuff so someone should check over it.
From bdb38e35a684bffe35f04a403227fcf06a89bd8f Mon Sep 17 00:00:00 2001
From: Iain Patterson <[email protected]>
Date: Fri, 10 Feb 2012 11:02:25 +0000
Subject: [PATCH] Made ARROWLESS_KBD a preference.
Replace the ARROWLESS_KBD #define with the ViKeyMenus preference.
When ViKeyMenus is TRUE, users can type h/j/k/l to scroll around menus.
Since ARROWLESS_KBD was previously undefined by default, ViKeyMenus is
FALSE by default.
---
WPrefs.app/MenuPreferences.c | 14 +++++++++++---
src/WindowMaker.h | 1 +
src/defaults.c | 2 ++
src/menu.c | 32 ++++++++++++++++++++------------
src/wconfig.h.in | 3 ---
5 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/WPrefs.app/MenuPreferences.c b/WPrefs.app/MenuPreferences.c
index 8d270ab..a579858 100644
--- a/WPrefs.app/MenuPreferences.c
+++ b/WPrefs.app/MenuPreferences.c
@@ -41,6 +41,7 @@ typedef struct _Panel {
WMFrame *optF;
WMButton *autoB;
+ WMButton *autoC;
WMButton *wrapB;
} _Panel;
@@ -64,6 +65,8 @@ static void showData(_Panel * panel)
WMSetButtonSelected(panel->wrapB, GetBoolForKey("WrapMenus"));
WMSetButtonSelected(panel->autoB, GetBoolForKey("ScrollableMenus"));
+
+ WMSetButtonSelected(panel->autoC, GetBoolForKey("ViKeyMenus"));
}
static void storeData(_Panel * panel)
@@ -80,6 +83,7 @@ static void storeData(_Panel * panel)
SetBoolForKey(WMGetButtonSelected(panel->wrapB), "WrapMenus");
SetBoolForKey(WMGetButtonSelected(panel->autoB), "ScrollableMenus");
+ SetBoolForKey(WMGetButtonSelected(panel->autoC), "ViKeyMenus");
}
static void createPanel(Panel * p)
@@ -184,8 +188,8 @@ static void createPanel(Panel * p)
/***************** Options ****************/
panel->optF = WMCreateFrame(panel->box);
- WMResizeWidget(panel->optF, 475, 80);
- WMMoveWidget(panel->optF, 25, 130);
+ WMResizeWidget(panel->optF, 475, 96);
+ WMMoveWidget(panel->optF, 25, 120);
panel->wrapB = WMCreateSwitchButton(panel->optF);
WMResizeWidget(panel->wrapB, 440, 32);
@@ -196,8 +200,12 @@ static void createPanel(Panel * p)
panel->autoB = WMCreateSwitchButton(panel->optF);
WMResizeWidget(panel->autoB, 440, 32);
- WMMoveWidget(panel->autoB, 25, 45);
+ WMMoveWidget(panel->autoB, 25, 34);
WMSetButtonText(panel->autoB, _("Scroll off-screen menus when pointer
is moved over them."));
+ panel->autoC = WMCreateSwitchButton(panel->optF);
+ WMResizeWidget(panel->autoC, 440, 32);
+ WMMoveWidget(panel->autoC, 25, 58);
+ WMSetButtonText(panel->autoC, _("Use h/j/k/l keys to select menu
options."));
WMMapSubwidgets(panel->optF);
diff --git a/src/WindowMaker.h b/src/WindowMaker.h
index 5168910..c0560a7 100644
--- a/src/WindowMaker.h
+++ b/src/WindowMaker.h
@@ -324,6 +324,7 @@ typedef struct WPreferences {
char opaque_move_resize_keyboard; /* update window position during
move,resize with keyboard */
char wrap_menus; /* wrap menus at edge of screen */
char scrollable_menus; /* let them be scrolled */
+ char vi_key_menus; /* use h/j/k/l to select */
char align_menus; /* align menu with their parents */
char use_saveunders; /* turn on SaveUnders for menus, icons
etc. */
char no_window_over_dock;
diff --git a/src/defaults.c b/src/defaults.c
index 70a372a..2b6efd6 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -391,6 +391,8 @@ WDefaultEntry optionList[] = {
&wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
{"AlignSubmenus", "NO", NULL,
&wPreferences.align_menus, getBool, NULL, NULL, NULL},
+ {"ViKeyMenus", "NO", NULL,
+ &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
{"OpenTransientOnOwnerWorkspace", "NO", NULL,
&wPreferences.open_transients_with_parent, getBool, NULL, NULL,
NULL},
{"WindowPlacement", "auto", sePlacements,
diff --git a/src/menu.c b/src/menu.c
index dd84ca2..5286899 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -892,6 +892,26 @@ static int keyboardMenu(WMenu * menu)
switch (event.type) {
case KeyPress:
ksym = XLookupKeysym(&event.xkey, 0);
+ if (wPreferences.vi_key_menus) {
+ switch (ksym) {
+ case XK_h:
+ ksym = XK_Left;
+ break;
+
+ case XK_j:
+ ksym = XK_Down;
+ break;
+
+ case XK_k:
+ ksym = XK_Up;
+ break;
+
+ case XK_l:
+ ksym = XK_Right;
+ break;
+
+ }
+ }
switch (ksym) {
case XK_Escape:
done = 1;
@@ -914,9 +934,6 @@ static int keyboardMenu(WMenu * menu)
break;
case XK_Up:
-#ifdef ARROWLESS_KBD
- case XK_k:
-#endif
#ifdef XK_KP_Up
case XK_KP_Up:
#endif
@@ -928,9 +945,6 @@ static int keyboardMenu(WMenu * menu)
break;
case XK_Down:
-#ifdef ARROWLESS_KBD
- case XK_j:
-#endif
#ifdef XK_KP_Down
case XK_KP_Down:
#endif
@@ -944,9 +958,6 @@ static int keyboardMenu(WMenu * menu)
break;
case XK_Right:
-#ifdef ARROWLESS_KBD
- case XK_l:
-#endif
#ifdef XK_KP_Right
case XK_KP_Right:
#endif
@@ -970,9 +981,6 @@ static int keyboardMenu(WMenu * menu)
break;
case XK_Left:
-#ifdef ARROWLESS_KBD
- case XK_h:
-#endif
#ifdef XK_KP_Left
case XK_KP_Left:
#endif
diff --git a/src/wconfig.h.in b/src/wconfig.h.in
index 5b70e53..855d7df 100644
--- a/src/wconfig.h.in
+++ b/src/wconfig.h.in
@@ -348,9 +348,6 @@
#define KEY_CONTROL_WINDOW_WEIGHT 1
-/* if your keyboard don't have arrow keys */
-#undef ARROWLESS_KBD
-
/* don't put titles in miniwindows */
#undef NO_MINIWINDOW_TITLES
--
1.7.7.6