9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] plan9ports rio patch
@ 2004-09-04 22:28 lists
  2004-09-22  0:59 ` Russ Cox
  0 siblings, 1 reply; 3+ messages in thread
From: lists @ 2004-09-04 22:28 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 324 bytes --]

greetings list,

i've attached a patch for the current source for rio from plan9ports.  it
appends a window id to menu items which are duplicated in the menu,
making it easier to locate a certain client.  somebody else might find
it useful.

-- 
glaive@vaned.net
4405 5BA1 62D1 9DA1 7774  B4A3 2CB2 3872 24ED 2441

[-- Attachment #2: rio-xid.diff --]
[-- Type: text/plain, Size: 3262 bytes --]

--- fns.h.orig	Sat Sep  4 15:38:59 2004
+++ fns.h	Sat Sep  4 15:39:24 2004
@@ -71,6 +71,7 @@
 void	unhide();
 void	unhidec();
 void	renamec();
+char	*gethideid();
 
 /* client.c */
 void	setactive();

--- menu.c.orig	Sat Sep  4 15:32:09 2004
+++ menu.c	Sat Sep  4 16:39:41 2004
@@ -34,6 +34,8 @@
 	version,
 };
 
+static char extid[14];
+
 void
 button(XButtonEvent *e)
 {
@@ -282,4 +284,32 @@
 			b3items[B3FIXED+i] = name;
 			return;
 		}
+}
+
+char *
+gethideid(int n)
+{
+	Client *c;
+	int i;
+
+	if (n >= numhidden) {
+		fprintf(stderr, "rio: gethideid: n %d numhidden %d\n", n, numhidden);
+		return 0;
+	}
+	c = hiddenc[n];
+	if (!hidden(c)) {
+		fprintf(stderr, "rio: gethideid: not hidden: %s(0x%x)\n",
+			c->label, (int)c->window);
+		return 0;
+	}
+	for (i = 0; i < numhidden; i++) {
+		if (i == n)
+			continue;
+		if (strcmp(c->label, hiddenc[i]->label) == 0)
+			break;
+	}
+	if (i >= numhidden)
+		return 0;
+	snprintf(extid, sizeof(extid), " <0x%lx>", c->window);
+	return(extid);
 }

--- grab.c.orig	Sat Sep  4 14:57:45 2004
+++ grab.c	Sat Sep  4 16:48:23 2004
@@ -47,14 +47,21 @@
 }
 
 static void
-drawstring(Display *dpy, ScreenInfo *s, Menu *m, int wide, int high, int i, int selected)
+drawstring(Display *dpy, ScreenInfo *s, Menu *m, int wide, int high, int i, int selected, char *ext)
 {
-	int tx, ty;
+	int tx, txe, ty;
+	int twidth, n;
 
-	tx = (wide - XTextWidth(font, m->item[i], strlen(m->item[i])))/2;
+	twidth = n = XTextWidth(font, m->item[i], strlen(m->item[i]));
+	if (ext)
+		twidth += XTextWidth(font, ext, strlen(ext));
+	tx = (wide - twidth)/2;
+	txe = tx + n;
 	ty = i*high + font->ascent + 1;
 	XFillRectangle(dpy, s->menuwin, selected ? s->gcmenubgs : s->gcmenubg, 0, i*high, wide, high);
 	XDrawString(dpy, s->menuwin, selected ? s->gcmenufgs : s->gcmenufg, tx, ty, m->item[i], strlen(m->item[i]));
+	if (ext)
+		XDrawString(dpy, s->menuwin, selected ? s->gcmenufgs : s->gcmenufg, txe, ty, ext, strlen(ext));
 }
 
 int
@@ -63,6 +70,7 @@
 	XEvent ev;
 	int i, n, cur, old, wide, high, status, drawn, warp;
 	int x, y, dx, dy, xmax, ymax;
+	char *extptr;
 	ScreenInfo *s;
 
 	if (font == 0)
@@ -74,6 +82,9 @@
 	dx = 0;
 	for (n = 0; m->item[n]; n++) {
 		wide = XTextWidth(font, m->item[n], strlen(m->item[n])) + 4;
+		if (m == &b3menu)
+			if ((n >= B3FIXED) && (extptr = gethideid(n - B3FIXED)))
+				wide += XTextWidth(font, extptr, strlen(extptr));
 		if (wide > dx)
 			dx = wide;
 	}
@@ -164,14 +175,14 @@
 			if (cur == old)
 				break;
 			if (old >= 0 && old < n)
-				drawstring(dpy, s, m, wide, high, old, 0);
+				drawstring(dpy, s, m, wide, high, old, 0, (m == &b3menu && old >= B3FIXED) ? gethideid(old - B3FIXED) : 0);
 			if (cur >= 0 && cur < n)
-				drawstring(dpy, s, m, wide, high, cur, 1);
+				drawstring(dpy, s, m, wide, high, cur, 1, (m == &b3menu && cur >= B3FIXED) ? gethideid(cur - B3FIXED) : 0);
 			break;
 		case Expose:
 			XClearWindow(dpy, s->menuwin);
 			for (i = 0; i < n; i++)
-				drawstring(dpy, s, m, wide, high, i, cur==i);
+				drawstring(dpy, s, m, wide, high, i, cur==i, (m == &b3menu && i >= B3FIXED) ? gethideid(i - B3FIXED) : 0);
 			drawn = 1;
 		}
 	}

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

* Re: [9fans] plan9ports rio patch
  2004-09-04 22:28 [9fans] plan9ports rio patch lists
@ 2004-09-22  0:59 ` Russ Cox
  2004-09-22  9:15   ` Axel Belinfante
  0 siblings, 1 reply; 3+ messages in thread
From: Russ Cox @ 2004-09-22  0:59 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> i've attached a patch for the current source for rio from plan9ports.  it
> appends a window id to menu items which are duplicated in the menu,
> making it easier to locate a certain client.  somebody else might find
> it useful.

i'm curious which clients you have many of that
don't do the right thing.  perhaps a better solution
is to arrange for them to have distinguishing names that
are more useful than foo <1> and foo <2>?

the main thing i have a lot of is 9terms, and i usually
use awd to set their labels to the current directory.

russ


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

* Re: [9fans] plan9ports rio patch
  2004-09-22  0:59 ` Russ Cox
@ 2004-09-22  9:15   ` Axel Belinfante
  0 siblings, 0 replies; 3+ messages in thread
From: Axel Belinfante @ 2004-09-22  9:15 UTC (permalink / raw)
  To: Russ Cox, Fans of the OS Plan 9 from Bell Labs

> the main thing i have a lot of is 9terms, and i usually
> use awd to set their labels to the current directory.

Since I found it useful to see on what machine a (9 x)^term
is logged in to (in unix, not all machines are equal),
my labels currently show a user@host next to the directory
One disadvantage: the menu gets very wide
(this is less noticable when mozilla is running - also it
 generates sometimes very wide labels).
(also, the scheme of "/dir/path user@home" didn't seem to
 integrate perfectly with win in acme - but I seldomly use win).
 

I hacked 9term to be able to take the directory part of
the labels I use (such that plumbing works).
Because I was unsure about general interest, I think I
did not provide a patch. If there is interest, let me know.

(I also hacked 9term to display a ? cursor when plumbing fails;
 I think I sent the patch for that to Russ)

Axel.



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

end of thread, other threads:[~2004-09-22  9:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-04 22:28 [9fans] plan9ports rio patch lists
2004-09-22  0:59 ` Russ Cox
2004-09-22  9:15   ` Axel Belinfante

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).