wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit f05e39aeed3b5329723af56a3b511b46a0e56c40
parent 0fd8d49ee81d7115a2b033bfe5710e2d448293e8
Author: Kris Maglione <bsdaemon@wmii.de>
Date:   Thu, 29 Jun 2006 20:02:52 -0400

Began changes required for Xinerema support


Diffstat:
cmd/wm/area.c | 30+++++++++++++++---------------
cmd/wm/bar.c | 44++++++++++++++++++++++----------------------
cmd/wm/client.c | 18+++++++++---------
cmd/wm/column.c | 19++++++++++++-------
cmd/wm/event.c | 16++++++++--------
cmd/wm/frame.c | 2+-
cmd/wm/fs.c | 24++++++++++++------------
cmd/wm/mouse.c | 2+-
cmd/wm/view.c | 47++++++++++++++++++++++++-----------------------
cmd/wm/wm.c | 106++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
cmd/wm/wm.h | 15+++------------
11 files changed, 166 insertions(+), 157 deletions(-)

diff --git a/cmd/wm/area.c b/cmd/wm/area.c @@ -26,23 +26,23 @@ create_area(View *v, Area *pos, unsigned int w) if(!w) { if(area_size > 1) - w = rect.width / area_size - 1; + w = screen->rect.width / area_size - 1; else - w = rect.width; + w = screen->rect.width; } if(w < MIN_COLWIDTH) w = MIN_COLWIDTH; - if(area_size >= 2 && (area_size - 1) * MIN_COLWIDTH + w > rect.width) + if(area_size >= 2 && (area_size - 1) * MIN_COLWIDTH + w > screen->rect.width) return nil; if(area_size > 1) - scale_view(v, rect.width - w); + scale_view(v, screen->rect.width - w); a = cext_emallocz(sizeof(Area)); a->view = v; a->id = id++; - a->rect = rect; - a->rect.height = rect.height - brect.height; + a->rect = screen->rect; + a->rect.height = screen->rect.height - screen->brect.height; a->mode = def.colmode; a->rect.width = w; a->frame = nil; @@ -91,7 +91,7 @@ place_client(Area *a, Client *c) unsigned int i, j, x, y, maxx, maxy, dx, dy, cx, cy, diff, num = 0; XPoint p1 = {0, 0}, p2 = {0, 0}; Frame *f = c->sel; - int snap = rect.height / 66; + int snap = screen->rect.height / 66; XRectangle *rects; if(c->trans) @@ -104,8 +104,8 @@ place_client(Area *a, Client *c) rects = rects_of_view(a->view, &num); if(!field) { - mx = rect.width / 8; - my = rect.height / 8; + mx = screen->rect.width / 8; + my = screen->rect.height / 8; field = cext_emallocz(my * mx * sizeof(Bool)); } @@ -113,8 +113,8 @@ place_client(Area *a, Client *c) for(x = 0; x < mx; x++) field[y*mx + x] = True; - dx = rect.width / mx; - dy = rect.height / my; + dx = screen->rect.width / mx; + dy = screen->rect.height / my; for(fr=a->frame; fr; fr=fr->anext) { if(fr == f) { cx = f->rect.width / dx; @@ -318,8 +318,8 @@ select_area(Area *a, char *arg) if(p->anext == f) break; a->sel = p; arrange_column(a, False); - if(v == sel) - focus_view(v); + if(v == screen->sel) + focus_view(screen, v); flush_masked_events(EnterWindowMask); return nil; } @@ -329,8 +329,8 @@ select_area(Area *a, char *arg) p = f->anext ? f->anext : a->frame; a->sel = p; arrange_column(a, False); - if(v == sel) - focus_view(v); + if(v == screen->sel) + focus_view(screen, v); flush_masked_events(EnterWindowMask); return nil; } diff --git a/cmd/wm/bar.c b/cmd/wm/bar.c @@ -28,7 +28,7 @@ create_bar(Bar **b_link, char *name) b->id = id++; cext_strlcpy(b->name, name, sizeof(b->name)); - b->brush = bbrush; + b->brush = screen->bbrush; b->brush.color = def.normcolor; for(i=b_link; *i; i=&(*i)->next) @@ -59,22 +59,22 @@ height_of_bar() } void -resize_bar() +resize_bar(WMScreen *s) { View *v; Area *a; Frame *f; - brect = rect; - brect.height = height_of_bar(); - brect.y = rect.height - brect.height; - XMoveResizeWindow(blz.display, barwin, brect.x, brect.y, brect.width, brect.height); + 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); - draw_bar(); + draw_bar(s); for(v=view; v; v=v->next) { for(a = v->area; a; a=a->next) { - a->rect.height = rect.height - brect.height; + a->rect.height = s->rect.height - s->brect.height; arrange_column(a, False); } for(f=v->area->frame; f; f=f->anext) { @@ -84,33 +84,33 @@ resize_bar() } void -draw_bar() +draw_bar(WMScreen *s) { unsigned int width, tw, nb, size; float shrink; Bar *b, *tb, *largest, **pb; - blitz_draw_tile(&bbrush); + blitz_draw_tile(&s->bbrush); - if(!lbar && !rbar) + if(!s->lbar && !s->rbar) goto MapBar; largest = b = tb = nil; tw = width = nb = size = 0; - for(b=lbar, nb=2 ;nb; --nb && (b = rbar)) + for(b=s->lbar, nb=2 ;nb; --nb && (b = s->rbar)) for(; b; b=b->next) { b->brush.rect.x = b->brush.rect.y = 0; - b->brush.rect.width = brect.height; + b->brush.rect.width = s->brect.height; if(b->text && strlen(b->text)) b->brush.rect.width += blitz_textwidth(b->brush.font, b->text); - b->brush.rect.height = brect.height; + b->brush.rect.height = s->brect.height; width += b->brush.rect.width; } /* Not enough room. Shrink bars until they all fit */ - if(width > brect.width) { - for(b=lbar, nb=2 ;nb; --nb && (b = rbar)) + if(width > s->brect.width) { + for(b=s->lbar, nb=2 ;nb; --nb && (b = s->rbar)) for(; b; b=b->next) { for(pb=&largest; *pb; pb=&(*pb)->smaller) if((*pb)->brush.rect.width < b->brush.rect.width) break; @@ -120,7 +120,7 @@ draw_bar() for(tb=largest; tb; tb=tb->smaller) { width -= tb->brush.rect.width; tw += tb->brush.rect.width; - shrink = (brect.width - width) / (float)tw; + shrink = (s->brect.width - width) / (float)tw; if(tb->smaller) if(tb->brush.rect.width * shrink >= tb->smaller->brush.rect.width) break; @@ -131,11 +131,11 @@ draw_bar() tb=nil; } - for(b=lbar, nb=2 ;nb; b=rbar, nb--) + for(b=s->lbar, nb=2 ;nb; b=s->rbar, nb--) for(; b; tb = b, b=b->next) { - if(b == rbar) { + if(b == s->rbar) { b->brush.align = EAST; - rbar->brush.rect.width += (brect.width - width); + s->rbar->brush.rect.width += (s->brect.width - width); }else b->brush.align = CENTER; if(tb) @@ -143,8 +143,8 @@ draw_bar() blitz_draw_label(&b->brush, b->text); } MapBar: - XCopyArea(blz.display, bbrush.drawable, barwin, bbrush.gc, 0, 0, - brect.width, brect.height, 0, 0); + XCopyArea(blz.display, s->bbrush.drawable, s->barwin, s->bbrush.gc, 0, 0, + s->brect.width, s->brect.height, 0, 0); XSync(blz.display, False); } diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -17,7 +17,7 @@ static char *Ebadcmd = "bad command", Client * sel_client() { - return sel && sel->sel->sel ? sel->sel->sel->client : nil; + return screen->sel && screen->sel->sel->sel ? screen->sel->sel->sel->client : nil; } int @@ -395,7 +395,7 @@ manage_client(Client *c) map_client(c); XMapWindow(blz.display, c->framewin); XSync(blz.display, False); - if(c->sel->area->view == sel) + if(c->sel->area->view == screen->sel) focus_client(c, False); flush_masked_events(EnterWindowMask); } @@ -531,17 +531,17 @@ resize_client(Client *c, XRectangle *r, Bool ignore_xcall) if(!ignore_xcall) { if(floating && - (c->rect.width >= rect.width) && - (c->rect.height >= rect.height)) + (c->rect.width >= screen->rect.width) && + (c->rect.height >= screen->rect.height)) { f->rect.x = -def.border; f->rect.y = -height_of_bar(); } - if(f->area->view == sel) + if(f->area->view == screen->sel) XMoveResizeWindow(blz.display, c->framewin, f->rect.x, f->rect.y, f->rect.width, f->rect.height); else - XMoveResizeWindow(blz.display, c->framewin, 2 * rect.width + f->rect.x, + XMoveResizeWindow(blz.display, c->framewin, 2 * screen->rect.width + f->rect.x, f->rect.y, f->rect.width, f->rect.height); } @@ -701,7 +701,7 @@ focus(Client *c, Bool restack) arrange_column(f->area, False); focus_client(c, restack); - focus_view(v); + focus_view(screen, v); } void @@ -723,7 +723,7 @@ update_client_views(Client *c, char **tags) if(*tags) { if(!*fp || cmp > 0) { f = create_frame(c, get_view(*tags)); - if(f->view == sel || !c->sel) + if(f->view == screen->sel || !c->sel) c->sel = f; attach_to_view(f->view, f); f->cnext = *fp; @@ -756,7 +756,7 @@ apply_tags(Client *c, const char *tags) if(!strncmp(toks[i], "~", 2)) c->floating = True; else if(!strncmp(toks[i], "!", 2)) - toks[j++] = view ? sel->name : "nil"; + toks[j++] = view ? screen->sel->name : "nil"; else if(strncmp(toks[i], "sel", 4)) toks[j++] = toks[i]; } diff --git a/cmd/wm/column.c b/cmd/wm/column.c @@ -194,7 +194,7 @@ Fallthrough: case Colmax: for(f=a->frame; f; f=f->anext) { f->rect = a->rect; - if(f != a->sel) f->rect.x = rect.width * 2; + if(f != a->sel) f->rect.x = screen->rect.width * 2; resize_client(f->client, &f->rect, True); } break; @@ -203,6 +203,7 @@ Fallthrough: } relax_column(a); + focus_view(screen, v); flush_masked_events(EnterWindowMask); } @@ -319,15 +320,15 @@ AfterHorizontal: AfterVertical: relax_column(a); - focus_view(v); + focus_view(screen, v); } static Frame * frame_of_point(XPoint *pt) { - Frame *f = nil; Area *a; - View *v = sel; + View *v = screen->sel; + Frame *f = nil; if(!v) return nil; @@ -343,9 +344,13 @@ frame_of_point(XPoint *pt) static void drop_move(Frame *f, XRectangle *new, XPoint *pt) { - Area *tgt = nil, *src = f->area; - View *v = src->view; + Area *tgt, *src; Frame *ft, *tf; + View *v; + + tgt = nil; + src = f->area; + v = src->view; if(!pt) return; @@ -359,7 +364,7 @@ drop_move(Frame *f, XRectangle *new, XPoint *pt) send_to_area(tgt, src, f); } } - else if(pt->x >= rect.width - 16) { + else if(pt->x >= screen->rect.width - 16) { if((src->frame && src->frame->anext) || src->next) { for(tgt=src; tgt->next; tgt=tgt->next); tgt = new_column(v, tgt, 0); diff --git a/cmd/wm/event.c b/cmd/wm/event.c @@ -67,12 +67,12 @@ handle_buttonrelease(XEvent *e) Frame *f; Bar *b; XButtonPressedEvent *ev = &e->xbutton; - if(ev->window == barwin) { - for(b=lbar; b; b=b->next) + if(ev->window == screen->barwin) { + for(b=screen->lbar; b; b=b->next) if(blitz_ispointinrect(ev->x, ev->y, &b->brush.rect)) return write_event("LeftBarClick %d %s\n", ev->button, b->name); - for(b=rbar; b; b=b->next) + for(b=screen->rbar; b; b=b->next) if(blitz_ispointinrect(ev->x, ev->y, &b->brush.rect)) return write_event("RightBarClick %d %s\n", ev->button, b->name); @@ -155,7 +155,7 @@ handle_configurerequest(XEvent *e) else frect=&c->sel->revert; - if(c->rect.width >= rect.width && c->rect.height >= rect.height) { + if(c->rect.width >= screen->rect.width && c->rect.height >= screen->rect.height) { frect->y = wc.y = -height_of_bar(); frect->x = wc.x = -def.border; } @@ -169,8 +169,8 @@ handle_configurerequest(XEvent *e) wc.border_width = 1; wc.sibling = None; wc.stack_mode = ev->detail; - if(c->sel->area->view != sel) - wc.x += 2 * rect.width; + 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); configure_client(c); @@ -249,8 +249,8 @@ handle_expose(XEvent *e) XExposeEvent *ev = &e->xexpose; static Frame *f; if(ev->count == 0) { - if(ev->window == barwin) - draw_bar(); + if(ev->window == screen->barwin) + draw_bar(screen); else if((f = frame_of_win(ev->window))) draw_frame(f); } diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c @@ -139,7 +139,7 @@ draw_frames() { Client *c; for(c=client; c; c=c->next) - if(c->sel && (c->sel->area->view == sel)) { + if(c->sel && (c->sel->area->view == screen->sel)) { update_frame_widget_colors(c->sel); draw_frame(c->sel); } diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -88,7 +88,7 @@ P9Srv p9srv = { .freefid=fs_freefid }; -/* ad-hoc file tree. Empty names ("") indicate a dynamic entry to be filled +/* ad-hoc file tree. Empty names ("") indicate dynamic entries to be filled * in by lookup_file */ static Dirtab dirtab_root[]= {{".", P9QTDIR, FsRoot, 0500|P9DMDIR }, @@ -166,7 +166,7 @@ free_file(FileId *f) { } /* This function's name belies it's true purpose. It increases - * the reference count of the FileId list */ + * the reference counts of the FileId list */ static void clone_files(FileId *f) { for(; f; f=f->next) @@ -287,7 +287,7 @@ message_root(char *message) cext_strlcpy(def.grabmod, message, sizeof(def.grabmod)); def.mod = mod; if(view) - restack_view(sel); + restack_view(screen->sel); }else return Ebadcmd; @@ -298,8 +298,8 @@ char * read_root_ctl() { unsigned int i = 0; - if(sel) - i += snprintf(&buffer[i], (BUFFER_SIZE - i), "view %s\n", sel->name); + if(screen->sel) + i += snprintf(&buffer[i], (BUFFER_SIZE - i), "view %s\n", screen->sel->name); i += snprintf(&buffer[i], (BUFFER_SIZE - i), "selcolors %s\n", def.selcolor.colstr); i += snprintf(&buffer[i], (BUFFER_SIZE - i), "normcolors %s\n", def.normcolor.colstr); i += snprintf(&buffer[i], (BUFFER_SIZE - i), "font %s\n", def.font.fontstr); @@ -427,12 +427,12 @@ lookup_file(FileId *parent, char *name) break; case FsDTags: if(!name || !strncmp(name, "sel", 4)) { - if(sel) { + if(screen->sel) { file = get_file(); *last = file; last = &file->next; - file->ref = sel; - file->id = sel->id; + file->ref = screen->sel; + file->id = screen->sel->id; file->tab = *dir; file->tab.name = strdup("sel"); }if(name) goto LastItem; @@ -480,9 +480,9 @@ lookup_file(FileId *parent, char *name) switch(file->tab.type) { case FsDBars: if(!strncmp(file->tab.name, "lbar", 5)) - file->ref = &lbar; + file->ref = &screen[0].lbar; else - file->ref = &rbar; + file->ref = &screen[0].rbar; break; case FsFColRules: file->ref = &def.colrules; @@ -816,7 +816,7 @@ fs_remove(P9Req *r) { return respond(r, Enoperm); case FsFBar: destroy_bar(f->next->bar_p, f->bar); - draw_bar(); + draw_bar(screen); respond(r, nil); break; } @@ -855,7 +855,7 @@ fs_clunk(P9Req *r) { while(i > 0 && buf[i - 1] == '\n') buf[--i] = '\0'; cext_strlcpy(f->bar->text, buf, sizeof(f->bar->text)); - draw_bar(); + draw_bar(screen); break; case FsFEvent: for(fl=&pending_event_fids; *fl; fl=&(*fl)->next) diff --git a/cmd/wm/mouse.c b/cmd/wm/mouse.c @@ -180,7 +180,7 @@ do_mouse_resize(Client *c, BlitzAlign align) unsigned int num = 0, di; Frame *f = c->sel; Bool floating = f->area->floating; - int snap = floating ? rect.height / 66 : 0; + int snap = floating ? screen->rect.height / 66 : 0; XRectangle *rects = floating ? rects_of_view(f->area->view, &num) : nil; XRectangle frect = f->rect, ofrect; XRectangle origin = frect; diff --git a/cmd/wm/view.c b/cmd/wm/view.c @@ -32,11 +32,11 @@ clientframe_of_view(View *v, Client *c) static void assign_sel_view(View *v) { - if(sel != v) { - if(sel) - write_event("UnfocusTag %s\n", sel->name); - sel = v; - write_event("FocusTag %s\n", sel->name); + if(screen->sel != v) { + if(screen->sel) + write_event("UnfocusTag %s\n",screen->sel->name); + screen->sel = v; + write_event("FocusTag %s\n", screen->sel->name); } } @@ -76,7 +76,7 @@ create_view(const char *name) *i = v; write_event("CreateTag %s\n", v->name); - if(!sel) + if(!screen->sel) assign_sel_view(v); return v; @@ -97,9 +97,9 @@ destroy_view(View *v) if(*i == v) break; *i = v->next; - if(sel == v) - for(sel=view; sel && sel->next; sel=sel->next) - if(sel->next == *i) break; + if(screen->sel == v) + for(screen->sel=view; screen->sel && screen->sel->next; screen->sel=screen->sel->next) + if(screen->sel->next == *i) break; write_event("DestroyTag %s\n", v->name); free(v); @@ -116,7 +116,7 @@ update_frame_selectors(View *v) } void -focus_view(View *v) +focus_view(WMScreen *s, View *v) { Frame *f; Client *c; @@ -133,7 +133,8 @@ focus_view(View *v) XMoveWindow(blz.display, c->framewin, f->rect.x, f->rect.y); resize_client(c, &f->rect, False); }else - XMoveWindow(blz.display, c->framewin, 2 * rect.width + f->rect.x, f->rect.y); + XMoveWindow(blz.display, c->framewin, 2 * s->rect.width + f->rect.x, + f->rect.y); } if((c = sel_client())) @@ -166,7 +167,7 @@ attach_to_view(View *v, Frame *f) c->revert = nil; if(c->trans || c->floating || c->fixedsize - || (c->rect.width == rect.width && c->rect.height == rect.height)) + || (c->rect.width == screen->rect.width && c->rect.height == screen->rect.height)) a = v->area; else if(starting && v->sel->floating) a = v->area->next; @@ -257,11 +258,11 @@ arrange_view(View *v) if(!v->area->next) return; - scale_view(v, rect.width); + scale_view(v, screen->rect.width); for(a=v->area->next; a; a=a->next) { a->rect.x = xoff; a->rect.y = 0; - a->rect.height = rect.height - brect.height; + a->rect.height = screen->rect.height - screen->brect.height; xoff += a->rect.width; arrange_column(a, False); } @@ -279,8 +280,8 @@ rects_of_view(View *v, unsigned int *num) result = cext_emallocz(*num * sizeof(XRectangle)); for(f=v->area->frame; f; f=f->anext) *result++ = f->rect; - *result++ = rect; - *result++ = brect; + *result++ = screen->rect; + *result++ = screen->brect; return result - *num; } @@ -378,8 +379,8 @@ message_view(View *v, char *message) { a->mode = i; arrange_column(a, True); restack_view(v); - if(v == sel) - focus_view(v); + if(v == screen->sel) + focus_view(screen, v); draw_frames(); return nil; } @@ -390,7 +391,7 @@ void update_views() { View *n, *v; - View *old = sel; + View *old = screen->sel; for(v=view; v; v=v->next) update_frame_selectors(v); @@ -403,9 +404,9 @@ update_views() destroy_view(v); if(old) - focus_view(old); - else if(sel) - focus_view(sel); + focus_view(screen, old); + else if(screen->sel) + focus_view(screen, screen->sel); } unsigned int @@ -425,7 +426,7 @@ newcolw_of_view(View *v) for(a=v->area, i=0; a; a=a->next, i++); if(n && n >= i) { if(sscanf(toks[i - 1], "%u", &n) == 1) - return (rect.width * n) / 100; + return (screen->rect.width * n) / 100; } break; } diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -150,7 +150,7 @@ init_cursors() } static void -init_screen() +init_screen(WMScreen *screen) { Window w; int ret; @@ -165,10 +165,10 @@ init_screen() xorgc = XCreateGC(blz.display, blz.root, GCForeground | GCGraphicsExposures | GCFunction | GCSubwindowMode | GCPlaneMask, &gcv); - rect.x = rect.y = 0; - rect.width = DisplayWidth(blz.display, blz.screen); - rect.height = DisplayHeight(blz.display, blz.screen); - def.snap = rect.height / 63; + screen->rect.x = screen->rect.y = 0; + screen->rect.width = DisplayWidth(blz.display, blz.screen); + screen->rect.height = DisplayHeight(blz.display, blz.screen); + def.snap = screen->rect.height / 63; sel_screen = XQueryPointer(blz.display, blz.root, &w, &w, &ret, &ret, &ret, &ret, &mask); } @@ -225,8 +225,9 @@ cleanup() int main(int argc, char *argv[]) { - int i, j; + int i; char *address = nil, *wmiirc = nil, *namespace, *errstr; + WMScreen *s; struct passwd *passwd; XSetWindowAttributes wa; @@ -312,11 +313,8 @@ main(int argc, char *argv[]) case 0: if(setsid() == -1) error("wmiim: can't setsid: %s\n", strerror(errno)); - /* This is only necessary because I can't get the fileno of - * the X socket */ - j = getdtablesize(); - for(i = 3; i < j; i++) - close(i); + close(i); + close(ConnectionNumber(blz.display)); 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)); @@ -333,9 +331,8 @@ main(int argc, char *argv[]) /* X server */ ixp_server_open_conn(&srv, ConnectionNumber(blz.display), nil, check_x_event, nil); - sel = view = nil; + view = nil; client = nil; - lbar = nil; key = nil; passwd = getpwuid(getuid()); @@ -361,41 +358,56 @@ main(int argc, char *argv[]) init_cursors(); blitz_loadfont(&blz, &def.font); init_lock_keys(); - init_screen(); - - pmap = XCreatePixmap(blz.display, blz.root, rect.width, rect.height, - DefaultDepth(blz.display, blz.screen)); - - wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask; - wa.cursor = cursor[CurNormal]; - XChangeWindowAttributes(blz.display, blz.root, CWEventMask | CWCursor, &wa); - - wa.override_redirect = 1; - wa.background_pixmap = ParentRelative; - wa.event_mask = ExposureMask | ButtonReleaseMask - | SubstructureRedirectMask | SubstructureNotifyMask; - - brect = rect; - brect.height = height_of_bar(); - brect.y = rect.height - brect.height; - barwin = XCreateWindow(blz.display, RootWindow(blz.display, blz.screen), brect.x, brect.y, - brect.width, brect.height, 0, DefaultDepth(blz.display, blz.screen), - CopyFromParent, DefaultVisual(blz.display, blz.screen), - CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); - XSync(blz.display, False); - bbrush.blitz = &blz; - bbrush.gc = XCreateGC(blz.display, barwin, 0, 0); - bbrush.drawable = pmap; - bbrush.rect = brect; - bbrush.rect.x = 0; - bbrush.rect.y = 0; - bbrush.color = def.normcolor; - bbrush.font = &def.font; - bbrush.border = True; - - XMapRaised(blz.display, barwin); - draw_bar(); + num_screens = 1; + screens = cext_emallocz(num_screens * sizeof(*screens)); + + for(i = 0; i < num_screens; i++) { + s = &screens[i]; + s->lbar = nil; + s->rbar = nil; + s->sel = nil; + + init_screen(s); + + pmap = XCreatePixmap(blz.display, blz.root, s->rect.width, s->rect.height, + DefaultDepth(blz.display, blz.screen)); + + wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask; + wa.cursor = cursor[CurNormal]; + XChangeWindowAttributes(blz.display, blz.root, CWEventMask | CWCursor, &wa); + + wa.override_redirect = 1; + wa.background_pixmap = ParentRelative; + wa.event_mask = ExposureMask | ButtonReleaseMask + | SubstructureRedirectMask | SubstructureNotifyMask; + + 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->brect.x, s->brect.y, + s->brect.width, s->brect.height, 0, + DefaultDepth(blz.display, blz.screen), + CopyFromParent, DefaultVisual(blz.display, blz.screen), + CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); + XSync(blz.display, False); + + s->bbrush.blitz = &blz; + s->bbrush.gc = XCreateGC(blz.display, s->barwin, 0, 0); + s->bbrush.drawable = pmap; + s->bbrush.rect = s->brect; + s->bbrush.rect.x = 0; + s->bbrush.rect.y = 0; + s->bbrush.color = def.normcolor; + s->bbrush.font = &def.font; + s->bbrush.border = True; + + draw_bar(s); + XMapRaised(blz.display, s->barwin); + } + + screen = &screens[0]; scan_wins(); update_views(); diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -169,16 +169,7 @@ struct WMScreen { XRectangle rect; XRectangle brect; BlitzBrush bbrush; -} *screens; -/* to be removed */ - Bar *lbar; - Bar *rbar; - View *sel; - Window barwin; - - XRectangle rect; - XRectangle brect; - BlitzBrush bbrush; +} *screens, *screen; Client *client; View *view; @@ -225,7 +216,7 @@ Client *sel_client_of_area(Area *a); /* bar.c */ Bar *create_bar(Bar **b_link, char *name); void destroy_bar(Bar **b_link, Bar *b); -void draw_bar(); +void draw_bar(WMScreen *s); void resize_bar(); unsigned int height_of_bar(); Bar *bar_of_name(Bar *b_link, const char *name); @@ -317,7 +308,7 @@ void arrange_view(View *v); void scale_view(View *v, float w); View *get_view(const char *name); View *create_view(const char *name); -void focus_view(View *v); +void focus_view(WMScreen *s, View *v); void update_client_views(Client *c, char **tags); XRectangle *rects_of_view(View *v, unsigned int *num); View *view_of_id(unsigned short id);