shithub: riscv

Download patch

ref: 81f867f4fb3d7fd495be3282a01d2e4a9b1a56fd
parent: 06a0dc5319435aa6d6e1152a789fb9d7dcba98de
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat May 14 14:14:08 EDT 2016

rio: only the current window may change the cursor, fix typo screen->r vs w->screenr in drag()

--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -964,7 +964,7 @@
 	p = mouse->xy;
 	riosetcursor(inborder(r, p) ? corners[whichcorner(r, p)] : nil);
 	menuing = FALSE;
-	if(mouse->buttons!=0 || !goodrect(r) || eqrect(r, screen->r)){
+	if(mouse->buttons!=0 || !goodrect(r) || eqrect(r, w->screenr)){
 		flushimage(display, 1);
 		while(mouse->buttons)
 			readmouse(mousectl);
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -1099,7 +1099,7 @@
 int
 wctlmesg(Window *w, int m, Rectangle r, void *p)
 {
-	char buf[64];
+	char *oldname;
 	Image *i = p;
 
 	switch(m){
@@ -1115,10 +1115,10 @@
 			freeimage(i);
 			break;
 		}
+		oldname = estrdup(w->name);
 		w->screenr = r;
-		strcpy(buf, w->name);
 		wresize(w, i);
-		proccreate(deletetimeoutproc, estrdup(buf), 4096);
+		proccreate(deletetimeoutproc, oldname, 4096);
 		if(Dx(r)<=0){	/* window got hidden, if we had the input, drop it */
 			if(w==input)
 				input = nil;
@@ -1157,8 +1157,10 @@
 				wsendctlmesg(oi, Repaint, ZR, nil);
 			}
 			wclose(oi);
-		} else
+		} else {
 			input = w;
+			wsetcursor(w, FALSE);
+		}
 		w->wctlready = 1;
 		if(m!=Topped && w==input)
 			break;
@@ -1295,16 +1297,15 @@
 
 	if(menuing || sweeping)
 		return;
-	if(w==nil || w->i==nil || Dx(w->screenr)<=0)
+	if(w==nil || Dx(w->screenr)<=0 || wpointto(mouse->xy)!=w)
 		p = nil;
-	else if(wpointto(mouse->xy) == w){
+	else {
 		p = w->cursorp;
 		if(p==nil && w->holding)
 			p = &whitearrow;
-	}else
-		p = nil;
-	if(force)	/* force cursor reload */
-		lastcursor = (void*)~0;
+	}
+	if(p && force)	/* force cursor reload */
+		lastcursor = nil;
 	riosetcursor(p);
 }
 
@@ -1373,7 +1374,7 @@
 	w->deleted = TRUE;
 	if(w == input){
 		input = nil;
-		wsetcursor(w, FALSE);
+		riosetcursor(nil);
 	}
 	if(w == wkeyboard)
 		wkeyboard = nil;
--- a/sys/src/cmd/rio/xfid.c
+++ b/sys/src/cmd/rio/xfid.c
@@ -333,7 +333,8 @@
 		break;
 	case Qcursor:
 		w->cursorp = nil;
-		wsetcursor(w, FALSE);
+		if(w==input)
+			wsetcursor(w, FALSE);
 		break;
 	case Qkbd:
 		w->kbdopen = FALSE;
@@ -478,7 +479,8 @@
 			memmove(w->cursor.clr, x->data+2*4, 2*2*16);
 			w->cursorp = &w->cursor;
 		}
-		wsetcursor(w, !sweeping && !menuing);
+		if(w==input)
+			wsetcursor(w, TRUE);
 		break;
 
 	case Qlabel:
--