shod

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit ed0790bb6f1e43a253d20c884504718c3f59aadc
parent 9ed6e6559b059a2a0e932c2568f9f5691361cc48
Author: Lucas de Sena <lucas@seninha.org>
Date:   Thu, 20 Apr 2023 20:34:37 -0300

throw away some lines of code

Throw away code copying pixmap into window.  Now set window background
pixmap and let X11 copy it into the window when exposed.

Diffstat:
Mshod.c | 4++--
Mshod.h | 3+--
Mxcontainer.c | 10+++++-----
Mxdock.c | 2+-
Mxdraw.c | 127++++---------------------------------------------------------------------------
Mxevents.c | 37++-----------------------------------
Mxmenu.c | 4++--
Mxnotif.c | 2+-
Mxprompt.c | 12+-----------
9 files changed, 20 insertions(+), 181 deletions(-)

diff --git a/shod.c b/shod.c @@ -23,7 +23,7 @@ static int (*xerrorxlib)(Display *, XErrorEvent *); /* shared variables */ unsigned long clientmask = CWEventMask | CWColormap | CWBackPixel | CWBorderPixel; XSetWindowAttributes clientswa = { - .event_mask = SubstructureNotifyMask | ExposureMask | ButtonReleaseMask + .event_mask = SubstructureNotifyMask | ButtonReleaseMask | SubstructureRedirectMask | ButtonPressMask | FocusChangeMask | Button1MotionMask }; @@ -247,7 +247,7 @@ initdock(void) TAILQ_INIT(&dock.dappq); dock.pix = None; - swa.event_mask = SubstructureNotifyMask | SubstructureRedirectMask | ExposureMask; + swa.event_mask = SubstructureNotifyMask | SubstructureRedirectMask; swa.background_pixel = BlackPixel(dpy, screen); swa.border_pixel = BlackPixel(dpy, screen); swa.colormap = colormap; diff --git a/shod.h b/shod.h @@ -784,7 +784,7 @@ void winclose(Window win); /* decoration routines */ void pixmapnew(Pixmap *pix, Window win, int w, int h); -void drawcommit(Pixmap pix, Window win, int w, int h); +void drawcommit(Pixmap pix, Window win); void drawborders(Pixmap pix, int w, int h, int style); void drawbackground(Pixmap pix, int x, int y, int w, int h, int style); void drawframe(Pixmap pix, int isshaded, int w, int h, enum Octant o, int style); @@ -794,7 +794,6 @@ void drawprompt(Pixmap pix, int w, int h); void drawdock(Pixmap pix, int w, int h); void buttonleftdecorate(Window button, Pixmap pix, int style, int pressed); void buttonrightdecorate(Window button, Pixmap pix, int style, int pressed); -void copypixmap(Window win); void cleantheme(void); void setresources(char *xrm); int settheme(void); diff --git a/xcontainer.c b/xcontainer.c @@ -528,7 +528,7 @@ dialogdecorate(struct Dialog *d) d->ph = fullh; drawborders(d->pix, fullw, fullh, tabgetstyle(d->tab)); - drawcommit(d->pix, d->frame, fullw, fullh); + drawcommit(d->pix, d->frame); } /* get focused fullscreen window in given monitor and desktop */ @@ -1025,7 +1025,7 @@ containerdecorate(struct Container *c, struct Column *cdiv, struct Row *rdiv, in /* draw background of titlebar pixmap */ drawbackground(row->pixbar, 0, 0, col->w, config.titlewidth, style); - drawcommit(row->pixbar, row->bar, col->w, config.titlewidth); + drawcommit(row->pixbar, row->bar); /* draw buttons */ buttonleftdecorate(row->bl, row->pixbl, style, 0); @@ -1043,7 +1043,7 @@ containerdecorate(struct Container *c, struct Column *cdiv, struct Row *rdiv, in } } - drawcommit(c->pix, c->frame, c->w, c->h); + drawcommit(c->pix, c->frame); } /* check if container needs to be redecorated and redecorate it */ @@ -1772,8 +1772,8 @@ tabdecorate(struct Tab *t, int pressed) /* draw frame background */ drawbackground(t->pix, 0, 0, t->winw, t->winh, style); - drawcommit(t->pixtitle, t->title, t->w, config.titlewidth); - drawcommit(t->pix, t->frame, t->winw, t->winh); + drawcommit(t->pixtitle, t->title); + drawcommit(t->pix, t->frame); } /* update tab urgency */ diff --git a/xdock.c b/xdock.c @@ -9,7 +9,7 @@ dockdecorate(void) dock.pw = dock.w; dock.ph = dock.h; drawdock(dock.pix, dock.w, dock.h); - drawcommit(dock.pix, dock.win, dock.w, dock.h); + drawcommit(dock.pix, dock.win); } /* configure dockapp window */ diff --git a/xdraw.c b/xdraw.c @@ -30,112 +30,6 @@ openfont(const char *s) return font; } -/* win was exposed, return the pixmap of its contents and the pixmap's size */ -static int -getexposed(Window win, Pixmap *pix, int *pw, int *ph) -{ - struct Object *n, *t, *d, *m; - struct Container *c; - struct Column *col; - struct Row *row; - struct Tab *tab; - struct Dialog *dial; - struct Menu *menu; - struct Notification *notif; - - TAILQ_FOREACH(c, &wm.focusq, entry) { - if (c->frame == win) { - *pix = c->pix; - *pw = c->pw; - *ph = c->ph; - return 1; - } - TAILQ_FOREACH(col, &(c)->colq, entry) { - TAILQ_FOREACH(row, &col->rowq, entry) { - if (row->bar == win) { - *pix = row->pixbar; - *pw = row->pw; - *ph = config.titlewidth; - return 1; - } - if (row->bl == win) { - *pix = row->pixbl; - *pw = config.titlewidth; - *ph = config.titlewidth; - return 1; - } - if (row->br == win) { - *pix = row->pixbr; - *pw = config.titlewidth; - *ph = config.titlewidth; - return 1; - } - TAILQ_FOREACH(t, &row->tabq, entry) { - tab = (struct Tab *)t; - if (tab->frame == win) { - *pix = tab->pix; - *pw = tab->pw; - *ph = tab->ph; - return 1; - } - if (tab->title == win) { - *pix = tab->pixtitle; - *pw = tab->ptw; - *ph = config.titlewidth; - return 1; - } - TAILQ_FOREACH(d, &tab->dialq, entry) { - dial = (struct Dialog *)d; - if (dial->frame == win) { - *pix = dial->pix; - *pw = dial->pw; - *ph = dial->ph; - return 1; - } - } - } - } - } - } - if (dock.win == win) { - *pix = dock.pix; - *pw = dock.w; - *ph = dock.h; - return 1; - } - TAILQ_FOREACH(m, &wm.menuq, entry) { - menu = (struct Menu *)m; - if (menu->frame == win) { - *pix = menu->pix; - *pw = menu->pw; - *ph = menu->ph; - return 1; - } - if (menu->titlebar == win) { - *pix = menu->pixtitlebar; - *pw = menu->tw; - *ph = menu->th; - return 1; - } - if (menu->button == win) { - *pix = menu->pixbutton; - *pw = config.titlewidth; - *ph = config.titlewidth; - return 1; - } - } - TAILQ_FOREACH(n, &wm.notifq, entry) { - notif = (struct Notification *)n; - if (notif->frame == win) { - *pix = notif->frame; - *pw = notif->pw; - *ph = notif->ph; - return 1; - } - } - return 0; -} - void pixmapnew(Pixmap *pix, Window win, int w, int h) { @@ -145,9 +39,10 @@ pixmapnew(Pixmap *pix, Window win, int w, int h) } void -drawcommit(Pixmap pix, Window win, int w, int h) +drawcommit(Pixmap pix, Window win) { - XCopyArea(dpy, pix, win, gc, 0, 0, w, h, 0, 0); + XSetWindowBackgroundPixmap(dpy, win, pix); + XClearWindow(dpy, win); } /* draw text into drawable */ @@ -637,7 +532,7 @@ buttonleftdecorate(Window button, Pixmap pix, int style, int pressed) XFillRectangles(dpy, pix, gc, recs, 2); } - drawcommit(pix, button, config.titlewidth, config.titlewidth); + drawcommit(pix, button); } /* draw title bar buttons */ @@ -694,19 +589,7 @@ buttonrightdecorate(Window button, Pixmap pix, int style, int pressed) XDrawLines(dpy, pix, gc, pts, 9, CoordModePrevious); } - drawcommit(pix, button, config.titlewidth, config.titlewidth); -} - -/* copy pixmap into exposed window */ -void -copypixmap(Window win) -{ - Pixmap pix; - int pw, ph; - - if (getexposed(win, &pix, &pw, &ph)) { - drawcommit(pix, win, pw, ph); - } + drawcommit(pix, button); } void diff --git a/xevents.c b/xevents.c @@ -4,8 +4,8 @@ #include <X11/XKBlib.h> -#define MOUSEEVENTMASK (ButtonReleaseMask | PointerMotionMask | ExposureMask) -#define ALTTABMASK (KeyPressMask | KeyReleaseMask | ExposureMask) +#define MOUSEEVENTMASK (ButtonReleaseMask | PointerMotionMask) +#define ALTTABMASK (KeyPressMask | KeyReleaseMask) #define DOUBLECLICK 250 /* time in miliseconds of a double click */ #define BETWEEN(a, b, c) ((a) <= (b) && (b) < (c)) @@ -781,10 +781,6 @@ alttab(int shift) c = containerraisetemp(c, shift); while (!XMaskEvent(dpy, ALTTABMASK, &ev)) { switch (ev.type) { - case Expose: - if (ev.xexpose.count == 0) - copypixmap(ev.xexpose.window); - break; case KeyPress: if (ev.xkey.keycode == config.tabkeycode && isvalidstate(ev.xkey.state)) { containerbacktoplace(c, 1); @@ -833,10 +829,6 @@ mouseretab(struct Tab *tab, int xroot, int yroot, int x, int y) XRaiseWindow(dpy, wm.dragwin); while (!XMaskEvent(dpy, MOUSEEVENTMASK, &ev)) { switch (ev.type) { - case Expose: - if (ev.xexpose.count == 0) - copypixmap(ev.xexpose.window); - break; case MotionNotify: XMoveWindow( dpy, wm.dragwin, @@ -974,10 +966,6 @@ mouseresize(int type, void *obj, int xroot, int yroot, enum Octant o) lasttime = 0; while (!XMaskEvent(dpy, MOUSEEVENTMASK, &ev)) { switch (ev.type) { - case Expose: - if (ev.xexpose.count == 0) - copypixmap(ev.xexpose.window); - break; case ButtonRelease: goto done; break; @@ -1075,10 +1063,6 @@ mousemove(Window win, int type, void *p, int xroot, int yroot, enum Octant o) goto done; while (!XMaskEvent(dpy, MOUSEEVENTMASK, &ev)) { switch (ev.type) { - case Expose: - if (ev.xexpose.count == 0) - copypixmap(ev.xexpose.window); - break; case ButtonRelease: goto done; break; @@ -1141,10 +1125,6 @@ mouseretile(struct Container *c, struct Column *cdiv, struct Row *rdiv, int xroo goto done; while (!XMaskEvent(dpy, MOUSEEVENTMASK, &ev)) { switch (ev.type) { - case Expose: - if (ev.xexpose.count == 0) - copypixmap(ev.xexpose.window); - break; case ButtonRelease: goto done; break; @@ -1675,18 +1655,6 @@ xevententernotify(XEvent *e) } } -/* redraw window decoration */ -static void -xeventexpose(XEvent *e) -{ - XExposeEvent *ev; - - ev = &e->xexpose; - if (ev->count == 0) { - copypixmap(ev->window); - } -} - /* handle focusin event */ static void xeventfocusin(XEvent *e) @@ -1910,7 +1878,6 @@ void (*xevents[LASTEvent])(XEvent *) = { [ConfigureRequest] = xeventconfigurerequest, [DestroyNotify] = xeventdestroynotify, [EnterNotify] = xevententernotify, - [Expose] = xeventexpose, [FocusIn] = xeventfocusin, [KeyPress] = xeventkeypress, [MapRequest] = xeventmaprequest, diff --git a/xmenu.c b/xmenu.c @@ -117,8 +117,8 @@ menudecorate(struct Menu *menu, int titlepressed) if (menu->name != NULL) drawtitle(menu->pixtitlebar, menu->name, menu->tw, 0, FOCUSED, 0, 1); buttonrightdecorate(menu->button, menu->pixbutton, FOCUSED, 0); - drawcommit(menu->pix, menu->frame, menu->pw, menu->ph); - drawcommit(menu->pixtitlebar, menu->titlebar, menu->tw, menu->th); + drawcommit(menu->pix, menu->frame); + drawcommit(menu->pixtitlebar, menu->titlebar); } void diff --git a/xnotif.c b/xnotif.c @@ -43,7 +43,7 @@ notifdecorate(struct Notification *n) drawborders(n->pix, n->w, n->h, FOCUSED); - drawcommit(n->pix, n->frame, n->w, n->h); + drawcommit(n->pix, n->frame); } /* place notifications */ diff --git a/xprompt.c b/xprompt.c @@ -33,7 +33,6 @@ promptvalidevent(Display *dpy, XEvent *ev, XPointer arg) if (ev->xconfigurerequest.window == win) return True; break; - case Expose: case ButtonPress: return True; } @@ -49,7 +48,7 @@ promptdecorate(Window frame, Pixmap *pix, int w, int h) *pix = XCreatePixmap(dpy, frame, w, h, depth); drawbackground(*pix, 0, 0, w, h, FOCUSED); drawprompt(*pix, w, h); - drawcommit(*pix, frame, w, h); + drawcommit(*pix, frame); } /* map prompt, give it focus, wait for it to close, then revert focus to previously focused window */ @@ -79,15 +78,6 @@ manageprompt(struct Tab *tab, struct Monitor *mon, int desk, Window win, Window promptdecorate(frame, &pix, fw, fh); while (!XIfEvent(dpy, &ev, promptvalidevent, (XPointer)&win)) { switch (ev.type) { - case Expose: - if (ev.xexpose.count == 0) { - if (ev.xexpose.window == frame) { - drawcommit(pix, frame, w, h); - } else { - copypixmap(ev.xexpose.window); - } - } - break; case DestroyNotify: case UnmapNotify: goto done;