From 9c3130a17c8e99315be143a49af5d42a90aa3fea Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Fri, 29 Jul 2011 11:53:22 +0200 Subject: [PATCH] BarWindow/Event: Make barwindows linked to improve render with expose event --- src/barwin.c | 4 ++++ src/event.c | 22 ++++++++-------------- src/init.c | 9 +++++---- src/structs.h | 8 ++++---- src/wmfs.c | 8 ++++++++ src/wmfs.h | 11 ++++++++--- 6 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/barwin.c b/src/barwin.c index 0564ad3..bb7630e 100644 --- a/src/barwin.c +++ b/src/barwin.c @@ -100,6 +100,9 @@ barwin_create(Window parent, FLAGAPPLY(bw->flags, stipple, StippleFlag); bw->stipple_color = -1; + /* Attach */ + SLIST_INSERT_HEAD(&bwhead, bw, next); + return bw; } @@ -144,6 +147,7 @@ barwin_color_set(BarWindow *bw, uint bg, char *fg) void barwin_delete(BarWindow *bw) { + SLIST_REMOVE(&bwhead, bw, BarWindow, next); XSelectInput(dpy, bw->win, NoEventMask); XDestroyWindow(dpy, bw->win); XFreePixmap(dpy, bw->dr); diff --git a/src/event.c b/src/event.c index f6053e9..62eea81 100644 --- a/src/event.c +++ b/src/event.c @@ -402,21 +402,15 @@ expose(XEvent *e) { XExposeEvent *ev = &e->xexpose; Client *c; - int i, sc; + BarWindow *bw; - /* InfoBar member */ - for(sc = 0; sc < screen_count(); ++sc) - { - if(ev->window == infobar[sc].bar->win) - barwin_refresh(infobar[sc].bar); - if(ev->window == infobar[sc].layout_button->win) - barwin_refresh(infobar[sc].layout_button); - if(conf.bars.selbar && ev->window == infobar[sc].selbar->win) - barwin_refresh(infobar[sc].selbar); - for(i = 1; i < conf.ntag[sc] + 1; ++i) - if(ev->window == infobar[sc].tags[i]->win) - barwin_refresh(infobar[sc].tags[i]); - } + /* BarWindows */ + SLIST_FOREACH(bw, &bwhead, next) + if(ev->window == bw->win) + { + barwin_refresh(bw); + break; + } /* Client frame */ if((c = client_gb_titlebar(ev->window))) diff --git a/src/init.c b/src/init.c index 67e845b..47f1707 100644 --- a/src/init.c +++ b/src/init.c @@ -201,6 +201,11 @@ init_root(void) void init(void) { + /* Init lists heads */ + SLIST_INIT(&bwhead); + SLIST_INIT(&clients); + SLIST_INIT(&trayicons); + /* First init */ ewmh_init_hints(); init_conf(); @@ -216,10 +221,6 @@ init(void) ewmh_update_current_tag_prop(); grabkeys(); - /* Init lists heads */ - SLIST_INIT(&clients); - SLIST_INIT(&trayicons); - return; } diff --git a/src/structs.h b/src/structs.h index 081fea9..2665ae1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -184,7 +184,7 @@ typedef struct * BarWindow Structure * (titlebar, infobar..) */ -typedef struct +typedef struct BarWindow { Window win; Drawable dr; @@ -201,11 +201,11 @@ typedef struct uint stipple_color; Geo geo; uint flags; + SLIST_ENTRY(BarWindow) next; } BarWindow; /* Client Structure. */ -typedef struct Client Client; -struct Client +typedef struct Client { /* Client title */ char *title; @@ -246,7 +246,7 @@ struct Client uint flags; /* Simply-linked list */ SLIST_ENTRY(Client) next; -}; +} Client; /* Keybind Structure */ typedef struct diff --git a/src/wmfs.c b/src/wmfs.c index 35a62ac..c92474e 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -80,6 +80,7 @@ void quit(void) { Client *c; + BarWindow *bw; size_t i, len; /* Set the silent error handler */ @@ -112,6 +113,13 @@ quit(void) XFreeGC(dpy, gc_stipple); infobar_destroy(); + /* BarWindows */ + while(!SLIST_EMPTY(&bwhead)) + { + bw = SLIST_FIRST(&bwhead); + SLIST_REMOVE_HEAD(&bwhead, next); + } + free(sgeo); free(spgeo); free(infobar); diff --git a/src/wmfs.h b/src/wmfs.h index b7b4d99..12b3e96 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -436,7 +436,7 @@ void uicb_reload(uicb_t); /* Variables */ -/* Principal */ +/* Main */ Display *dpy; GC gc, gc_stipple; int selscreen; @@ -472,20 +472,25 @@ struct clndx { Client *client; } clist_index[MAXCLIST]; -/* Important Client */ +/* Client */ SLIST_HEAD(, Client) clients; Client *sel; -/* Other */ +/* Event */ int nevent; void (**event_handle)(XEvent*); extern const func_name_list_t func_list[]; extern const func_name_list_t layout_list[]; uint numlockmask; + +/* Systray */ SLIST_HEAD(, Systray) trayicons; Window traywin; int tray_width; +/* BarWindow */ +SLIST_HEAD(, BarWindow) bwhead; + #endif /* WMFS_H */