X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Fresize.c;h=3608ecb88f17e693538a0c5739ec74df55307235;hp=22950ee9250beccba5c1f227fc69ff672bcab5f4;hb=e3aec18706513a87eaa7839dfdaf7e0fcd0d8d2a;hpb=ae4260bb64817c11f9a7140324cd3e3ba113e297 diff --git a/ioncore/resize.c b/ioncore/resize.c index 22950ee..3608ecb 100644 --- a/ioncore/resize.c +++ b/ioncore/resize.c @@ -1,7 +1,7 @@ /* * ion/ioncore/resize.c * - * Copyright (c) Tuomo Valkonen 1999-2007. + * Copyright (c) Tuomo Valkonen 1999-2009. * * See the included file LICENSE for details. */ @@ -30,6 +30,9 @@ #define XOR_RESIZE (!ioncore_g.opaque_resize) +extern int ioncore_edge_resistance; + + /*{{{ Size/position display and rubberband */ @@ -139,14 +142,14 @@ static void moveres_draw_infowin(WMoveresMode *mode) w=mode->geom.w; h=mode->geom.h; - if((mode->hints.inc_set) && - (mode->hints.width_inc>1 || mode->hints.height_inc>1)){ - if(mode->hints.base_set){ - w-=mode->hints.base_width; - h-=mode->hints.base_height; - } - w/=mode->hints.width_inc; - h/=mode->hints.height_inc; + if(mode->hints.base_set){ + w=maxof(0, w-mode->hints.base_width); + h=maxof(0, h-mode->hints.base_height); + } + + if(mode->hints.inc_set){ + w/=maxof(1, mode->hints.width_inc); + h/=maxof(1, mode->hints.height_inc); } snprintf(buf, INFOWIN_BUFFER_LEN, "%dx%d", w, h); @@ -249,10 +252,9 @@ static bool moveresmode_init(WMoveresMode *mode, WRegion *reg, if(mgr==(WRegion*)parent){ mode->snapgeom.x=0; mode->snapgeom.y=0; - mode->snap_enabled=FALSE; - }else if(REGION_PARENT(mgr)==parent){ - mode->snap_enabled=TRUE; + /*mode->snap_enabled=FALSE;*/ } + mode->snap_enabled=TRUE; } if(!mode->hints.min_set || mode->hints.min_width<1) @@ -341,12 +343,19 @@ static void moveresmode_do_newgeom(WMoveresMode *mode, WRQGeomParams *rq) } +static int clamp_up(int t, int low, int high) +{ + return (t < high && t > low ? high : t); +} + + static void moveresmode_delta(WMoveresMode *mode, int dx1, int dx2, int dy1, int dy2, WRectangle *rret) { int realdx1, realdx2, realdy1, realdy2; WRQGeomParams rq=RQGEOMPARAMS_INIT; + int er=ioncore_edge_resistance; int w=0, h=0; realdx1=(mode->dx1+=dx1); @@ -358,7 +367,6 @@ static void moveresmode_delta(WMoveresMode *mode, /* snap */ if(mode->snap_enabled){ WRectangle *sg=&mode->snapgeom; - int er=CF_EDGE_RESISTANCE; if(mode->dx1!=0 && rq.geom.x+mode->dx1x && rq.geom.x+mode->dx1>sg->x-er) realdx1=sg->x-rq.geom.x; @@ -370,14 +378,15 @@ static void moveresmode_delta(WMoveresMode *mode, realdy2=sg->y+sg->h-rq.geom.y-rq.geom.h; } - w=mode->origgeom.w-realdx1+realdx2; - h=mode->origgeom.h-realdy1+realdy2; - - if(w<=0) - w=mode->hints.min_width; - if(h<=0) - h=mode->hints.min_height; + w=maxof(1, mode->origgeom.w-realdx1+realdx2); + h=maxof(1, mode->origgeom.h-realdy1+realdy2); + + if(mode->snap_enabled && mode->hints.base_set){ + w=clamp_up(w, mode->hints.base_width-er, mode->hints.base_width); + h=clamp_up(h, mode->hints.base_height-er, mode->hints.base_height); + } + /* Correct size */ sizehints_correct(&mode->hints, &w, &h, TRUE, TRUE); /* Do not modify coordinates and sizes that were not requested to be @@ -747,9 +756,11 @@ void frame_maximize_vert(WFrame *frame) int oy, oh; if(frame->flags&FRAME_SHADED || frame->flags&FRAME_MAXED_VERT){ + if(frame->flags&FRAME_SHADED) + frame->flags|=FRAME_SHADED_TOGGLE; if(frame->flags&FRAME_SAVED_VERT) rqh(frame, frame->saved_y, frame->saved_h); - frame->flags&=~(FRAME_MAXED_VERT|FRAME_SAVED_VERT); + frame->flags&=~(FRAME_MAXED_VERT|FRAME_SAVED_VERT|FRAME_SHADED_TOGGLE); return; }