9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] better rio exit menu entry check
@ 2022-08-04 14:36 Jacob Moody
  2022-08-04 14:56 ` sirjofri
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jacob Moody @ 2022-08-04 14:36 UTC (permalink / raw)
  To: 9front

Checking for if the binary name contains .out always seemed a bit
like a hack. What I seem to want most of the time is for the
Exit option to show up on subrios, but not my "main" rio.
This patch does this by checking for an existing
rio mounted on /mnt/wsys.

diff 0541a434cb9cfd1a776f1ef29de3a8a7aa1d9b99 uncommitted
--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -124,7 +124,7 @@
 	Image *i;
 	Rectangle r;

-	if(strstr(argv[0], ".out") == nil){
+	if(access("/mnt/wsys/wctl", AEXIST) != 0){
 		menu3str[Exit] = nil;
 		Hidden--;
 	}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] [PATCH] better rio exit menu entry check
  2022-08-04 14:36 [9front] [PATCH] better rio exit menu entry check Jacob Moody
@ 2022-08-04 14:56 ` sirjofri
  2022-08-04 16:45 ` B. Atticus Grobe
  2022-08-04 20:18 ` qwx
  2 siblings, 0 replies; 7+ messages in thread
From: sirjofri @ 2022-08-04 14:56 UTC (permalink / raw)
  To: 9front

Nice, I love that idea!

I didn't review and can't commit this, but that's my opinion.

Give this person an apple.

sirjofri

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [9front] [PATCH] better rio exit menu entry check
  2022-08-04 14:36 [9front] [PATCH] better rio exit menu entry check Jacob Moody
  2022-08-04 14:56 ` sirjofri
@ 2022-08-04 16:45 ` B. Atticus Grobe
  2022-08-04 19:19   ` umbraticus
  2022-08-04 20:18 ` qwx
  2 siblings, 1 reply; 7+ messages in thread
From: B. Atticus Grobe @ 2022-08-04 16:45 UTC (permalink / raw)
  To: 9front

LGTM. Works fine, and something I'll certainly make use of.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] [PATCH] better rio exit menu entry check
  2022-08-04 16:45 ` B. Atticus Grobe
@ 2022-08-04 19:19   ` umbraticus
  0 siblings, 0 replies; 7+ messages in thread
From: umbraticus @ 2022-08-04 19:19 UTC (permalink / raw)
  To: 9front

Amen.

Of course, every time I run “kill rio” and pick
thru to find the right lines to send, I remind
myself I could have just Deleted the window
from the parent rio… but this is nice too.

umbraticus

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] [PATCH] better rio exit menu entry check
  2022-08-04 14:36 [9front] [PATCH] better rio exit menu entry check Jacob Moody
  2022-08-04 14:56 ` sirjofri
  2022-08-04 16:45 ` B. Atticus Grobe
@ 2022-08-04 20:18 ` qwx
  2022-08-04 22:08   ` umbraticus
  2 siblings, 1 reply; 7+ messages in thread
From: qwx @ 2022-08-04 20:18 UTC (permalink / raw)
  To: 9front

On Thu Aug  4 16:36:38 +0200 2022, moody@mail.posixcafe.org wrote:
> Checking for if the binary name contains .out always seemed a bit
> like a hack. What I seem to want most of the time is for the
> Exit option to show up on subrios, but not my "main" rio.
> This patch does this by checking for an existing
> rio mounted on /mnt/wsys.

I've been using subrios heavily for years now, and I find that an
Exit entry is massively useful for me, but with a safeguard:  a
second click for confirmation like in mothra.  Thanks to this, I
have never had an accidental discharge despite being a total klutz.
Personally I'd prefer the Exit to be present regardless of context,
but this is a nice idea.

Cheers,
qwx


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;
 
-	if(strstr(argv[0], ".out") == nil){
-		menu3str[Exit] = nil;
-		Hidden--;
-	}
 	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;


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] [PATCH] better rio exit menu entry check
  2022-08-04 20:18 ` qwx
@ 2022-08-04 22:08   ` umbraticus
  2022-08-05  4:55     ` qwx
  0 siblings, 1 reply; 7+ messages in thread
From: umbraticus @ 2022-08-04 22:08 UTC (permalink / raw)
  To: 9front

nice, but wrong cursor ;)

/sys/src/cmd/tweak.c:/skull

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] [PATCH] better rio exit menu entry check
  2022-08-04 22:08   ` umbraticus
@ 2022-08-05  4:55     ` qwx
  0 siblings, 0 replies; 7+ messages in thread
From: qwx @ 2022-08-05  4:55 UTC (permalink / raw)
  To: 9front

On Fri Aug  5 00:08:14 +0200 2022, umbraticus@prosimetrum.com wrote:
> nice, but wrong cursor ;)
> 
> /sys/src/cmd/tweak.c:/skull

Good point! :)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-08-05  4:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04 14:36 [9front] [PATCH] better rio exit menu entry check Jacob Moody
2022-08-04 14:56 ` sirjofri
2022-08-04 16:45 ` B. Atticus Grobe
2022-08-04 19:19   ` umbraticus
2022-08-04 20:18 ` qwx
2022-08-04 22:08   ` umbraticus
2022-08-05  4:55     ` qwx

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).