client/screen: Add screen_get_with_geo for get the current screen with X & Y, and improve the client free placement
This commit is contained in:
parent
4c0a33ddfc
commit
dde207ebf8
25
src/client.c
25
src/client.c
@ -355,11 +355,13 @@ client_manage(Window w, XWindowAttributes *wa)
|
|||||||
Window trans;
|
Window trans;
|
||||||
Status rettrans;
|
Status rettrans;
|
||||||
XSetWindowAttributes at;
|
XSetWindowAttributes at;
|
||||||
int mx, my;
|
int mx, my, s;
|
||||||
|
|
||||||
|
screen_get_sel();
|
||||||
|
|
||||||
c = emalloc(1, sizeof(Client));
|
c = emalloc(1, sizeof(Client));
|
||||||
c->win = w;
|
c->win = w;
|
||||||
c->screen = screen_get_sel();
|
c->screen = selscreen;
|
||||||
|
|
||||||
if(conf.client.place_at_mouse)
|
if(conf.client.place_at_mouse)
|
||||||
{
|
{
|
||||||
@ -382,6 +384,14 @@ client_manage(Window w, XWindowAttributes *wa)
|
|||||||
{
|
{
|
||||||
mx = wa->x + BORDH;
|
mx = wa->x + BORDH;
|
||||||
my = wa->y + TBARH + INFOBARH;
|
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;
|
c->ogeo.x = c->geo.x = mx;
|
||||||
@ -395,7 +405,7 @@ client_manage(Window w, XWindowAttributes *wa)
|
|||||||
frame_create(c);
|
frame_create(c);
|
||||||
client_size_hints(c);
|
client_size_hints(c);
|
||||||
XChangeWindowAttributes(dpy, c->win, CWEventMask, &at);
|
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);
|
mouse_grabbuttons(c, False);
|
||||||
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
|
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
|
||||||
for(t = clients; t && t->win != trans; t = t->next);
|
for(t = clients; t && t->win != trans; t = t->next);
|
||||||
@ -425,8 +435,6 @@ client_moveresize(Client *c, XRectangle geo, bool r)
|
|||||||
{
|
{
|
||||||
CHECK(c);
|
CHECK(c);
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Resize hints {{{ */
|
/* Resize hints {{{ */
|
||||||
if(r)
|
if(r)
|
||||||
{
|
{
|
||||||
@ -482,12 +490,7 @@ client_moveresize(Client *c, XRectangle geo, bool r)
|
|||||||
c->geo = geo;
|
c->geo = geo;
|
||||||
|
|
||||||
/* Set the client screen */
|
/* Set the client screen */
|
||||||
for(i = 0; i < screen_count(); ++i)
|
c->screen = screen_get_with_geo(geo.x, geo.y);
|
||||||
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;
|
|
||||||
|
|
||||||
frame_moveresize(c, c->geo);
|
frame_moveresize(c, c->geo);
|
||||||
XMoveResizeWindow(dpy, c->win, BORDH, BORDH + TBARH, c->geo.width, c->geo.height);
|
XMoveResizeWindow(dpy, c->win, BORDH, BORDH + TBARH, c->geo.width, c->geo.height);
|
||||||
|
|||||||
@ -480,6 +480,8 @@ void
|
|||||||
uicb_togglefree(uicb_t cmd)
|
uicb_togglefree(uicb_t cmd)
|
||||||
{
|
{
|
||||||
CHECK(sel);
|
CHECK(sel);
|
||||||
|
if(!sel || sel->screen != screen_get_sel())
|
||||||
|
return;
|
||||||
|
|
||||||
sel->free = !sel->free;
|
sel->free = !sel->free;
|
||||||
sel->tile = False;
|
sel->tile = False;
|
||||||
|
|||||||
37
src/screen.c
37
src/screen.c
@ -83,6 +83,25 @@ screen_get_geo(int s)
|
|||||||
return geo;
|
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
|
/** Get and set the selected screen
|
||||||
*\return The number of the selected screen
|
*\return The number of the selected screen
|
||||||
*/
|
*/
|
||||||
@ -91,22 +110,16 @@ screen_get_sel(void)
|
|||||||
{
|
{
|
||||||
if(XineramaIsActive(dpy))
|
if(XineramaIsActive(dpy))
|
||||||
{
|
{
|
||||||
|
/* Unused variables */
|
||||||
Window w;
|
Window w;
|
||||||
uint du;
|
int d, u, x, y;
|
||||||
int x, y, d, i;
|
|
||||||
|
|
||||||
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)
|
selscreen = screen_get_with_geo(x, y);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return 0;
|
return selscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Init screen geo
|
/** Init screen geo
|
||||||
|
|||||||
@ -198,6 +198,7 @@ void uicb_tagtransfert(uicb_t);
|
|||||||
/* screen */
|
/* screen */
|
||||||
int screen_count(void);
|
int screen_count(void);
|
||||||
XRectangle screen_get_geo(int s);
|
XRectangle screen_get_geo(int s);
|
||||||
|
int screen_get_with_geo(int x, int y);
|
||||||
int screen_get_sel(void);
|
int screen_get_sel(void);
|
||||||
void screen_init_geo(void);
|
void screen_init_geo(void);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user