| @@ -186,14 +186,13 @@ void win_open(win_t *win) |
| 186 | 186 | | int c, i, j, n; |
| 187 | 187 | | win_env_t *e; |
| 188 | 188 | | XClassHint classhint; |
| 189 | | − | XSetWindowAttributes attr; |
| 190 | | − | unsigned long attr_mask; |
| 191 | 189 | | unsigned long *icon_data; |
| 192 | 190 | | XColor col; |
| 193 | 191 | | char none_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 194 | 192 | | Pixmap none; |
| 195 | 193 | | int gmask; |
| 196 | 194 | | XSizeHints sizehints; |
| 195 | + | Bool fullscreen = options->fullscreen && fs_support; |
| 197 | 196 | | |
| 198 | 197 | | if (win == NULL) |
| 199 | 198 | | return; |
| @@ -237,18 +236,15 @@ void win_open(win_t *win) |
| 237 | 236 | | win->y = 0; |
| 238 | 237 | | } |
| 239 | 238 | | |
| 240 | | − | attr.background_pixel = win->bgcol; |
| 241 | | − | attr_mask = CWBackPixel; |
| 242 | | − | |
| 243 | 239 | | win->xwin = XCreateWindow(e->dpy, RootWindow(e->dpy, e->scr), |
| 244 | 240 | | win->x, win->y, win->w, win->h, 0, |
| 245 | | − | e->depth, InputOutput, e->vis, attr_mask, &attr); |
| 241 | + | e->depth, InputOutput, e->vis, 0, NULL); |
| 246 | 242 | | if (win->xwin == None) |
| 247 | 243 | | die("could not create window"); |
| 248 | 244 | | |
| 249 | 245 | | XSelectInput(e->dpy, win->xwin, |
| 250 | | − | ExposureMask | ButtonReleaseMask | ButtonPressMask | |
| 251 | | − | KeyPressMask | PointerMotionMask | StructureNotifyMask); |
| 246 | + | ButtonReleaseMask | ButtonPressMask | KeyPressMask | |
| 247 | + | PointerMotionMask | StructureNotifyMask); |
| 252 | 248 | | |
| 253 | 249 | | carrow = XCreateFontCursor(e->dpy, XC_left_ptr); |
| 254 | 250 | | chand = XCreateFontCursor(e->dpy, XC_fleur); |
| @@ -299,10 +295,18 @@ void win_open(win_t *win) |
| 299 | 295 | | |
| 300 | 296 | | win->h -= win->bar.h; |
| 301 | 297 | | |
| 298 | + | win->buf.w = e->scrw; |
| 299 | + | win->buf.h = e->scrh; |
| 300 | + | win->buf.pm = XCreatePixmap(e->dpy, win->xwin, |
| 301 | + | win->buf.w, win->buf.h, e->depth); |
| 302 | + | XSetForeground(e->dpy, gc, fullscreen ? win->fscol : win->bgcol); |
| 303 | + | XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h); |
| 304 | + | XSetWindowBackgroundPixmap(e->dpy, win->xwin, win->buf.pm); |
| 305 | + | |
| 302 | 306 | | XMapWindow(e->dpy, win->xwin); |
| 303 | 307 | | XFlush(e->dpy); |
| 304 | 308 | | |
| 305 | | − | if (options->fullscreen) |
| 309 | + | if (fullscreen) |
| 306 | 310 | | win_toggle_fullscreen(win); |
| 307 | 311 | | } |
| 308 | 312 | | |
| @@ -329,12 +333,7 @@ bool win_configure(win_t *win, XConfigureEvent *c) |
| 329 | 333 | | if (win == NULL || c == NULL) |
| 330 | 334 | | return false; |
| 331 | 335 | | |
| 332 | | − | if ((changed = win->w != c->width || win->h + win->bar.h != c->height)) { |
| 333 | | − | if (win->pm != None) { |
| 334 | | − | XFreePixmap(win->env.dpy, win->pm); |
| 335 | | − | win->pm = None; |
| 336 | | − | } |
| 337 | | − | } |
| 336 | + | changed = win->w != c->width || win->h + win->bar.h != c->height; |
| 338 | 337 | | |
| 339 | 338 | | win->x = c->x; |
| 340 | 339 | | win->y = c->y; |
| @@ -345,15 +344,6 @@ bool win_configure(win_t *win, XConfigureEvent *c) |
| 345 | 344 | | return changed; |
| 346 | 345 | | } |
| 347 | 346 | | |
| 348 | | − | void win_expose(win_t *win, XExposeEvent *e) |
| 349 | | − | { |
| 350 | | − | if (win == NULL || win->xwin == None || win->pm == None || e == NULL) |
| 351 | | − | return; |
| 352 | | − | |
| 353 | | − | XCopyArea(win->env.dpy, win->pm, win->xwin, gc, |
| 354 | | − | e->x, e->y, e->width, e->height, e->x, e->y); |
| 355 | | − | } |
| 356 | | − | |
| 357 | 347 | | void win_toggle_fullscreen(win_t *win) |
| 358 | 348 | | { |
| 359 | 349 | | XEvent ev; |
| @@ -402,20 +392,22 @@ void win_toggle_bar(win_t *win) |
| 402 | 392 | | |
| 403 | 393 | | void win_clear(win_t *win) |
| 404 | 394 | | { |
| 405 | | − | int h; |
| 406 | 395 | | win_env_t *e; |
| 407 | 396 | | |
| 408 | 397 | | if (win == NULL || win->xwin == None) |
| 409 | 398 | | return; |
| 410 | 399 | | |
| 411 | | − | h = win->h + win->bar.h; |
| 412 | 400 | | e = &win->env; |
| 413 | 401 | | |
| 414 | | − | if (win->pm == None) |
| 415 | | − | win->pm = XCreatePixmap(e->dpy, win->xwin, win->w, h, e->depth); |
| 416 | | − | |
| 402 | + | if (win->w > win->buf.w || win->h + win->bar.h > win->buf.h) { |
| 403 | + | XFreePixmap(e->dpy, win->buf.pm); |
| 404 | + | win->buf.w = MAX(win->buf.w, win->w); |
| 405 | + | win->buf.h = MAX(win->buf.h, win->h + win->bar.h); |
| 406 | + | win->buf.pm = XCreatePixmap(e->dpy, win->xwin, |
| 407 | + | win->buf.w, win->buf.h, e->depth); |
| 408 | + | } |
| 417 | 409 | | XSetForeground(e->dpy, gc, win->fullscreen ? win->fscol : win->bgcol); |
| 418 | | − | XFillRectangle(e->dpy, win->pm, gc, 0, 0, win->w, h); |
| 410 | + | XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h); |
| 419 | 411 | | } |
| 420 | 412 | | |
| 421 | 413 | | void win_draw_bar(win_t *win) |
| @@ -425,7 +417,7 @@ void win_draw_bar(win_t *win) |
| 425 | 417 | | const char *dots = "..."; |
| 426 | 418 | | win_env_t *e; |
| 427 | 419 | | |
| 428 | | − | if (win == NULL || win->xwin == None || win->pm == None) |
| 420 | + | if (win == NULL || win->xwin == None) |
| 429 | 421 | | return; |
| 430 | 422 | | |
| 431 | 423 | | e = &win->env; |
| @@ -433,7 +425,7 @@ void win_draw_bar(win_t *win) |
| 433 | 425 | | w = win->w; |
| 434 | 426 | | |
| 435 | 427 | | XSetForeground(e->dpy, gc, win->bar.bgcol); |
| 436 | | − | XFillRectangle(e->dpy, win->pm, gc, 0, win->h, win->w, win->bar.h); |
| 428 | + | XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h); |
| 437 | 429 | | |
| 438 | 430 | | XSetForeground(e->dpy, gc, win->bar.fgcol); |
| 439 | 431 | | XSetBackground(e->dpy, gc, win->bar.bgcol); |
| @@ -444,9 +436,9 @@ void win_draw_bar(win_t *win) |
| 444 | 436 | | x = win->w - tw + H_TEXT_PAD; |
| 445 | 437 | | w -= tw; |
| 446 | 438 | | if (font.set) |
| 447 | | − | XmbDrawString(e->dpy, win->pm, font.set, gc, x, y, win->bar.r, len); |
| 439 | + | XmbDrawString(e->dpy, win->buf.pm, font.set, gc, x, y, win->bar.r, len); |
| 448 | 440 | | else |
| 449 | | − | XDrawString(e->dpy, win->pm, gc, x, y, win->bar.r, len); |
| 441 | + | XDrawString(e->dpy, win->buf.pm, gc, x, y, win->bar.r, len); |
| 450 | 442 | | } |
| 451 | 443 | | if ((len = strlen(win->bar.l)) > 0) { |
| 452 | 444 | | olen = len; |
| @@ -462,9 +454,9 @@ void win_draw_bar(win_t *win) |
| 462 | 454 | | } |
| 463 | 455 | | x = H_TEXT_PAD; |
| 464 | 456 | | if (font.set) |
| 465 | | − | XmbDrawString(e->dpy, win->pm, font.set, gc, x, y, win->bar.l, len); |
| 457 | + | XmbDrawString(e->dpy, win->buf.pm, font.set, gc, x, y, win->bar.l, len); |
| 466 | 458 | | else |
| 467 | | − | XDrawString(e->dpy, win->pm, gc, x, y, win->bar.l, len); |
| 459 | + | XDrawString(e->dpy, win->buf.pm, gc, x, y, win->bar.l, len); |
| 468 | 460 | | if (len != olen) |
| 469 | 461 | | memcpy(win->bar.l + len - w, rest, w); |
| 470 | 462 | | } |
| @@ -473,14 +465,14 @@ void win_draw_bar(win_t *win) |
| 473 | 465 | | |
| 474 | 466 | | void win_draw(win_t *win) |
| 475 | 467 | | { |
| 476 | | − | if (win == NULL || win->xwin == None || win->pm == None) |
| 468 | + | if (win == NULL || win->xwin == None) |
| 477 | 469 | | return; |
| 478 | 470 | | |
| 479 | 471 | | if (win->bar.h > 0) |
| 480 | 472 | | win_draw_bar(win); |
| 481 | 473 | | |
| 482 | | − | XCopyArea(win->env.dpy, win->pm, win->xwin, gc, |
| 483 | | − | 0, 0, win->w, win->h + win->bar.h, 0, 0); |
| 474 | + | XSetWindowBackgroundPixmap(win->env.dpy, win->xwin, win->buf.pm); |
| 475 | + | XClearWindow(win->env.dpy, win->xwin); |
| 484 | 476 | | XFlush(win->env.dpy); |
| 485 | 477 | | } |
| 486 | 478 | | |
| @@ -502,19 +494,6 @@ void win_draw_rect(win_t *win, Pixmap pm, int x, int y, int w, int h, |
| 502 | 494 | | XDrawRectangle(win->env.dpy, pm, gc, x, y, w, h); |
| 503 | 495 | | } |
| 504 | 496 | | |
| 505 | | − | void win_update_bar(win_t *win) |
| 506 | | − | { |
| 507 | | − | if (win == NULL || win->xwin == None || win->pm == None) |
| 508 | | − | return; |
| 509 | | − | |
| 510 | | − | if (win->bar.h > 0) { |
| 511 | | − | win_draw_bar(win); |
| 512 | | − | XCopyArea(win->env.dpy, win->pm, win->xwin, gc, |
| 513 | | − | 0, win->h, win->w, win->bar.h, 0, win->h); |
| 514 | | − | XFlush(win->env.dpy); |
| 515 | | − | } |
| 516 | | − | } |
| 517 | | − | |
| 518 | 497 | | int win_textwidth(const char *text, unsigned int len, bool with_padding) |
| 519 | 498 | | { |
| 520 | 499 | | XRectangle r; |