commit 33f5f61d7ef359c93e8e8f5bebf6ab5e95b142e4
parent d202e339aba516e0c3587800cc0f7f90e0fc67ef
Author: Bart Trojanowski <bart@jukie.net>
Date: Sun, 29 Mar 2009 23:11:32 -0400
add wimenu screen selection support
Diffstat:
2 files changed, 26 insertions(+), 14 deletions(-)
diff --git 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
@@ -22,7 +22,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
@@ -182,23 +182,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();
}
@@ -210,6 +217,7 @@ main(int argc, char *argv[]) {
char *histfile;
int i;
long ndump;
+ int screen;
quotefmtinstall();
fmtinstall('r', errfmt);
@@ -217,6 +225,7 @@ main(int argc, char *argv[]) {
histfile = nil;
prompt = nil;
promptw = 0;
+ screen = SCREEN_WITH_POINTER;
find = strstr;
compare = strncmp;
@@ -236,6 +245,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;
@@ -299,7 +311,7 @@ main(int argc, char *argv[]) {
if(barwin == nil)
menu_init();
- init_screens();
+ init_screens(screen);
i = ixp_serverloop(&srv);
if(i)