<commit_before>/*
 * ion/ioncore/manage.c
 *
 * Copyright (c) <NAME> 1999-2008. 
 *
 * See the included file LICENSE for details.
 */

#include <libtu/objp.h>
#include <libextl/extl.h>
#include "global.h"
#include "common.h"
#include "region.h"
#include "manage.h"
#include "names.h"
#include "fullscreen.h"
#include "pointer.h"
#include "netwm.h"
#include "extlconv.h"
#include "return.h"
#include "conf.h"
#include "detach.h"
#include "group-ws.h"


/*{{{ Add */


WScreen *clientwin_find_suitable_screen(WClientWin *cwin, 
                                        const WManageParams *param)
{
    WScreen *scr=NULL, *found=NULL;
    bool respectpos=(param->tfor!=NULL || param->userpos);
    
    FOR_ALL_SCREENS(scr){
        if(!region_same_rootwin((WRegion*)scr, (WRegion*)cwin))
            continue;
            
        if(!OBJ_IS(scr, WRootWin)){
            /* The root window itself is only a fallback */
            
            if(REGION_IS_ACTIVE(scr)){
                found=scr;
                if(!respectpos)
                    break;
            }
            
            if(rectangle_contains(&REGION_GEOM(scr), 
                                  param->geom.x, param->geom.y)){
                found=scr;
                if(respectpos)
                    break;
            }
        }
        
        if(found==NULL)
            found=scr;
    }
    
    return found;
}


/*extern WRegion *ioncore_newly_created;*/


static WPHolder *try_target(WClientWin *cwin, const WManageParams *param, 
                            const char *target)
{
    WRegion *r=ioncore_lookup_region(target, NULL);
        
    if(r==NULL)
        return NULL;
    
    return region_prepare_manage(r, cwin, param, MANAGE_PRIORITY_NONE);
}


static bool handle_target_winprops(WClientWin *cwin, const WManageParams *param,
                                   WScreen *scr, WPHolder **ph_ret)<commit_msg>Added same rootwin check for 'target' winprop<commit_after>/*
 * ion/ioncore/manage.c
 *
 * Copyright (c) <NAME> 1999-2008. 
 *
 * See the included file LICENSE for details.
 */

#include <libtu/objp.h>
#include <libextl/extl.h>
#include "global.h"
#include "common.h"
#include "region.h"
#include "manage.h"
#include "names.h"
#include "fullscreen.h"
#include "pointer.h"
#include "netwm.h"
#include "extlconv.h"
#include "return.h"
#include "conf.h"
#include "detach.h"
#include "group-ws.h"


/*{{{ Add */


WScreen *clientwin_find_suitable_screen(WClientWin *cwin, 
                                        const WManageParams *param)
{
    WScreen *scr=NULL, *found=NULL;
    bool respectpos=(param->tfor!=NULL || param->userpos);
    
    FOR_ALL_SCREENS(scr){
        if(!region_same_rootwin((WRegion*)scr, (WRegion*)cwin))
            continue;
            
        if(!OBJ_IS(scr, WRootWin)){
            /* The root window itself is only a fallback */
            
            if(REGION_IS_ACTIVE(scr)){
                found=scr;
                if(!respectpos)
                    break;
            }
            
            if(rectangle_contains(&REGION_GEOM(scr), 
                                  param->geom.x, param->geom.y)){
                found=scr;
                if(respectpos)
                    break;
            }
        }
        
        if(found==NULL)
            found=scr;
    }
    
    return found;
}


/*extern WRegion *ioncore_newly_created;*/


static WPHolder *try_target(WClientWin *cwin, const WManageParams *param, 
                            const char *target)
{
    WRegion *r=ioncore_lookup_region(target, NULL);
        
    if(r==NULL)
        return NULL;
    
    if(!region_same_rootwin(r, (WRegion*)cwin))
        return NULL;
    
    return region_prepare_manage(r, cwin, param, MANAGE_PRIORITY_NONE);
}


static bool handle_target_winprops(WClientWin *cwin, const WManageParams *param,
                                   WScreen *scr, WPHolder **ph_ret)
{'fraction_non_alphanumeric': 0.12079510703363915, 'fraction_numerical': 0.004077471967380225, 'mean_word_length': 1.890279823269514, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6369382', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1250, 'n_words': 247}