1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

Factorize duplicate run command code

Run command from the menu and run command from the key shortcut are from two different codes.
Merge them into one function instead.
This commit is contained in:
David Maciejak
2023-02-18 19:30:29 +08:00
committed by Carlos R. Mafra
parent 14d1b8197a
commit 630e9292c2
4 changed files with 21 additions and 29 deletions

View File

@@ -1852,21 +1852,7 @@ static void handleKeyPress(XEvent * event)
case WKBD_RUN: case WKBD_RUN:
{ {
char *cmdline; ExecuteInputCommand(scr, _("exec %A(Run, Type command:)"));
cmdline = ExpandOptions(scr, _("exec %A(Run,Type command to run:)"));
if (cmdline) {
XGrabPointer(dpy, scr->root_win, True, 0,
GrabModeAsync, GrabModeAsync, None, wPreferences.cursor[WCUR_WAIT], CurrentTime);
XSync(dpy, False);
ExecuteShellCommand(scr, cmdline);
wfree(cmdline);
XUngrabPointer(dpy, CurrentTime);
XSync(dpy, False);
}
break; break;
} }

View File

@@ -679,6 +679,24 @@ char *ExpandOptions(WScreen *scr, const char *cmdline)
return NULL; return NULL;
} }
void ExecuteInputCommand(WScreen *scr, const char *cmdline)
{
char *cmd;
cmd = ExpandOptions(scr, cmdline);
if (cmd) {
XGrabPointer(dpy, scr->root_win, True, 0,
GrabModeAsync, GrabModeAsync, None, wPreferences.cursor[WCUR_WAIT], CurrentTime);
XSync(dpy, False);
ExecuteShellCommand(scr, cmd);
wfree(cmd);
XUngrabPointer(dpy, CurrentTime);
XSync(dpy, False);
}
}
void ParseWindowName(WMPropList *value, char **winstance, char **wclass, const char *where) void ParseWindowName(WMPropList *value, char **winstance, char **wclass, const char *where)
{ {
char *name; char *name;

View File

@@ -45,6 +45,7 @@ void SendHelperMessage(WScreen *scr, char type, int workspace, const char *msg);
char *ShrinkString(WMFont *font, const char *string, int width); 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);
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);

View File

@@ -148,20 +148,7 @@ static Shortcut *shortcutList = NULL;
static void execCommand(WMenu * menu, WMenuEntry * entry) static void execCommand(WMenu * menu, WMenuEntry * entry)
{ {
char *cmdline; ExecuteInputCommand(menu->frame->screen_ptr, (char *)entry->clientdata);
cmdline = ExpandOptions(menu->frame->screen_ptr, (char *)entry->clientdata);
XGrabPointer(dpy, menu->frame->screen_ptr->root_win, True, 0,
GrabModeAsync, GrabModeAsync, None, wPreferences.cursor[WCUR_WAIT], CurrentTime);
XSync(dpy, 0);
if (cmdline) {
ExecuteShellCommand(menu->frame->screen_ptr, cmdline);
wfree(cmdline);
}
XUngrabPointer(dpy, CurrentTime);
XSync(dpy, 0);
} }
static void exitCommand(WMenu * menu, WMenuEntry * entry) static void exitCommand(WMenu * menu, WMenuEntry * entry)