diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-04-17 22:44:05 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-04-17 22:44:05 +0200 |
| commit | 432abd07bb9a91e13af27533bb4bc045e6741473 (patch) | |
| tree | 613ee431abf25ffa33c6a9d4e0f8d830b7cd2cc6 | |
| parent | bcde9052c250bb8a684516930069379f1c1349ce (diff) | |
trigger redraw only once a cycle
| -rw-r--r-- | swt.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -55,6 +55,7 @@ typedef struct { unsigned width; unsigned height; } tty; + int redraw; } Window; @@ -391,7 +392,7 @@ void wsetmode(int set, unsigned int flags) { int mode = win.mode; MODBIT(win.mode, set, flags); if ((win.mode & MODE_REVERSE) != (mode & MODE_REVERSE)) - redraw(); + win.redraw = 1; } @@ -731,7 +732,7 @@ pointer_motion(void *data, struct wl_pointer *pointer, uint32_t time, wl_fixed_t SEL_REGULAR, 0 ); - draw(); + win.redraw = 1; } } @@ -761,7 +762,7 @@ pointer_button(void *data, struct wl_pointer *pointer, uint32_t serial, uint32_t MIN(wintotty(client.pointer.position.y, height), win.tty.height - 1), snap ); - draw(); + win.redraw = 1; } else if (button == BTN_LEFT && !state) { client.pointer.buttons.button &= ~BTN_LEFT; selextend( @@ -881,7 +882,6 @@ run() { struct itimerspec spec = { 0 }; struct pollfd fds[3]; - int req_redraw = 0; fds[0].fd = wl_display_get_fd(client.display); fds[0].events = POLLIN; @@ -891,7 +891,7 @@ run() fds[2].events = POLLIN; while (running) { - req_redraw = 0; + win.redraw = 0; if (wl_display_flush(client.display) < 0) { if (errno == EAGAIN) @@ -908,7 +908,7 @@ run() /* handle ttyfd at first so we have the real current screen */ if (fds[2].revents & POLLIN) { ttyread(); - req_redraw = 1; + win.redraw = 1; } if (fds[0].revents & POLLIN) { @@ -922,10 +922,10 @@ run() spec.it_value.tv_sec = client.kb.repeat.period / 1000; spec.it_value.tv_nsec = (client.kb.repeat.period % 1000) * 1000000; timerfd_settime(client.kb.repeat.timer, 0, &spec, 0); - req_redraw = 1; + win.redraw = 1; } - if (req_redraw) { + if (win.redraw) { draw(); } } |