Krolyxon
Commit d7ff54b

Branches

Refs →

nsxivd7ff54b

Optimized redraw timeout after window resize for tiling window managers; related to issue #44

Author
Bert Münnich
Date
2012-03-13 21:58 +0100
Parent
3238ef6
Commit
d7ff54bb6efc3dbaa2e524a141b423f894bcbc98

+16 −2

2 files changed

  1. M Makefile +1 −1
  2. M main.c +15 −1
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20120302
1+VERSION = git-20120313
22
33 CC = gcc
44 CFLAGS = -ansi -Wall -pedantic -O2
M main.c View
@@ -53,6 +53,7 @@ typedef struct {
5353 void redraw(void);
5454 void reset_cursor(void);
5555 void animate(void);
56+void clear_resize(void);
5657
5758 appmode_t mode;
5859 img_t img;
@@ -65,6 +66,8 @@ size_t filesize;
6566
6667 int prefix;
6768
69+bool resized = false;
70+
6871 char win_bar_l[INFO_STR_LEN];
6972 char win_bar_r[INFO_STR_LEN];
7073 char win_title[INFO_STR_LEN];
@@ -73,6 +76,7 @@ timeout_t timeouts[] = {
7376 { { 0, 0 }, false, redraw },
7477 { { 0, 0 }, false, reset_cursor },
7578 { { 0, 0 }, false, animate },
79+ { { 0, 0 }, false, clear_resize },
7680 };
7781
7882 void cleanup(void) {
@@ -321,6 +325,10 @@ void animate(void) {
321325 }
322326 }
323327
328+void clear_resize(void) {
329+ resized = false;
330+}
331+
324332 bool keymask(const keymap_t *k, unsigned int state) {
325333 return (k->ctrl ? ControlMask : 0) == (state & ControlMask);
326334 }
@@ -452,11 +460,17 @@ void run(void) {
452460 break;
453461 case ConfigureNotify:
454462 if (win_configure(&win, &ev.xconfigure)) {
455− set_timeout(redraw, TO_REDRAW_RESIZE, false);
456463 if (mode == MODE_IMAGE)
457464 img.checkpan = true;
458465 else
459466 tns.dirty = true;
467+ if (!resized || win.fullscreen) {
468+ redraw();
469+ set_timeout(clear_resize, TO_REDRAW_RESIZE, false);
470+ resized = true;
471+ } else {
472+ set_timeout(redraw, TO_REDRAW_RESIZE, false);
473+ }
460474 }
461475 break;
462476 case KeyPress: