Fix focus bugs. Darken background when floating area selected. Make printevent custom formatter.

This commit is contained in:
Kris Maglione 2008-05-27 18:34:59 -04:00
parent a01c4f7b6a
commit d951419167
11 changed files with 168 additions and 131 deletions

View File

@ -188,6 +188,10 @@ area_setsel(Area *a, Frame *f) {
View *v;
v = a->view;
for(; f && f->collapsed && f->anext; f=f->anext)
;
for(; f && f->collapsed && f->aprev; f=f->aprev)
;
if(a == v->sel && f)
frame_focus(f);
else

View File

@ -853,6 +853,7 @@ enter_event(Window *w, XCrossingEvent *e) {
c = w->aux;
if(e->detail != NotifyInferior) {
if(e->detail != NotifyVirtual)
if(!ignoreenter && screen->focus != c) {
Dprint(DFocus, "enter_notify([%C]%s)\n", c, c->name);
focus(c, false);

View File

@ -89,6 +89,13 @@ stack_info(Frame *f, Frame **firstp, int *dyp, int *nframep) {
nframe = 0;
dy = 0;
first = nil;
for(ft=f; ft && ft->collapsed; ft=ft->anext)
;
if(ft && ft != f) {
f = ft;
dy += Dy(f->colr);
}
for(ft=f; ft && !ft->collapsed; ft=ft->aprev) {
first = ft;
nframe++;
@ -133,7 +140,8 @@ column_detach(Frame *f) {
stack_info(f, &first, &dy, nil);
column_remove(f);
if(a->frame) {
stack_scale(first, dy);
if(first)
stack_scale(first, dy);
column_arrange(a, false);
}else if(a->view->area->next->next)
area_destroy(a);
@ -480,6 +488,7 @@ column_arrange(Area *a, bool dirty) {
}
column_scale(a);
resize:
area_setsel(a, a->sel);
if(v == screen->sel) {
//view_restack(v);
client_resize(a->sel->client, a->sel->r);

View File

@ -7,8 +7,7 @@
void
dispatch_event(XEvent *e) {
Debug(DEvent)
printevent(e);
Dprint(DEvent, "%E\n", e);
if(e->type < nelem(handler)) {
if(handler[e->type])
handler[e->type](e);

View File

@ -213,6 +213,7 @@ enter_event(Window *w, XCrossingEvent *e) {
f = c->sel;
if(screen->focus != c || selclient() != c) {
Dprint(DFocus, "enter_notify(f) => %s\n", f->client->name);
if(e->detail != NotifyInferior)
if(!ignoreenter && (f->area->floating || !f->collapsed))
focus(f->client, false);
}
@ -575,6 +576,11 @@ frame_focus(Frame *f) {
a = f->area;
old_a = v->sel;
for(; f->collapsed && f->anext; f=f->anext)
;
for(; f->collapsed && f->aprev; f=f->aprev)
;
old_f = old_a->sel;
a->sel = f;

View File

@ -235,7 +235,7 @@ static void
trampoline(int fn, Frame *f) {
while(fn > 0) {
f->collapsed = false;
//f->collapsed = false;
fn = tramp[fn](f);
}
ungrabpointer();
@ -356,7 +356,7 @@ column_drop(Area *a, Frame *f, int y) {
return;
}
for(ff=a->frame; ff->anext; ff=ff->anext)
if(y < ff->colr.max.y) break;
if(y <= ff->colr.max.y) break;
y = max(y, ff->colr.min.y + labelh(def.font));
y = min(y, ff->colr.max.y);
@ -365,7 +365,7 @@ column_drop(Area *a, Frame *f, int y) {
f->collapsed = true;
f->colr.min.y = 0;
f->colr.max.y = labelh(def.font);
column_openstack(a, ff->anext, labelh(def.font) - dy);
column_openstack(a, ff, labelh(def.font) - dy);
}else {
f->colr.min.y = y;
f->colr.max.y = ff->colr.max.y;
@ -381,7 +381,7 @@ thcol(Frame *f) {
Area *a;
Point pt, pt2;
uint button;
int ret;
int ret, collapsed;
focus(f->client, false);
@ -407,16 +407,29 @@ thcol(Frame *f) {
if(a->floating)
area_detach(f);
else {
collapsed = f->collapsed;
fp = f->aprev;
fn = f->anext;
column_remove(f);
if(fp)
fp->colr.max.y = f->colr.max.y;
else if(fn && fw->pt.y > fn->r.min.y)
fn->colr.min.y = f->colr.min.y;
if(!f->collapsed)
if(fp)
fp->colr.max.y = f->colr.max.y;
else if(fn && fw->pt.y > fn->r.min.y)
fn->colr.min.y = f->colr.min.y;
}
column_drop(fw->ra, f, fw->pt.y);
if(collapsed) {
/* XXX */
for(; fn && fn->collapsed; fn=fn->anext)
;
if(fn == nil)
for(fn=fp; fn && fn->collapsed; fn=fn->aprev)
;
if(fp)
fp->colr.max.x += labelh(def.font);
}
if(!a->frame && !a->floating && f->view->area->next->next)
area_destroy(a);

View File

@ -302,6 +302,8 @@ main(int argc, char *argv[]) {
fmtinstall('r', errfmt);
fmtinstall('a', afmt);
fmtinstall('C', Cfmt);
extern int fmtevent(Fmt*);
fmtinstall('E', fmtevent);
wmiirc = "wmiistartrc";

View File

@ -493,22 +493,18 @@ TAtom(Fmt *b, va_list *ap) {
#define TEnd nil
typedef void (*Tfn)(Fmt*, va_list*);
static void
pevent(void *e, ...) {
Fmt f;
static int
pevent(Fmt *fmt, void *e, ...) {
va_list ap;
Tfn fn;
XAnyEvent *ev;
char *key, *s;
char *key;
int n;
if(fmtstrinit(&f) < 0)
return;
ev = e;
fmtprint(&f, "%3ld %-20s ", ev->serial, eventtype(ev->type));
fmtprint(fmt, "%3ld %-20s ", ev->serial, eventtype(ev->type));
if(ev->send_event)
fmtstrcpy(&f, "(sendevent) ");
fmtstrcpy(fmt, "(sendevent) ");
n = 0;
va_start(ap, e);
@ -518,31 +514,25 @@ pevent(void *e, ...) {
break;
if(n++ != 0)
fmtprint(&f, "%s", sep);
fmtprint(fmt, "%s", sep);
key = va_arg(ap, char*);
fmtprint(&f, "%s=", key);
fn(&f, &ap);
fmtprint(fmt, "%s=", key);
fn(fmt, &ap);
}
va_end(ap);
fmtstrcpy(&f, "\n");
s = fmtstrflush(&f);
void dprint(const char*, ...);
dprint("%s", s);
free(s);
return 0;
}
/*****************************************************************************/
/*** Routines to print out readable values for the field of various events ***/
/*****************************************************************************/
static void
VerbMotion(XEvent *e) {
static int
VerbMotion(Fmt *fmt, XEvent *e) {
XMotionEvent *ev = &e->xmotion;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TWindow, _(root),
TWindow, _(subwindow),
@ -556,11 +546,11 @@ VerbMotion(XEvent *e) {
//fprintf(stderr, "is_hint=%s%s", IsHint(ev->is_hint), sep);
}
static void
VerbButton(XEvent *e) {
static int
VerbButton(Fmt *fmt, XEvent *e) {
XButtonEvent *ev = &e->xbutton;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TWindow, _(root),
TWindow, _(subwindow),
@ -574,11 +564,11 @@ VerbButton(XEvent *e) {
);
}
static void
VerbColormap(XEvent *e) {
static int
VerbColormap(Fmt *fmt, XEvent *e) {
XColormapEvent *ev = &e->xcolormap;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TIntNone, _(colormap),
TBool, _(new),
@ -587,11 +577,11 @@ VerbColormap(XEvent *e) {
);
}
static void
VerbCrossing(XEvent *e) {
static int
VerbCrossing(Fmt *fmt, XEvent *e) {
XCrossingEvent *ev = &e->xcrossing;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TWindow, _(root),
TWindow, _(subwindow),
@ -607,11 +597,11 @@ VerbCrossing(XEvent *e) {
);
}
static void
VerbExpose(XEvent *e) {
static int
VerbExpose(Fmt *fmt, XEvent *e) {
XExposeEvent *ev = &e->xexpose;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TInt, _(x), TInt, _(y),
TInt, _(width), TInt, _(height),
@ -620,11 +610,11 @@ VerbExpose(XEvent *e) {
);
}
static void
VerbGraphicsExpose(XEvent *e) {
static int
VerbGraphicsExpose(Fmt *fmt, XEvent *e) {
XGraphicsExposeEvent *ev = &e->xgraphicsexpose;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(drawable),
TInt, _(x), TInt, _(y),
TInt, _(width), TInt, _(height),
@ -634,11 +624,11 @@ VerbGraphicsExpose(XEvent *e) {
);
}
static void
VerbNoExpose(XEvent *e) {
static int
VerbNoExpose(Fmt *fmt, XEvent *e) {
XNoExposeEvent *ev = &e->xnoexpose;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(drawable),
TMajor, _(major_code),
TInt, _(minor_code),
@ -646,11 +636,11 @@ VerbNoExpose(XEvent *e) {
);
}
static void
VerbFocus(XEvent *e) {
static int
VerbFocus(Fmt *fmt, XEvent *e) {
XFocusChangeEvent *ev = &e->xfocus;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TGrabMode, _(mode),
TFocus, _(detail),
@ -658,23 +648,24 @@ VerbFocus(XEvent *e) {
);
}
static void
VerbKeymap(XEvent *e) {
static int
VerbKeymap(Fmt *fmt, XEvent *e) {
XKeymapEvent *ev = &e->xkeymap;
int i;
fprint(2, "window=0x%x%s", (int)ev->window, sep);
fprint(2, "key_vector=");
fmtprint(fmt, "window=0x%x%s", (int)ev->window, sep);
fmtprint(fmt, "key_vector=");
for (i = 0; i < 32; i++)
fprint(2, "%02x", ev->key_vector[i]);
fprint(2, "\n");
fmtprint(fmt, "%02x", ev->key_vector[i]);
fmtprint(fmt, "\n");
return 0;
}
static void
VerbKey(XEvent *e) {
static int
VerbKey(Fmt *fmt, XEvent *e) {
XKeyEvent *ev = &e->xkey;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TWindow, _(root),
TWindow, _(subwindow),
@ -688,11 +679,11 @@ VerbKey(XEvent *e) {
);
}
static void
VerbProperty(XEvent *e) {
static int
VerbProperty(Fmt *fmt, XEvent *e) {
XPropertyEvent *ev = &e->xproperty;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TAtom, _(atom),
TTime, _(time),
@ -701,22 +692,22 @@ VerbProperty(XEvent *e) {
);
}
static void
VerbResizeRequest(XEvent *e) {
static int
VerbResizeRequest(Fmt *fmt, XEvent *e) {
XResizeRequestEvent *ev = &e->xresizerequest;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TInt, _(width), TInt, _(height),
TEnd
);
}
static void
VerbCirculate(XEvent *e) {
static int
VerbCirculate(Fmt *fmt, XEvent *e) {
XCirculateEvent *ev = &e->xcirculate;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(event),
TWindow, _(window),
TPlace, _(place),
@ -724,11 +715,11 @@ VerbCirculate(XEvent *e) {
);
}
static void
VerbConfigure(XEvent *e) {
static int
VerbConfigure(Fmt *fmt, XEvent *e) {
XConfigureEvent *ev = &e->xconfigure;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(event),
TWindow, _(window),
TInt, _(x), TInt, _(y),
@ -740,11 +731,11 @@ VerbConfigure(XEvent *e) {
);
}
static void
VerbCreateWindow(XEvent *e) {
static int
VerbCreateWindow(Fmt *fmt, XEvent *e) {
XCreateWindowEvent *ev = &e->xcreatewindow;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(parent),
TWindow, _(window),
TInt, _(x), TInt, _(y),
@ -755,22 +746,22 @@ VerbCreateWindow(XEvent *e) {
);
}
static void
VerbDestroyWindow(XEvent *e) {
static int
VerbDestroyWindow(Fmt *fmt, XEvent *e) {
XDestroyWindowEvent *ev = &e->xdestroywindow;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(event),
TWindow, _(window),
TEnd
);
}
static void
VerbGravity(XEvent *e) {
static int
VerbGravity(Fmt *fmt, XEvent *e) {
XGravityEvent *ev = &e->xgravity;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(event),
TWindow, _(window),
TInt, _(x), TInt, _(y),
@ -778,11 +769,11 @@ VerbGravity(XEvent *e) {
);
}
static void
VerbMap(XEvent *e) {
static int
VerbMap(Fmt *fmt, XEvent *e) {
XMapEvent *ev = &e->xmap;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(event),
TWindow, _(window),
TBool, _(override_redirect),
@ -790,11 +781,11 @@ VerbMap(XEvent *e) {
);
}
static void
VerbReparent(XEvent *e) {
static int
VerbReparent(Fmt *fmt, XEvent *e) {
XReparentEvent *ev = &e->xreparent;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(event),
TWindow, _(window),
TWindow, _(parent),
@ -804,11 +795,11 @@ VerbReparent(XEvent *e) {
);
}
static void
VerbUnmap(XEvent *e) {
static int
VerbUnmap(Fmt *fmt, XEvent *e) {
XUnmapEvent *ev = &e->xunmap;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(event),
TWindow, _(window),
TBool, _(from_configure),
@ -816,11 +807,11 @@ VerbUnmap(XEvent *e) {
);
}
static void
VerbCirculateRequest(XEvent *e) {
static int
VerbCirculateRequest(Fmt *fmt, XEvent *e) {
XCirculateRequestEvent *ev = &e->xcirculaterequest;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(parent),
TWindow, _(window),
TPlace, _(place),
@ -828,11 +819,11 @@ VerbCirculateRequest(XEvent *e) {
);
}
static void
VerbConfigureRequest(XEvent *e) {
static int
VerbConfigureRequest(Fmt *fmt, XEvent *e) {
XConfigureRequestEvent *ev = &e->xconfigurerequest;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(parent),
TWindow, _(window),
TInt, _(x), TInt, _(y),
@ -845,22 +836,22 @@ VerbConfigureRequest(XEvent *e) {
);
}
static void
VerbMapRequest(XEvent *e) {
static int
VerbMapRequest(Fmt *fmt, XEvent *e) {
XMapRequestEvent *ev = &e->xmaprequest;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(parent),
TWindow, _(window),
TEnd
);
}
static void
VerbClient(XEvent *e) {
static int
VerbClient(Fmt *fmt, XEvent *e) {
XClientMessageEvent *ev = &e->xclient;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TAtom, _(message_type),
TInt, _(format),
@ -869,11 +860,11 @@ VerbClient(XEvent *e) {
);
}
static void
VerbMapping(XEvent *e) {
static int
VerbMapping(Fmt *fmt, XEvent *e) {
XMappingEvent *ev = &e->xmapping;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TMapping, _(request),
TWindow, _(first_keycode),
@ -882,11 +873,11 @@ VerbMapping(XEvent *e) {
);
}
static void
VerbSelectionClear(XEvent *e) {
static int
VerbSelectionClear(Fmt *fmt, XEvent *e) {
XSelectionClearEvent *ev = &e->xselectionclear;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TAtom, _(selection),
TTime, _(time),
@ -894,11 +885,11 @@ VerbSelectionClear(XEvent *e) {
);
}
static void
VerbSelection(XEvent *e) {
static int
VerbSelection(Fmt *fmt, XEvent *e) {
XSelectionEvent *ev = &e->xselection;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(requestor),
TAtom, _(selection),
TAtom, _(target),
@ -908,11 +899,11 @@ VerbSelection(XEvent *e) {
);
}
static void
VerbSelectionRequest(XEvent *e) {
static int
VerbSelectionRequest(Fmt *fmt, XEvent *e) {
XSelectionRequestEvent *ev = &e->xselectionrequest;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(owner),
TWindow, _(requestor),
TAtom, _(selection),
@ -923,11 +914,11 @@ VerbSelectionRequest(XEvent *e) {
);
}
static void
VerbVisibility(XEvent *e) {
static int
VerbVisibility(Fmt *fmt, XEvent *e) {
XVisibilityEvent *ev = &e->xvisibility;
pevent(ev,
return pevent(fmt, ev,
TWindow, _(window),
TVis, _(state),
TEnd
@ -941,12 +932,13 @@ VerbVisibility(XEvent *e) {
typedef struct Handler Handler;
struct Handler {
int key;
void (*fn)(XEvent*);
int (*fn)(Fmt*, XEvent*);
};
void
printevent(XEvent *e) {
XAnyEvent *ev = &e->xany;
int
fmtevent(Fmt *fmt) {
XEvent *e;
XAnyEvent *ev;
/*
fprintf(stderr, "type=%s%s", eventtype(e->xany.type), sep);
fprintf(stderr, "serial=%lu%s", ev->serial, sep);
@ -991,9 +983,12 @@ printevent(XEvent *e) {
};
Handler *p;
e = va_arg(fmt->args, XEvent*);
ev = &e->xany;
for (p = fns; p->fn; p++)
if (p->key == ev->type) {
p->fn(e);
break;
}
if (p->key == ev->type)
return p->fn(fmt, e);
return 1;
}

View File

@ -1,4 +1,4 @@
void printevent(XEvent*);
int fmtevent(Fmt *fmt);
enum {
X_CreateWindow = 1,

View File

@ -37,7 +37,8 @@ _view_select(View *v) {
if(screen->sel)
event("UnfocusTag %s\n",screen->sel->name);
screen->sel = v;
event("FocusTag %s\n", screen->sel->name);
event("FocusTag %s\n", v->name);
event("AreaFocus %a\n", v->sel);
ewmh_updateview();
}
}

View File

@ -22,6 +22,8 @@ wmiifont='-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*'
wmiinormcol=`{echo '#000000 #c1c48b #81654f'}
wmiifocuscol=`{echo '#000000 #81654f #000000'}
wmiibackground='#333333'
wmiifloatbackground='#222222'
fn setbackground { xsetroot -solid $* }
# Programs
WMII_TERM=(xterm)
@ -76,6 +78,11 @@ fn Event-UrgentTag {
fn Event-NotUrgentTag {
shift
wmiir xwrite /lbar/$"* $"*}
fn Event-AreaFocus {
if(~ $1 '~')
setbackground $wmiifloatbackground
if not
setbackground $wmiibackground }
fn Event-Unresponsive {
client = $1; shift
@ -233,7 +240,7 @@ wmiir write /ctl <<!
focuscolors $wmiifocuscol
normcolors $wmiinormcol
!
xsetroot -solid $wmiibackground
setbackground $wmiibackground
# Source Overrides
Action overridekeys