mirror of https://github.com/0intro/wmii
added dynamic height calculation in all tools
This commit is contained in:
parent
ae5f40b906
commit
10266b4705
|
@ -135,7 +135,7 @@ void destroy_frame(Frame * f)
|
|||
|
||||
unsigned int tab_height(Frame * f)
|
||||
{
|
||||
if (_strtonum(f->file[F_TAB]->content, 0, 1))
|
||||
if (_strtonum(f->file[F_TAB]->content, 1, 1))
|
||||
return font->ascent + font->descent + 4;
|
||||
return 0;
|
||||
}
|
||||
|
@ -313,18 +313,14 @@ void draw_frame(void *frame, void *aux)
|
|||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
void handle_frame_buttonpress(XButtonEvent * e, Frame * f)
|
||||
void handle_frame_buttonpress(XButtonEvent *e, Frame *f)
|
||||
{
|
||||
Align align;
|
||||
size_t size = cext_sizeof(&f->clients);
|
||||
int bindex, cindex = e->x / f->rect.width / size;
|
||||
Client *c = cext_list_get_item(&f->clients, cindex);
|
||||
XRaiseWindow(dpy, f->win);
|
||||
if (get_sel_client() != c) {
|
||||
sel_client(c);
|
||||
draw_frame(f, nil);
|
||||
return;
|
||||
}
|
||||
cext_stack_top_item(&f->clients, c);
|
||||
sel_frame(f, cext_list_get_item_index(&f->area->page->areas, f->area) == 0);
|
||||
if (e->button == Button1) {
|
||||
align = cursor_to_align(f->cursor);
|
||||
if (align == CENTER)
|
||||
|
|
|
@ -57,6 +57,8 @@ static void deinit_float(Area *a)
|
|||
static Bool attach_float(Area *a, Client *c)
|
||||
{
|
||||
Frame *f = get_sel_frame_of_area(a);
|
||||
Bool center = False;
|
||||
|
||||
cext_attach_item(&a->clients, c);
|
||||
/* check for tabbing? */
|
||||
if (f && (((char *) f->file[F_LOCKED]->content)[0] == '1'))
|
||||
|
@ -65,10 +67,14 @@ static Bool attach_float(Area *a, Client *c)
|
|||
f = alloc_frame(&c->rect);
|
||||
attach_frame_to_area(a, f);
|
||||
cext_attach_item((Container *)a->aux, f);
|
||||
center = True;
|
||||
}
|
||||
attach_client_to_frame(f, c);
|
||||
if (a->page == get_sel_page())
|
||||
XMapRaised(dpy, f->win);
|
||||
XMapWindow(dpy, f->win);
|
||||
sel_frame(f, 1);
|
||||
if (center)
|
||||
center_pointer(f);
|
||||
draw_frame(f, nil);
|
||||
return True;
|
||||
}
|
||||
|
@ -93,3 +99,6 @@ static void resize_float(Frame *f, XRectangle *new, XPoint *pt)
|
|||
static Container *get_frames_float(Area *a) {
|
||||
return a->aux;
|
||||
}
|
||||
|
||||
|
||||
center_pointer(f);
|
||||
|
|
|
@ -592,6 +592,7 @@ void mouse_resize(Frame * f, Align align)
|
|||
}
|
||||
|
||||
|
||||
/* XXXX seems obsolete: */
|
||||
void drop_move(Frame *f, XRectangle *new, XPoint *pt)
|
||||
{
|
||||
Frame *f1, *f2;
|
||||
|
@ -616,3 +617,24 @@ void drop_move(Frame *f, XRectangle *new, XPoint *pt)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void center_pointer(Frame * f)
|
||||
{
|
||||
|
||||
Window dummy;
|
||||
int wex, wey, ex, ey, i;
|
||||
unsigned int dmask;
|
||||
if (!f)
|
||||
return;
|
||||
XQueryPointer(dpy, f->win, &dummy, &dummy, &i, &i, &wex, &wey, &dmask);
|
||||
XTranslateCoordinates(dpy, f->win, root, wex, wey, &ex, &ey, &dummy);
|
||||
if (blitz_ispointinrect(ex, ey, &f->rect))
|
||||
return;
|
||||
/* suppress EnterNotify's while mouse warping */
|
||||
XSelectInput(dpy, root, ROOT_MASK & ~StructureNotifyMask);
|
||||
XWarpPointer(dpy, None, f->win, 0, 0, 0, 0, f->rect.width / 2,
|
||||
f->rect.height / 2);
|
||||
XSync(dpy, False);
|
||||
XSelectInput(dpy, root, ROOT_MASK);
|
||||
|
||||
}
|
||||
|
|
|
@ -118,27 +118,6 @@ XRectangle *rectangles(unsigned int *num)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void center_pointer(Frame * f)
|
||||
{
|
||||
|
||||
Window dummy;
|
||||
int wex, wey, ex, ey, i;
|
||||
unsigned int dmask;
|
||||
if (!f)
|
||||
return;
|
||||
XQueryPointer(dpy, f->win, &dummy, &dummy, &i, &i, &wex, &wey, &dmask);
|
||||
XTranslateCoordinates(dpy, f->win, root, wex, wey, &ex, &ey, &dummy);
|
||||
if (blitz_ispointinrect(ex, ey, &f->rect))
|
||||
return;
|
||||
/* suppress EnterNotify's while mouse warping */
|
||||
XSelectInput(dpy, root, ROOT_MASK & ~StructureNotifyMask);
|
||||
XWarpPointer(dpy, None, f->win, 0, 0, 0, 0, f->rect.width / 2,
|
||||
f->rect.height / 2);
|
||||
XSync(dpy, False);
|
||||
XSelectInput(dpy, root, ROOT_MASK);
|
||||
|
||||
}
|
||||
|
||||
static void select_frame(void *obj, char *cmd)
|
||||
{
|
||||
Area *a;
|
||||
|
|
|
@ -260,6 +260,7 @@ Cursor cursor_for_motion(Frame * f, int x, int y);
|
|||
Align cursor_to_align(Cursor cursor);
|
||||
Align xy_to_align(XRectangle * rect, int x, int y);
|
||||
void drop_move(Frame * f, XRectangle * new, XPoint * pt);
|
||||
void center_pointer(Frame * f);
|
||||
|
||||
/* page.c */
|
||||
Page *get_sel_page();
|
||||
|
|
158
cmd/wmibar.c
158
cmd/wmibar.c
|
@ -48,6 +48,7 @@ static File *file[B_LAST];
|
|||
static Container items = {0};
|
||||
static Pixmap pmap;
|
||||
static XFontStruct *font;
|
||||
static Align align = SOUTH;
|
||||
|
||||
static Draw zero_draw = { 0 };
|
||||
|
||||
|
@ -75,7 +76,7 @@ static char *version[] = {
|
|||
static void usage()
|
||||
{
|
||||
fprintf(stderr, "%s",
|
||||
"usage: wmibar -s <socket file> [-v] [<x>,<y>,<width>,<height>]\n"
|
||||
"usage: wmibar -s <socket file> [-v]\n"
|
||||
" -s socket file\n" " -v version info\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -359,13 +360,17 @@ static void check_event(Connection * e)
|
|||
}
|
||||
}
|
||||
|
||||
static void update_geometry(char *size)
|
||||
static void update_geometry()
|
||||
{
|
||||
blitz_strtorect(&rect, &brect, size);
|
||||
if (!brect.width)
|
||||
brect.width = DisplayWidth(dpy, screen_num);
|
||||
if (!brect.height)
|
||||
brect.height = 20;
|
||||
brect = rect;
|
||||
brect.height = font->ascent + font->descent + 4;
|
||||
if (align == SOUTH)
|
||||
brect.y = rect.height - brect.height;
|
||||
XMoveResizeWindow(dpy, win, brect.x, brect.y, brect.width, brect.height);
|
||||
XSync(dpy, False);
|
||||
XFreePixmap(dpy, pmap);
|
||||
pmap = XCreatePixmap(dpy, win, brect.width, brect.height, DefaultDepth(dpy, screen_num));
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
static void handle_after_write(IXPServer * s, File * f)
|
||||
|
@ -383,15 +388,12 @@ static void handle_after_write(IXPServer * s, File * f)
|
|||
draw();
|
||||
}
|
||||
} else if (file[B_GEOMETRY] == f) {
|
||||
char *geom = file[B_GEOMETRY]->content;
|
||||
if (geom && strrchr(geom, ',')) {
|
||||
update_geometry(geom);
|
||||
XMoveResizeWindow(dpy, win, brect.x, brect.y,
|
||||
brect.width, brect.height);
|
||||
XSync(dpy, False);
|
||||
pmap = XCreatePixmap(dpy, win, brect.width, brect.height,
|
||||
DefaultDepth(dpy, screen_num));
|
||||
XSync(dpy, False);
|
||||
if (f->content) {
|
||||
if (!strncmp(f->content, "south", 6))
|
||||
align = SOUTH;
|
||||
else if(!strncmp(f->content, "north", 6))
|
||||
align = NORTH;
|
||||
update_geometry();
|
||||
draw_bar(0, 0);
|
||||
}
|
||||
} else if (file[B_CTL] == f) {
|
||||
|
@ -409,6 +411,8 @@ static void handle_after_write(IXPServer * s, File * f)
|
|||
} else if (file[B_FONT] == f) {
|
||||
XFreeFont(dpy, font);
|
||||
font = blitz_getfont(dpy, file[B_FONT]->content);
|
||||
update_geometry();
|
||||
draw_bar(0, 0);
|
||||
}
|
||||
check_event(0);
|
||||
}
|
||||
|
@ -417,11 +421,13 @@ static void handle_before_read(IXPServer * s, File * f)
|
|||
{
|
||||
char buf[64];
|
||||
if (f == file[B_GEOMETRY]) {
|
||||
snprintf(buf, sizeof(buf), "%d,%d,%d,%d", brect.x, brect.y, brect.width, brect.height);
|
||||
if (f->content)
|
||||
free(f->content);
|
||||
f->content = strdup(buf);
|
||||
f->size = strlen(buf);
|
||||
if (align == SOUTH)
|
||||
f->content = strdup("south");
|
||||
else
|
||||
f->content = strdup("north");
|
||||
f->size = strlen(f->content);
|
||||
} else if (f == file[B_NEW]) {
|
||||
snprintf(buf, sizeof(buf), "%d", id++);
|
||||
if (f->content)
|
||||
|
@ -433,61 +439,6 @@ static void handle_before_read(IXPServer * s, File * f)
|
|||
}
|
||||
}
|
||||
|
||||
static void run(char *geom)
|
||||
{
|
||||
XSetWindowAttributes wa;
|
||||
XGCValues gcv;
|
||||
|
||||
/* init */
|
||||
if (!(file[B_CTL] = ixp_create(ixps, "/ctl"))) {
|
||||
perror("wmibar: cannot connect IXP server");
|
||||
exit(1);
|
||||
}
|
||||
file[B_CTL]->after_write = handle_after_write;
|
||||
file[B_NEW] = ixp_create(ixps, "/new");
|
||||
file[B_NEW]->before_read = handle_before_read;
|
||||
file[B_FONT] = wmii_create_ixpfile(ixps, "/font", BLITZ_FONT);
|
||||
file[B_FONT]->after_write = handle_after_write;
|
||||
font = blitz_getfont(dpy, file[B_FONT]->content);
|
||||
file[B_BG_COLOR] = wmii_create_ixpfile(ixps, "/bgcolor", BLITZ_NORM_BG_COLOR);
|
||||
file[B_FG_COLOR] = wmii_create_ixpfile(ixps, "/fgcolor", BLITZ_NORM_FG_COLOR);
|
||||
file[B_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/bordercolor", BLITZ_NORM_BORDER_COLOR);
|
||||
file[B_GEOMETRY] = ixp_create(ixps, "/geometry");
|
||||
file[B_GEOMETRY]->before_read = handle_before_read;
|
||||
file[B_GEOMETRY]->after_write = handle_after_write;
|
||||
file[B_EXPANDABLE] = ixp_create(ixps, "/expandable");
|
||||
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = ExposureMask | ButtonPressMask | SubstructureRedirectMask | SubstructureNotifyMask;
|
||||
|
||||
brect.x = brect.y = brect.width = brect.height = 0;
|
||||
rect.x = rect.y = 0;
|
||||
rect.width = DisplayWidth(dpy, screen_num);
|
||||
rect.height = DisplayHeight(dpy, screen_num);
|
||||
update_geometry(geom);
|
||||
|
||||
win = XCreateWindow(dpy, RootWindow(dpy, screen_num), brect.x, brect.y,
|
||||
brect.width, brect.height, 0, DefaultDepth(dpy, screen_num),
|
||||
CopyFromParent, DefaultVisual(dpy, screen_num),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_left_ptr));
|
||||
XSync(dpy, False);
|
||||
|
||||
gcv.function = GXcopy;
|
||||
gcv.graphics_exposures = False;
|
||||
gc = XCreateGC(dpy, win, 0, 0);
|
||||
|
||||
pmap = XCreatePixmap(dpy, win, brect.width, brect.height, DefaultDepth(dpy, screen_num));
|
||||
|
||||
/* main event loop */
|
||||
run_server_with_fd_support(ixps, ConnectionNumber(dpy), check_event, 0);
|
||||
deinit_server(ixps);
|
||||
XFreePixmap(dpy, pmap);
|
||||
XFreeGC(dpy, gc);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
|
||||
static int dummy_error_handler(Display * dpy, XErrorEvent * err)
|
||||
{
|
||||
return 0;
|
||||
|
@ -495,8 +446,9 @@ static int dummy_error_handler(Display * dpy, XErrorEvent * err)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char geom[64];
|
||||
int i;
|
||||
XSetWindowAttributes wa;
|
||||
XGCValues gcv;
|
||||
|
||||
/* command line args */
|
||||
for (i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
|
||||
|
@ -525,12 +477,58 @@ int main(int argc, char *argv[])
|
|||
XSetErrorHandler(dummy_error_handler);
|
||||
screen_num = DefaultScreen(dpy);
|
||||
|
||||
geom[0] = 0;
|
||||
if (argc > i)
|
||||
cext_strlcpy(geom, argv[i], sizeof(geom));
|
||||
|
||||
ixps = wmii_setup_server(sockfile);
|
||||
run(geom);
|
||||
|
||||
|
||||
/* init */
|
||||
if (!(file[B_CTL] = ixp_create(ixps, "/ctl"))) {
|
||||
perror("wmibar: cannot connect IXP server");
|
||||
exit(1);
|
||||
}
|
||||
file[B_CTL]->after_write = handle_after_write;
|
||||
file[B_NEW] = ixp_create(ixps, "/new");
|
||||
file[B_NEW]->before_read = handle_before_read;
|
||||
file[B_FONT] = wmii_create_ixpfile(ixps, "/font", BLITZ_FONT);
|
||||
file[B_FONT]->after_write = handle_after_write;
|
||||
font = blitz_getfont(dpy, file[B_FONT]->content);
|
||||
file[B_BG_COLOR] = wmii_create_ixpfile(ixps, "/bgcolor", BLITZ_NORM_BG_COLOR);
|
||||
file[B_FG_COLOR] = wmii_create_ixpfile(ixps, "/fgcolor", BLITZ_NORM_FG_COLOR);
|
||||
file[B_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/bordercolor", BLITZ_NORM_BORDER_COLOR);
|
||||
file[B_GEOMETRY] = ixp_create(ixps, "/geometry");
|
||||
file[B_GEOMETRY]->before_read = handle_before_read;
|
||||
file[B_GEOMETRY]->after_write = handle_after_write;
|
||||
file[B_EXPANDABLE] = ixp_create(ixps, "/expandable");
|
||||
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = ExposureMask | ButtonPressMask | SubstructureRedirectMask | SubstructureNotifyMask;
|
||||
|
||||
rect.x = rect.y = 0;
|
||||
rect.width = DisplayWidth(dpy, screen_num);
|
||||
rect.height = DisplayHeight(dpy, screen_num);
|
||||
brect = rect;
|
||||
brect.height = font->ascent + font->descent + 4;
|
||||
brect.y = rect.height - brect.height;
|
||||
|
||||
win = XCreateWindow(dpy, RootWindow(dpy, screen_num), brect.x, brect.y,
|
||||
brect.width, brect.height, 0, DefaultDepth(dpy, screen_num),
|
||||
CopyFromParent, DefaultVisual(dpy, screen_num),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_left_ptr));
|
||||
XSync(dpy, False);
|
||||
|
||||
gcv.function = GXcopy;
|
||||
gcv.graphics_exposures = False;
|
||||
gc = XCreateGC(dpy, win, 0, 0);
|
||||
|
||||
pmap = XCreatePixmap(dpy, win, brect.width, brect.height, DefaultDepth(dpy, screen_num));
|
||||
|
||||
/* main event loop */
|
||||
run_server_with_fd_support(ixps, ConnectionNumber(dpy), check_event, 0);
|
||||
deinit_server(ixps);
|
||||
XFreePixmap(dpy, pmap);
|
||||
XFreeGC(dpy, gc);
|
||||
XCloseDisplay(dpy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
142
cmd/wmikeys.c
142
cmd/wmikeys.c
|
@ -69,21 +69,21 @@ static char *version[] = {
|
|||
" (C)opyright MMIV-MMV Anselm R. Garbe\n", 0
|
||||
};
|
||||
|
||||
static void usage()
|
||||
{
|
||||
fprintf(stderr, "%s",
|
||||
"usage: wmikeys [-s <socket file>] [-v]\n"
|
||||
" -s socket file (default: /tmp/.ixp-$USER/wmikeys-$WMII_IDENT)\n"
|
||||
" -v version info\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void center()
|
||||
{
|
||||
krect.x = rect.width / 2 - krect.width / 2;
|
||||
krect.y = rect.height / 2 - krect.height / 2;
|
||||
}
|
||||
|
||||
static void usage()
|
||||
{
|
||||
fprintf(stderr, "%s",
|
||||
"usage: wmikeys [-s <socket file>] [-v] [<x>,<y>,<width>,<height>]\n"
|
||||
" -s socket file (default: /tmp/.ixp-$USER/wmikeys-$WMII_IDENT)\n"
|
||||
" -v version info\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* grabs shortcut on all screens */
|
||||
static void grab_shortcut(Shortcut * s)
|
||||
{
|
||||
|
@ -307,6 +307,7 @@ static void draw_shortcut_box(char *text)
|
|||
|
||||
d.font = font;
|
||||
krect.width = XTextWidth(d.font, text, strlen(text)) + krect.height;
|
||||
krect.height = font->ascent + font->descent + 4;
|
||||
center();
|
||||
XMoveResizeWindow(dpy, win, krect.x, krect.y, krect.width, krect.height);
|
||||
|
||||
|
@ -382,73 +383,6 @@ static void handle_after_write(IXPServer * s, File * f)
|
|||
check_event(0);
|
||||
}
|
||||
|
||||
static void run(char *size)
|
||||
{
|
||||
XSetWindowAttributes wa;
|
||||
XGCValues gcv;
|
||||
|
||||
/* init */
|
||||
if (!(files[K_CTL] = ixp_create(ixps, "/ctl"))) {
|
||||
perror("wmikeys: cannot connect IXP server");
|
||||
exit(1);
|
||||
}
|
||||
files[K_CTL]->after_write = handle_after_write;
|
||||
files[K_LOOKUP] = ixp_create(ixps, "/lookup");
|
||||
files[K_LOOKUP]->after_write = handle_after_write;
|
||||
files[K_GRAB_KB] = wmii_create_ixpfile(ixps, "/grabkeyb", "0");
|
||||
files[K_GRAB_KB]->after_write = handle_after_write;
|
||||
files[K_FONT] = wmii_create_ixpfile(ixps, "/box/font", BLITZ_FONT);
|
||||
files[K_FONT]->after_write = handle_after_write;
|
||||
font = blitz_getfont(dpy, files[K_FONT]->content);
|
||||
files[K_FG_COLOR] = wmii_create_ixpfile(ixps, "/box/fgcolor", BLITZ_SEL_FG_COLOR);
|
||||
files[K_BG_COLOR] = wmii_create_ixpfile(ixps, "/box/bgcolor", BLITZ_SEL_BG_COLOR);
|
||||
files[K_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/box/bordercolor", BLITZ_SEL_BORDER_COLOR);
|
||||
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask =
|
||||
ExposureMask | SubstructureRedirectMask | SubstructureNotifyMask;
|
||||
|
||||
root = RootWindow(dpy, screen_num);
|
||||
rect.x = rect.y = 0;
|
||||
rect.width = DisplayWidth(dpy, screen_num);
|
||||
rect.height = DisplayHeight(dpy, screen_num);
|
||||
krect.x = krect.y = -1;
|
||||
krect.width = krect.height = 0;
|
||||
blitz_strtorect(&rect, &krect, size);
|
||||
/* default is center position */
|
||||
if (!krect.width) {
|
||||
krect.width = 200;
|
||||
}
|
||||
if (!krect.height) {
|
||||
krect.height = 20;
|
||||
}
|
||||
center();
|
||||
|
||||
init_lock_modifiers(dpy, &valid_mask, &num_lock_mask);
|
||||
|
||||
win = XCreateWindow(dpy, RootWindow(dpy, screen_num), krect.x, krect.y,
|
||||
krect.width, krect.height, 0, DefaultDepth(dpy,
|
||||
screen_num),
|
||||
CopyFromParent, DefaultVisual(dpy, screen_num),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask,
|
||||
&wa);
|
||||
XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_left_ptr));
|
||||
XSync(dpy, False);
|
||||
|
||||
gcv.function = GXcopy;
|
||||
gcv.graphics_exposures = False;
|
||||
|
||||
gc = XCreateGC(dpy, win, 0, 0);
|
||||
|
||||
/* main event loop */
|
||||
run_server_with_fd_support(ixps, ConnectionNumber(dpy),
|
||||
check_event, 0);
|
||||
deinit_server(ixps);
|
||||
XFreeGC(dpy, gc);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
|
||||
static int dummy_error_handler(Display * dpy, XErrorEvent * err)
|
||||
{
|
||||
return 0;
|
||||
|
@ -456,8 +390,9 @@ static int dummy_error_handler(Display * dpy, XErrorEvent * err)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char size[64];
|
||||
int i;
|
||||
XSetWindowAttributes wa;
|
||||
XGCValues gcv;
|
||||
|
||||
/* command line args */
|
||||
for (i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
|
||||
|
@ -485,13 +420,58 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
XSetErrorHandler(dummy_error_handler);
|
||||
screen_num = DefaultScreen(dpy);
|
||||
size[0] = 0;
|
||||
if (argc > i)
|
||||
cext_strlcpy(size, argv[i], sizeof(size));
|
||||
|
||||
/* init */
|
||||
ixps = wmii_setup_server(sockfile);
|
||||
|
||||
run(size);
|
||||
if (!(files[K_CTL] = ixp_create(ixps, "/ctl"))) {
|
||||
perror("wmikeys: cannot connect IXP server");
|
||||
exit(1);
|
||||
}
|
||||
files[K_CTL]->after_write = handle_after_write;
|
||||
files[K_LOOKUP] = ixp_create(ixps, "/lookup");
|
||||
files[K_LOOKUP]->after_write = handle_after_write;
|
||||
files[K_GRAB_KB] = wmii_create_ixpfile(ixps, "/grabkeyb", "0");
|
||||
files[K_GRAB_KB]->after_write = handle_after_write;
|
||||
files[K_FONT] = wmii_create_ixpfile(ixps, "/box/font", BLITZ_FONT);
|
||||
files[K_FONT]->after_write = handle_after_write;
|
||||
font = blitz_getfont(dpy, files[K_FONT]->content);
|
||||
files[K_FG_COLOR] = wmii_create_ixpfile(ixps, "/box/fgcolor", BLITZ_SEL_FG_COLOR);
|
||||
files[K_BG_COLOR] = wmii_create_ixpfile(ixps, "/box/bgcolor", BLITZ_SEL_BG_COLOR);
|
||||
files[K_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/box/bordercolor", BLITZ_SEL_BORDER_COLOR);
|
||||
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask =
|
||||
ExposureMask | SubstructureRedirectMask | SubstructureNotifyMask;
|
||||
|
||||
root = RootWindow(dpy, screen_num);
|
||||
rect.x = rect.y = 0;
|
||||
rect.width = DisplayWidth(dpy, screen_num);
|
||||
rect.height = DisplayHeight(dpy, screen_num);
|
||||
krect.x = krect.y = 0;
|
||||
krect.width = krect.height = 1;
|
||||
|
||||
init_lock_modifiers(dpy, &valid_mask, &num_lock_mask);
|
||||
|
||||
win = XCreateWindow(dpy, RootWindow(dpy, screen_num), krect.x, krect.y,
|
||||
krect.width, krect.height, 0, DefaultDepth(dpy, screen_num),
|
||||
CopyFromParent, DefaultVisual(dpy, screen_num),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_left_ptr));
|
||||
XSync(dpy, False);
|
||||
|
||||
gcv.function = GXcopy;
|
||||
gcv.graphics_exposures = False;
|
||||
|
||||
gc = XCreateGC(dpy, win, 0, 0);
|
||||
|
||||
/* main event loop */
|
||||
run_server_with_fd_support(ixps, ConnectionNumber(dpy),
|
||||
check_event, 0);
|
||||
deinit_server(ixps);
|
||||
XFreeGC(dpy, gc);
|
||||
XCloseDisplay(dpy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
110
cmd/wmimenu.c
110
cmd/wmimenu.c
|
@ -57,6 +57,7 @@ static Pixmap pmap;
|
|||
static const int seek = 30; /* 30px */
|
||||
static XFontStruct *font;
|
||||
static unsigned int sel = 0;
|
||||
static Align align = SOUTH;
|
||||
|
||||
static void check_event(Connection * c);
|
||||
static void draw_menu(void);
|
||||
|
@ -79,7 +80,7 @@ static char *version[] = {
|
|||
static void usage()
|
||||
{
|
||||
fprintf(stderr, "%s",
|
||||
"usage: wmimenu [-s <socket file>] [-r] [-v] [<x>,<y>,<width>,<height>]\n"
|
||||
"usage: wmimenu [-s <socket file>] [-r] [-v]\n"
|
||||
" -s socket file (default: /tmp/.ixp-$USER/wmimenu-%s-%s)\n"
|
||||
" -v version info\n");
|
||||
exit(1);
|
||||
|
@ -460,6 +461,19 @@ static void check_event(Connection * c)
|
|||
}
|
||||
}
|
||||
|
||||
static void update_geometry()
|
||||
{
|
||||
mrect = rect;
|
||||
mrect.height = font->ascent + font->descent + 4;
|
||||
if (align == SOUTH)
|
||||
mrect.y = rect.height - mrect.height;
|
||||
XMoveResizeWindow(dpy, win, mrect.x, mrect.y, mrect.width, mrect.height);
|
||||
XSync(dpy, False);
|
||||
XFreePixmap(dpy, pmap);
|
||||
pmap = XCreatePixmap(dpy, win, mrect.width, mrect.height, DefaultDepth(dpy, screen_num));
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
static void handle_after_write(IXPServer * s, File * f)
|
||||
{
|
||||
int i;
|
||||
|
@ -478,19 +492,19 @@ static void handle_after_write(IXPServer * s, File * f)
|
|||
}
|
||||
}
|
||||
} else if (files[M_GEOMETRY] == f) {
|
||||
char *size = files[M_GEOMETRY]->content;
|
||||
if (size && strrchr(size, ',')) {
|
||||
blitz_strtorect(&rect, &mrect, size);
|
||||
XFreePixmap(dpy, pmap);
|
||||
XMoveResizeWindow(dpy, win, mrect.x, mrect.y, mrect.width, mrect.height);
|
||||
XSync(dpy, False);
|
||||
pmap = XCreatePixmap(dpy, win, mrect.width, mrect.height, DefaultDepth(dpy, screen_num));
|
||||
XSync(dpy, False);
|
||||
if (f->content) {
|
||||
if (!strncmp(f->content, "south", 6))
|
||||
align = SOUTH;
|
||||
else if(!strncmp(f->content, "north", 6))
|
||||
align = NORTH;
|
||||
update_geometry();
|
||||
draw_menu();
|
||||
}
|
||||
} else if (files[M_FONT] == f) {
|
||||
XFreeFont(dpy, font);
|
||||
font = blitz_getfont(dpy, files[M_FONT]->content);
|
||||
update_geometry();
|
||||
draw_menu();
|
||||
} else if (files[M_COMMAND] == f) {
|
||||
update_items(files[M_COMMAND]->content);
|
||||
draw_menu();
|
||||
|
@ -511,11 +525,40 @@ static void handle_before_read(IXPServer * s, File * f)
|
|||
f->size = strlen(buf);
|
||||
}
|
||||
|
||||
static void run(char *size)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
XSetWindowAttributes wa;
|
||||
XGCValues gcv;
|
||||
|
||||
/* command line args */
|
||||
for (i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
|
||||
switch (argv[i][1]) {
|
||||
case 'v':
|
||||
fprintf(stdout, "%s", version[0]);
|
||||
exit(0);
|
||||
break;
|
||||
case 's':
|
||||
if (i + 1 < argc)
|
||||
sockfile = argv[++i];
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dpy = XOpenDisplay(0);
|
||||
if (!dpy) {
|
||||
fprintf(stderr, "%s", "wmimenu: cannot open display\n");
|
||||
exit(1);
|
||||
}
|
||||
screen_num = DefaultScreen(dpy);
|
||||
|
||||
ixps = wmii_setup_server(sockfile);
|
||||
|
||||
/* init */
|
||||
if (!(files[M_CTL] = ixp_create(ixps, "/ctl"))) {
|
||||
perror("wmimenu: cannot connect IXP server");
|
||||
|
@ -549,11 +592,9 @@ static void run(char *size)
|
|||
rect.x = rect.y = 0;
|
||||
rect.width = DisplayWidth(dpy, screen_num);
|
||||
rect.height = DisplayHeight(dpy, screen_num);
|
||||
blitz_strtorect(&rect, &mrect, size);
|
||||
if (!mrect.width)
|
||||
mrect.width = DisplayWidth(dpy, screen_num);
|
||||
if (!mrect.height)
|
||||
mrect.height = 20;
|
||||
mrect = rect;
|
||||
mrect.height = font->ascent + font->descent + 4;
|
||||
mrect.y = rect.height - mrect.height;
|
||||
|
||||
win = XCreateWindow(dpy, RootWindow(dpy, screen_num), mrect.x, mrect.y,
|
||||
mrect.width, mrect.height, 0, DefaultDepth(dpy, screen_num),
|
||||
|
@ -575,45 +616,6 @@ static void run(char *size)
|
|||
XFreePixmap(dpy, pmap);
|
||||
XFreeGC(dpy, gc);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char size[64];
|
||||
int i;
|
||||
|
||||
/* command line args */
|
||||
for (i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
|
||||
switch (argv[i][1]) {
|
||||
case 'v':
|
||||
fprintf(stdout, "%s", version[0]);
|
||||
exit(0);
|
||||
break;
|
||||
case 's':
|
||||
if (i + 1 < argc)
|
||||
sockfile = argv[++i];
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dpy = XOpenDisplay(0);
|
||||
if (!dpy) {
|
||||
fprintf(stderr, "%s", "wmimenu: cannot open display\n");
|
||||
exit(1);
|
||||
}
|
||||
screen_num = DefaultScreen(dpy);
|
||||
|
||||
size[0] = 0;
|
||||
if (argc > i)
|
||||
cext_strlcpy(size, argv[i], sizeof(size));
|
||||
|
||||
ixps = wmii_setup_server(sockfile);
|
||||
run(size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
25
rc/wmirc
25
rc/wmirc
|
@ -124,33 +124,13 @@ frameconf /wm/default norefresh
|
|||
|
||||
kbind bare $MODKEY-Escape 'kmode normal'
|
||||
|
||||
kbind move Escape 'kmode normal'
|
||||
kbind move $MODKEY-C-r 'kmode resize'
|
||||
kbind move $NORTHKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry -0,-30,-0,-0'
|
||||
kbind move $SOUTHKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry +0,+30,+0,+0'
|
||||
kbind move $WESTKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry -40,-0,-0,-0'
|
||||
kbind move $EASTKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry +40,+0,+0,+0'
|
||||
kbind move S-$NORTHKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry -0,north,-0,-0'
|
||||
kbind move S-$SOUTHKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry +0,south-'^$BAR_HEIGHT^',+0,+0'
|
||||
kbind move S-$WESTKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry west,-0,-0,-0'
|
||||
kbind move S-$EASTKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry east,+0,+0,+0'
|
||||
|
||||
kbind resize Escape 'kmode normal'
|
||||
kbind resize $MODKEY-C-m 'kmode move'
|
||||
kbind resize $NORTHKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry +0,+0,+0,-30'
|
||||
kbind resize $SOUTHKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry +0,+0,+0,+30'
|
||||
kbind resize $WESTKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry +0,+0,-40,+0'
|
||||
kbind resize $EASTKEY 'wmir write /wm/sel/layout/sel/frame/sel/geometry +0,+0,+40,+0'
|
||||
|
||||
kbind normal $MODKEY-C-b 'kmode bare'
|
||||
kbind normal $MODKEY-C-m 'kmode move'
|
||||
kbind normal $MODKEY-C-r 'kmode resize'
|
||||
kbind normal $MODKEY-C-a 'wmir write /menu/precmd ''''; wmir write /menu/lookup /items/actions; wmir write /menu/ctl ''display 1'''
|
||||
kbind normal $MODKEY-C-p 'wmir write /menu/precmd extern; wmir write /menu/lookup /items/programs; wmir write /menu/ctl ''display 1'''
|
||||
kbind normal $MODKEY-C-c 'wmir write /wm/ctl close'
|
||||
kbind normal $MODKEY-C-q,y quit
|
||||
kbind normal $MODKEY-C-w,y wmirc
|
||||
kbind normal $MODKEY-t 'extern urxvt ''+sb'' -bg ''#000000'' -fg ''#ffffff'' -cr ''#ffffff'' -sl 4000 -fn -artwiz-smoothansi-*-*-*-*-*-*-*-*-*-*-*-*'
|
||||
kbind normal $MODKEY-t 'extern xterm ''+sb'' -bg ''#000000'' -fg ''#ffffff'' -cr ''#ffffff'' -sl 4000 -fn -artwiz-smoothansi-*-*-*-*-*-*-*-*-*-*-*-*'
|
||||
kbind normal $MODKEY-d 'wmir write /wm/ctl detach'
|
||||
kbind normal $MODKEY-a 'wmir write /wm/ctl attach'
|
||||
kbind normal $MODKEY-S-a 'wmir write /wm/ctl icons'
|
||||
|
@ -187,6 +167,5 @@ normstyle /menu/nstyle >[2]/dev/null
|
|||
selstyle /menu/sstyle >[2]/dev/null
|
||||
|
||||
# MISC
|
||||
feh --bg-scale $HOME/wallpaper/bg.png
|
||||
xsetroot -solid black
|
||||
status &
|
||||
#mpc && status-mpd &
|
||||
|
|
Loading…
Reference in New Issue