/*
* ion/ioncore/resize.c
*
- * Copyright (c) Tuomo Valkonen 1999-2007.
+ * Copyright (c) Tuomo Valkonen 1999-2009.
*
* See the included file LICENSE for details.
*/
#define XOR_RESIZE (!ioncore_g.opaque_resize)
+extern int ioncore_edge_resistance;
+
+
/*{{{ Size/position display and rubberband */
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);
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)
}
+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);
/* snap */
if(mode->snap_enabled){
WRectangle *sg=&mode->snapgeom;
- int er=CF_EDGE_RESISTANCE;
if(mode->dx1!=0 && rq.geom.x+mode->dx1<sg->x && rq.geom.x+mode->dx1>sg->x-er)
realdx1=sg->x-rq.geom.x;
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
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;
}