A common feature in several desktop environments is the ability to bring up a "run application" dialog via a keyboard shortcut (frequently Mod1+F2). This feature has been available to Window Maker users only through the root menu.
This patch adds the ability for a user to set up a keyboard shortcut to accomplish this, either via WPrefs or by editing ~/GNUstep/Defaults/WindowMaker, e.g., with RunKey = "Mod1+F2"; Code from the execCommand function in rootmenu.c has been copied almost directly into the handleKeyPress function in misc.c to accomplish this. --- WPrefs.app/KeyboardShortcuts.c | 1 + src/defaults.c | 2 ++ src/event.c | 19 +++++++++++++++++++ src/keybind.h | 3 +++ 4 files changed, 25 insertions(+) diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c index 19e9905..ae23c18 100644 --- a/WPrefs.app/KeyboardShortcuts.c +++ b/WPrefs.app/KeyboardShortcuts.c @@ -147,6 +147,7 @@ static const struct { /* Misc. */ { "WindowRelaunchKey", N_("Launch new instance of application") }, { "ScreenSwitchKey", N_("Switch to Next Screen/Monitor") }, + { "RunKey", N_("Run application") }, { "DockRaiseLowerKey", N_("Raise/Lower Dock") }, { "ClipRaiseLowerKey", N_("Raise/Lower Clip") } #ifdef XKB_MODELOCK diff --git a/src/defaults.c b/src/defaults.c index c5fd853..7d66372 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -721,6 +721,8 @@ WDefaultEntry optionList[] = { NULL, getKeybind, setKeyGrab, NULL, NULL}, {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN, NULL, getKeybind, setKeyGrab, NULL, NULL}, + {"RunKey", "None", (void *)WKBD_RUN, + NULL, getKeybind, setKeyGrab, NULL, NULL}, #ifdef KEEP_XKB_LOCK_STATUS {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE, diff --git a/src/event.c b/src/event.c index 73614cf..e85de54 100644 --- a/src/event.c +++ b/src/event.c @@ -1715,6 +1715,25 @@ static void handleKeyPress(XEvent * event) } break; + case WKBD_RUN: + { + char *cmdline; + + cmdline = ExpandOptions(scr, _("exec %a(Run,Type command to run:)")); + + XGrabPointer(dpy, scr->root_win, True, 0, + GrabModeAsync, GrabModeAsync, None, wPreferences.cursor[WCUR_WAIT], CurrentTime); + XSync(dpy, 0); + + if (cmdline) { + ExecuteShellCommand(scr, cmdline); + wfree(cmdline); + } + XUngrabPointer(dpy, CurrentTime); + XSync(dpy, 0); + break; + } + case WKBD_NEXTWSLAYER: case WKBD_PREVWSLAYER: { diff --git a/src/keybind.h b/src/keybind.h index 6576a16..37ace18 100644 --- a/src/keybind.h +++ b/src/keybind.h @@ -116,6 +116,9 @@ enum { /* screen */ WKBD_SWITCH_SCREEN, + /* open "run" dialog */ + WKBD_RUN, + #ifdef KEEP_XKB_LOCK_STATUS WKBD_TOGGLE, #endif -- 1.9.1 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.