mirror of
https://github.com/0intro/wmii
synced 2025-03-19 05:03:50 +03:00
renamed Blitz' dsiplay into dpy
This commit is contained in:
parent
9a0bae0b61
commit
2af8fef0e0
@ -66,8 +66,8 @@ resize_bar(WMScreen *s)
|
||||
s->brect = s->rect;
|
||||
s->brect.height = height_of_bar();
|
||||
s->brect.y = s->rect.height - s->brect.height;
|
||||
XMoveResizeWindow(blz.display, s->barwin, s->brect.x, s->brect.y, s->brect.width, s->brect.height);
|
||||
XSync(blz.display, False);
|
||||
XMoveResizeWindow(blz.dpy, s->barwin, s->brect.x, s->brect.y, s->brect.width, s->brect.height);
|
||||
XSync(blz.dpy, False);
|
||||
draw_bar(s);
|
||||
|
||||
for(v=view; v; v=v->next)
|
||||
@ -135,9 +135,9 @@ draw_bar(WMScreen *s)
|
||||
blitz_draw_label(&b->brush, b->text);
|
||||
}
|
||||
MapBar:
|
||||
XCopyArea(blz.display, s->bbrush.drawable, s->barwin, s->bbrush.gc, 0, 0,
|
||||
XCopyArea(blz.dpy, s->bbrush.drawable, s->barwin, s->bbrush.gc, 0, 0,
|
||||
s->brect.width, s->brect.height, 0, 0);
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
||||
Bar *
|
||||
|
@ -55,15 +55,15 @@ update_client_name(Client *c)
|
||||
|
||||
name.nitems = 0;
|
||||
c->name[0] = 0;
|
||||
XGetTextProperty(blz.display, c->win, &name, net_atom[NetWMName]);
|
||||
XGetTextProperty(blz.dpy, c->win, &name, net_atom[NetWMName]);
|
||||
if(!name.nitems)
|
||||
XGetWMName(blz.display, c->win, &name);
|
||||
XGetWMName(blz.dpy, c->win, &name);
|
||||
if(!name.nitems)
|
||||
return;
|
||||
if(name.encoding == XA_STRING)
|
||||
cext_strlcpy(c->name, (char *)name.value, sizeof(c->name));
|
||||
else {
|
||||
if(XmbTextPropertyToTextList(blz.display, &name, &list, &n) >= Success
|
||||
if(XmbTextPropertyToTextList(blz.dpy, &name, &list, &n) >= Success
|
||||
&& n > 0 && *list)
|
||||
{
|
||||
cext_strlcpy(c->name, *list, sizeof(c->name));
|
||||
@ -71,7 +71,7 @@ update_client_name(Client *c)
|
||||
}
|
||||
}
|
||||
XFree(name.value);
|
||||
if(XGetClassHint(blz.display, c->win, &ch)) {
|
||||
if(XGetClassHint(blz.dpy, c->win, &ch)) {
|
||||
snprintf(c->props, sizeof(c->props), "%s:%s:%s",
|
||||
ch.res_class ? ch.res_class : "",
|
||||
ch.res_name ? ch.res_name : "",
|
||||
@ -99,10 +99,10 @@ create_client(Window w, XWindowAttributes *wa)
|
||||
c->border = wa->border_width;
|
||||
c->rect.width = wa->width;
|
||||
c->rect.height = wa->height;
|
||||
XSetWindowBorderWidth(blz.display, c->win, 0);
|
||||
XSetWindowBorderWidth(blz.dpy, c->win, 0);
|
||||
c->proto = win_proto(c->win);
|
||||
XGetTransientForHint(blz.display, c->win, &c->trans);
|
||||
if(!XGetWMNormalHints(blz.display, c->win, &c->size, &msize) || !c->size.flags)
|
||||
XGetTransientForHint(blz.dpy, c->win, &c->trans);
|
||||
if(!XGetWMNormalHints(blz.dpy, c->win, &c->size, &msize) || !c->size.flags)
|
||||
c->size.flags = PSize;
|
||||
if(c->size.flags & PMinSize && c->size.flags & PMaxSize
|
||||
&& c->size.min_width == c->size.max_width
|
||||
@ -110,7 +110,7 @@ create_client(Window w, XWindowAttributes *wa)
|
||||
c->fixedsize = True;
|
||||
else
|
||||
c->fixedsize = False;
|
||||
XAddToSaveSet(blz.display, c->win);
|
||||
XAddToSaveSet(blz.dpy, c->win);
|
||||
update_client_name(c);
|
||||
fwa.override_redirect = 1;
|
||||
fwa.background_pixmap = ParentRelative;
|
||||
@ -118,14 +118,14 @@ create_client(Window w, XWindowAttributes *wa)
|
||||
SubstructureRedirectMask | SubstructureNotifyMask | ExposureMask
|
||||
| ButtonPressMask | PointerMotionMask | ButtonReleaseMask | KeyPressMask;
|
||||
|
||||
c->framewin = XCreateWindow(blz.display, blz.root, c->rect.x, c->rect.y,
|
||||
c->framewin = XCreateWindow(blz.dpy, blz.root, c->rect.x, c->rect.y,
|
||||
c->rect.width + 2 * def.border,
|
||||
c->rect.height + def.border + height_of_bar(), 0,
|
||||
DefaultDepth(blz.display, blz.screen), CopyFromParent,
|
||||
DefaultVisual(blz.display, blz.screen),
|
||||
DefaultDepth(blz.dpy, blz.screen), CopyFromParent,
|
||||
DefaultVisual(blz.dpy, blz.screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &fwa);
|
||||
c->gc = XCreateGC(blz.display, c->framewin, 0, 0);
|
||||
XSync(blz.display, False);
|
||||
c->gc = XCreateGC(blz.dpy, c->framewin, 0, 0);
|
||||
XSync(blz.dpy, False);
|
||||
|
||||
for(t=&client, i=0; *t; t=&(*t)->next, i++);
|
||||
c->next = *t; /* *t == nil */
|
||||
@ -139,7 +139,7 @@ void
|
||||
set_client_state(Client * c, int state)
|
||||
{
|
||||
long data[] = { state, None };
|
||||
XChangeProperty(blz.display, c->win, wm_atom[WMState], wm_atom[WMState], 32,
|
||||
XChangeProperty(blz.dpy, c->win, wm_atom[WMState], wm_atom[WMState], 32,
|
||||
PropModeReplace, (unsigned char *) data, 2);
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ focus_client(Client *c, Bool restack)
|
||||
|
||||
if(!c->floating && f->area->mode == Colstack)
|
||||
arrange_column(f->area, False);
|
||||
XSetInputFocus(blz.display, c->win, RevertToPointerRoot, CurrentTime);
|
||||
XSetInputFocus(blz.dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||
if(old && old != old_in_area && old != c) {
|
||||
update_frame_widget_colors(old->sel);
|
||||
draw_frame(old->sel);
|
||||
@ -196,34 +196,34 @@ focus_client(Client *c, Bool restack)
|
||||
}
|
||||
update_frame_widget_colors(c->sel);
|
||||
draw_frame(c->sel);
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
write_event("ClientFocus %d\n", idx_of_client(c));
|
||||
}
|
||||
|
||||
void
|
||||
map_client(Client *c)
|
||||
{
|
||||
XSelectInput(blz.display, c->win, CLIENT_MASK & ~StructureNotifyMask);
|
||||
XMapWindow(blz.display, c->win);
|
||||
XSelectInput(blz.display, c->win, CLIENT_MASK);
|
||||
XSelectInput(blz.dpy, c->win, CLIENT_MASK & ~StructureNotifyMask);
|
||||
XMapWindow(blz.dpy, c->win);
|
||||
XSelectInput(blz.dpy, c->win, CLIENT_MASK);
|
||||
set_client_state(c, NormalState);
|
||||
}
|
||||
|
||||
void
|
||||
unmap_client(Client *c)
|
||||
{
|
||||
XSelectInput(blz.display, c->win, CLIENT_MASK & ~StructureNotifyMask);
|
||||
XUnmapWindow(blz.display, c->win);
|
||||
XSelectInput(blz.display, c->win, CLIENT_MASK);
|
||||
XSelectInput(blz.dpy, c->win, CLIENT_MASK & ~StructureNotifyMask);
|
||||
XUnmapWindow(blz.dpy, c->win);
|
||||
XSelectInput(blz.dpy, c->win, CLIENT_MASK);
|
||||
set_client_state(c, WithdrawnState);
|
||||
}
|
||||
|
||||
void
|
||||
reparent_client(Client *c, Window w, int x, int y)
|
||||
{
|
||||
XSelectInput(blz.display, c->win, CLIENT_MASK & ~StructureNotifyMask);
|
||||
XReparentWindow(blz.display, c->win, w, x, y);
|
||||
XSelectInput(blz.display, c->win, CLIENT_MASK);
|
||||
XSelectInput(blz.dpy, c->win, CLIENT_MASK & ~StructureNotifyMask);
|
||||
XReparentWindow(blz.dpy, c->win, w, x, y);
|
||||
XSelectInput(blz.dpy, c->win, CLIENT_MASK);
|
||||
}
|
||||
|
||||
void
|
||||
@ -245,10 +245,10 @@ configure_client(Client *c)
|
||||
e.border_width = c->border;
|
||||
e.above = None;
|
||||
e.override_redirect = False;
|
||||
XSelectInput(blz.display, c->win, CLIENT_MASK & ~StructureNotifyMask);
|
||||
XSendEvent(blz.display, c->win, False, StructureNotifyMask, (XEvent *) & e);
|
||||
XSelectInput(blz.display, c->win, CLIENT_MASK);
|
||||
XSync(blz.display, False);
|
||||
XSelectInput(blz.dpy, c->win, CLIENT_MASK & ~StructureNotifyMask);
|
||||
XSendEvent(blz.dpy, c->win, False, StructureNotifyMask, (XEvent *) & e);
|
||||
XSelectInput(blz.dpy, c->win, CLIENT_MASK);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -262,8 +262,8 @@ send_client_message(Window w, Atom a, long value)
|
||||
e.xclient.data.l[0] = value;
|
||||
e.xclient.data.l[1] = CurrentTime;
|
||||
|
||||
XSendEvent(blz.display, w, False, NoEventMask, &e);
|
||||
XSync(blz.display, False);
|
||||
XSendEvent(blz.dpy, w, False, NoEventMask, &e);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
@ -272,7 +272,7 @@ kill_client(Client * c)
|
||||
if(c->proto & WM_PROTOCOL_DELWIN)
|
||||
send_client_message(c->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
|
||||
else
|
||||
XKillClient(blz.display, c->win);
|
||||
XKillClient(blz.dpy, c->win);
|
||||
}
|
||||
|
||||
void
|
||||
@ -287,10 +287,10 @@ prop_client(Client *c, XPropertyEvent *e)
|
||||
}
|
||||
switch (e->atom) {
|
||||
case XA_WM_TRANSIENT_FOR:
|
||||
XGetTransientForHint(blz.display, c->win, &c->trans);
|
||||
XGetTransientForHint(blz.dpy, c->win, &c->trans);
|
||||
break;
|
||||
case XA_WM_NORMAL_HINTS:
|
||||
if(!XGetWMNormalHints(blz.display, c->win, &c->size, &msize) || !c->size.flags) {
|
||||
if(!XGetWMNormalHints(blz.dpy, c->win, &c->size, &msize) || !c->size.flags) {
|
||||
c->size.flags = PSize;
|
||||
}
|
||||
if(c->size.flags & PMinSize && c->size.flags & PMaxSize
|
||||
@ -377,7 +377,7 @@ manage_client(Client *c)
|
||||
Client *trans;
|
||||
|
||||
tags.nitems = 0;
|
||||
XGetTextProperty(blz.display, c->win, &tags, tags_atom);
|
||||
XGetTextProperty(blz.dpy, c->win, &tags, tags_atom);
|
||||
|
||||
if(c->trans && (trans = client_of_win(c->trans)))
|
||||
cext_strlcpy(c->tags, trans->tags, sizeof(c->tags));
|
||||
@ -395,8 +395,8 @@ manage_client(Client *c)
|
||||
if(!starting)
|
||||
update_views();
|
||||
map_client(c);
|
||||
XMapWindow(blz.display, c->framewin);
|
||||
XSync(blz.display, False);
|
||||
XMapWindow(blz.dpy, c->framewin);
|
||||
XSync(blz.dpy, False);
|
||||
if(c->sel->area->view == screen->sel)
|
||||
focus_client(c, False);
|
||||
flush_masked_events(EnterWindowMask);
|
||||
@ -414,7 +414,7 @@ destroy_client(Client *c)
|
||||
char *dummy = nil;
|
||||
Client **tc;
|
||||
|
||||
XGrabServer(blz.display);
|
||||
XGrabServer(blz.dpy);
|
||||
XSetErrorHandler(dummy_error_handler);
|
||||
|
||||
if(c->frame) {
|
||||
@ -427,8 +427,8 @@ destroy_client(Client *c)
|
||||
unmap_client(c);
|
||||
|
||||
reparent_client(c, blz.root, c->rect.x, c->rect.y);
|
||||
XFreeGC(blz.display, c->gc);
|
||||
XDestroyWindow(blz.display, c->framewin);
|
||||
XFreeGC(blz.dpy, c->gc);
|
||||
XDestroyWindow(blz.dpy, c->framewin);
|
||||
|
||||
for(tc=&client; *tc && *tc != c; tc=&(*tc)->next);
|
||||
cext_assert(*tc == c);
|
||||
@ -437,9 +437,9 @@ destroy_client(Client *c)
|
||||
update_views();
|
||||
free(c);
|
||||
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
XSetErrorHandler(wmii_error_handler);
|
||||
XUngrabServer(blz.display);
|
||||
XUngrabServer(blz.dpy);
|
||||
flush_masked_events(EnterWindowMask);
|
||||
}
|
||||
|
||||
@ -555,10 +555,10 @@ resize_client(Client *c, XRectangle *r, Bool ignore_xcall)
|
||||
}
|
||||
}
|
||||
if(f->area->view == screen->sel)
|
||||
XMoveResizeWindow(blz.display, c->framewin, f->rect.x,
|
||||
XMoveResizeWindow(blz.dpy, c->framewin, f->rect.x,
|
||||
f->rect.y, f->rect.width, f->rect.height);
|
||||
else
|
||||
XMoveResizeWindow(blz.display, c->framewin, 2 * screen->rect.width + f->rect.x,
|
||||
XMoveResizeWindow(blz.dpy, c->framewin, 2 * screen->rect.width + f->rect.x,
|
||||
f->rect.y, f->rect.width, f->rect.height);
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ resize_client(Client *c, XRectangle *r, Bool ignore_xcall)
|
||||
c->rect.height = f->rect.height - def.border - height_of_bar();
|
||||
}
|
||||
if(!ignore_xcall) {
|
||||
XMoveResizeWindow(blz.display, c->win, c->rect.x, c->rect.y,
|
||||
XMoveResizeWindow(blz.dpy, c->win, c->rect.x, c->rect.y,
|
||||
c->rect.width, c->rect.height);
|
||||
configure_client(c);
|
||||
}
|
||||
@ -799,11 +799,11 @@ apply_tags(Client *c, const char *tags)
|
||||
toks[n] = nil;
|
||||
update_client_views(c, toks);
|
||||
|
||||
XChangeProperty(blz.display, c->win, tags_atom, XA_STRING, 8,
|
||||
XChangeProperty(blz.dpy, c->win, tags_atom, XA_STRING, 8,
|
||||
PropModeReplace, (unsigned char *)c->tags, strlen(c->tags));
|
||||
|
||||
for(f = c->frame; f; f = f->cnext)
|
||||
blitz_settext_input(&f->tagbar, c->tags);
|
||||
blitz_setinput(&f->tagbar, c->tags);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -45,8 +45,8 @@ void
|
||||
check_x_event(IXPConn *c)
|
||||
{
|
||||
XEvent ev;
|
||||
while(XPending(blz.display)) { /* main event loop */
|
||||
XNextEvent(blz.display, &ev);
|
||||
while(XPending(blz.dpy)) { /* main event loop */
|
||||
XNextEvent(blz.dpy, &ev);
|
||||
if(handler[ev.type])
|
||||
(handler[ev.type]) (&ev); /* call handler */
|
||||
}
|
||||
@ -57,7 +57,7 @@ flush_masked_events(long even_mask)
|
||||
{
|
||||
XEvent ev;
|
||||
unsigned int n = 0;
|
||||
while(XCheckMaskEvent(blz.display, even_mask, &ev)) n++;
|
||||
while(XCheckMaskEvent(blz.dpy, even_mask, &ev)) n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ handle_configurerequest(XEvent *e)
|
||||
if(c->sel->area->view != screen->sel)
|
||||
wc.x += 2 * screen->rect.width;
|
||||
if(c->sel->area->floating) {
|
||||
XConfigureWindow(blz.display, c->framewin, ev->value_mask, &wc);
|
||||
XConfigureWindow(blz.dpy, c->framewin, ev->value_mask, &wc);
|
||||
configure_client(c);
|
||||
}
|
||||
}
|
||||
@ -194,9 +194,9 @@ handle_configurerequest(XEvent *e)
|
||||
wc.stack_mode = Above;
|
||||
ev->value_mask &= ~CWStackMode;
|
||||
ev->value_mask |= CWBorderWidth;
|
||||
XConfigureWindow(blz.display, ev->window, ev->value_mask, &wc);
|
||||
XConfigureWindow(blz.dpy, ev->window, ev->value_mask, &wc);
|
||||
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -275,7 +275,7 @@ handle_keypress(XEvent *e)
|
||||
return;
|
||||
buf[n] = 0;
|
||||
|
||||
if(blitz_kpress_input(&f->tagbar, ev->state, k, buf))
|
||||
if(blitz_kpress_input(&f->tagbar, k, buf))
|
||||
draw_frame(f);
|
||||
}
|
||||
else
|
||||
@ -294,11 +294,11 @@ handle_maprequest(XEvent *e)
|
||||
XMapRequestEvent *ev = &e->xmaprequest;
|
||||
static XWindowAttributes wa;
|
||||
|
||||
if(!XGetWindowAttributes(blz.display, ev->window, &wa))
|
||||
if(!XGetWindowAttributes(blz.dpy, ev->window, &wa))
|
||||
return;
|
||||
|
||||
if(wa.override_redirect) {
|
||||
XSelectInput(blz.display, ev->window,
|
||||
XSelectInput(blz.dpy, ev->window,
|
||||
(StructureNotifyMask | PropertyChangeMask));
|
||||
return;
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ create_frame(Client *c, View *v)
|
||||
if(c->frame) {
|
||||
f->revert = c->sel->revert;
|
||||
f->rect = c->sel->rect;
|
||||
}else{
|
||||
}
|
||||
else{
|
||||
f->revert = f->rect = c->rect;
|
||||
f->revert.width = f->rect.width += 2 * def.border;
|
||||
f->revert.height = f->rect.height += def.border + height_of_bar();
|
||||
@ -40,11 +41,11 @@ create_frame(Client *c, View *v)
|
||||
|
||||
f->tagbar.blitz = &blz;
|
||||
f->tagbar.drawable = pmap;
|
||||
f->tagbar.window = c->framewin;
|
||||
f->tagbar.win = c->framewin;
|
||||
f->tagbar.gc = c->gc;
|
||||
f->tagbar.font = &def.font;
|
||||
f->tagbar.color = def.normcolor;
|
||||
blitz_settext_input(&f->tagbar, c->tags);
|
||||
blitz_setinput(&f->tagbar, c->tags);
|
||||
|
||||
return f;
|
||||
}
|
||||
@ -132,9 +133,9 @@ draw_frame(Frame *f)
|
||||
blitz_draw_input(&f->tagbar);
|
||||
blitz_draw_label(&f->titlebar, f->client->name);
|
||||
blitz_draw_label(&f->posbar, buffer);
|
||||
XCopyArea(blz.display, pmap, f->client->framewin, f->client->gc,
|
||||
XCopyArea(blz.dpy, pmap, f->client->framewin, f->client->gc,
|
||||
0, 0, f->rect.width, f->rect.height, 0, 0);
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
|
48
cmd/wm/key.c
48
cmd/wm/key.c
@ -22,8 +22,8 @@ init_lock_keys()
|
||||
int i;
|
||||
|
||||
num_lock_mask = 0;
|
||||
modmap = XGetModifierMapping(blz.display);
|
||||
num_lock = XKeysymToKeycode(blz.display, XStringToKeysym("Num_Lock"));
|
||||
modmap = XGetModifierMapping(blz.dpy);
|
||||
num_lock = XKeysymToKeycode(blz.dpy, XStringToKeysym("Num_Lock"));
|
||||
|
||||
if(modmap && modmap->max_keypermod > 0) {
|
||||
int max = (sizeof(masks) / sizeof(int)) * modmap->max_keypermod;
|
||||
@ -60,26 +60,26 @@ mod_key_of_str(char *val)
|
||||
static void
|
||||
grab_key(Key *k)
|
||||
{
|
||||
XGrabKey(blz.display, k->key, k->mod, blz.root,
|
||||
XGrabKey(blz.dpy, k->key, k->mod, blz.root,
|
||||
True, GrabModeAsync, GrabModeAsync);
|
||||
if(num_lock_mask) {
|
||||
XGrabKey(blz.display, k->key, k->mod | num_lock_mask, blz.root,
|
||||
XGrabKey(blz.dpy, k->key, k->mod | num_lock_mask, blz.root,
|
||||
True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(blz.display, k->key, k->mod | num_lock_mask | LockMask, blz.root,
|
||||
XGrabKey(blz.dpy, k->key, k->mod | num_lock_mask | LockMask, blz.root,
|
||||
True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
||||
static void
|
||||
ungrab_key(Key *k)
|
||||
{
|
||||
XUngrabKey(blz.display, k->key, k->mod, blz.root);
|
||||
XUngrabKey(blz.dpy, k->key, k->mod, blz.root);
|
||||
if(num_lock_mask) {
|
||||
XUngrabKey(blz.display, k->key, k->mod | num_lock_mask, blz.root);
|
||||
XUngrabKey(blz.display, k->key, k->mod | num_lock_mask | LockMask, blz.root);
|
||||
XUngrabKey(blz.dpy, k->key, k->mod | num_lock_mask, blz.root);
|
||||
XUngrabKey(blz.dpy, k->key, k->mod | num_lock_mask | LockMask, blz.root);
|
||||
}
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
||||
static Key *
|
||||
@ -121,7 +121,7 @@ get_key(const char *name)
|
||||
kstr++;
|
||||
else
|
||||
kstr = seq[i];
|
||||
k->key = XKeysymToKeycode(blz.display, XStringToKeysym(kstr));
|
||||
k->key = XKeysymToKeycode(blz.dpy, XStringToKeysym(kstr));
|
||||
k->mod = mod_key_of_str(seq[i]);
|
||||
}
|
||||
if(r) {
|
||||
@ -140,10 +140,10 @@ next_keystroke(unsigned long *mod, KeyCode *keyCode)
|
||||
KeySym sym;
|
||||
*mod = 0;
|
||||
do {
|
||||
XMaskEvent(blz.display, KeyPressMask, &e);
|
||||
XMaskEvent(blz.dpy, KeyPressMask, &e);
|
||||
*mod |= e.xkey.state & valid_mask;
|
||||
*keyCode = (KeyCode) e.xkey.keycode;
|
||||
sym = XKeycodeToKeysym(blz.display, e.xkey.keycode, 0);
|
||||
sym = XKeycodeToKeysym(blz.dpy, e.xkey.keycode, 0);
|
||||
} while(IsModifierKey(sym));
|
||||
}
|
||||
|
||||
@ -154,18 +154,18 @@ emulate_key_press(unsigned long mod, KeyCode key)
|
||||
Window client_win;
|
||||
int revert;
|
||||
|
||||
XGetInputFocus(blz.display, &client_win, &revert);
|
||||
XGetInputFocus(blz.dpy, &client_win, &revert);
|
||||
|
||||
e.xkey.type = KeyPress;
|
||||
e.xkey.time = CurrentTime;
|
||||
e.xkey.window = client_win;
|
||||
e.xkey.display = blz.display;
|
||||
e.xkey.display = blz.dpy;
|
||||
e.xkey.state = mod;
|
||||
e.xkey.keycode = key;
|
||||
XSendEvent(blz.display, client_win, True, KeyPressMask, &e);
|
||||
XSendEvent(blz.dpy, client_win, True, KeyPressMask, &e);
|
||||
e.xkey.type = KeyRelease;
|
||||
XSendEvent(blz.display, client_win, True, KeyReleaseMask, &e);
|
||||
XSync(blz.display, False);
|
||||
XSendEvent(blz.dpy, client_win, True, KeyReleaseMask, &e);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
||||
static Key *
|
||||
@ -197,7 +197,7 @@ handle_key_seq(Window w, Key *done)
|
||||
emulate_key_press(mod, key); /* double key */
|
||||
else {
|
||||
if(!found) {
|
||||
XBell(blz.display, 0);
|
||||
XBell(blz.dpy, 0);
|
||||
} /* grabbed but not found */
|
||||
else if(!found->tnext && !found->next)
|
||||
write_event("Key %s\n", found->name);
|
||||
@ -215,15 +215,15 @@ handle_key(Window w, unsigned long mod, KeyCode keycode)
|
||||
Key *found = match_keys(key, mod, keycode, False);
|
||||
|
||||
if(!found) {
|
||||
XBell(blz.display, 0);
|
||||
XBell(blz.dpy, 0);
|
||||
} /* grabbed but not found */
|
||||
else if(!found->tnext && !found->next)
|
||||
write_event("Key %s\n", found->name);
|
||||
else {
|
||||
XGrabKeyboard(blz.display, w, True, GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||
XGrabKeyboard(blz.dpy, w, True, GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||
handle_key_seq(w, found);
|
||||
XUngrabKeyboard(blz.display, CurrentTime);
|
||||
XSync(blz.display, False);
|
||||
XUngrabKeyboard(blz.dpy, CurrentTime);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,5 +261,5 @@ update_keys()
|
||||
grab_key(k);
|
||||
}
|
||||
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
@ -159,14 +159,14 @@ draw_xor_border(XRectangle *r)
|
||||
xor.y += 2;
|
||||
xor.width = xor.width > 4 ? xor.width - 4 : 0;
|
||||
xor.height = xor.height > 4 ? xor.height - 4 : 0;
|
||||
XSetLineAttributes(blz.display, xorgc, 1, LineSolid, CapNotLast, JoinMiter);
|
||||
XDrawLine(blz.display, blz.root, xorgc, xor.x + 2, xor.y + xor.height / 2,
|
||||
XSetLineAttributes(blz.dpy, xorgc, 1, LineSolid, CapNotLast, JoinMiter);
|
||||
XDrawLine(blz.dpy, blz.root, xorgc, xor.x + 2, xor.y + xor.height / 2,
|
||||
xor.x + xor.width - 2, xor.y + xor.height / 2);
|
||||
XDrawLine(blz.display, blz.root, xorgc, xor.x + xor.width / 2, xor.y + 2,
|
||||
XDrawLine(blz.dpy, blz.root, xorgc, xor.x + xor.width / 2, xor.y + 2,
|
||||
xor.x + xor.width / 2, xor.y + xor.height - 2);
|
||||
XSetLineAttributes(blz.display, xorgc, 4, LineSolid, CapNotLast, JoinMiter);
|
||||
XDrawRectangles(blz.display, blz.root, xorgc, &xor, 1);
|
||||
XSync(blz.display, False);
|
||||
XSetLineAttributes(blz.dpy, xorgc, 4, LineSolid, CapNotLast, JoinMiter);
|
||||
XDrawRectangles(blz.dpy, blz.root, xorgc, &xor, 1);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
@ -186,7 +186,7 @@ do_mouse_resize(Client *c, BlitzAlign align)
|
||||
XRectangle origin = frect;
|
||||
XPoint pt;
|
||||
|
||||
XQueryPointer(blz.display, c->framewin, &dummy, &dummy, &i, &i, &ox, &oy, &di);
|
||||
XQueryPointer(blz.dpy, c->framewin, &dummy, &dummy, &i, &i, &ox, &oy, &di);
|
||||
rx = (float)ox / frect.width;
|
||||
ry = (float)oy / frect.height;
|
||||
|
||||
@ -202,21 +202,21 @@ do_mouse_resize(Client *c, BlitzAlign align)
|
||||
if(align&WEST)
|
||||
ox -= px;
|
||||
|
||||
XWarpPointer(blz.display, None, c->framewin, 0, 0, 0, 0, ox, oy);
|
||||
XWarpPointer(blz.dpy, None, c->framewin, 0, 0, 0, 0, ox, oy);
|
||||
}
|
||||
|
||||
XTranslateCoordinates(blz.display, c->framewin, blz.root, ox, oy, &ox, &oy, &dummy);
|
||||
XTranslateCoordinates(blz.dpy, c->framewin, blz.root, ox, oy, &ox, &oy, &dummy);
|
||||
pt.x = ox; pt.y = oy;
|
||||
|
||||
XSync(blz.display, False);
|
||||
if(XGrabPointer(blz.display, c->framewin, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
||||
XSync(blz.dpy, False);
|
||||
if(XGrabPointer(blz.dpy, c->framewin, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
|
||||
XGrabServer(blz.display);
|
||||
XGrabServer(blz.dpy);
|
||||
draw_xor_border(&frect);
|
||||
for(;;) {
|
||||
XMaskEvent(blz.display, MouseMask | ExposureMask, &ev);
|
||||
XMaskEvent(blz.dpy, MouseMask | ExposureMask, &ev);
|
||||
switch (ev.type) {
|
||||
case ButtonRelease:
|
||||
draw_xor_border(&frect);
|
||||
@ -226,11 +226,11 @@ do_mouse_resize(Client *c, BlitzAlign align)
|
||||
resize_client(c, &frect, False);
|
||||
if(rects)
|
||||
free(rects);
|
||||
XUngrabServer(blz.display);
|
||||
XUngrabPointer(blz.display, CurrentTime);
|
||||
XSync(blz.display, False);
|
||||
XUngrabServer(blz.dpy);
|
||||
XUngrabPointer(blz.dpy, CurrentTime);
|
||||
XSync(blz.dpy, False);
|
||||
|
||||
XWarpPointer(blz.display, None, c->framewin, 0, 0, 0, 0,
|
||||
XWarpPointer(blz.dpy, None, c->framewin, 0, 0, 0, 0,
|
||||
frect.width * rx, frect.height * ry);
|
||||
return;
|
||||
break;
|
||||
@ -239,7 +239,7 @@ do_mouse_resize(Client *c, BlitzAlign align)
|
||||
|
||||
pt.x = ev.xmotion.x;
|
||||
pt.y = ev.xmotion.y;
|
||||
XTranslateCoordinates(blz.display, c->framewin, blz.root, ev.xmotion.x,
|
||||
XTranslateCoordinates(blz.dpy, c->framewin, blz.root, ev.xmotion.x,
|
||||
ev.xmotion.y, &px, &py, &dummy);
|
||||
|
||||
rect_morph_xy(&origin, px-ox, py-oy, &align);
|
||||
@ -266,12 +266,12 @@ do_mouse_resize(Client *c, BlitzAlign align)
|
||||
void
|
||||
grab_mouse(Window w, unsigned long mod, unsigned int button)
|
||||
{
|
||||
XGrabButton(blz.display, button, mod, w, False, ButtonMask,
|
||||
XGrabButton(blz.dpy, button, mod, w, False, ButtonMask,
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
if((mod != AnyModifier) && num_lock_mask) {
|
||||
XGrabButton(blz.display, button, mod | num_lock_mask, w, False, ButtonMask,
|
||||
XGrabButton(blz.dpy, button, mod | num_lock_mask, w, False, ButtonMask,
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
XGrabButton(blz.display, button, mod | num_lock_mask | LockMask, w, False,
|
||||
XGrabButton(blz.dpy, button, mod | num_lock_mask | LockMask, w, False,
|
||||
ButtonMask, GrabModeAsync, GrabModeSync, None, None);
|
||||
}
|
||||
}
|
||||
@ -279,9 +279,9 @@ grab_mouse(Window w, unsigned long mod, unsigned int button)
|
||||
void
|
||||
ungrab_mouse(Window w, unsigned long mod, unsigned int button)
|
||||
{
|
||||
XUngrabButton(blz.display, button, mod, w);
|
||||
XUngrabButton(blz.dpy, button, mod, w);
|
||||
if(mod != AnyModifier && num_lock_mask) {
|
||||
XUngrabButton(blz.display, button, mod | num_lock_mask, w);
|
||||
XUngrabButton(blz.display, button, mod | num_lock_mask | LockMask, w);
|
||||
XUngrabButton(blz.dpy, button, mod | num_lock_mask, w);
|
||||
XUngrabButton(blz.dpy, button, mod | num_lock_mask | LockMask, w);
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ focus_view(WMScreen *s, View *v)
|
||||
Frame *f;
|
||||
Client *c;
|
||||
|
||||
XGrabServer(blz.display);
|
||||
XGrabServer(blz.dpy);
|
||||
assign_sel_view(v);
|
||||
|
||||
update_frame_selectors(v);
|
||||
@ -131,9 +131,9 @@ focus_view(WMScreen *s, View *v)
|
||||
if((f = c->sel)) {
|
||||
if(f->view == v) {
|
||||
resize_client(c, &f->rect, False);
|
||||
//XMoveWindow(blz.display, c->framewin, f->rect.x, f->rect.y);
|
||||
//XMoveWindow(blz.dpy, c->framewin, f->rect.x, f->rect.y);
|
||||
}else
|
||||
XMoveWindow(blz.display, c->framewin, 2 * s->rect.width + f->rect.x,
|
||||
XMoveWindow(blz.dpy, c->framewin, 2 * s->rect.width + f->rect.x,
|
||||
f->rect.y);
|
||||
}
|
||||
|
||||
@ -141,8 +141,8 @@ focus_view(WMScreen *s, View *v)
|
||||
focus_client(c, True);
|
||||
|
||||
draw_frames();
|
||||
XSync(blz.display, False);
|
||||
XUngrabServer(blz.display);
|
||||
XSync(blz.dpy, False);
|
||||
XUngrabServer(blz.dpy);
|
||||
flush_masked_events(EnterWindowMask);
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ restack_view(View *v)
|
||||
}
|
||||
|
||||
if(n)
|
||||
XRestackWindows(blz.display, wins, n);
|
||||
XRestackWindows(blz.dpy, wins, n);
|
||||
}
|
||||
|
||||
void
|
||||
|
82
cmd/wm/wm.c
82
cmd/wm/wm.c
@ -49,11 +49,11 @@ scan_wins()
|
||||
XWindowAttributes wa;
|
||||
Window d1, d2;
|
||||
|
||||
if(XQueryTree(blz.display, blz.root, &d1, &d2, &wins, &num)) {
|
||||
if(XQueryTree(blz.dpy, blz.root, &d1, &d2, &wins, &num)) {
|
||||
for(i = 0; i < num; i++) {
|
||||
if(!XGetWindowAttributes(blz.display, wins[i], &wa))
|
||||
if(!XGetWindowAttributes(blz.dpy, wins[i], &wa))
|
||||
continue;
|
||||
if(wa.override_redirect || XGetTransientForHint(blz.display, wins[i], &d1))
|
||||
if(wa.override_redirect || XGetTransientForHint(blz.dpy, wins[i], &d1))
|
||||
continue;
|
||||
if(wa.map_state == IsViewable)
|
||||
manage_client(create_client(wins[i], &wa));
|
||||
@ -71,7 +71,7 @@ win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
|
||||
unsigned long res, extra;
|
||||
int status;
|
||||
|
||||
status = XGetWindowProperty(blz.display, w, a, 0L, l, False, t, &real, &format,
|
||||
status = XGetWindowProperty(blz.dpy, w, a, 0L, l, False, t, &real, &format,
|
||||
&res, &extra, prop);
|
||||
|
||||
if(status != Success || *prop == 0) {
|
||||
@ -108,7 +108,7 @@ int
|
||||
win_state(Window w)
|
||||
{
|
||||
/* state hints */
|
||||
XWMHints *hints = XGetWMHints(blz.display, w);
|
||||
XWMHints *hints = XGetWMHints(blz.dpy, w);
|
||||
int res;
|
||||
|
||||
long *prop = 0;
|
||||
@ -130,23 +130,23 @@ win_state(Window w)
|
||||
static void
|
||||
init_atoms()
|
||||
{
|
||||
wm_atom[WMState] = XInternAtom(blz.display, "WM_STATE", False);
|
||||
wm_atom[WMProtocols] = XInternAtom(blz.display, "WM_PROTOCOLS", False);
|
||||
wm_atom[WMDelete] = XInternAtom(blz.display, "WM_DELETE_WINDOW", False);
|
||||
net_atom[NetSupported] = XInternAtom(blz.display, "_NET_SUPPORTED", False);
|
||||
net_atom[NetWMName] = XInternAtom(blz.display, "_NET_WM_NAME", False);
|
||||
tags_atom = XInternAtom(blz.display, "_WIN_TAGS", False);
|
||||
wm_atom[WMState] = XInternAtom(blz.dpy, "WM_STATE", False);
|
||||
wm_atom[WMProtocols] = XInternAtom(blz.dpy, "WM_PROTOCOLS", False);
|
||||
wm_atom[WMDelete] = XInternAtom(blz.dpy, "WM_DELETE_WINDOW", False);
|
||||
net_atom[NetSupported] = XInternAtom(blz.dpy, "_NET_SUPPORTED", False);
|
||||
net_atom[NetWMName] = XInternAtom(blz.dpy, "_NET_WM_NAME", False);
|
||||
tags_atom = XInternAtom(blz.dpy, "_WIN_TAGS", False);
|
||||
|
||||
XChangeProperty(blz.display, blz.root, net_atom[NetSupported], XA_ATOM, 32,
|
||||
XChangeProperty(blz.dpy, blz.root, net_atom[NetSupported], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *) net_atom, NetLast);
|
||||
}
|
||||
|
||||
static void
|
||||
init_cursors()
|
||||
{
|
||||
cursor[CurNormal] = XCreateFontCursor(blz.display, XC_left_ptr);
|
||||
cursor[CurResize] = XCreateFontCursor(blz.display, XC_sizing);
|
||||
cursor[CurMove] = XCreateFontCursor(blz.display, XC_fleur);
|
||||
cursor[CurNormal] = XCreateFontCursor(blz.dpy, XC_left_ptr);
|
||||
cursor[CurResize] = XCreateFontCursor(blz.dpy, XC_sizing);
|
||||
cursor[CurMove] = XCreateFontCursor(blz.dpy, XC_fleur);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -162,15 +162,15 @@ init_screen(WMScreen *screen)
|
||||
gcv.foreground = def.selcolor.bg;
|
||||
gcv.plane_mask = AllPlanes;
|
||||
gcv.graphics_exposures = False;
|
||||
xorgc = XCreateGC(blz.display, blz.root, GCForeground | GCGraphicsExposures |
|
||||
xorgc = XCreateGC(blz.dpy, blz.root, GCForeground | GCGraphicsExposures |
|
||||
GCFunction | GCSubwindowMode | GCPlaneMask, &gcv);
|
||||
|
||||
screen->rect.x = screen->rect.y = 0;
|
||||
screen->rect.width = DisplayWidth(blz.display, blz.screen);
|
||||
screen->rect.height = DisplayHeight(blz.display, blz.screen);
|
||||
screen->rect.width = DisplayWidth(blz.dpy, blz.screen);
|
||||
screen->rect.height = DisplayHeight(blz.dpy, blz.screen);
|
||||
def.snap = screen->rect.height / 63;
|
||||
|
||||
sel_screen = XQueryPointer(blz.display, blz.root, &w, &w, &ret, &ret, &ret, &ret, &mask);
|
||||
sel_screen = XQueryPointer(blz.dpy, blz.root, &w, &w, &ret, &ret, &ret, &ret, &mask);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -198,7 +198,7 @@ wmii_error_handler(Display *dpy, XErrorEvent *error)
|
||||
return 0;
|
||||
fprintf(stderr, "wmiiwm: fatal error: Xrequest code=%d, Xerror code=%d\n",
|
||||
error->request_code, error->error_code);
|
||||
return x_error_handler(blz.display, error); /* calls exit() */
|
||||
return x_error_handler(blz.dpy, error); /* calls exit() */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -218,8 +218,8 @@ cleanup()
|
||||
Client *c;
|
||||
for(c=client; c; c=c->next)
|
||||
reparent_client(c, blz.root, c->sel->rect.x, c->sel->rect.y);
|
||||
XSetInputFocus(blz.display, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XSync(blz.display, False);
|
||||
XSetInputFocus(blz.dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
||||
int
|
||||
@ -258,18 +258,18 @@ main(int argc, char *argv[])
|
||||
|
||||
starting = True;
|
||||
|
||||
blz.display = XOpenDisplay(0);
|
||||
if(!blz.display)
|
||||
error("wmiiwm: cannot open display\n");
|
||||
blz.screen = DefaultScreen(blz.display);
|
||||
blz.root = RootWindow(blz.display, blz.screen);
|
||||
blz.dpy = XOpenDisplay(0);
|
||||
if(!blz.dpy)
|
||||
error("wmiiwm: cannot open dpy\n");
|
||||
blz.screen = DefaultScreen(blz.dpy);
|
||||
blz.root = RootWindow(blz.dpy, blz.screen);
|
||||
|
||||
/* check if another WM is already running */
|
||||
other_wm_running = 0;
|
||||
XSetErrorHandler(startup_error_handler);
|
||||
/* this causes an error if some other WM is running */
|
||||
XSelectInput(blz.display, blz.root, SubstructureRedirectMask | EnterWindowMask);
|
||||
XSync(blz.display, False);
|
||||
XSelectInput(blz.dpy, blz.root, SubstructureRedirectMask | EnterWindowMask);
|
||||
XSync(blz.dpy, False);
|
||||
|
||||
if(other_wm_running)
|
||||
error("wmiiwm: another window manager is already running\n");
|
||||
@ -314,7 +314,7 @@ main(int argc, char *argv[])
|
||||
if(setsid() == -1)
|
||||
error("wmiim: can't setsid: %s\n", strerror(errno));
|
||||
close(i);
|
||||
close(ConnectionNumber(blz.display));
|
||||
close(ConnectionNumber(blz.dpy));
|
||||
snprintf(execstr, name_len, "exec %s", wmiirc);
|
||||
execl("/bin/sh", "sh", "-c", execstr, nil);
|
||||
error("wmiiwm: can't exec \"%s\": %s\n", wmiirc, strerror(errno));
|
||||
@ -329,7 +329,7 @@ main(int argc, char *argv[])
|
||||
ixp_server_open_conn(&srv, i, &p9srv, serve_9pcon, nil);
|
||||
|
||||
/* X server */
|
||||
ixp_server_open_conn(&srv, ConnectionNumber(blz.display), nil, check_x_event, nil);
|
||||
ixp_server_open_conn(&srv, ConnectionNumber(blz.dpy), nil, check_x_event, nil);
|
||||
|
||||
view = nil;
|
||||
client = nil;
|
||||
@ -370,12 +370,12 @@ main(int argc, char *argv[])
|
||||
|
||||
init_screen(s);
|
||||
|
||||
pmap = XCreatePixmap(blz.display, blz.root, s->rect.width, s->rect.height,
|
||||
DefaultDepth(blz.display, blz.screen));
|
||||
pmap = XCreatePixmap(blz.dpy, blz.root, s->rect.width, s->rect.height,
|
||||
DefaultDepth(blz.dpy, blz.screen));
|
||||
|
||||
wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
|
||||
wa.cursor = cursor[CurNormal];
|
||||
XChangeWindowAttributes(blz.display, blz.root, CWEventMask | CWCursor, &wa);
|
||||
XChangeWindowAttributes(blz.dpy, blz.root, CWEventMask | CWCursor, &wa);
|
||||
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
@ -385,16 +385,16 @@ main(int argc, char *argv[])
|
||||
s->brect = s->rect;
|
||||
s->brect.height = height_of_bar();
|
||||
s->brect.y = s->rect.height - s->brect.height;
|
||||
s->barwin = XCreateWindow(blz.display, RootWindow(blz.display, blz.screen),
|
||||
s->barwin = XCreateWindow(blz.dpy, RootWindow(blz.dpy, blz.screen),
|
||||
s->brect.x, s->brect.y,
|
||||
s->brect.width, s->brect.height, 0,
|
||||
DefaultDepth(blz.display, blz.screen),
|
||||
CopyFromParent, DefaultVisual(blz.display, blz.screen),
|
||||
DefaultDepth(blz.dpy, blz.screen),
|
||||
CopyFromParent, DefaultVisual(blz.dpy, blz.screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
|
||||
s->bbrush.blitz = &blz;
|
||||
s->bbrush.gc = XCreateGC(blz.display, s->barwin, 0, 0);
|
||||
s->bbrush.gc = XCreateGC(blz.dpy, s->barwin, 0, 0);
|
||||
s->bbrush.drawable = pmap;
|
||||
s->bbrush.rect = s->brect;
|
||||
s->bbrush.rect.x = 0;
|
||||
@ -404,7 +404,7 @@ main(int argc, char *argv[])
|
||||
s->bbrush.border = True;
|
||||
|
||||
draw_bar(s);
|
||||
XMapRaised(blz.display, s->barwin);
|
||||
XMapRaised(blz.dpy, s->barwin);
|
||||
}
|
||||
|
||||
screen = &screens[0];
|
||||
@ -419,7 +419,7 @@ main(int argc, char *argv[])
|
||||
fprintf(stderr, "wmii: fatal: %s\n", errstr);
|
||||
|
||||
cleanup();
|
||||
XCloseDisplay(blz.display);
|
||||
XCloseDisplay(blz.dpy);
|
||||
ixp_server_close(&srv);
|
||||
|
||||
return errstr ? 1 : 0;
|
||||
|
@ -185,9 +185,9 @@ draw_menu()
|
||||
brush.rect.width = seek;
|
||||
blitz_draw_label(&brush, item.size > nextoff ? ">" : nil);
|
||||
}
|
||||
XCopyArea(blz.display, brush.drawable, win, brush.gc, 0, 0, irect.width,
|
||||
XCopyArea(blz.dpy, brush.drawable, win, brush.gc, 0, 0, irect.width,
|
||||
irect.height, 0, 0);
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -367,19 +367,19 @@ main(int argc, char *argv[])
|
||||
usage();
|
||||
}
|
||||
|
||||
blz.display = XOpenDisplay(0);
|
||||
if(!blz.display) {
|
||||
fprintf(stderr, "%s", "wmiimenu: cannot open display\n");
|
||||
blz.dpy = XOpenDisplay(0);
|
||||
if(!blz.dpy) {
|
||||
fprintf(stderr, "%s", "wmiimenu: cannot open dpy\n");
|
||||
exit(1);
|
||||
}
|
||||
blz.screen = DefaultScreen(blz.display);
|
||||
blz.root = RootWindow(blz.display, blz.screen);
|
||||
blz.screen = DefaultScreen(blz.dpy);
|
||||
blz.root = RootWindow(blz.dpy, blz.screen);
|
||||
|
||||
maxname = read_allitems();
|
||||
|
||||
/* grab as early as possible, but after reading all items!!! */
|
||||
while(XGrabKeyboard
|
||||
(blz.display, blz.root, True, GrabModeAsync,
|
||||
(blz.dpy, blz.root, True, GrabModeAsync,
|
||||
GrabModeAsync, CurrentTime) != GrabSuccess)
|
||||
usleep(1000);
|
||||
|
||||
@ -405,24 +405,24 @@ main(int argc, char *argv[])
|
||||
wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask
|
||||
| SubstructureRedirectMask | SubstructureNotifyMask;
|
||||
|
||||
irect.width = DisplayWidth(blz.display, blz.screen);
|
||||
irect.width = DisplayWidth(blz.dpy, blz.screen);
|
||||
irect.height = font.ascent + font.descent + 4;
|
||||
irect.y = DisplayHeight(blz.display, blz.screen) - irect.height;
|
||||
irect.y = DisplayHeight(blz.dpy, blz.screen) - irect.height;
|
||||
irect.x = 0;
|
||||
|
||||
win = XCreateWindow(blz.display, blz.root, irect.x, irect.y,
|
||||
irect.width, irect.height, 0, DefaultDepth(blz.display, blz.screen),
|
||||
CopyFromParent, DefaultVisual(blz.display, blz.screen),
|
||||
win = XCreateWindow(blz.dpy, blz.root, irect.x, irect.y,
|
||||
irect.width, irect.height, 0, DefaultDepth(blz.dpy, blz.screen),
|
||||
CopyFromParent, DefaultVisual(blz.dpy, blz.screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(blz.display, win, XCreateFontCursor(blz.display, XC_xterm));
|
||||
XSync(blz.display, False);
|
||||
XDefineCursor(blz.dpy, win, XCreateFontCursor(blz.dpy, XC_xterm));
|
||||
XSync(blz.dpy, False);
|
||||
|
||||
/* pixmap */
|
||||
gc = XCreateGC(blz.display, win, 0, 0);
|
||||
pmap = XCreatePixmap(blz.display, win, irect.width, irect.height,
|
||||
DefaultDepth(blz.display, blz.screen));
|
||||
gc = XCreateGC(blz.dpy, win, 0, 0);
|
||||
pmap = XCreatePixmap(blz.dpy, win, irect.width, irect.height,
|
||||
DefaultDepth(blz.dpy, blz.screen));
|
||||
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
|
||||
brush.blitz = &blz;
|
||||
brush.color = normcolor;
|
||||
@ -445,12 +445,12 @@ main(int argc, char *argv[])
|
||||
|
||||
text[0] = 0;
|
||||
update_items(text);
|
||||
XMapRaised(blz.display, win);
|
||||
XMapRaised(blz.dpy, win);
|
||||
draw_menu();
|
||||
XSync(blz.display, False);
|
||||
XSync(blz.dpy, False);
|
||||
|
||||
/* main event loop */
|
||||
while(!XNextEvent(blz.display, &ev)) {
|
||||
while(!XNextEvent(blz.dpy, &ev)) {
|
||||
switch (ev.type) {
|
||||
case KeyPress:
|
||||
handle_kpress(&ev.xkey);
|
||||
@ -467,11 +467,11 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
XUngrabKeyboard(blz.display, CurrentTime);
|
||||
XFreePixmap(blz.display, pmap);
|
||||
XFreeGC(blz.display, gc);
|
||||
XDestroyWindow(blz.display, win);
|
||||
XCloseDisplay(blz.display);
|
||||
XUngrabKeyboard(blz.dpy, CurrentTime);
|
||||
XFreePixmap(blz.dpy, pmap);
|
||||
XFreeGC(blz.dpy, gc);
|
||||
XDestroyWindow(blz.dpy, win);
|
||||
XCloseDisplay(blz.dpy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ typedef struct BlitzBrush BlitzBrush;
|
||||
typedef struct BlitzInput BlitzInput;
|
||||
|
||||
struct Blitz {
|
||||
Display *display;
|
||||
Display *dpy;
|
||||
int screen;
|
||||
Window root;
|
||||
};
|
||||
@ -66,10 +66,11 @@ struct BlitzInput {
|
||||
char *text;
|
||||
char *curstart;
|
||||
char *curend;
|
||||
Bool drag;
|
||||
unsigned int size;
|
||||
unsigned int len;
|
||||
Bool drag;
|
||||
Drawable drawable;
|
||||
Window window;
|
||||
Window win;
|
||||
GC gc;
|
||||
BlitzColor color;
|
||||
BlitzFont *font;
|
||||
@ -101,5 +102,5 @@ Bool blitz_bpress_input(BlitzInput *i, int x, int y);
|
||||
Bool blitz_brelease_input(BlitzInput *i, int x, int y);
|
||||
Bool blitz_bmotion_input(BlitzInput *i, int x, int y);
|
||||
Bool blitz_ispointinrect(int x, int y, XRectangle * r);
|
||||
void blitz_settext_input(BlitzInput *i, const char *text);
|
||||
Bool blitz_kpress_input(BlitzInput *i, unsigned long mod, KeySym k, const char *ks);
|
||||
void blitz_setinput(BlitzInput *i, char *text);
|
||||
Bool blitz_kpress_input(BlitzInput *i, KeySym k, char *ks);
|
||||
|
@ -12,7 +12,7 @@
|
||||
void
|
||||
blitz_draw_tile(BlitzBrush *b)
|
||||
{
|
||||
blitz_drawbg(b->blitz->display, b->drawable, b->gc, b->rect,
|
||||
blitz_drawbg(b->blitz->dpy, b->drawable, b->gc, b->rect,
|
||||
b->color, b->border);
|
||||
}
|
||||
|
||||
@ -35,10 +35,10 @@ blitz_draw_label(BlitzBrush *b, char *text)
|
||||
gcv.foreground = b->color.fg;
|
||||
gcv.background = b->color.bg;
|
||||
if(b->font->set)
|
||||
XChangeGC(b->blitz->display, b->gc, GCForeground | GCBackground, &gcv);
|
||||
XChangeGC(b->blitz->dpy, b->gc, GCForeground | GCBackground, &gcv);
|
||||
else {
|
||||
gcv.font = b->font->xfont->fid;
|
||||
XChangeGC(b->blitz->display, b->gc, GCForeground | GCBackground | GCFont, &gcv);
|
||||
XChangeGC(b->blitz->dpy, b->gc, GCForeground | GCBackground | GCFont, &gcv);
|
||||
}
|
||||
|
||||
h = b->font->ascent + b->font->descent;
|
||||
@ -78,8 +78,8 @@ blitz_draw_label(BlitzBrush *b, char *text)
|
||||
break;
|
||||
}
|
||||
if(b->font->set)
|
||||
XmbDrawImageString(b->blitz->display, b->drawable, b->font->set, b->gc,
|
||||
XmbDrawImageString(b->blitz->dpy, b->drawable, b->font->set, b->gc,
|
||||
x, y, buf, len);
|
||||
else
|
||||
XDrawImageString(b->blitz->display, b->drawable, b->gc, x, y, buf, len);
|
||||
XDrawImageString(b->blitz->dpy, b->drawable, b->gc, x, y, buf, len);
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ xloadcolor(Blitz *blitz, char *colstr)
|
||||
|
||||
cext_strlcpy(col, colstr, sizeof(col));
|
||||
col[7] = 0;
|
||||
XAllocNamedColor(blitz->display,
|
||||
DefaultColormap(blitz->display, blitz->screen), col, &color, &color);
|
||||
XAllocNamedColor(blitz->dpy,
|
||||
DefaultColormap(blitz->dpy, blitz->screen), col, &color, &color);
|
||||
return color.pixel;
|
||||
}
|
||||
|
||||
|
@ -37,14 +37,14 @@ blitz_loadfont(Blitz *blitz, BlitzFont *font)
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
if(font->set)
|
||||
XFreeFontSet(blitz->display, font->set);
|
||||
font->set = XCreateFontSet(blitz->display, fontname, &missing, &n, &def);
|
||||
XFreeFontSet(blitz->dpy, font->set);
|
||||
font->set = XCreateFontSet(blitz->dpy, fontname, &missing, &n, &def);
|
||||
if(missing) {
|
||||
while(n--)
|
||||
fprintf(stderr, "liblitz: missing fontset: %s\n", missing[n]);
|
||||
XFreeStringList(missing);
|
||||
if(font->set) {
|
||||
XFreeFontSet(blitz->display, font->set);
|
||||
XFreeFontSet(blitz->dpy, font->set);
|
||||
font->set = nil;
|
||||
}
|
||||
}
|
||||
@ -67,12 +67,12 @@ blitz_loadfont(Blitz *blitz, BlitzFont *font)
|
||||
}
|
||||
else {
|
||||
if(font->xfont)
|
||||
XFreeFont(blitz->display, font->xfont);
|
||||
XFreeFont(blitz->dpy, font->xfont);
|
||||
font->xfont = nil;
|
||||
font->xfont = XLoadQueryFont(blitz->display, fontname);
|
||||
font->xfont = XLoadQueryFont(blitz->dpy, fontname);
|
||||
if (!font->xfont) {
|
||||
fontname = "fixed";
|
||||
font->xfont = XLoadQueryFont(blitz->display, fontname);
|
||||
font->xfont = XLoadQueryFont(blitz->dpy, fontname);
|
||||
}
|
||||
if (!font->xfont) {
|
||||
fprintf(stderr, "%s", "liblitz: error, cannot load 'fixed' font\n");
|
||||
|
258
liblitz/input.c
258
liblitz/input.c
@ -25,10 +25,10 @@ xchangegc(BlitzInput *i, BlitzColor *c, Bool invert)
|
||||
gcv.background = c->bg;
|
||||
}
|
||||
if(i->font->set)
|
||||
XChangeGC(i->blitz->display, i->gc, GCForeground | GCBackground, &gcv);
|
||||
XChangeGC(i->blitz->dpy, i->gc, GCForeground | GCBackground, &gcv);
|
||||
else {
|
||||
gcv.font = i->font->xfont->fid;
|
||||
XChangeGC(i->blitz->display, i->gc, GCForeground | GCBackground | GCFont, &gcv);
|
||||
XChangeGC(i->blitz->dpy, i->gc, GCForeground | GCBackground | GCFont, &gcv);
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,64 +36,69 @@ static void
|
||||
xdrawtextpart(BlitzInput *i, char *start, char *end,
|
||||
unsigned int *xoff, unsigned int yoff)
|
||||
{
|
||||
char c;
|
||||
unsigned int len;
|
||||
|
||||
if(!start)
|
||||
if(!start || !(len = end - start))
|
||||
return;
|
||||
if(end) {
|
||||
c = *end;
|
||||
*end = 0;
|
||||
}
|
||||
if(i->font->set)
|
||||
XmbDrawImageString(i->blitz->display, i->drawable, i->font->set, i->gc,
|
||||
*xoff, yoff, start, strlen(start));
|
||||
else
|
||||
XDrawImageString(i->blitz->display, i->drawable, i->gc, *xoff, yoff,
|
||||
start, strlen(start));
|
||||
|
||||
*xoff += blitz_textwidth(i->font, start);
|
||||
if(end)
|
||||
*end = c;
|
||||
if(i->font->set)
|
||||
XmbDrawImageString(i->blitz->dpy, i->drawable, i->font->set, i->gc,
|
||||
*xoff, yoff, start, len);
|
||||
else
|
||||
XDrawImageString(i->blitz->dpy, i->drawable, i->gc, *xoff, yoff,
|
||||
start, len);
|
||||
|
||||
*xoff += blitz_textwidth_l(i->font, start, len);
|
||||
}
|
||||
|
||||
void
|
||||
blitz_setinput(BlitzInput *i, char *text)
|
||||
{
|
||||
if(!text) {
|
||||
if(i->size) {
|
||||
i->text[0] = 0;
|
||||
i->len = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
i->len = strlen(text);
|
||||
if(i->len > i->size) {
|
||||
i->size = 2 * i->len;
|
||||
i->text = realloc(i->text, i->size);
|
||||
}
|
||||
memcpy(i->text, text, i->len + 1);
|
||||
i->curstart = i->curend = i->text + i->len;
|
||||
}
|
||||
|
||||
static char *
|
||||
curend(BlitzInput *i)
|
||||
{
|
||||
if(i->curstart && i->curend) {
|
||||
if(i->curstart < i->curend)
|
||||
return i->curend;
|
||||
else
|
||||
return i->curstart;
|
||||
}
|
||||
else if(i->curend)
|
||||
return nil;
|
||||
return i->curend;
|
||||
if(i->curstart < i->curend)
|
||||
return i->curend;
|
||||
else
|
||||
return i->curstart;
|
||||
}
|
||||
|
||||
static char *
|
||||
curstart(BlitzInput *i)
|
||||
{
|
||||
if(i->curstart && i->curend) {
|
||||
if(i->curstart < i->curend)
|
||||
return i->curstart;
|
||||
else
|
||||
return i->curend;
|
||||
}
|
||||
else if(i->curend)
|
||||
if(i->curstart < i->curend)
|
||||
return i->curstart;
|
||||
else
|
||||
return i->curend;
|
||||
return i->curstart;
|
||||
}
|
||||
|
||||
void
|
||||
blitz_draw_input(BlitzInput *i)
|
||||
{
|
||||
unsigned int xoff, yoff, xcursor, h;
|
||||
char *start, *end;
|
||||
unsigned int xoff, yoff, xcursor, h;
|
||||
|
||||
if (!i)
|
||||
return;
|
||||
|
||||
blitz_drawbg(i->blitz->display, i->drawable, i->gc, i->rect, i->color, True);
|
||||
blitz_drawbg(i->blitz->dpy, i->drawable, i->gc, i->rect, i->color, True);
|
||||
|
||||
h = (i->font->ascent + i->font->descent);
|
||||
yoff = i->rect.y + (i->rect.height - h) / 2 + i->font->ascent;
|
||||
@ -111,13 +116,13 @@ blitz_draw_input(BlitzInput *i)
|
||||
xdrawtextpart(i, start, end, &xoff, yoff);
|
||||
/* draw remaining normal text */
|
||||
xchangegc(i, &i->color, False);
|
||||
xdrawtextpart(i, end, nil, &xoff, yoff);
|
||||
xdrawtextpart(i, end, i->text + i->len, &xoff, yoff);
|
||||
|
||||
/* draw cursor */
|
||||
if(!start && !end)
|
||||
xcursor = xoff;
|
||||
if(start == end)
|
||||
blitz_drawcursor(i->blitz->display, i->drawable, i->gc,
|
||||
blitz_drawcursor(i->blitz->dpy, i->drawable, i->gc,
|
||||
xcursor, yoff - h + 2, h - 1, i->color);
|
||||
}
|
||||
|
||||
@ -148,110 +153,16 @@ xcharof(BlitzInput *i, int x, char *start, unsigned int len)
|
||||
static char *
|
||||
charof(BlitzInput *i, int x, int y)
|
||||
{
|
||||
unsigned int len;
|
||||
|
||||
if(!i->text || !blitz_ispointinrect(x, y, &i->rect))
|
||||
return nil;
|
||||
|
||||
len = strlen(i->text);
|
||||
/* normalize and check x */
|
||||
if((x -= (i->rect.x + i->rect.height / 2)) < 0)
|
||||
return i->text;
|
||||
else if(x > blitz_textwidth_l(i->font, i->text, len))
|
||||
return nil;
|
||||
else if(x > blitz_textwidth_l(i->font, i->text, i->len))
|
||||
return i->text + i->len;
|
||||
|
||||
return xcharof(i, x, i->text, strlen(i->text));
|
||||
}
|
||||
|
||||
static char *
|
||||
cursor(BlitzInput *i)
|
||||
{
|
||||
char *start = curstart(i);
|
||||
char *end = curend(i);
|
||||
|
||||
if(!start && i->text)
|
||||
return i->text + (i->size - 1);
|
||||
return end;
|
||||
}
|
||||
|
||||
static Bool
|
||||
insert(BlitzInput *i, const char s)
|
||||
{
|
||||
char *buf, *c, *p, *q;
|
||||
|
||||
if(!(c = cursor(i)))
|
||||
return False;
|
||||
|
||||
buf = cext_emallocz(++i->size);
|
||||
for(p = i->text, q = buf; p != c; p++, q++)
|
||||
*q = *p;
|
||||
*q = s;
|
||||
for(q++; *p; p++, q++)
|
||||
*q = *p;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
static Bool
|
||||
delete(BlitzInput *i)
|
||||
{
|
||||
char *c, *p, *q;
|
||||
|
||||
if(!(c = cursor(i)))
|
||||
return False;
|
||||
|
||||
for(q = c, p = c + 1; *p; p++, q++)
|
||||
*q = *p;
|
||||
return True;
|
||||
}
|
||||
|
||||
static void
|
||||
left(BlitzInput *i)
|
||||
{
|
||||
char *c;
|
||||
if(!(c = cursor(i)))
|
||||
return;
|
||||
|
||||
if(c > i->text)
|
||||
i->curstart = i->curend = c - 1;
|
||||
else
|
||||
i->curstart = i->curstart = i->text;
|
||||
}
|
||||
|
||||
static void
|
||||
right(BlitzInput *i)
|
||||
{
|
||||
char *c = cursor(i);
|
||||
|
||||
if(!c)
|
||||
i->curstart = i->curend = nil;
|
||||
else {
|
||||
if(c < i->text + (i->size - 1))
|
||||
i->curstart = i->curend = c + 1;
|
||||
else
|
||||
i->curstart = i->curend = nil;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
blitz_settext_input(BlitzInput *i, const char *text)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
|
||||
if(!text) {
|
||||
i->size = 0;
|
||||
if(i->text)
|
||||
free(i->text);
|
||||
i->text = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(len = strlen(text)))
|
||||
return;
|
||||
|
||||
i->size = len + 1;
|
||||
i->text = realloc(i->text, i->size);
|
||||
memcpy(i->text, text, i->size);
|
||||
return xcharof(i, x, i->text, i->len);
|
||||
}
|
||||
|
||||
Bool
|
||||
@ -274,8 +185,6 @@ blitz_brelease_input(BlitzInput *i, int x, int y)
|
||||
|
||||
if(!(i->drag = blitz_ispointinrect(x, y, &i->rect)))
|
||||
return False;
|
||||
/*XGrabKeyboard(i->blitz->display, i->window, True,
|
||||
GrabModeAsync, GrabModeAsync, CurrentTime);*/
|
||||
oend = i->curend;
|
||||
i->curend = charof(i, x, y);
|
||||
i->drag = False;
|
||||
@ -286,78 +195,57 @@ Bool
|
||||
blitz_bmotion_input(BlitzInput *i, int x, int y)
|
||||
{
|
||||
char *oend;
|
||||
Bool focus;
|
||||
|
||||
if(!i->drag || !(i->drag = blitz_ispointinrect(x, y, &i->rect)))
|
||||
focus = blitz_ispointinrect(x, y, &i->rect);
|
||||
|
||||
if(focus)
|
||||
XSetInputFocus(i->blitz->dpy, i->win,
|
||||
RevertToPointerRoot, CurrentTime);
|
||||
|
||||
if(!i->drag || !(i->drag = focus))
|
||||
return False;
|
||||
|
||||
oend = i->curend;
|
||||
i->curend = charof(i, x, y);
|
||||
return i->curend == oend;
|
||||
}
|
||||
|
||||
Bool
|
||||
blitz_kpress_input(BlitzInput *i, unsigned long mod, KeySym k, const char *ks)
|
||||
blitz_kpress_input(BlitzInput *i, KeySym k, char *ks)
|
||||
{
|
||||
if(mod & ControlMask) {
|
||||
switch (k) {
|
||||
case XK_a:
|
||||
k = XK_Begin;
|
||||
break;
|
||||
case XK_b:
|
||||
k = XK_Left;
|
||||
break;
|
||||
case XK_e:
|
||||
k = XK_End;
|
||||
break;
|
||||
case XK_h:
|
||||
k = XK_BackSpace;
|
||||
break;
|
||||
case XK_j:
|
||||
k= XK_Return;
|
||||
break;
|
||||
case XK_k:
|
||||
k = XK_Delete;
|
||||
break;
|
||||
case XK_u:
|
||||
blitz_settext_input(i, nil);
|
||||
return True;
|
||||
case XK_w:
|
||||
k = XK_BackSpace;
|
||||
break;
|
||||
default:
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
char *start, *end;
|
||||
if(IsCursorKey(k)) {
|
||||
start = curstart(i);
|
||||
end = curend(i);
|
||||
switch(k) {
|
||||
case XK_Home:
|
||||
case XK_Begin:
|
||||
i->curstart = i->curend = i->text;
|
||||
return True;
|
||||
case XK_Left:
|
||||
left(i);
|
||||
if(start != end)
|
||||
i->curstart = i->curend = start;
|
||||
else if(start > i->start)
|
||||
i->curstart = i->curend = start--;
|
||||
else
|
||||
i->curstart = i->curend = i->start;
|
||||
return True;
|
||||
case XK_Right:
|
||||
right(i);
|
||||
return True;
|
||||
case XK_End:
|
||||
i->curstart = i->curend = nil;
|
||||
if(start != end)
|
||||
i->curstart = i->curend = end;
|
||||
else if(start < i->end)
|
||||
i->curstart = i->curend = start++;
|
||||
else
|
||||
i->curstart = i->curend = i->end;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch(k) {
|
||||
case XK_Tab:
|
||||
case XK_Num_Lock:
|
||||
case XK_Return:
|
||||
break;
|
||||
case XK_Delete:
|
||||
case XK_BackSpace:
|
||||
return delete(i);
|
||||
default:
|
||||
return insert(i, *ks);
|
||||
return insert(i, ks);
|
||||
}
|
||||
}
|
||||
*/
|
||||
return False;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user