use Area to store window geoms
This commit is contained in:
parent
5a66ffb2e7
commit
163acc8624
98
client.c
98
client.c
|
@ -315,20 +315,20 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
|||
c = p_new(Client, 1);
|
||||
|
||||
c->win = w;
|
||||
c->x = c->rx = wa->x;
|
||||
c->y = c->ry = wa->y;
|
||||
c->w = c->rw = wa->width;
|
||||
c->h = c->rh = wa->height;
|
||||
c->geometry.x = c->f_geometry.x = c->m_geometry.x = wa->x;
|
||||
c->geometry.y = c->f_geometry.y = c->m_geometry.y = wa->y;
|
||||
c->geometry.width = c->f_geometry.width = c->m_geometry.width = wa->width;
|
||||
c->geometry.height = c->f_geometry.height = c->m_geometry.height = wa->height;
|
||||
c->oldborder = wa->border_width;
|
||||
|
||||
c->screen = get_screen_bycoord(c->x, c->y);
|
||||
c->screen = get_screen_bycoord(c->geometry.x, c->geometry.y);
|
||||
|
||||
move_client_to_screen(c, screen, True);
|
||||
|
||||
/* update window title */
|
||||
client_updatetitle(c);
|
||||
|
||||
if(c->w == area.width && c->h == area.height)
|
||||
if(c->geometry.width == area.width && c->geometry.height == area.height)
|
||||
c->border = wa->border_width;
|
||||
else
|
||||
c->border = globalconf.screens[screen].borderpx;
|
||||
|
@ -340,10 +340,10 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
|||
|
||||
|
||||
/* if window request fullscreen mode */
|
||||
if(c->w == area.width && c->h == area.height)
|
||||
if(c->geometry.width == area.width && c->geometry.height == area.height)
|
||||
{
|
||||
c->x = area.x;
|
||||
c->y = area.y;
|
||||
c->geometry.x = area.x;
|
||||
c->geometry.y = area.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -351,23 +351,24 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
|||
globalconf.screens[screen].statusbar,
|
||||
&globalconf.screens[screen].padding);
|
||||
|
||||
if(c->x + c->w + 2 * c->border > darea.x + darea.width)
|
||||
c->x = c->rx = darea.x + darea.width - c->w - 2 * c->border;
|
||||
if(c->y + c->h + 2 * c->border > darea.y + darea.height)
|
||||
c->y = c->ry = darea.y + darea.height - c->h - 2 * c->border;
|
||||
if(c->x < darea.x)
|
||||
c->x = c->rx = darea.x;
|
||||
if(c->y < darea.y)
|
||||
c->y = c->ry = darea.y;
|
||||
if(c->geometry.x + c->geometry.width + 2 * c->border > darea.x + darea.width)
|
||||
c->geometry.x = c->f_geometry.x = darea.x + darea.width - c->geometry.width - 2 * c->border;
|
||||
if(c->geometry.y + c->geometry.height + 2 * c->border > darea.y + darea.height)
|
||||
c->geometry.y = c->f_geometry.y = darea.y + darea.height - c->geometry.height - 2 * c->border;
|
||||
if(c->geometry.x < darea.x)
|
||||
c->geometry.x = c->f_geometry.x = darea.x;
|
||||
if(c->geometry.y < darea.y)
|
||||
c->geometry.y = c->f_geometry.y = darea.y;
|
||||
}
|
||||
|
||||
/* XXX if this necessary ? */
|
||||
/* set borders */
|
||||
wc.border_width = c->border;
|
||||
XConfigureWindow(globalconf.display, w, CWBorderWidth, &wc);
|
||||
XSetWindowBorder(globalconf.display, w, globalconf.screens[screen].colors_normal[ColBorder].pixel);
|
||||
|
||||
/* propagates border_width, if size doesn't change */
|
||||
window_configure(c->win, c->x, c->y, c->w, c->h, c->border);
|
||||
window_configure(c->win, c->geometry.x, c->geometry.y,
|
||||
c->geometry.width, c->geometry.height, c->border);
|
||||
|
||||
/* update hints */
|
||||
client_updatesizehints(c);
|
||||
|
@ -415,7 +416,8 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
|||
}
|
||||
|
||||
/* some windows require this */
|
||||
XMoveResizeWindow(globalconf.display, c->win, c->x, c->y, c->w, c->h);
|
||||
XMoveResizeWindow(globalconf.display, c->win, c->geometry.x, c->geometry.y,
|
||||
c->geometry.width, c->geometry.height);
|
||||
|
||||
focus(c, True, screen);
|
||||
|
||||
|
@ -496,27 +498,28 @@ client_resize(Client *c, int x, int y, int w, int h,
|
|||
x = 0;
|
||||
if(y + h + 2 * c->border < 0)
|
||||
y = 0;
|
||||
if(c->x != x || c->y != y || c->w != w || c->h != h)
|
||||
if(c->geometry.x != x || c->geometry.y != y
|
||||
|| c->geometry.width != w || c->geometry.height != h)
|
||||
{
|
||||
c->x = x;
|
||||
c->y = y;
|
||||
c->w = w;
|
||||
c->h = h;
|
||||
c->geometry.x = x;
|
||||
c->geometry.y = y;
|
||||
c->geometry.width = w;
|
||||
c->geometry.height = h;
|
||||
curtags = get_current_tags(c->screen);
|
||||
if(!volatile_coords && (c->isfloating
|
||||
|| curtags[0]->layout->arrange == layout_floating))
|
||||
{
|
||||
c->rx = c->x;
|
||||
c->ry = c->y;
|
||||
c->rw = c->w;
|
||||
c->rh = c->h;
|
||||
c->f_geometry.x = x;
|
||||
c->f_geometry.y = y;
|
||||
c->f_geometry.width = w;
|
||||
c->f_geometry.height = h;
|
||||
}
|
||||
p_delete(&curtags);
|
||||
XMoveResizeWindow(globalconf.display, c->win, c->x, c->y, c->w, c->h);
|
||||
window_configure(c->win, c->x, c->y, c->w, c->h, c->border);
|
||||
XMoveResizeWindow(globalconf.display, c->win, x, y, w, h);
|
||||
window_configure(c->win, x, y, w, h, c->border);
|
||||
if(XineramaIsActive(globalconf.display))
|
||||
{
|
||||
int new_screen = get_screen_bycoord(c->x, c->y);
|
||||
int new_screen = get_screen_bycoord(x, y);
|
||||
if(c->screen != new_screen)
|
||||
move_client_to_screen(c, new_screen, False);
|
||||
}
|
||||
|
@ -801,15 +804,15 @@ uicb_client_moveresize(int screen, char *arg)
|
|||
p_delete(&curtags);
|
||||
if(sscanf(arg, "%s %s %s %s", x, y, w, h) != 4)
|
||||
return;
|
||||
nx = (int) compute_new_value_from_arg(x, sel->x);
|
||||
ny = (int) compute_new_value_from_arg(y, sel->y);
|
||||
nw = (int) compute_new_value_from_arg(w, sel->w);
|
||||
nh = (int) compute_new_value_from_arg(h, sel->h);
|
||||
nx = (int) compute_new_value_from_arg(x, sel->geometry.x);
|
||||
ny = (int) compute_new_value_from_arg(y, sel->geometry.y);
|
||||
nw = (int) compute_new_value_from_arg(w, sel->geometry.width);
|
||||
nh = (int) compute_new_value_from_arg(h, sel->geometry.height);
|
||||
|
||||
ox = sel->x;
|
||||
oy = sel->y;
|
||||
ow = sel->w;
|
||||
oh = sel->h;
|
||||
ox = sel->geometry.x;
|
||||
oy = sel->geometry.y;
|
||||
ow = sel->geometry.width;
|
||||
oh = sel->geometry.height;
|
||||
|
||||
Bool xqp = XQueryPointer(globalconf.display,
|
||||
RootWindow(globalconf.display,
|
||||
|
@ -818,8 +821,8 @@ uicb_client_moveresize(int screen, char *arg)
|
|||
client_resize(sel, nx, ny, nw, nh, True, False);
|
||||
if (xqp && ox <= mx && (ox + ow) >= mx && oy <= my && (oy + oh) >= my)
|
||||
{
|
||||
nmx = mx - ox + sel->w - ow - 1 < 0 ? 0 : mx - ox + sel->w - ow - 1;
|
||||
nmy = my - oy + sel->h - oh - 1 < 0 ? 0 : my - oy + sel->h - oh - 1;
|
||||
nmx = mx - ox + sel->geometry.width - ow - 1 < 0 ? 0 : mx - ox + sel->geometry.width - ow - 1;
|
||||
nmy = my - oy + sel->geometry.height - oh - 1 < 0 ? 0 : my - oy + sel->geometry.height - oh - 1;
|
||||
XWarpPointer(globalconf.display,
|
||||
None, sel->win,
|
||||
0, 0, 0, 0, nmx, nmy);
|
||||
|
@ -875,7 +878,8 @@ client_maximize(Client *c, int x, int y, int w, int h, Bool borders)
|
|||
client_resize(c, x, y, w, h, False, True);
|
||||
}
|
||||
else if(c->wasfloating)
|
||||
client_resize(c, c->rx, c->ry, c->rw, c->rh, True, False);
|
||||
client_resize(c, c->f_geometry.x, c->f_geometry.y,
|
||||
c->f_geometry.width, c->f_geometry.height, True, False);
|
||||
else
|
||||
c->isfloating = False;
|
||||
|
||||
|
@ -917,8 +921,8 @@ uicb_client_toggleverticalmax(int screen, char *arg __attribute__ ((unused)))
|
|||
&globalconf.screens[screen].padding);
|
||||
|
||||
if(sel)
|
||||
client_maximize(sel, sel->x, area.y,
|
||||
sel->w,
|
||||
client_maximize(sel, sel->geometry.x, area.y,
|
||||
sel->geometry.width,
|
||||
area.height - 2 * sel->border, False);
|
||||
}
|
||||
|
||||
|
@ -937,9 +941,9 @@ uicb_client_togglehorizontalmax(int screen, char *arg __attribute__ ((unused)))
|
|||
&globalconf.screens[screen].padding);
|
||||
|
||||
if(sel)
|
||||
client_maximize(sel, area.x, sel->y,
|
||||
client_maximize(sel, area.x, sel->geometry.y,
|
||||
area.height - 2 * sel->border,
|
||||
sel->h, False);
|
||||
sel->geometry.height, False);
|
||||
}
|
||||
|
||||
/** Zoom client
|
||||
|
|
8
config.h
8
config.h
|
@ -152,9 +152,11 @@ struct Client
|
|||
/** Client name */
|
||||
char name[256];
|
||||
/** Window geometry */
|
||||
int x, y, w, h;
|
||||
/** Real window geometry for floating */
|
||||
int rx, ry, rw, rh;
|
||||
Area geometry;
|
||||
/** Floating window geometry */
|
||||
Area f_geometry;
|
||||
/** Max window geometry */
|
||||
Area m_geometry;
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
int minax, maxax, minay, maxay;
|
||||
int border, oldborder;
|
||||
|
|
19
event.c
19
event.c
|
@ -146,18 +146,19 @@ handle_event_configurerequest(XEvent * e)
|
|||
if(c->isfixed)
|
||||
{
|
||||
if(ev->value_mask & CWX)
|
||||
c->rx = c->x = ev->x - c->border;
|
||||
c->f_geometry.x = c->geometry.x = ev->x - c->border;
|
||||
if(ev->value_mask & CWY)
|
||||
c->ry = c->y = ev->y - c->border;
|
||||
c->f_geometry.y = c->f_geometry.y = ev->y - c->border;
|
||||
if(ev->value_mask & CWWidth)
|
||||
c->rw = c->w = ev->width;
|
||||
c->f_geometry.width = c->geometry.width = ev->width;
|
||||
if(ev->value_mask & CWHeight)
|
||||
c->rh = c->h = ev->height;
|
||||
c->f_geometry.height = c->geometry.height = ev->height;
|
||||
if((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight)))
|
||||
window_configure(c->win, c->x, c->y, c->w, c->h, c->border);
|
||||
window_configure(c->win, c->geometry.x, c->geometry.y,
|
||||
c->geometry.width, c->geometry.height, c->border);
|
||||
/* recompute screen */
|
||||
old_screen = c->screen;
|
||||
c->screen = get_screen_bycoord(c->x, c->y);
|
||||
c->screen = get_screen_bycoord(c->geometry.x, c->geometry.y);
|
||||
if(old_screen != c->screen)
|
||||
{
|
||||
move_client_to_screen(c, c->screen, False);
|
||||
|
@ -165,11 +166,13 @@ handle_event_configurerequest(XEvent * e)
|
|||
statusbar_draw_all(c->screen);
|
||||
}
|
||||
tag_client_with_rules(c);
|
||||
XMoveResizeWindow(e->xany.display, c->win, c->rx, c->ry, c->rw, c->rh);
|
||||
XMoveResizeWindow(e->xany.display, c->win, c->f_geometry.x, c->f_geometry.y,
|
||||
c->f_geometry.width, c->f_geometry.height);
|
||||
arrange(c->screen);
|
||||
}
|
||||
else
|
||||
window_configure(c->win, c->x, c->y, c->w, c->h, c->border);
|
||||
window_configure(c->win, c->geometry.x, c->geometry.y,
|
||||
c->geometry.width, c->geometry.height, c->border);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
3
layout.c
3
layout.c
|
@ -181,7 +181,8 @@ restack(int screen)
|
|||
p_delete(&curtags);
|
||||
}
|
||||
if(globalconf.screens[screen].focus_move_pointer)
|
||||
XWarpPointer(globalconf.display, None, sel->win, 0, 0, 0, 0, sel->w / 2, sel->h / 2);
|
||||
XWarpPointer(globalconf.display, None, sel->win, 0, 0, 0, 0,
|
||||
sel->geometry.width / 2, sel->geometry.height / 2);
|
||||
XSync(globalconf.display, False);
|
||||
while(XCheckMaskEvent(globalconf.display, EnterWindowMask, &ev));
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ layout_floating(int screen)
|
|||
|
||||
for(c = globalconf.clients; c; c = c->next)
|
||||
if(client_isvisible(c, screen) && !c->ismax)
|
||||
client_resize(c, c->rx, c->ry, c->rw, c->rh, True, False);
|
||||
client_resize(c, c->f_geometry.x, c->f_geometry.y,
|
||||
c->f_geometry.width, c->f_geometry.height, True, False);
|
||||
}
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
24
mouse.c
24
mouse.c
|
@ -66,8 +66,8 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
|
|||
globalconf.screens[screen].statusbar,
|
||||
&globalconf.screens[screen].padding);
|
||||
|
||||
ocx = nx = c->x;
|
||||
ocy = ny = c->y;
|
||||
ocx = nx = c->geometry.x;
|
||||
ocy = ny = c->geometry.y;
|
||||
phys_screen = get_phys_screen(c->screen);
|
||||
if(XGrabPointer(globalconf.display,
|
||||
RootWindow(globalconf.display, phys_screen),
|
||||
|
@ -101,13 +101,13 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
|
|||
ny = ocy + (ev.xmotion.y - y);
|
||||
if(abs(nx) < globalconf.screens[screen].snap + area.x && nx > area.x)
|
||||
nx = area.x;
|
||||
else if(abs((area.x + area.width) - (nx + c->w + 2 * c->border)) < globalconf.screens[screen].snap)
|
||||
nx = area.x + area.width - c->w - 2 * c->border;
|
||||
else if(abs((area.x + area.width) - (nx + c->geometry.width + 2 * c->border)) < globalconf.screens[screen].snap)
|
||||
nx = area.x + area.width - c->geometry.width - 2 * c->border;
|
||||
if(abs(ny) < globalconf.screens[screen].snap + area.y && ny > area.y)
|
||||
ny = area.y;
|
||||
else if(abs((area.y + area.height) - (ny + c->h + 2 * c->border)) < globalconf.screens[screen].snap)
|
||||
ny = area.y + area.height - c->h - 2 * c->border;
|
||||
client_resize(c, nx, ny, c->w, c->h, False, False);
|
||||
else if(abs((area.y + area.height) - (ny + c->geometry.height + 2 * c->border)) < globalconf.screens[screen].snap)
|
||||
ny = area.y + area.height - c->geometry.height - 2 * c->border;
|
||||
client_resize(c, nx, ny, c->geometry.width, c->geometry.height, False, False);
|
||||
while(XCheckMaskEvent(globalconf.display, PointerMotionMask, &ev));
|
||||
break;
|
||||
}
|
||||
|
@ -135,8 +135,8 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
|
|||
if((curtags[0]->layout->arrange == layout_floating) || c->isfloating)
|
||||
{
|
||||
restack(screen);
|
||||
ocx = c->x;
|
||||
ocy = c->y;
|
||||
ocx = c->geometry.x;
|
||||
ocy = c->geometry.y;
|
||||
c->ismax = False;
|
||||
}
|
||||
else if (curtags[0]->layout->arrange == layout_tile
|
||||
|
@ -166,9 +166,9 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
|
|||
return;
|
||||
|
||||
if(curtags[0]->layout->arrange == layout_tileleft)
|
||||
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0, 0, c->h + c->border - 1);
|
||||
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0, 0, c->geometry.height + c->border - 1);
|
||||
else
|
||||
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
|
||||
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0, c->geometry.width + c->border - 1, c->geometry.height + c->border - 1);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
|
|||
nw = 1;
|
||||
if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
|
||||
nh = 1;
|
||||
client_resize(c, c->x, c->y, nw, nh, True, False);
|
||||
client_resize(c, c->geometry.x, c->geometry.y, nw, nh, True, False);
|
||||
}
|
||||
else if(curtags[0]->layout->arrange == layout_tile
|
||||
|| curtags[0]->layout->arrange == layout_tileleft)
|
||||
|
|
23
screen.c
23
screen.c
|
@ -209,19 +209,20 @@ move_client_to_screen(Client *c, int new_screen, Bool doresize)
|
|||
from = get_screen_area(old_screen, NULL, NULL);
|
||||
|
||||
/* compute new coords in new screen */
|
||||
c->rx = (c->rx - from.x) + to.x;
|
||||
c->ry = (c->ry - from.y) + to.y;
|
||||
c->f_geometry.x = (c->f_geometry.x - from.x) + to.x;
|
||||
c->f_geometry.y = (c->f_geometry.y - from.y) + to.y;
|
||||
/* check that new coords are still in the screen */
|
||||
if(c->rw > to.width)
|
||||
c->rw = to.width;
|
||||
if(c->rh > to.height)
|
||||
c->rh = to.height;
|
||||
if(c->rx + c->rw >= to.x + to.width)
|
||||
c->rx = to.x + to.width - c->rw - 2 * c->border;
|
||||
if(c->ry + c->rh >= to.y + to.height)
|
||||
c->ry = to.y + to.height - c->rh - 2 * c->border;
|
||||
if(c->f_geometry.width > to.width)
|
||||
c->f_geometry.width = to.width;
|
||||
if(c->f_geometry.height > to.height)
|
||||
c->f_geometry.height = to.height;
|
||||
if(c->f_geometry.x + c->f_geometry.width >= to.x + to.width)
|
||||
c->f_geometry.x = to.x + to.width - c->f_geometry.width - 2 * c->border;
|
||||
if(c->f_geometry.y + c->f_geometry.height >= to.y + to.height)
|
||||
c->f_geometry.y = to.y + to.height - c->f_geometry.height - 2 * c->border;
|
||||
|
||||
client_resize(c, c->rx, c->ry, c->rw, c->rh, True, False);
|
||||
client_resize(c, c->f_geometry.x, c->f_geometry.y,
|
||||
c->f_geometry.width, c->f_geometry.height, True, False);
|
||||
}
|
||||
|
||||
focus(c, True, c->screen);
|
||||
|
|
6
tag.c
6
tag.c
|
@ -216,9 +216,11 @@ uicb_client_togglefloating(int screen, char *arg __attribute__ ((unused)))
|
|||
sel->isfloating = !sel->isfloating;
|
||||
|
||||
if (arg == NULL)
|
||||
client_resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True, False);
|
||||
client_resize(sel, sel->f_geometry.x, sel->f_geometry.y,
|
||||
sel->f_geometry.width, sel->f_geometry.height, True, False);
|
||||
else
|
||||
client_resize(sel, sel->x, sel->y, sel->w, sel->h, True, True);
|
||||
client_resize(sel, sel->geometry.x, sel->geometry.y,
|
||||
sel->geometry.width, sel->geometry.height, True, True);
|
||||
|
||||
client_saveprops(sel);
|
||||
arrange(screen);
|
||||
|
|
Loading…
Reference in New Issue