mirror of https://github.com/0intro/wmii
add wimenu screen selection support
This commit is contained in:
parent
d202e339ab
commit
33f5f61d7e
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue