From bdd408cd6c77da06b69db13f527a8ea2af811249 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 27 Sep 2007 16:34:51 +0200 Subject: [PATCH] use get_screen_count instead of ScreenCount where needed --- awesome.c | 14 ++++++++------ event.c | 17 +++++++++++++---- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/awesome.c b/awesome.c index 0c6644cf8..9766c7938 100644 --- a/awesome.c +++ b/awesome.c @@ -66,7 +66,7 @@ cleanup(Display *disp, DC *drawcontext, awesome_config *awesomeconf) unmanage(stack, drawcontext, NormalState, awesomeconf); } - for(screen = 0; screen < ScreenCount(disp); screen++) + for(screen = 0; screen < get_screen_count(disp); screen++) { if(drawcontext[screen].font.set) XFreeFontSet(disp, drawcontext[screen].font.set); @@ -323,10 +323,10 @@ main(int argc, char *argv[]) netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); /* allocate stuff */ - dc = p_new(DC, ScreenCount(dpy)); - awesomeconf = p_new(awesome_config, ScreenCount(dpy)); + dc = p_new(DC, get_screen_count(dpy)); + awesomeconf = p_new(awesome_config, get_screen_count(dpy)); - for(screen = 0; screen < ScreenCount(dpy); screen++) + for(screen = 0; screen < get_screen_count(dpy); screen++) { parse_config(dpy, screen, &dc[screen], confpath, &awesomeconf[screen]); setup(dpy, screen, &dc[screen], &awesomeconf[screen]); @@ -363,13 +363,15 @@ main(int argc, char *argv[]) handler[randr_event_base + RRScreenChangeNotify] = handle_event_randr_screen_change_notify; } - for(screen = 0; screen < ScreenCount(dpy); screen++) + for(screen = 0; screen < get_screen_count(dpy); screen++) { awesomeconf[screen].have_shape = awesomeconf[0].have_shape; awesomeconf[screen].have_randr = awesomeconf[0].have_randr; - scan(dpy, screen, &dc[screen], &awesomeconf[screen]); } + for(screen = 0; screen < ScreenCount(dpy); screen++) + scan(dpy, screen, &dc[screen], &awesomeconf[screen]); + XSync(dpy, False); /* main event loop, also reads status text from stdin */ diff --git a/event.c b/event.c index 77de84f1d..c52a1d105 100644 --- a/event.c +++ b/event.c @@ -148,7 +148,7 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf) Client *c; XButtonPressedEvent *ev = &e->xbutton; - for(screen = 0; screen < ScreenCount(e->xany.display); screen++) + for(screen = 0; screen < get_screen_count(e->xany.display); screen++) if(awesomeconf[screen].statusbar.window == ev->window) { int x = 0; @@ -326,7 +326,7 @@ handle_event_expose(XEvent * e, awesome_config *awesomeconf) int screen; if(!ev->count) - for(screen = 0; screen < ScreenCount(e->xany.display); screen++) + for(screen = 0; screen < get_screen_count(e->xany.display); screen++) if(awesomeconf[screen].statusbar.window == ev->window) drawstatusbar(e->xany.display, &dc[screen], &awesomeconf[screen]); } @@ -346,8 +346,17 @@ handle_event_keypress(XEvent * e, awesome_config *awesomeconf) if(sel) screen = sel->screen; else - for(screen = 0; screen < ScreenCount(e->xany.display) && - !XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen), &dummy, &dummy, &y, &x, &d, &d, &m); screen++); + for(screen = 0; screen < ScreenCount(e->xany.display); screen++) + if(XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen), &dummy, &dummy, &x, &y, &d, &d, &m)) + { + /* if screen is 0, we are on first Zaphod screen or on the + * only screen in Xinerama, so we can ask for a better screen + * number with get_screen_bycoord: we'll get 0 in Zaphod mode + * so it's the same, or maybe the real Xinerama screen */ + if(screen == 0) + screen = get_screen_bycoord(e->xany.display, x, y); + break; + } for(i = 0; i < awesomeconf[screen].nkeys; i++) if(keysym == awesomeconf[screen].keys[i].keysym