diff --git a/awesome.c b/awesome.c index 4981494af..755646f59 100644 --- a/awesome.c +++ b/awesome.c @@ -77,7 +77,6 @@ scan() { if(XQueryTree(globalconf.display, RootWindow(globalconf.display, screen), &d1, &d2, &wins, &num)) { - real_screen = screen; for(i = 0; i < num; i++) { /* XGetWindowAttributes return 1 on success */ @@ -87,8 +86,7 @@ scan() continue; if(wa.map_state == IsViewable || window_getstate(wins[i]) == IconicState) { - if(screen == 0) - real_screen = screen_get_bycoord(wa.x, wa.y); + real_screen = screen_get_bycoord(screen, wa.x, wa.y); client_manage(wins[i], &wa, real_screen); } } @@ -100,8 +98,7 @@ scan() if(XGetTransientForHint(globalconf.display, wins[i], &d1) && (wa.map_state == IsViewable || window_getstate(wins[i]) == IconicState)) { - if(screen == 0) - real_screen = screen_get_bycoord(wa.x, wa.y); + real_screen = screen_get_bycoord(screen, wa.x, wa.y); client_manage(wins[i], &wa, real_screen); } } diff --git a/client.c b/client.c index 1a29f850a..c3994eb9f 100644 --- a/client.c +++ b/client.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "client.h" #include "tag.h" @@ -253,7 +254,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen) c = p_new(Client, 1); - c->screen = screen_get_bycoord(wa->x, wa->y); + c->screen = screen_get_bycoord(screen, wa->x, wa->y); screen_geom = screen_get_area(c->screen, globalconf.screens[screen].statusbar, @@ -447,7 +448,7 @@ client_resize(Client *c, Area geometry, Bool sizehints) if(c->geometry.x != geometry.x || c->geometry.y != geometry.y || c->geometry.width != geometry.width || c->geometry.height != geometry.height) { - new_screen = screen_get_bycoord(geometry.x, geometry.y); + new_screen = screen_get_bycoord(c->screen, geometry.x, geometry.y); c->geometry.x = wc.x = geometry.x; c->geometry.y = wc.y = geometry.y; diff --git a/event.c b/event.c index d0ce38b60..877982a1b 100644 --- a/event.c +++ b/event.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "screen.h" #include "event.h" @@ -134,7 +135,7 @@ handle_event_buttonpress(XEvent *e) &wdummy, &x, &y, &i, &i, &udummy)) { - screen = screen_get_bycoord(x, y); + screen = screen_get_bycoord(screen, x, y); handle_mouse_button_press(screen, ev->button, ev->state, globalconf.buttons.root, NULL); return; @@ -273,8 +274,7 @@ handle_event_keypress(XEvent * e) * only screen in Xinerama, so we can ask for a better screen * number with screen_get_bycoord: we'll get 0 in Zaphod mode * so it's the same, or maybe the real Xinerama screen */ - if(screen == 0) - screen = screen_get_bycoord(x, y); + screen = screen_get_bycoord(screen, x, y); break; } @@ -315,7 +315,7 @@ handle_event_maprequest(XEvent *e) { static XWindowAttributes wa; XMapRequestEvent *ev = &e->xmaprequest; - int screen, x, y, d; + int screen = 0, x, y, d; unsigned int m; Window dummy; @@ -325,10 +325,13 @@ handle_event_maprequest(XEvent *e) return; if(!client_get_bywin(globalconf.clients, ev->window)) { - for(screen = 0; wa.screen != ScreenOfDisplay(e->xany.display, screen); screen++); - if(screen == 0 && XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen), - &dummy, &dummy, &x, &y, &d, &d, &m)) - screen = screen_get_bycoord(x, y); + if(XineramaIsActive(globalconf.display) + && XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen), + &dummy, &dummy, &x, &y, &d, &d, &m)) + screen = screen_get_bycoord(screen, x, y); + else + for(screen = 0; wa.screen != ScreenOfDisplay(e->xany.display, screen); screen++); + client_manage(ev->window, &wa, screen); } } diff --git a/ewmh.c b/ewmh.c index ac2672582..e1da86ed0 100644 --- a/ewmh.c +++ b/ewmh.c @@ -149,10 +149,9 @@ ewmh_update_net_client_list(int phys_screen) int n = 0; for(c = globalconf.clients; c; c = c->next) - if(get_phys_screen(c->screen) == phys_screen) - n++; + n++; - wins = p_new(Window, n + 1); + wins = p_new(Window, n); for(n = 0, c = globalconf.clients; c; c = c->next, n++) if(get_phys_screen(c->screen) == phys_screen) @@ -162,7 +161,6 @@ ewmh_update_net_client_list(int phys_screen) net_client_list, XA_WINDOW, 32, PropModeReplace, (unsigned char *) wins, n); p_delete(&wins); - XFlush(globalconf.display); } void diff --git a/mouse.c b/mouse.c index 5d3d2ca63..dcd594172 100644 --- a/mouse.c +++ b/mouse.c @@ -116,7 +116,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) XQueryPointer(globalconf.display, RootWindow(globalconf.display, phys_screen), &dummy, &child, &x, &y, &di, &di, &dui); - if((newscreen = screen_get_bycoord(x, y)) != c->screen) + if((newscreen = screen_get_bycoord(c->screen, x, y)) != c->screen) { move_client_to_screen(c, newscreen, True); globalconf.screens[c->screen].need_arrange = True; diff --git a/screen.c b/screen.c index 645b09fbf..736b86706 100644 --- a/screen.c +++ b/screen.c @@ -110,14 +110,14 @@ get_display_area(int screen, Statusbar *statusbar, Padding *padding) * \return screen number or DefaultScreen of disp on no match */ int -screen_get_bycoord(int x, int y) +screen_get_bycoord(int screen, int x, int y) { int i; Area area; /* don't waste our time */ if(!XineramaIsActive(globalconf.display)) - return DefaultScreen(globalconf.display); + return screen; for(i = 0; i < globalconf.nscreen; i++) { diff --git a/screen.h b/screen.h index fb76b4b90..acc98e6ab 100644 --- a/screen.h +++ b/screen.h @@ -26,7 +26,7 @@ Area screen_get_area(int, Statusbar *, Padding *); Area get_display_area(int, Statusbar *, Padding *); -int screen_get_bycoord(int, int); +int screen_get_bycoord(int, int, int); void screen_build_screens(void); int get_phys_screen(int); void move_client_to_screen(Client *, int, Bool);