diff options
author | Aurélien Aptel <aurelien.aptel@gmail.com> | 2010-09-11 16:05:57 +0200 |
---|---|---|
committer | Aurélien Aptel <aurelien.aptel@gmail.com> | 2010-09-11 16:05:57 +0200 |
commit | 047aa071f349aa685bb27fd20f52990fee2b6b98 (patch) | |
tree | b63a2ca4354cf230ff4b37781386a68393dc4aae | |
parent | d3440e1e0faa976353692a683dc1c7c67400ae1b (diff) | |
download | st-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.c | 29 |
1 files changed, 25 insertions, 4 deletions
@@ -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 | ||
120 | typedef struct { | 121 | typedef struct { |
@@ -187,6 +188,8 @@ static void xloadcols(void); | |||
187 | static void xseturgency(int); | 188 | static void xseturgency(int); |
188 | 189 | ||
189 | static void expose(XEvent *); | 190 | static void expose(XEvent *); |
191 | static void visibility(XEvent *); | ||
192 | static void unmap(XEvent *); | ||
190 | static char* kmap(KeySym); | 193 | static char* kmap(KeySym); |
191 | static void kpress(XEvent *); | 194 | static void kpress(XEvent *); |
192 | static void resize(XEvent *); | 195 | static void resize(XEvent *); |
@@ -198,8 +201,10 @@ static void bmotion(XEvent *); | |||
198 | 201 | ||
199 | static void (*handler[LASTEvent])(XEvent *) = { | 202 | static 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 | ||
1360 | void | 1368 | void |
1369 | visibility(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 | |||
1376 | void | ||
1377 | unmap(XEvent *ev) { | ||
1378 | xw.vis = 0; | ||
1379 | } | ||
1380 | |||
1381 | void | ||
1361 | xseturgency(int add) { | 1382 | xseturgency(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); |