shithub: patch

Download patch

ref: 7d6d832eae980d69af1357c5a5db6129c10d3d01
parent: c93293e83cc4749b4d6dab5670e720ee67a8a8bb
author: qwx <qwx@sciops.net>
date: Sun Dec 6 09:49:20 EST 2020

rio: add exit option with confirmation like mothra

--- a/rio-exit
+++ b/rio-exit
@@ -1,9 +1,49 @@
-rio: always enable kill menu option
-
-diff -r 49bd5e4c9bde sys/src/cmd/rio/rio.c
---- a/sys/src/cmd/rio/rio.c	Wed Feb 07 18:53:08 2018 +0000
-+++ b/sys/src/cmd/rio/rio.c	Thu Feb 15 23:00:00 2018 +0100
-@@ -125,10 +125,6 @@
+diff -r c055db14ff2b sys/src/cmd/rio/dat.h
+--- a/sys/src/cmd/rio/dat.h	Sun Dec 06 14:50:50 2020 +0100
++++ b/sys/src/cmd/rio/dat.h	Sun Dec 06 15:36:58 2020 +0100
+@@ -308,6 +308,7 @@
+ Display	*display;
+ Image	*view;
+ Screen	*wscreen;
++Cursor	confirmcursor;
+ Cursor	boxcursor;
+ Cursor	crosscursor;
+ Cursor	sightcursor;
+diff -r c055db14ff2b sys/src/cmd/rio/data.c
+--- a/sys/src/cmd/rio/data.c	Sun Dec 06 14:50:50 2020 +0100
++++ b/sys/src/cmd/rio/data.c	Sun Dec 06 15:36:58 2020 +0100
+@@ -10,6 +10,19 @@
+ #include "dat.h"
+ #include "fns.h"
+ 
++Cursor confirmcursor={
++	0, 0,
++	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
++	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
++	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
++	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
++
++	0x00, 0x0E, 0x07, 0x1F, 0x03, 0x17, 0x73, 0x6F,
++	0xFB, 0xCE, 0xDB, 0x8C, 0xDB, 0xC0, 0xFB, 0x6C,
++	0x77, 0xFC, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03,
++	0x94, 0xA6, 0x63, 0x3C, 0x63, 0x18, 0x94, 0x90,
++};
++
+ Cursor crosscursor = {
+ 	{-7, -7},
+ 	{0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0,
+diff -r c055db14ff2b sys/src/cmd/rio/rio.c
+--- a/sys/src/cmd/rio/rio.c	Sun Dec 06 14:50:50 2020 +0100
++++ b/sys/src/cmd/rio/rio.c	Sun Dec 06 15:36:58 2020 +0100
+@@ -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;
  
@@ -14,3 +54,44 @@
  	initstr = nil;
  	kbdin = nil;
  	maxtab = 0;
+@@ -731,11 +728,8 @@
+ 		hide();
+ 		break;
+ 	case Exit:
+-		if(Hidden > Exit){
+-			send(exitchan, nil);
+-			break;
+-		}
+-		/* else fall through */
++		confirmexit();
++		break;
+ 	default:
+ 		unhide(i);
+ 		break;
+@@ -1006,6 +1000,26 @@
+ }
+ 
+ void
++confirmexit(void)
++{
++	menuing = TRUE;
++	riosetcursor(&confirmcursor);
++	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
+ resize(void)
+ {
+ 	Window *w;