| @@ -188,8 +188,9 @@ void win_open(win_t *win) { |
| 188 | 188 | | if (win->xwin == None) |
| 189 | 189 | | die("could not create window"); |
| 190 | 190 | | |
| 191 | | − | XSelectInput(e->dpy, win->xwin, StructureNotifyMask | KeyPressMask | |
| 192 | | − | ButtonPressMask | ButtonReleaseMask | PointerMotionMask); |
| 191 | + | XSelectInput(e->dpy, win->xwin, |
| 192 | + | ExposureMask | ButtonReleaseMask | ButtonPressMask | |
| 193 | + | KeyPressMask | PointerMotionMask | StructureNotifyMask); |
| 193 | 194 | | |
| 194 | 195 | | carrow = XCreateFontCursor(e->dpy, XC_left_ptr); |
| 195 | 196 | | chand = XCreateFontCursor(e->dpy, XC_fleur); |
| @@ -246,10 +247,15 @@ void win_close(win_t *win) { |
| 246 | 247 | | bool win_configure(win_t *win, XConfigureEvent *c) { |
| 247 | 248 | | bool changed; |
| 248 | 249 | | |
| 249 | | − | if (win == NULL) |
| 250 | + | if (win == NULL || c == NULL) |
| 250 | 251 | | return false; |
| 251 | 252 | | |
| 252 | | − | changed = win->w != c->width || win->h + win->barh != c->height; |
| 253 | + | if ((changed = win->w != c->width || win->h + win->barh != c->height)) { |
| 254 | + | if (win->pm != None) { |
| 255 | + | XFreePixmap(win->env.dpy, win->pm); |
| 256 | + | win->pm = None; |
| 257 | + | } |
| 258 | + | } |
| 253 | 259 | | |
| 254 | 260 | | win->x = c->x; |
| 255 | 261 | | win->y = c->y; |
| @@ -260,6 +266,14 @@ bool win_configure(win_t *win, XConfigureEvent *c) { |
| 260 | 266 | | return changed; |
| 261 | 267 | | } |
| 262 | 268 | | |
| 269 | + | void win_expose(win_t *win, XExposeEvent *e) { |
| 270 | + | if (win == NULL || win->xwin == None || win->pm == None || e == NULL) |
| 271 | + | return; |
| 272 | + | |
| 273 | + | XCopyArea(win->env.dpy, win->pm, win->xwin, gc, |
| 274 | + | e->x, e->y, e->width, e->height, e->x, e->y); |
| 275 | + | } |
| 276 | + | |
| 263 | 277 | | bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) { |
| 264 | 278 | | if (win == NULL || win->xwin == None) |
| 265 | 279 | | return false; |
| @@ -323,19 +337,20 @@ void win_toggle_bar(win_t *win) { |
| 323 | 337 | | } |
| 324 | 338 | | |
| 325 | 339 | | void win_clear(win_t *win) { |
| 340 | + | int h; |
| 326 | 341 | | win_env_t *e; |
| 327 | 342 | | |
| 328 | 343 | | if (win == NULL || win->xwin == None) |
| 329 | 344 | | return; |
| 330 | 345 | | |
| 346 | + | h = win->h + win->barh; |
| 331 | 347 | | e = &win->env; |
| 332 | 348 | | |
| 333 | | − | if (win->pm != None) |
| 334 | | − | XFreePixmap(e->dpy, win->pm); |
| 335 | | − | win->pm = XCreatePixmap(e->dpy, win->xwin, e->scrw, e->scrh, e->depth); |
| 349 | + | if (win->pm == None) |
| 350 | + | win->pm = XCreatePixmap(e->dpy, win->xwin, win->w, h, e->depth); |
| 336 | 351 | | |
| 337 | 352 | | XSetForeground(e->dpy, gc, win->fullscreen ? win->fscol : win->bgcol); |
| 338 | | − | XFillRectangle(e->dpy, win->pm, gc, 0, 0, e->scrw, e->scrh); |
| 353 | + | XFillRectangle(e->dpy, win->pm, gc, 0, 0, win->w, h); |
| 339 | 354 | | } |
| 340 | 355 | | |
| 341 | 356 | | void win_draw_bar(win_t *win) { |
| @@ -343,7 +358,7 @@ void win_draw_bar(win_t *win) { |
| 343 | 358 | | int len, x, y, w, tw = 0, seplen; |
| 344 | 359 | | const char *rt; |
| 345 | 360 | | |
| 346 | | − | if (win == NULL || win->xwin == None) |
| 361 | + | if (win == NULL || win->xwin == None || win->pm == None) |
| 347 | 362 | | return; |
| 348 | 363 | | |
| 349 | 364 | | e = &win->env; |
| @@ -391,18 +406,19 @@ void win_draw_bar(win_t *win) { |
| 391 | 406 | | } |
| 392 | 407 | | |
| 393 | 408 | | void win_draw(win_t *win) { |
| 394 | | − | if (win == NULL || win->xwin == None) |
| 409 | + | if (win == NULL || win->xwin == None || win->pm == None) |
| 395 | 410 | | return; |
| 396 | 411 | | |
| 397 | 412 | | if (win->barh > 0) |
| 398 | 413 | | win_draw_bar(win); |
| 399 | 414 | | |
| 400 | | − | XSetWindowBackgroundPixmap(win->env.dpy, win->xwin, win->pm); |
| 401 | | − | XClearWindow(win->env.dpy, win->xwin); |
| 415 | + | XCopyArea(win->env.dpy, win->pm, win->xwin, gc, |
| 416 | + | 0, 0, win->w, win->h + win->barh, 0, 0); |
| 402 | 417 | | } |
| 403 | 418 | | |
| 404 | 419 | | void win_draw_rect(win_t *win, Pixmap pm, int x, int y, int w, int h, |
| 405 | | − | bool fill, int lw, unsigned long col) { |
| 420 | + | bool fill, int lw, unsigned long col) |
| 421 | + | { |
| 406 | 422 | | XGCValues gcval; |
| 407 | 423 | | |
| 408 | 424 | | if (win == NULL || pm == None) |