infobar: Add launcher ! (alt-p in the basic configuration).
This commit is contained in:
@@ -63,7 +63,8 @@ conf_init_func_list(void)
|
|||||||
{"screen_select", uicb_screen_select },
|
{"screen_select", uicb_screen_select },
|
||||||
{"screen_next", uicb_screen_next },
|
{"screen_next", uicb_screen_next },
|
||||||
{"screen_prev", uicb_screen_prev },
|
{"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));
|
func_list = emalloc(LEN(tmp_list), sizeof(func_name_list_t));
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ infobar_init(void)
|
|||||||
barwin_map_subwin(infobar[sc].tags[i]);
|
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,
|
infobar[sc].layout_button = barwin_create(infobar[sc].bar->win, j + PAD / 2, 0,
|
||||||
textw(tags[sc][seltag[sc]].layout.symbol) + PAD,
|
textw(tags[sc][seltag[sc]].layout.symbol) + PAD,
|
||||||
infobar[sc].geo.height,
|
infobar[sc].geo.height,
|
||||||
@@ -199,3 +199,81 @@ uicb_infobar_togglepos(uicb_t cmd)
|
|||||||
|
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,8 @@
|
|||||||
#define CHECK(x) if(!(x)) return
|
#define CHECK(x) if(!(x)) return
|
||||||
#define LEN(x) (sizeof(x) / sizeof((x)[0]))
|
#define LEN(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
#define deb(p) fprintf(stderr, "debug: %d\n", (p))
|
#define deb(p) fprintf(stderr, "debug: %d\n", (p))
|
||||||
#define PAD 14
|
#define PAD (14)
|
||||||
|
#define LPROMPT "Exec: "
|
||||||
|
|
||||||
/* barwin.c */
|
/* barwin.c */
|
||||||
BarWindow *barwin_create(Window parent,
|
BarWindow *barwin_create(Window parent,
|
||||||
@@ -119,6 +120,7 @@ void infobar_draw_layout(int sc);
|
|||||||
void infobar_draw_taglist(int sc);
|
void infobar_draw_taglist(int sc);
|
||||||
void infobar_destroy(void);
|
void infobar_destroy(void);
|
||||||
void uicb_infobar_togglepos(uicb_t);
|
void uicb_infobar_togglepos(uicb_t);
|
||||||
|
void uicb_launcher(uicb_t);
|
||||||
|
|
||||||
/* client.c */
|
/* client.c */
|
||||||
void client_attach(Client *c);
|
void client_attach(Client *c);
|
||||||
|
|||||||
1
wmfsrc
1
wmfsrc
@@ -118,6 +118,7 @@ keys
|
|||||||
key { mod = {"Alt", "Shift"} key = "l" func = "set_nmaster" cmd = "+1" }
|
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", "Shift"} key = "h" func = "set_nmaster" cmd = "-1" }
|
||||||
|
|
||||||
|
key { mod = { "Alt" } key = "p" func = "launcher" }
|
||||||
|
|
||||||
# tag manipulation keybind
|
# tag manipulation keybind
|
||||||
key { mod = {"Alt"} key = "F1" func = "tag" cmd = "1" }
|
key { mod = {"Alt"} key = "F1" func = "tag" cmd = "1" }
|
||||||
|
|||||||
Reference in New Issue
Block a user