diff --git a/src/client.c b/src/client.c index 39b464f..ada9dd8 100644 --- a/src/client.c +++ b/src/client.c @@ -355,11 +355,13 @@ client_manage(Window w, XWindowAttributes *wa) Window trans; Status rettrans; XSetWindowAttributes at; - int mx, my; + int mx, my, s; + + screen_get_sel(); c = emalloc(1, sizeof(Client)); c->win = w; - c->screen = screen_get_sel(); + c->screen = selscreen; if(conf.client.place_at_mouse) { @@ -382,6 +384,14 @@ client_manage(Window w, XWindowAttributes *wa) { mx = wa->x + BORDH; my = wa->y + TBARH + INFOBARH; + + s = screen_get_with_geo(mx, my); + + if(s != selscreen) + { + mx += sgeo[selscreen].x - BORDH; + my += sgeo[selscreen].y - TBARH - INFOBARH; + } } c->ogeo.x = c->geo.x = mx; @@ -395,7 +405,7 @@ client_manage(Window w, XWindowAttributes *wa) frame_create(c); client_size_hints(c); XChangeWindowAttributes(dpy, c->win, CWEventMask, &at); - XSetWindowBorderWidth(dpy, c->win, 0); /* client win must _not_ has border */ + XSetWindowBorderWidth(dpy, c->win, 0); /* client win sould _not_ have borders */ mouse_grabbuttons(c, False); if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success)) for(t = clients; t && t->win != trans; t = t->next); @@ -425,8 +435,6 @@ client_moveresize(Client *c, XRectangle geo, bool r) { CHECK(c); - int i; - /* Resize hints {{{ */ if(r) { @@ -482,12 +490,7 @@ client_moveresize(Client *c, XRectangle geo, bool r) c->geo = geo; /* Set the client screen */ - for(i = 0; i < screen_count(); ++i) - if(geo.x >= sgeo[i].x - && geo.x < sgeo[i].x + sgeo[i].width - && geo.y >= sgeo[i].y - INFOBARH - TBARH - && geo.y < sgeo[i].y - INFOBARH - TBARH + sgeo[i].height + INFOBARH) - c->screen = i; + c->screen = screen_get_with_geo(geo.x, geo.y); frame_moveresize(c, c->geo); XMoveResizeWindow(dpy, c->win, BORDH, BORDH + TBARH, c->geo.width, c->geo.height); diff --git a/src/layout.c b/src/layout.c index 52e3f51..18a192e 100644 --- a/src/layout.c +++ b/src/layout.c @@ -480,6 +480,8 @@ void uicb_togglefree(uicb_t cmd) { CHECK(sel); + if(!sel || sel->screen != screen_get_sel()) + return; sel->free = !sel->free; sel->tile = False; diff --git a/src/screen.c b/src/screen.c index 2bb0cb6..3c03e60 100644 --- a/src/screen.c +++ b/src/screen.c @@ -83,6 +83,25 @@ screen_get_geo(int s) return geo; } +/** Get the current screen number with + * coordinated + *\param geo Geometry for get the screen number + *\return The screen number +*/ +int +screen_get_with_geo(int x, int y) +{ + int i, r = 0; + + for(i = 0; i < screen_count(); ++i) + if((x >= sgeo[i].x && x < sgeo[i].x + sgeo[i].width) + && (y >= sgeo[i].y - INFOBARH - TBARH + && y < sgeo[i].y - INFOBARH - TBARH + sgeo[i].height + INFOBARH)) + r = i; + + return r; +} + /** Get and set the selected screen *\return The number of the selected screen */ @@ -91,22 +110,16 @@ screen_get_sel(void) { if(XineramaIsActive(dpy)) { + /* Unused variables */ Window w; - uint du; - int x, y, d, i; + int d, u, x, y; - XQueryPointer(dpy, root, &w, &w, &x, &y, &d, &d, &du); + XQueryPointer(dpy, root, &w, &w, &x, &y, &d, &d, (uint *)&u); - for(i = 0; i < screen_count(); ++i) - if((x >= sgeo[i].x && x < sgeo[i].x + sgeo[i].width) - && (y >= sgeo[i].y - INFOBARH - TBARH - && y < sgeo[i].y - INFOBARH - TBARH + sgeo[i].height + INFOBARH)) - selscreen = i; - - return selscreen; + selscreen = screen_get_with_geo(x, y); } - else - return 0; + + return selscreen; } /** Init screen geo diff --git a/src/wmfs.h b/src/wmfs.h index dc73d47..5c9bbc5 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -198,6 +198,7 @@ void uicb_tagtransfert(uicb_t); /* screen */ int screen_count(void); XRectangle screen_get_geo(int s); +int screen_get_with_geo(int x, int y); int screen_get_sel(void); void screen_init_geo(void);