Xinqi Bao's Git
projects
/
st.git
/ diff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
f693476
)
don't draw if the window is not visible.
author
Aurélien Aptel <
[email protected]
>
Sat, 11 Sep 2010 14:05:57 +0000
(16:05 +0200)
committer
Aurélien Aptel <
[email protected]
>
Sat, 11 Sep 2010 14:05:57 +0000
(16:05 +0200)
st.c
diff
|
blob
|
history
diff --git
a/st.c
b/st.c
index
d2f8c2e
..
c9d0fb8
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-115,6
+115,7
@@
typedef struct {
int ch; /* char height */
int cw; /* char width */
int hasfocus;
int ch; /* char height */
int cw; /* char width */
int hasfocus;
+ int vis; /* is visible */
} XWindow;
typedef struct {
} XWindow;
typedef struct {
@@
-187,6
+188,8
@@
static void xloadcols(void);
static void xseturgency(int);
static void expose(XEvent *);
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 *);
static char* kmap(KeySym);
static void kpress(XEvent *);
static void resize(XEvent *);
@@
-198,8
+201,10
@@
static void bmotion(XEvent *);
static void (*handler[LASTEvent])(XEvent *) = {
[KeyPress] = kpress,
static void (*handler[LASTEvent])(XEvent *) = {
[KeyPress] = kpress,
- [Expose] = expose,
[ConfigureNotify] = resize,
[ConfigureNotify] = resize,
+ [VisibilityNotify] = visibility,
+ [UnmapNotify] = unmap,
+ [Expose] = expose,
[FocusIn] = focus,
[FocusOut] = focus,
[MotionNotify] = bmotion,
[FocusIn] = focus,
[FocusOut] = focus,
[MotionNotify] = bmotion,
@@
-1211,9
+1216,9
@@
xinit(void) {
attrs.background_pixel = dc.col[DefaultBG];
attrs.border_pixel = dc.col[DefaultBG];
attrs.bit_gravity = NorthWestGravity;
attrs.background_pixel = dc.col[DefaultBG];
attrs.border_pixel = dc.col[DefaultBG];
attrs.bit_gravity = NorthWestGravity;
- attrs.event_mask =
Exposur
eMask | KeyPressMask
- |
StructureNotifyMask | FocusChangeMask | PointerMotion
Mask
- | ButtonPressMask | ButtonReleaseMask;
+ attrs.event_mask =
FocusChang
eMask | KeyPressMask
+ |
ExposureMask | VisibilityChangeMask | StructureNotify
Mask
+ |
PointerMotionMask |
ButtonPressMask | ButtonReleaseMask;
attrs.colormap = xw.cmap;
xw.win = XCreateWindow(xw.dis, XRootWindow(xw.dis, xw.scr), 0, 0,
attrs.colormap = xw.cmap;
xw.win = XCreateWindow(xw.dis, XRootWindow(xw.dis, xw.scr), 0, 0,
@@
-1321,6
+1326,9
@@
draw(int redraw_all) {
Glyph base, new;
char buf[DRAW_BUF_SIZ];
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];
xclear(0, 0, term.col-1, term.row-1);
for(y = 0; y < term.row; y++) {
base = term.line[y][0];
@@
-1357,6
+1365,19
@@
expose(XEvent *ev) {
draw(SCREEN_REDRAW);
}
draw(SCREEN_REDRAW);
}
+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);
void
xseturgency(int add) {
XWMHints *h = XGetWMHints(xw.dis, xw.win);