]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/resize.c
Update cfg_kludge_flash for Flash 10
[ion3.git] / ioncore / resize.c
index ec94cdade243f3bcfe8c9844741fb29fa7ab3bb3..3608ecb88f17e693538a0c5739ec74df55307235 100644 (file)
@@ -1,12 +1,9 @@
 /* 
  * ion/ioncore/resize.c
  *
- * Copyright (c) Tuomo Valkonen 1999-2007
+ * Copyright (c) Tuomo Valkonen 1999-2009
  *
- * Ion is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
+ * See the included file LICENSE for details.
  */
 
 #include <stdio.h>
@@ -33,6 +30,9 @@
 #define XOR_RESIZE (!ioncore_g.opaque_resize)
 
 
+extern int ioncore_edge_resistance;
+
+
 /*{{{ Size/position display and rubberband */
 
 
@@ -142,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);
@@ -252,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)
@@ -344,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);
@@ -361,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->dx1<sg->x && rq.geom.x+mode->dx1>sg->x-er)
             realdx1=sg->x-rq.geom.x;
@@ -373,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
@@ -750,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;
     }