shithub: riscv

Download patch

ref: c931e96364ec6e587f9137e768ad0f9b70e2e9fa
parent: 1d93a5628adc0f08463fe4272dc88fb0f61e631d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Nov 29 12:51:57 EST 2020

rio: avoid redrawing window text on resize for programs using libdraw

As long as the client as the mouse file open
and maintains reading the winname file of the window
after a resize we will avoid drawing the text frame
on a resize as it will be overdrawn by the client.

This reduces flicker on resize somewhat for slow systems.

--- a/sys/src/cmd/rio/dat.h
+++ b/sys/src/cmd/rio/dat.h
@@ -169,6 +169,7 @@
 	uchar		deleted;
 	uchar		mouseopen;
 	uchar		kbdopen;
+	uchar		winnameread;
 	char			*label;
 	char			*dir;
 };
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -101,16 +101,19 @@
 	frinit(w, r, w->font, w->i, cols);
 	wsetcols(w, 1);
 	w->maxtab = maxtab*stringwidth(w->font, "0");
-	r = insetrect(w->i->r, Selborder);
-	draw(w->i, r, cols[BACK], nil, w->entire.min);
-	wfill(w);
-	wsetselect(w, w->q0, w->q1);
-	wscrdraw(w);
+	if(!w->mouseopen || !w->winnameread){
+		r = insetrect(w->i->r, Selborder);
+		draw(w->i, r, cols[BACK], nil, w->entire.min);
+		wfill(w);
+		wsetselect(w, w->q0, w->q1);
+		wscrdraw(w);
+	}
 	wborder(w, Selborder);
 	flushimage(display, 1);
 	wsetname(w);
 	w->topped = ++topped;
 	w->resized = TRUE;
+	w->winnameread = FALSE;
 	w->mouse.counter++;
 	w->wctlready = 1;
 }
@@ -751,7 +754,7 @@
 wrepaint(Window *w)
 {
 	wsetcols(w, w == input);
-	if(!w->mouseopen)
+	if(!w->mouseopen || !w->winnameread)
 		frredraw(w);
 	if(w == input)
 		wborder(w, Selborder);
@@ -1180,7 +1183,7 @@
 		flushimage(display, 1);
 		break;
 	case Refresh:
-		if(w->i==nil || Dx(w->screenr)<=0 || w->mouseopen)
+		if(w->i==nil || Dx(w->screenr)<=0)
 			break;
 		wrefresh(w);
 		flushimage(display, 1);
--- a/sys/src/cmd/rio/xfid.c
+++ b/sys/src/cmd/rio/xfid.c
@@ -345,6 +345,7 @@
 	case Qmouse:
 		w->resized = FALSE;
 		w->mouseopen = FALSE;
+		w->winnameread = FALSE;
 		if(w->i != nil)
 			wsendctlmesg(w, Refresh, w->i->r, nil);
 		break;
@@ -776,6 +777,7 @@
 			break;
 		}
 		t = estrdup(w->name);
+		w->winnameread = TRUE;
 		goto Text;
 
 	case Qwindow: