This patch adds support for selecting which screen will get the wimenu
bar. Example:
seq 1 100 | wimenu -s 0
It can be grown to accept -s pointer or -s active, which would then ask
for that info via ixp.
-Bart
---
cmd/menu/fns.h | 2 +-
cmd/menu/main.c | 38 +++++++++++++++++++++++++-------------
2 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/cmd/menu/fns.h b/cmd/menu/fns.h
index 3fcc000..166e518 100644
--- a/cmd/menu/fns.h
+++ b/cmd/menu/fns.h
@@ -12,7 +12,7 @@ uint flushevents(long, bool);
void history_dump(const char*, int);
char* history_search(int, char*, int);
char* histtext(Item*);
-void init_screens(void);
+void init_screens(int);
void menu_init(void);
void menu_show(void);
void xtime_kludge(void);
diff --git a/cmd/menu/main.c b/cmd/menu/main.c
index 0ff4271..51adda6 100644
--- a/cmd/menu/main.c
+++ b/cmd/menu/main.c
@@ -21,7 +21,7 @@ static char* ectl;
static void
usage(void) {
- fatal("usage: wimenu -i [-h <history>] [-a <address>] [-p <prompt>]\n");
+ fatal("usage: wimenu -i [-h <history>] [-a <address>] [-p <prompt>] [-s <screen>]\n");
}
static int
@@ -181,23 +181,30 @@ preselect(IxpServer *s) {
check_x_event(nil);
}
+#define SCREEN_WITH_POINTER -1
+
void
-init_screens(void) {
+init_screens(int screen_hint) {
Rectangle *rects;
Point p;
int i, n;
- /* Pick the screen with the pointer, for now. Later,
- * try for the screen with the focused window first.
- */
- p = querypointer(&scr.root);
rects = xinerama_screens(&n);
- for(i=0; i < n; i++)
- if(rect_haspoint_p(p, rects[i]))
- break;
- if(i == n)
- i = 0;
- /* Probably not the best route. */
+ if (screen_hint >= 0 && screen_hint < n) {
+ /* we were given a valid screen index, use that */
+ i = screen_hint;
+
+ } else {
+ /* Pick the screen with the pointer, for now. Later,
+ * try for the screen with the focused window first.
+ */
+ p = querypointer(&scr.root);
+ for(i=0; i < n; i++)
+ if(rect_haspoint_p(p, rects[i]))
+ break;
+ if(i == n)
+ i = 0;
+ }
scr.rect = rects[i];
menu_show();
}
@@ -209,6 +216,7 @@ main(int argc, char *argv[]) {
char *histfile;
int i;
long ndump;
+ int screen;
quotefmtinstall();
fmtinstall('r', errfmt);
@@ -216,6 +224,7 @@ main(int argc, char *argv[]) {
histfile = nil;
prompt = nil;
promptw = 0;
+ screen = SCREEN_WITH_POINTER;
find = strstr;
compare = strncmp;
@@ -235,6 +244,9 @@ main(int argc, char *argv[]) {
case 'p':
prompt = EARGF(usage());
break;
+ case 's':
+ screen = strtol(EARGF(usage()), nil, 10);
+ break;
case 'i':
find = strcasestr;
compare = strncasecmp;
@@ -294,7 +306,7 @@ main(int argc, char *argv[]) {
}
}
- init_screens();
+ init_screens(screen);
i = ixp_serverloop(&srv);
if(i)
--
1.6.2.rc2.17.gcdd2484
Received on Mon Mar 30 2009 - 01:47:13 UTC
This archive was generated by hypermail 2.2.0 : Mon Mar 30 2009 - 01:48:11 UTC