diff --git a/src/config.c b/src/config.c index e132157..13de07a 100644 --- a/src/config.c +++ b/src/config.c @@ -63,7 +63,8 @@ conf_init_func_list(void) {"screen_select", uicb_screen_select }, {"screen_next", uicb_screen_next }, {"screen_prev", uicb_screen_prev }, - {"reload", uicb_reload } + {"reload", uicb_reload }, + {"launcher", uicb_launcher } }; func_list = emalloc(LEN(tmp_list), sizeof(func_name_list_t)); diff --git a/src/infobar.c b/src/infobar.c index 2b825bf..a68105d 100644 --- a/src/infobar.c +++ b/src/infobar.c @@ -66,7 +66,7 @@ infobar_init(void) barwin_map_subwin(infobar[sc].tags[i]); } - /* Create layout switch & layout type switch barwindow */ + /* Create layout switch barwindow */ infobar[sc].layout_button = barwin_create(infobar[sc].bar->win, j + PAD / 2, 0, textw(tags[sc][seltag[sc]].layout.symbol) + PAD, infobar[sc].geo.height, @@ -199,3 +199,81 @@ uicb_infobar_togglepos(uicb_t cmd) return; } + +void +uicb_launcher(uicb_t cmd) +{ + XEvent ev; + KeySym ks; + char tmp[32] = { 0 }; + char buf[512] = { 0 }; + int pos = 0; + int lrun = 1; + BarWindow *launch = barwin_create(infobar[screen_get_sel()].bar->win, + /* X */ + (infobar[selscreen].layout_button->geo.x + + textw(tags[selscreen][seltag[selscreen]].layout.symbol) + PAD), + /* Y */ + 0, + /* WIDTH */ + (sgeo[selscreen].width + - (infobar[selscreen].layout_button->geo.x + + textw(tags[selscreen][seltag[selscreen]].layout.symbol) + PAD)), + /* HEIGHT */ + infobar[selscreen].geo.height, + /* COLOR */ + conf.colors.bar, conf.colors.text, + /* OPTION */ + False, False, False); + barwin_map(launch); + barwin_map_subwin(launch); + barwin_refresh_color(launch); + /* Draw Prompt */ + barwin_draw_text(launch, 2, font->height, LPROMPT); + barwin_refresh(launch); + + while(XGrabKeyboard(dpy, ROOT, True, GrabModeAsync, + GrabModeAsync, CurrentTime) != GrabSuccess) + sleep(500); + + + while(lrun) + { + if(ev.type == KeyPress) + { + XLookupString(&ev.xkey, tmp, sizeof(tmp), &ks, 0); + + switch(ks) + { + case XK_Return: + uicb_spawn(buf); + lrun = 0; + break; + case XK_Escape: + lrun = 0; + break; + case XK_BackSpace: + if(pos) + buf[--pos] = 0; + break; + default: + strncat(buf, tmp, sizeof(buf)); + ++pos; + break; + } + barwin_refresh_color(launch); + barwin_draw_text(launch, 2, font->height, LPROMPT); + barwin_draw_text(launch, textw(LPROMPT) + 2, font->height, buf); + barwin_refresh(launch); + } + /* else getevent(ev); */ + XNextEvent(dpy, &ev); + } + XUngrabKeyboard(dpy, CurrentTime); + barwin_delete(launch); + + return; +} + + + diff --git a/src/wmfs.h b/src/wmfs.h index 622fe37..63b0302 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -84,7 +84,8 @@ #define CHECK(x) if(!(x)) return #define LEN(x) (sizeof(x) / sizeof((x)[0])) #define deb(p) fprintf(stderr, "debug: %d\n", (p)) -#define PAD 14 +#define PAD (14) +#define LPROMPT "Exec: " /* barwin.c */ BarWindow *barwin_create(Window parent, @@ -119,6 +120,7 @@ void infobar_draw_layout(int sc); void infobar_draw_taglist(int sc); void infobar_destroy(void); void uicb_infobar_togglepos(uicb_t); +void uicb_launcher(uicb_t); /* client.c */ void client_attach(Client *c); diff --git a/wmfsrc b/wmfsrc index 562bbd9..76d3cec 100644 --- a/wmfsrc +++ b/wmfsrc @@ -118,6 +118,7 @@ keys key { mod = {"Alt", "Shift"} key = "l" func = "set_nmaster" cmd = "+1" } key { mod = {"Alt", "Shift"} key = "h" func = "set_nmaster" cmd = "-1" } + key { mod = { "Alt" } key = "p" func = "launcher" } # tag manipulation keybind key { mod = {"Alt"} key = "F1" func = "tag" cmd = "1" }