[hackers] [wmii] add wimenu screen selection support || Bart Trojanowski

From: <hg_AT_suckless.org>
Date: Mon, 30 Mar 2009 03:11:36 +0000 (UTC)

changeset: 2442:698304099ad9
tag: tip
user: Bart Trojanowski <bart_AT_jukie.net>
date: Sun Mar 29 23:11:32 2009 -0400
files: cmd/menu/fns.h cmd/menu/main.c
description:
add wimenu screen selection support

diff -r ea3781647895 -r 698304099ad9 cmd/menu/fns.h
--- a/cmd/menu/fns.h Sun Mar 29 23:07:36 2009 -0400
+++ b/cmd/menu/fns.h Sun Mar 29 23:11:32 2009 -0400
@@ -12,7 +12,7 @@
 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 -r ea3781647895 -r 698304099ad9 cmd/menu/main.c
--- a/cmd/menu/main.c Sun Mar 29 23:07:36 2009 -0400
+++ b/cmd/menu/main.c Sun Mar 29 23:11:32 2009 -0400
@@ -22,7 +22,7 @@
 
 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 @@
         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 @@
         char *histfile;
         int i;
         long ndump;
+ int screen;
 
         quotefmtinstall();
         fmtinstall('r', errfmt);
@@ -217,6 +225,7 @@
         histfile = nil;
         prompt = nil;
         promptw = 0;
+ screen = SCREEN_WITH_POINTER;
 
         find = strstr;
         compare = strncmp;
@@ -235,6 +244,9 @@
                 break;
         case 'p':
                 prompt = EARGF(usage());
+ break;
+ case 's':
+ screen = strtol(EARGF(usage()), nil, 10);
                 break;
         case 'i':
                 find = strcasestr;
@@ -299,7 +311,7 @@
         if(barwin == nil)
                 menu_init();
 
- init_screens();
+ init_screens(screen);
 
         i = ixp_serverloop(&srv);
         if(i)
Received on Mon Mar 30 2009 - 03:11:36 UTC

This archive was generated by hypermail 2.2.0 : Mon Mar 30 2009 - 03:12:05 UTC