<commit_before>/*
 * ion/mod_autows/autows.c
 *
 * Copyright (c) <NAME> 1999-2004. 
 *
 * 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.
 */

#include <string.h>

#include <libtu/objp.h>
#include <ioncore/common.h>
#include <ioncore/global.h>
#include <ioncore/region.h>
#include <ioncore/focus.h>
#include <ioncore/manage.h>
#include <ioncore/saveload.h>
#include <ioncore/attach.h>
#include <ioncore/extl.h>
#include <ioncore/regbind.h>
#include <ioncore/extlconv.h>
#include <ioncore/defer.h>
#include <mod_ionws/ionws.h>
#include <mod_ionws/split.h>
#include "autows.h"
#include "placement.h"
#include "main.h"


/*{{{ Create/destroy */


void autows_managed_add(WAutoWS *ws, WRegion *reg)
{
    region_add_bindmap_owned(reg, mod_autows_autows_bindmap, (WRegion*)ws);
    region_add_bindmap(reg, mod_autows_frame_bindmap);
    ionws_managed_add_default(&(ws->ionws), reg);
}


bool autows_init(WAutoWS *ws, WWindow *parent, const WFitParams *fp)
{
    return ionws_init(&(ws->ionws), parent, fp, FALSE);
}


WAutoWS *create_autows(WWindow *parent, const WFitParams *fp)
{
    CREATEOBJ_IMPL(WAutoWS, autows, (p, parent, fp));
}


void autows_deinit(WAutoWS *ws)
{
    ionws_deinit(&(ws->ionws));
}


void autows_managed_remove(WAutoWS *ws, WRegion *reg)
{
    bool ds=OBJ_IS_BEING_DESTROYED(ws);
    WRegion *other=ionws_do_managed_remove(&(ws->ionws), reg, !ds);
    
    region_remove_bindmap_owned(reg, mod_autows_autows_bindmap, (WRegion*)ws);
    region_remove_bindmap(reg, mod_autows_frame_bindmap);
    
    if(other==NULL){
        if(region_may_control_focus((WRegion*)ws))
            genws_fallback_focus((WGenWS*)ws, FALSE);
        if(ws->ionws.managed_list==NULL && ws->ionws.split_tree!=NULL){
            ioncore_defer_destroy((Obj*)(ws->ionws.split_tree));
            ws->ionws.split_tree=NULL;
        }
    }else{
        if(!ds && region_may_control_focus((WRegion*)ws))
            region_set_focus(other);
    }
}


/*}}}*/


/*{{{ Misc. */<commit_msg>trunk: changeset 1563<commit_after>/*
 * ion/mod_autows/autows.c
 *
 * Copyright (c) <NAME> 1999-2004. 
 *
 * 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.
 */

#include <string.h>

#include <libtu/objp.h>
#include <ioncore/common.h>
#include <ioncore/global.h>
#include <ioncore/region.h>
#include <ioncore/focus.h>
#include <ioncore/manage.h>
#include <ioncore/saveload.h>
#include <ioncore/attach.h>
#include <ioncore/extl.h>
#include <ioncore/regbind.h>
#include <ioncore/extlconv.h>
#include <ioncore/defer.h>
#include <mod_ionws/ionws.h>
#include <mod_ionws/split.h>
#include "autows.h"
#include "placement.h"
#include "main.h"


/*{{{ Create/destroy */


void autows_managed_add(WAutoWS *ws, WRegion *reg)
{
    region_add_bindmap_owned(reg, mod_autows_autows_bindmap, (WRegion*)ws);
    region_add_bindmap(reg, mod_autows_frame_bindmap);
    ionws_managed_add_default(&(ws->ionws), reg);
}


bool autows_init(WAutoWS *ws, WWindow *parent, const WFitParams *fp)
{
    return ionws_init(&(ws->ionws), parent, fp, FALSE);
}


WAutoWS *create_autows(WWindow *parent, const WFitParams *fp)
{
    CREATEOBJ_IMPL(WAutoWS, autows, (p, parent, fp));
}


void autows_deinit(WAutoWS *ws)
{
    ionws_deinit(&(ws->ionws));
}


void autows_managed_remove(WAutoWS *ws, WRegion *reg)
{
    bool ds=OBJ_IS_BEING_DESTROYED(ws);
    bool mcf=region_may_control_focus((WRegion*)ws);
    WRegion *other=ionws_do_managed_remove(&(ws->ionws), reg, !ds);
    
    region_remove_bindmap_owned(reg, mod_autows_autows_bindmap, (WRegion*)ws);
    region_remove_bindmap(reg, mod_autows_frame_bindmap);
    
    if(other==NULL){
        if(mcf)
            genws_fallback_focus((WGenWS*)ws, FALSE);
        if(ws->ionws.managed_list==NULL && ws->ionws.split_tree!=NULL){
            ioncore_defer_destroy((Obj*)(ws->ionws.split_tree));
            ws->ionws.split_tree=NULL;
        }
    }else{
        if(!ds && mcf)
            region_set_focus(other);
    }
}


/*}}}*/


/*{{{ Misc. */
{'fraction_non_alphanumeric': 0.1474844934527912, 'fraction_numerical': 0.005513439007580979, 'mean_word_length': 4.226890756302521, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5131469', 'n_tokens_mistral': 1705, 'n_tokens_neox': 1645, 'n_words': 310}