X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=mod_tiling%2Fops.c;h=48365528a2c2c16efc17ce8d35daf0135f8fef1b;hp=c86a80a94f6bbb2fc69a88b6b034d1d3b83bb0ea;hb=803afbc1cd633f6c025bcd9537e9b7e9aedadd0d;hpb=8366314611bf30a0f31d25bf5f5023186fa87692 diff --git a/mod_tiling/ops.c b/mod_tiling/ops.c index c86a80a..4836552 100644 --- a/mod_tiling/ops.c +++ b/mod_tiling/ops.c @@ -1,7 +1,7 @@ /* * ion/mod_tiling/ops.c * - * Copyright (c) Tuomo Valkonen 1999-2006. + * Copyright (c) Tuomo Valkonen 1999-2007. * * 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 @@ -9,109 +9,14 @@ * (at your option) any later version. */ -#include - #include #include #include +#include #include -#include -#include #include "tiling.h" -static WGroup *find_group(WRegion *reg, bool *detach_framed) -{ - WRegion *mgr=REGION_MANAGER(reg); - bool was_grouped=FALSE; - - if(OBJ_IS(mgr, WMPlex)){ - WMPlex *mplex=(WMPlex*)mgr; - *detach_framed=TRUE; - mgr=REGION_MANAGER(mgr); - if(OBJ_IS(mgr, WGroup)){ - assert(mplex->mgd!=NULL); - if(mplex->mgd->reg==reg && mplex->mgd->mgr_next==NULL){ - /* Nothing to detach */ - return NULL; - } - } - }else{ - was_grouped=OBJ_IS(mgr, WGroup); - *detach_framed=FALSE; - } - - while(mgr!=NULL){ - mgr=REGION_MANAGER(mgr); - if(OBJ_IS(mgr, WGroup)) - break; - } - - if(mgr==NULL && was_grouped) - warn(TR("Already detached.")); - - return (WGroup*)mgr; -} - - -static void get_relative_geom(WRectangle *g, WRegion *reg, WRegion *mgr) -{ - WWindow *rel=REGION_PARENT(mgr), *w; - - *g=REGION_GEOM(reg); - - for(w=REGION_PARENT(reg); - w!=rel && (WRegion*)w!=mgr; - w=REGION_PARENT(w)){ - - g->x+=REGION_GEOM(w).x; - g->y+=REGION_GEOM(w).y; - } -} - - -/*EXTL_DOC - * Detach \var{reg}, i.e. make it managed by its nearest ancestor - * \type{WGroup}, framed if \var{reg} is not itself \type{WFrame}. - */ -EXTL_EXPORT -bool mod_tiling_detach(WRegion *reg) -{ - bool detach_framed=!OBJ_IS(reg, WFrame); - WGroupAttachParams ap=GROUPATTACHPARAMS_INIT; - WRegionAttachData data; - WGroup *grp; - - grp=find_group(reg, &detach_framed); - - if(grp==NULL) - return FALSE; - - ap.switchto_set=TRUE; - ap.switchto=region_may_control_focus(reg); - - ap.geom_set=TRUE; - get_relative_geom(&ap.geom, reg, (WRegion*)grp); - - /* TODO: Retain (root-relative) geometry of reg for framed - * detach instead of making a frame of this size? - */ - - data.type=REGION_ATTACH_REPARENT; - data.u.reg=reg; - - if(detach_framed){ - WFramedParam fp=FRAMEDPARAM_INIT; - - return (region_attach_framed((WRegion*)grp, &fp, - (WRegionAttachFn*)group_do_attach, - &ap, &data)!=NULL); - }else{ - return (group_do_attach(grp, &ap, &data)!=NULL); - } -} - - static WRegion *mkbottom_fn(WWindow *parent, const WFitParams *fp, void *param) {