changeset: 147:cf4dab13f0e0
user: Aurélien Aptel <aurelien.aptel_AT_gmail.com>
date: Sat Sep 11 16:05:57 2010 +0200
files: st.c
description:
don't draw if the window is not visible.
diff -r e8c71d47ca56 -r cf4dab13f0e0 st.c
--- a/st.c Sat Sep 11 16:01:41 2010 +0200
+++ b/st.c Sat Sep 11 16:05:57 2010 +0200
@@ -115,6 +115,7 @@
int ch; /* char height */
int cw; /* char width */
int hasfocus;
+ int vis; /* is visible */
} XWindow;
typedef struct {
@@ -187,6 +188,8 @@
static void xseturgency(int);
static void expose(XEvent *);
+static void visibility(XEvent *);
+static void unmap(XEvent *);
static char* kmap(KeySym);
static void kpress(XEvent *);
static void resize(XEvent *);
@@ -198,8 +201,10 @@
static void (*handler[LASTEvent])(XEvent *) = {
[KeyPress] = kpress,
+ [ConfigureNotify] = resize,
+ [VisibilityNotify] = visibility,
+ [UnmapNotify] = unmap,
[Expose] = expose,
- [ConfigureNotify] = resize,
[FocusIn] = focus,
[FocusOut] = focus,
[MotionNotify] = bmotion,
@@ -1211,9 +1216,9 @@
attrs.background_pixel = dc.col[DefaultBG];
attrs.border_pixel = dc.col[DefaultBG];
attrs.bit_gravity = NorthWestGravity;
- attrs.event_mask = ExposureMask | KeyPressMask
- | StructureNotifyMask | FocusChangeMask | PointerMotionMask
- | ButtonPressMask | ButtonReleaseMask;
+ attrs.event_mask = FocusChangeMask | KeyPressMask
+ | ExposureMask | VisibilityChangeMask | StructureNotifyMask
+ | PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
attrs.colormap = xw.cmap;
xw.win = XCreateWindow(xw.dis, XRootWindow(xw.dis, xw.scr), 0, 0,
@@ -1321,6 +1326,9 @@
Glyph base, new;
char buf[DRAW_BUF_SIZ];
+ if(!xw.vis)
+ return;
+
xclear(0, 0, term.col-1, term.row-1);
for(y = 0; y < term.row; y++) {
base = term.line[y][0];
@@ -1358,6 +1366,19 @@
}
void
+visibility(XEvent *ev) {
+ XVisibilityEvent *e = &ev->xvisibility;
+ /* XXX if this goes from 0 to 1, need a full redraw for next Expose,
+ * not just a buf copy */
+ xw.vis = e->state != VisibilityFullyObscured;
+}
+
+void
+unmap(XEvent *ev) {
+ xw.vis = 0;
+}
+
+void
xseturgency(int add) {
XWMHints *h = XGetWMHints(xw.dis, xw.win);
h->flags = add ? (h->flags | XUrgencyHint) : (h->flags & ~XUrgencyHint);
Received on Sun Sep 12 2010 - 20:16:18 CEST
This archive was generated by hypermail 2.2.0 : Sun Sep 12 2010 - 20:24:05 CEST