| @@ -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,15 @@ 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 || e == NULL) |
| 271 | + | return; |
| 272 | + | |
| 273 | + | if (win->pm != None) |
| 274 | + | XCopyArea(win->env.dpy, win->pm, win->xwin, gc, |
| 275 | + | e->x, e->y, e->width, e->height, e->x, e->y); |
| 276 | + | } |
| 277 | + | |
| 263 | 278 | | bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) { |
| 264 | 279 | | if (win == NULL || win->xwin == None) |
| 265 | 280 | | return false; |
| @@ -323,19 +338,20 @@ void win_toggle_bar(win_t *win) { |
| 323 | 338 | | } |
| 324 | 339 | | |
| 325 | 340 | | void win_clear(win_t *win) { |
| 341 | + | int h; |
| 326 | 342 | | win_env_t *e; |
| 327 | 343 | | |
| 328 | 344 | | if (win == NULL || win->xwin == None) |
| 329 | 345 | | return; |
| 330 | 346 | | |
| 347 | + | h = win->h + win->barh; |
| 331 | 348 | | e = &win->env; |
| 332 | 349 | | |
| 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); |
| 350 | + | if (win->pm == None) |
| 351 | + | win->pm = XCreatePixmap(e->dpy, win->xwin, win->w, h, e->depth); |
| 336 | 352 | | |
| 337 | 353 | | XSetForeground(e->dpy, gc, win->fullscreen ? win->fscol : win->bgcol); |
| 338 | | − | XFillRectangle(e->dpy, win->pm, gc, 0, 0, e->scrw, e->scrh); |
| 354 | + | XFillRectangle(e->dpy, win->pm, gc, 0, 0, win->w, h); |
| 339 | 355 | | } |
| 340 | 356 | | |
| 341 | 357 | | void win_draw_bar(win_t *win) { |
| @@ -397,12 +413,13 @@ void win_draw(win_t *win) { |
| 397 | 413 | | if (win->barh > 0) |
| 398 | 414 | | win_draw_bar(win); |
| 399 | 415 | | |
| 400 | | − | XSetWindowBackgroundPixmap(win->env.dpy, win->xwin, win->pm); |
| 401 | | − | XClearWindow(win->env.dpy, win->xwin); |
| 416 | + | XCopyArea(win->env.dpy, win->pm, win->xwin, gc, |
| 417 | + | 0, 0, win->w, win->h + win->barh, 0, 0); |
| 402 | 418 | | } |
| 403 | 419 | | |
| 404 | 420 | | 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) { |
| 421 | + | bool fill, int lw, unsigned long col) |
| 422 | + | { |
| 406 | 423 | | XGCValues gcval; |
| 407 | 424 | | |
| 408 | 425 | | if (win == NULL || pm == None) |