mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 04:20:27 +01:00
Allow exit panel to be bound to a key shortcut
While debugging the save/restore workspace state, I found quite useful to be able to exit windowmaker using a key shortcut.
This commit is contained in:
committed by
Carlos R. Mafra
parent
630e9292c2
commit
fabd4252ab
@@ -156,6 +156,7 @@ static const struct {
|
|||||||
{ "WindowRelaunchKey", N_("Launch new instance of application") },
|
{ "WindowRelaunchKey", N_("Launch new instance of application") },
|
||||||
{ "ScreenSwitchKey", N_("Switch to Next Screen/Monitor") },
|
{ "ScreenSwitchKey", N_("Switch to Next Screen/Monitor") },
|
||||||
{ "RunKey", N_("Run application") },
|
{ "RunKey", N_("Run application") },
|
||||||
|
{ "ExitKey", N_("Exit Window Maker") },
|
||||||
{ "DockRaiseLowerKey", N_("Raise/Lower Dock") },
|
{ "DockRaiseLowerKey", N_("Raise/Lower Dock") },
|
||||||
{ "ClipRaiseLowerKey", N_("Raise/Lower Clip") }
|
{ "ClipRaiseLowerKey", N_("Raise/Lower Clip") }
|
||||||
#ifdef XKB_MODELOCK
|
#ifdef XKB_MODELOCK
|
||||||
|
|||||||
@@ -232,6 +232,7 @@
|
|||||||
WindowRelaunchKey = None;
|
WindowRelaunchKey = None;
|
||||||
ScreenSwitchKey = None;
|
ScreenSwitchKey = None;
|
||||||
RunKey = None;
|
RunKey = None;
|
||||||
|
ExitKey = None;
|
||||||
NormalCursor = (builtin, left_ptr);
|
NormalCursor = (builtin, left_ptr);
|
||||||
ArrowCursor = (builtin, top_left_arrow);
|
ArrowCursor = (builtin, top_left_arrow);
|
||||||
MoveCursor = (builtin, fleur);
|
MoveCursor = (builtin, fleur);
|
||||||
|
|||||||
@@ -788,6 +788,8 @@ WDefaultEntry optionList[] = {
|
|||||||
NULL, getKeybind, setKeyGrab, NULL, NULL},
|
NULL, getKeybind, setKeyGrab, NULL, NULL},
|
||||||
{"RunKey", "None", (void *)WKBD_RUN,
|
{"RunKey", "None", (void *)WKBD_RUN,
|
||||||
NULL, getKeybind, setKeyGrab, NULL, NULL},
|
NULL, getKeybind, setKeyGrab, NULL, NULL},
|
||||||
|
{"ExitKey", "None", (void *)WKBD_EXIT,
|
||||||
|
NULL, getKeybind, setKeyGrab, NULL, NULL},
|
||||||
|
|
||||||
#ifdef KEEP_XKB_LOCK_STATUS
|
#ifdef KEEP_XKB_LOCK_STATUS
|
||||||
{"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
|
{"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
|
||||||
|
|||||||
@@ -1856,6 +1856,13 @@ static void handleKeyPress(XEvent * event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WKBD_EXIT:
|
||||||
|
{
|
||||||
|
/* quick mode is not allowed to prevent inadvertently call */
|
||||||
|
ExecuteExitCommand(scr, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WKBD_NEXTWSLAYER:
|
case WKBD_NEXTWSLAYER:
|
||||||
case WKBD_PREVWSLAYER:
|
case WKBD_PREVWSLAYER:
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -145,6 +145,9 @@ enum {
|
|||||||
/* open "run" dialog */
|
/* open "run" dialog */
|
||||||
WKBD_RUN,
|
WKBD_RUN,
|
||||||
|
|
||||||
|
/* open "exit" dialog */
|
||||||
|
WKBD_EXIT,
|
||||||
|
|
||||||
#ifdef KEEP_XKB_LOCK_STATUS
|
#ifdef KEEP_XKB_LOCK_STATUS
|
||||||
WKBD_TOGGLE,
|
WKBD_TOGGLE,
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
41
src/misc.c
41
src/misc.c
@@ -53,6 +53,7 @@
|
|||||||
#include "xmodifier.h"
|
#include "xmodifier.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
#include "shutdown.h"
|
||||||
|
|
||||||
|
|
||||||
#define ICON_SIZE wPreferences.icon_size
|
#define ICON_SIZE wPreferences.icon_size
|
||||||
@@ -679,6 +680,46 @@ char *ExpandOptions(WScreen *scr, const char *cmdline)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExecuteExitCommand(WScreen *scr, long quickmode)
|
||||||
|
{
|
||||||
|
static int inside = 0;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
/* prevent reentrant calls */
|
||||||
|
if (inside)
|
||||||
|
return;
|
||||||
|
inside = 1;
|
||||||
|
|
||||||
|
#define R_CANCEL 0
|
||||||
|
#define R_EXIT 1
|
||||||
|
|
||||||
|
result = R_CANCEL;
|
||||||
|
|
||||||
|
if (quickmode == M_QUICK) {
|
||||||
|
result = R_EXIT;
|
||||||
|
} else {
|
||||||
|
int r, oldSaveSessionFlag;
|
||||||
|
|
||||||
|
oldSaveSessionFlag = wPreferences.save_session_on_exit;
|
||||||
|
r = wExitDialog(scr, _("Exit"),
|
||||||
|
_("Are you sure you want to quit Window Maker?"), _("Exit"), _("Cancel"), NULL);
|
||||||
|
|
||||||
|
if (r == WAPRDefault) {
|
||||||
|
result = R_EXIT;
|
||||||
|
} else if (r == WAPRAlternate) {
|
||||||
|
/* Don't modify the "save session on exit" flag if the
|
||||||
|
* user canceled the operation. */
|
||||||
|
wPreferences.save_session_on_exit = oldSaveSessionFlag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result == R_EXIT)
|
||||||
|
Shutdown(WSExitMode);
|
||||||
|
|
||||||
|
#undef R_EXIT
|
||||||
|
#undef R_CANCEL
|
||||||
|
inside = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ExecuteInputCommand(WScreen *scr, const char *cmdline)
|
void ExecuteInputCommand(WScreen *scr, const char *cmdline)
|
||||||
{
|
{
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
#include "keybind.h"
|
#include "keybind.h"
|
||||||
#include "appicon.h"
|
#include "appicon.h"
|
||||||
|
|
||||||
|
#define M_QUICK 1
|
||||||
|
|
||||||
Bool wFetchName(Display *dpy, Window win, char **winname);
|
Bool wFetchName(Display *dpy, Window win, char **winname);
|
||||||
Bool wGetIconName(Display *dpy, Window win, char **iconname);
|
Bool wGetIconName(Display *dpy, Window win, char **iconname);
|
||||||
Bool UpdateDomainFile(WDDomain * domain);
|
Bool UpdateDomainFile(WDDomain * domain);
|
||||||
@@ -46,6 +48,7 @@ char *ShrinkString(WMFont *font, const char *string, int width);
|
|||||||
char *FindImage(const char *paths, const char *file);
|
char *FindImage(const char *paths, const char *file);
|
||||||
char *ExpandOptions(WScreen * scr, const char *cmdline);
|
char *ExpandOptions(WScreen * scr, const char *cmdline);
|
||||||
void ExecuteInputCommand(WScreen *scr, const char *cmdline);
|
void ExecuteInputCommand(WScreen *scr, const char *cmdline);
|
||||||
|
void ExecuteExitCommand(WScreen *scr, long quickmode);
|
||||||
char *GetShortcutString(const char *text);
|
char *GetShortcutString(const char *text);
|
||||||
char *GetShortcutKey(WShortKey key);
|
char *GetShortcutKey(WShortKey key);
|
||||||
char *EscapeWM_CLASS(const char *name, const char *class);
|
char *EscapeWM_CLASS(const char *name, const char *class);
|
||||||
|
|||||||
@@ -142,8 +142,6 @@ static Shortcut *shortcutList = NULL;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define M_QUICK 1
|
|
||||||
|
|
||||||
/* menu commands */
|
/* menu commands */
|
||||||
|
|
||||||
static void execCommand(WMenu * menu, WMenuEntry * entry)
|
static void execCommand(WMenu * menu, WMenuEntry * entry)
|
||||||
@@ -153,42 +151,8 @@ static void execCommand(WMenu * menu, WMenuEntry * entry)
|
|||||||
|
|
||||||
static void exitCommand(WMenu * menu, WMenuEntry * entry)
|
static void exitCommand(WMenu * menu, WMenuEntry * entry)
|
||||||
{
|
{
|
||||||
static int inside = 0;
|
ExecuteExitCommand(menu->frame->screen_ptr, (long)entry->clientdata);
|
||||||
int result;
|
|
||||||
|
|
||||||
/* prevent reentrant calls */
|
|
||||||
if (inside)
|
|
||||||
return;
|
|
||||||
inside = 1;
|
|
||||||
|
|
||||||
#define R_CANCEL 0
|
|
||||||
#define R_EXIT 1
|
|
||||||
|
|
||||||
result = R_CANCEL;
|
|
||||||
|
|
||||||
if ((long)entry->clientdata == M_QUICK) {
|
|
||||||
result = R_EXIT;
|
|
||||||
} else {
|
|
||||||
int r, oldSaveSessionFlag;
|
|
||||||
|
|
||||||
oldSaveSessionFlag = wPreferences.save_session_on_exit;
|
|
||||||
r = wExitDialog(menu->frame->screen_ptr, _("Exit"),
|
|
||||||
_("Are you sure you want to quit Window Maker?"), _("Exit"), _("Cancel"), NULL);
|
|
||||||
|
|
||||||
if (r == WAPRDefault) {
|
|
||||||
result = R_EXIT;
|
|
||||||
} else if (r == WAPRAlternate) {
|
|
||||||
/* Don't modify the "save session on exit" flag if the
|
|
||||||
* user canceled the operation. */
|
|
||||||
wPreferences.save_session_on_exit = oldSaveSessionFlag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (result == R_EXIT)
|
|
||||||
Shutdown(WSExitMode);
|
|
||||||
|
|
||||||
#undef R_EXIT
|
|
||||||
#undef R_CANCEL
|
|
||||||
inside = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shutdownCommand(WMenu * menu, WMenuEntry * entry)
|
static void shutdownCommand(WMenu * menu, WMenuEntry * entry)
|
||||||
|
|||||||
Reference in New Issue
Block a user