Cfactor/Mouse: Replace mwfact resizing by cfactor resizing with mouse
This commit is contained in:
parent
50dcf7c8c2
commit
1061b79c5a
@ -106,10 +106,6 @@ cfactor_parentrow(XRectangle cg, XRectangle ccg, Position p)
|
||||
|
||||
switch(p)
|
||||
{
|
||||
default:
|
||||
case Right:
|
||||
ret = (ccg.x + ccg.width == cg.x + cg.width);
|
||||
break;
|
||||
case Left:
|
||||
ret = (ccg.x == cg.x);
|
||||
break;
|
||||
@ -119,9 +115,13 @@ cfactor_parentrow(XRectangle cg, XRectangle ccg, Position p)
|
||||
case Bottom:
|
||||
ret = (ccg.y + ccg.height == cg.y + cg.height);
|
||||
break;
|
||||
case Right:
|
||||
default:
|
||||
ret = (ccg.x + ccg.width == cg.x + cg.width);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Get c parents of row and resize
|
||||
@ -177,7 +177,7 @@ cfactor_check_geo(Client *c, Client *g, Position p, int fac)
|
||||
* \param p Direction of resizing
|
||||
* \param fac Factor of resizing
|
||||
*/
|
||||
static void
|
||||
void
|
||||
cfactor_set(Client *c, Position p, int fac)
|
||||
{
|
||||
Client *gc = NULL;
|
||||
@ -209,6 +209,24 @@ cfactor_set(Client *c, Position p, int fac)
|
||||
return;
|
||||
}
|
||||
|
||||
/** Apply a complete factor array to a client
|
||||
* \param c Client pointer
|
||||
* \param fac factor array
|
||||
*/
|
||||
void
|
||||
cfactor_multi_set(Client *c, int fac[4])
|
||||
{
|
||||
if(!c)
|
||||
return;
|
||||
|
||||
cfactor_set(c, Right, fac[Right]);
|
||||
cfactor_set(c, Left, fac[Left]);
|
||||
cfactor_set(c, Top, fac[Top]);
|
||||
cfactor_set(c, Bottom, fac[Bottom]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
uicb_client_resize_right(uicb_t cmd)
|
||||
{
|
||||
|
||||
29
src/mouse.c
29
src/mouse.c
@ -102,8 +102,6 @@ mouse_move_tag_client(Client *c)
|
||||
arrange(c->screen, True);
|
||||
}
|
||||
|
||||
client_focus_next(c);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -206,7 +204,7 @@ mouse_resize(Client *c)
|
||||
int d, u, omx, omy;
|
||||
XGCValues xgc;
|
||||
GC gci;
|
||||
float mwf = tags[selscreen][seltag[selscreen]].mwfact;
|
||||
int f[4] = { 0 };
|
||||
|
||||
if((c->flags & MaxFlag)
|
||||
|| (c->flags & LMaxFlag)
|
||||
@ -247,24 +245,13 @@ mouse_resize(Client *c)
|
||||
|
||||
if(ev.type == MotionNotify)
|
||||
{
|
||||
/* To resize MWFACT in tile mode */
|
||||
if((c->flags & TileFlag)
|
||||
&& tags[selscreen][seltag[selscreen]].layout.func != grid_vertical
|
||||
&& tags[selscreen][seltag[selscreen]].layout.func != grid_horizontal)
|
||||
/* To resize client in tile mode with cfactor */
|
||||
if(c->flags & TileFlag)
|
||||
{
|
||||
if(tags[selscreen][seltag[selscreen]].layout.func == tile)
|
||||
mwf += (ROUND(ev.xmotion.x_root) - omx) / (sgeo[c->screen].width);
|
||||
else if(tags[selscreen][seltag[selscreen]].layout.func == tile_left)
|
||||
mwf -= (ROUND(ev.xmotion.x_root) - omx) / (sgeo[c->screen].width);
|
||||
else if(tags[selscreen][seltag[selscreen]].layout.func == tile_top)
|
||||
mwf -= (ROUND(ev.xmotion.y_root) - omy) / (sgeo[c->screen].height);
|
||||
else
|
||||
mwf += (ROUND(ev.xmotion.y_root) - omy) / (sgeo[c->screen].height);
|
||||
|
||||
omx = ROUND(ev.xmotion.x_root);
|
||||
omy = ROUND(ev.xmotion.y_root);
|
||||
|
||||
tags[selscreen][seltag[selscreen]].mwfact = (mwf < 0.05) ? 0.05 : ((mwf > 0.95) ? 0.95 : mwf);
|
||||
f[Right] = ev.xmotion.x_root - omx;
|
||||
f[Left] = omx - ev.xmotion.x_root;
|
||||
f[Top] = omy - ev.xmotion.y_root;
|
||||
f[Bottom] = ev.xmotion.y_root - omy;
|
||||
}
|
||||
/* Free mode */
|
||||
else if(!(c->flags & TileFlag))
|
||||
@ -303,7 +290,7 @@ mouse_resize(Client *c)
|
||||
XUngrabServer(dpy);
|
||||
}
|
||||
else
|
||||
tags[selscreen][seltag[selscreen]].layout.func(c->screen);
|
||||
cfactor_multi_set(c, f);
|
||||
|
||||
client_update_attributes(c);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
|
||||
@ -155,6 +155,8 @@ void uicb_toggle_tagautohide(uicb_t);
|
||||
/* cfactor.c */
|
||||
void cfactor_clean(Client *c);
|
||||
XRectangle cfactor_geo(XRectangle geo, int fact[4], int *err);
|
||||
void cfactor_set(Client *c, Position p, int fac);
|
||||
void cfactor_multi_set(Client *c, int fac[4]);
|
||||
void uicb_client_resize_right(uicb_t cmd);
|
||||
void uicb_client_resize_left(uicb_t cmd);
|
||||
void uicb_client_resize_top(uicb_t cmd);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user