code: plan9front

Download patch

ref: f508dfaab17c0ec9519078db82c9d5b5f1ba76a5
parent: e7d03d19100fe3180906c8ce3f2cab3ba9387fe8
author: Jacob Moody <moody@posixcafe.org>
date: Thu Aug 18 07:44:46 EDT 2022

rio: require a confirmation for Exit

Even accidentally killing a subrio can be
annoying. So instead of only showing this
on subrios, show it always but always
require an additional click to actually
exit.

--- a/sys/src/cmd/rio/dat.h
+++ b/sys/src/cmd/rio/dat.h
@@ -308,6 +308,7 @@
 Cursor	whitearrow;
 Cursor	query;
 Cursor	*corners[9];
+Cursor	skull;
 
 Image	*background;
 Image	*cols[NCOL];
--- a/sys/src/cmd/rio/data.c
+++ b/sys/src/cmd/rio/data.c
@@ -82,6 +82,18 @@
 	 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x00, 0x00, }
 };
 
+Cursor skull = {
+	{-7,-7},
+	{0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xe7, 0xe7, 
+	 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0x1f, 0xf8, 
+	 0x0f, 0xf0, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 
+	 0xef, 0xf7, 0xc7, 0xe3, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03,
+	 0xE7, 0xE7, 0x3F, 0xFC, 0x0F, 0xF0, 0x0D, 0xB0,
+	 0x07, 0xE0, 0x06, 0x60, 0x37, 0xEC, 0xE4, 0x27,
+	 0xC3, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}
+};
+
 Cursor t = {
 	{-7, -8},
 	{0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x06, 0xc0, 
--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -26,6 +26,7 @@
 void		hide(void);
 void		unhide(int);
 void		newtile(int);
+void		confirmexit(void);
 Image*	sweep(void);
 Image*	bandsize(Window*);
 Image*	drag(Window*);
@@ -124,10 +125,6 @@
 	Image *i;
 	Rectangle r;
 
-	if(access("/dev/wctl", AEXIST) != 0){
-		menu3str[Exit] = nil;
-		Hidden--;
-	}
 	initstr = nil;
 	kbdin = nil;
 	maxtab = 0;
@@ -786,11 +783,8 @@
 		hide();
 		break;
 	case Exit:
-		if(Hidden > Exit){
-			send(exitchan, nil);
-			break;
-		}
-		/* else fall through */
+		confirmexit();
+		break;
 	default:
 		unhide(i);
 		break;
@@ -1058,6 +1052,26 @@
 	w = pointto(TRUE);
 	if(w!=nil)
 		wsendctlmesg(w, Deleted, ZR, nil);
+}
+
+void
+confirmexit(void)
+{
+	menuing = TRUE;
+	riosetcursor(&skull);
+	while(mouse->buttons == 0)
+		readmouse(mousectl);
+	if(mouse->buttons != 4)
+		goto Nope;
+	while(mouse->buttons){
+		if(mouse->buttons != 4)
+			goto Nope;
+		readmouse(mousectl);
+	}
+	send(exitchan, nil);
+Nope:
+	riosetcursor(nil);
+	menuing = FALSE;
 }
 
 void