ref: 4fd28b3c945e170a4e67ffb2dac95aa60b0633db
parent: ea55c0327e7e24150b4b0952c5ef96beb2f188d8
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon May 31 10:27:38 EDT 2021
add "force redraw" to mu_render (redrawing when window is (un)hidden)
--- a/demo/plan9.c
+++ b/demo/plan9.c
@@ -16,6 +16,7 @@
char *s;
Biobuf *snarf;
Keyboardctl *kctl;
+ int redraw;
Rune key;
Mouse m;
Alt a[] = {
@@ -50,11 +51,13 @@
process_frame();
oldbuttons = 0;
+ redraw = 0;
for (;;) {
process_frame();
- if (mu_render())
+ if (mu_render(redraw))
flushimage(display, 1);
+ redraw = 0;
gotevent = 1;
switch (alt(a)) {
case 0: /* mouse */
@@ -79,6 +82,7 @@
case 1: /* resize */
getwindow(display, Refnone);
+ redraw = 1;
break;
case 2: /* keyboard */
--- a/microui.c
+++ b/microui.c
@@ -1436,12 +1436,12 @@
}
int
-mu_render(void)
+mu_render(int force)
{
mu_Command *cmd;
mu_Rect r, iconr;
- if (memcmp(&mu_ctx.screen, &screen->r, sizeof(mu_ctx.screen)) != 0)
+ if (force || !eqrect(mu_ctx.screen, screen->r) != 0)
mu_ctx.screen = screen->r;
else if (mu_ctx.oldcmdsnum == mu_ctx.cmdsnum && memcmp(mu_ctx.oldcmds, mu_ctx.cmds, mu_ctx.cmdsnum*sizeof(mu_Command)) == 0)
if (mu_ctx.oldstrnum == mu_ctx.strnum && memcmp(mu_ctx.oldstr, mu_ctx.str, mu_ctx.strnum) == 0)
--- a/microui.h
+++ b/microui.h
@@ -253,7 +253,7 @@
Image *mu_color(u8int r, u8int g, u8int b, u8int a);
void mu_init(void);
-int mu_render(void);
+int mu_render(int force);
void mu_begin(void);
void mu_end(void);
void mu_set_focus(mu_Id id);