]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/detach.c
[svn-upgrade] Integrating new upstream version, ion3 (20070318)
[ion3.git] / ioncore / detach.c
index c93ca0cb2154b28d76c195e3811e8c9d73d37a55..8493b9afbca73dc82922b053aafef49d8d8ad9d6 100644 (file)
 #include <libtu/minmax.h>
 
 #include <ioncore/common.h>
+#include <ioncore/global.h>
 #include <ioncore/mplex.h>
 #include <ioncore/focus.h>
 #include <ioncore/group.h>
 #include <ioncore/group-ws.h>
 #include <ioncore/framedpholder.h>
 #include <ioncore/return.h>
+#include <ioncore/sizehint.h>
+#include <ioncore/resize.h>
 
 
 static void get_relative_geom(WRectangle *g, WRegion *reg, WRegion *mgr)
@@ -141,7 +144,7 @@ bool ioncore_detach(WRegion *reg, int sp)
     WGroup *grp;
     bool set, nset;
     
-    reg=region_group_if_bottom(reg);
+    reg=region_groupleader_of(reg);
     
     grp=find_group(check_mplex(reg, &mode));
     
@@ -192,3 +195,41 @@ bool ioncore_detach_extl(WRegion *reg, const char *how)
 }
 
 
+void do_unsqueeze(WRegion *reg)
+{
+    WSizeHints hints;
+    
+    if(REGION_MANAGER_CHK(reg, WScreen)!=NULL)
+        return;
+    
+    region_size_hints(reg, &hints);
+
+    if(!hints.min_set)
+        return;
+        
+    if(hints.min_width<=REGION_GEOM(reg).w &&
+       hints.min_height<=REGION_GEOM(reg).h){
+        return;
+    }
+    
+    if(!ioncore_detach(reg, SETPARAM_SET))
+        return;
+        
+    do_unsqueeze(reg);
+}
+
+
+/*EXTL_DOC
+ * Try to detach \var{reg} if it fits poorly in its 
+ * current location. This function does not do anything,
+ * unless \var{override} is set or the \var{unsqueeze} option
+ * of \fnref{ioncore.set} is set.
+ */
+EXTL_EXPORT
+void ioncore_unsqueeze(WRegion *reg, bool override)
+{
+    if(ioncore_g.unsqueeze_enabled || override)
+        do_unsqueeze(region_groupleader_of(reg));
+}
+
+