aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2010-09-11 16:05:57 +0200
committerAurélien Aptel <aurelien.aptel@gmail.com>2010-09-11 16:05:57 +0200
commit047aa071f349aa685bb27fd20f52990fee2b6b98 (patch)
treeb63a2ca4354cf230ff4b37781386a68393dc4aae
parentd3440e1e0faa976353692a683dc1c7c67400ae1b (diff)
downloadst-patched-047aa071f349aa685bb27fd20f52990fee2b6b98.tar.bz2
st-patched-047aa071f349aa685bb27fd20f52990fee2b6b98.tar.xz
st-patched-047aa071f349aa685bb27fd20f52990fee2b6b98.zip
don't draw if the window is not visible.
-rw-r--r--st.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/st.c b/st.c
index d2f8c2e..c9d0fb8 100644
--- a/st.c
+++ b/st.c
@@ -115,6 +115,7 @@ typedef struct {
115 int ch; /* char height */ 115 int ch; /* char height */
116 int cw; /* char width */ 116 int cw; /* char width */
117 int hasfocus; 117 int hasfocus;
118 int vis; /* is visible */
118} XWindow; 119} XWindow;
119 120
120typedef struct { 121typedef struct {
@@ -187,6 +188,8 @@ static void xloadcols(void);
187static void xseturgency(int); 188static void xseturgency(int);
188 189
189static void expose(XEvent *); 190static void expose(XEvent *);
191static void visibility(XEvent *);
192static void unmap(XEvent *);
190static char* kmap(KeySym); 193static char* kmap(KeySym);
191static void kpress(XEvent *); 194static void kpress(XEvent *);
192static void resize(XEvent *); 195static void resize(XEvent *);
@@ -198,8 +201,10 @@ static void bmotion(XEvent *);
198 201
199static void (*handler[LASTEvent])(XEvent *) = { 202static void (*handler[LASTEvent])(XEvent *) = {
200 [KeyPress] = kpress, 203 [KeyPress] = kpress,
201 [Expose] = expose,
202 [ConfigureNotify] = resize, 204 [ConfigureNotify] = resize,
205 [VisibilityNotify] = visibility,
206 [UnmapNotify] = unmap,
207 [Expose] = expose,
203 [FocusIn] = focus, 208 [FocusIn] = focus,
204 [FocusOut] = focus, 209 [FocusOut] = focus,
205 [MotionNotify] = bmotion, 210 [MotionNotify] = bmotion,
@@ -1211,9 +1216,9 @@ xinit(void) {
1211 attrs.background_pixel = dc.col[DefaultBG]; 1216 attrs.background_pixel = dc.col[DefaultBG];
1212 attrs.border_pixel = dc.col[DefaultBG]; 1217 attrs.border_pixel = dc.col[DefaultBG];
1213 attrs.bit_gravity = NorthWestGravity; 1218 attrs.bit_gravity = NorthWestGravity;
1214 attrs.event_mask = ExposureMask | KeyPressMask 1219 attrs.event_mask = FocusChangeMask | KeyPressMask
1215 | StructureNotifyMask | FocusChangeMask | PointerMotionMask 1220 | ExposureMask | VisibilityChangeMask | StructureNotifyMask
1216 | ButtonPressMask | ButtonReleaseMask; 1221 | PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
1217 attrs.colormap = xw.cmap; 1222 attrs.colormap = xw.cmap;
1218 1223
1219 xw.win = XCreateWindow(xw.dis, XRootWindow(xw.dis, xw.scr), 0, 0, 1224 xw.win = XCreateWindow(xw.dis, XRootWindow(xw.dis, xw.scr), 0, 0,
@@ -1321,6 +1326,9 @@ draw(int redraw_all) {
1321 Glyph base, new; 1326 Glyph base, new;
1322 char buf[DRAW_BUF_SIZ]; 1327 char buf[DRAW_BUF_SIZ];
1323 1328
1329 if(!xw.vis)
1330 return;
1331
1324 xclear(0, 0, term.col-1, term.row-1); 1332 xclear(0, 0, term.col-1, term.row-1);
1325 for(y = 0; y < term.row; y++) { 1333 for(y = 0; y < term.row; y++) {
1326 base = term.line[y][0]; 1334 base = term.line[y][0];
@@ -1358,6 +1366,19 @@ expose(XEvent *ev) {
1358} 1366}
1359 1367
1360void 1368void
1369visibility(XEvent *ev) {
1370 XVisibilityEvent *e = &ev->xvisibility;
1371 /* XXX if this goes from 0 to 1, need a full redraw for next Expose,
1372 * not just a buf copy */
1373 xw.vis = e->state != VisibilityFullyObscured;
1374}
1375
1376void
1377unmap(XEvent *ev) {
1378 xw.vis = 0;
1379}
1380
1381void
1361xseturgency(int add) { 1382xseturgency(int add) {
1362 XWMHints *h = XGetWMHints(xw.dis, xw.win); 1383 XWMHints *h = XGetWMHints(xw.dis, xw.win);
1363 h->flags = add ? (h->flags | XUrgencyHint) : (h->flags & ~XUrgencyHint); 1384 h->flags = add ? (h->flags | XUrgencyHint) : (h->flags & ~XUrgencyHint);