From: lists@vaned.net
To: 9fans@cse.psu.edu
Subject: [9fans] plan9ports rio patch
Date: Sat, 4 Sep 2004 17:28:20 -0500 [thread overview]
Message-ID: <20040904222820.GA15588@vaned.net> (raw)
[-- 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;
}
}
next reply other threads:[~2004-09-04 22:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-04 22:28 lists [this message]
2004-09-22 0:59 ` Russ Cox
2004-09-22 9:15 ` Axel Belinfante
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040904222820.GA15588@vaned.net \
--to=lists@vaned.net \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).