diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/event.c | 4 | ||||
-rw-r--r-- | src/menu.c | 1 | ||||
-rw-r--r-- | src/menu.h | 1 | ||||
-rw-r--r-- | src/parse.c | 10 | ||||
-rw-r--r-- | src/root.c | 20 | ||||
-rw-r--r-- | src/root.h | 11 |
6 files changed, 22 insertions, 25 deletions
diff --git a/src/event.c b/src/event.c index 05218d8..e95aee8 100644 --- a/src/event.c +++ b/src/event.c @@ -440,7 +440,7 @@ void HandleKeyPress(const XKeyEvent *event) { Restart(); break; case KEY_EXIT: - Exit(); + Exit(1); break; default: break; @@ -773,7 +773,7 @@ void HandleClientMessage(const XClientMessageEvent *event) { if(event->message_type == atoms[ATOM_JWM_RESTART]) { Restart(); } else if(event->message_type == atoms[ATOM_JWM_EXIT]) { - Exit(); + Exit(1); } else if(event->message_type == atoms[ATOM_NET_CURRENT_DESKTOP]) { ChangeDesktop(event->data.l[0]); } else { @@ -174,6 +174,7 @@ void DestroyMenu(Menu *menu) { } switch(menu->items->action.type) { case MA_EXECUTE: + case MA_EXIT_NOW: case MA_EXIT: if(menu->items->action.data.str) { Release(menu->items->action.data.str); @@ -26,6 +26,7 @@ typedef enum { MA_KILL, MA_CLOSE, MA_EXIT, + MA_EXIT_NOW, MA_RESTART } MenuActionType; diff --git a/src/parse.c b/src/parse.c index 65e3197..45a0470 100644 --- a/src/parse.c +++ b/src/parse.c @@ -649,11 +649,10 @@ MenuItem *ParseMenuItem(const TokenNode *start, Menu *menu, } value = FindAttribute(start->attributes, CONFIRM_ATTRIBUTE); - if(value && !strcmp(value, FALSE_VALUE)) { - SetShowExitConfirmation(0); - } else { - SetShowExitConfirmation(1); - } + if(value && !strcmp(value, FALSE_VALUE)) + last->action.type = MA_EXIT_NOW; + else + last->action.type = MA_EXIT; value = FindAttribute(start->attributes, LABEL_ATTRIBUTE); if(!value) { @@ -664,7 +663,6 @@ MenuItem *ParseMenuItem(const TokenNode *start, Menu *menu, value = FindAttribute(start->attributes, ICON_ATTRIBUTE); last->iconName = CopyString(value); - last->action.type = MA_EXIT; last->action.data.str = CopyString(start->value); break; @@ -18,7 +18,6 @@ #define ROOT_MENU_COUNT 10 static Menu *rootMenu[ROOT_MENU_COUNT]; -static int showExitConfirmation = 1; static void ExitHandler(ClientNode *np); static void PatchRootMenu(Menu *menu); @@ -131,12 +130,6 @@ void SetRootMenu(const char *indexes, Menu *m) { /*************************************************************************** ***************************************************************************/ -void SetShowExitConfirmation(int v) { - showExitConfirmation = v; -} - -/*************************************************************************** - ***************************************************************************/ int IsRootMenuDefined(int index) { if(index >= 0 && index < ROOT_MENU_COUNT && rootMenu[index]) { return 1; @@ -228,8 +221,8 @@ void Restart() { /*************************************************************************** ***************************************************************************/ -void Exit() { - if(showExitConfirmation) { +void Exit(int confirm) { + if(confirm) { ShowConfirmDialog(NULL, ExitHandler, "Exit JWM", "Are you sure?", @@ -251,12 +244,19 @@ void RunRootCommand(const MenuAction *action) { case MA_RESTART: Restart(); break; + case MA_EXIT_NOW: + if(exitCommand) { + Release(exitCommand); + } + exitCommand = CopyString(action->data.str); + Exit(0); + break; case MA_EXIT: if(exitCommand) { Release(exitCommand); } exitCommand = CopyString(action->data.str); - Exit(); + Exit(1); break; case MA_DESKTOP: ChangeDesktop(action->data.i); @@ -25,11 +25,6 @@ void DestroyRootMenu(); */ void SetRootMenu(const char *indexes, struct Menu *m); -/** Set whether a confirmation dialog is displayed on exit. - * @param v 1 to display confirmation, 0 to just exit. - */ -void SetShowExitConfirmation(int v); - /** Determine if a root menu is defined for the specified index. * @return 1 if it is defined, 0 if not. */ @@ -58,8 +53,10 @@ void RunCommand(const char *command); /** Restart the window manager. */ void Restart(); -/** Exit the window manager. */ -void Exit(); +/** Exit the window manager. + * @param confirm Whether to prompt for confirmation. + */ +void Exit(int confirm); #endif |