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(REGION_IS_ACTIVE(scr)){ found=scr; if(!respectpos) break; } if(rectangle_contains(®ION_GEOM(scr), param->geom.x, param->geom.y)){ found=scr; if(respectpos) break; } if(found==NULL) found=scr; } return found; }
bool tiling_fitrep(WTiling *ws, WWindow *par, const WFitParams *fp) { WTilingIterTmp tmp; bool ok=FALSE; if(par!=NULL){ if(!region_same_rootwin((WRegion*)ws, (WRegion*)par)) return FALSE; region_unset_parent((WRegion*)ws); XReparentWindow(ioncore_g.dpy, ws->dummywin, par->win, fp->g.x, fp->g.y); region_set_parent((WRegion*)ws, par); if(ws->split_tree!=NULL) split_reparent(ws->split_tree, par); } REGION_GEOM(ws)=fp->g; if(ws->split_tree!=NULL){ bool done=FALSE; if(fp->mode®ION_FIT_ROTATE) ok=split_rotate_to(ws->split_tree, &(fp->g), fp->rotation); if(!ok) split_resize(ws->split_tree, &(fp->g), PRIMN_ANY, PRIMN_ANY); } return TRUE; }
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 WDock *dock_find_suitable_dock(WClientWin *cwin, const WManageParams *param) { WDock *dock; for(dock=docks; dock; dock=dock->dock_next){ if(!dock->is_auto) continue; if(!region_same_rootwin((WRegion*)dock, (WRegion*)cwin)) continue; break; } return dock; }
bool menu_fitrep(WMenu *menu, WWindow *par, const WFitParams *fp) { WFitParams oldfp; if(par!=NULL && !region_same_rootwin((WRegion*)par, (WRegion*)menu)) return FALSE; oldfp=menu->last_fp; menu->last_fp=*fp; menu_do_refit(menu, par, &oldfp); if(menu->submenu!=NULL && !menu->pmenu_mode) region_fitrep((WRegion*)(menu->submenu), par, fp); return TRUE; }
WScreen *clientwin_fullscreen_chkrq(WClientWin *cwin, int w, int h) { WScreen *scr; WMwmHints *mwm; mwm=xwindow_get_mwmhints(cwin->win); if(mwm==NULL || !(mwm->flags&MWM_HINTS_DECORATIONS) || mwm->decorations!=0) return NULL; FOR_ALL_SCREENS(scr){ if(!region_same_rootwin((WRegion*)scr, (WRegion*)cwin)) continue; /* Only Mplayer supports single Xinerama region FS to my knowledge, * and doesn't set position, so we also don't check position here, * and instead take the first screen with matching size. */ if(REGION_GEOM(scr).w==w && REGION_GEOM(scr).h==h) return scr; } return NULL; }
bool group_fitrep(WGroup *ws, WWindow *par, const WFitParams *fp) { WGroupIterTmp tmp; WStacking *unweaved=NULL; int xdiff=0, ydiff=0; WStacking *st; WWindow *oldpar; WRectangle g; oldpar=REGION_PARENT(ws); if(par==NULL){ if(fp->mode®ION_FIT_WHATEVER) return TRUE; REGION_GEOM(ws)=fp->g; }else{ if(!region_same_rootwin((WRegion*)ws, (WRegion*)par)) return FALSE; if(ws->managed_stdisp!=NULL && ws->managed_stdisp->reg!=NULL) region_detach_manager(ws->managed_stdisp->reg); assert(ws->managed_stdisp==NULL); xdiff=fp->g.x-REGION_GEOM(ws).x; ydiff=fp->g.y-REGION_GEOM(ws).y; region_unset_parent((WRegion*)ws); XReparentWindow(ioncore_g.dpy, ws->dummywin, par->win, -1, -1); region_set_parent((WRegion*)ws, par); REGION_GEOM(ws).x=fp->g.x; REGION_GEOM(ws).y=fp->g.y; if(!(fp->mode®ION_FIT_WHATEVER)){ REGION_GEOM(ws).w=fp->g.w; REGION_GEOM(ws).h=fp->g.h; } if(oldpar!=NULL) unweaved=stacking_unweave(&oldpar->stacking, wsfilt, (void*)ws); } FOR_ALL_NODES_IN_GROUP(ws, st, tmp){ WFitParams fp2=*fp; if(st->reg==NULL) continue; g=REGION_GEOM(st->reg); g.x+=xdiff; g.y+=ydiff; if(fp->mode®ION_FIT_WHATEVER){ fp2.g=g; }else{ fp2.g=REGION_GEOM(ws); sizepolicy(&st->szplcy, st->reg, &g, REGION_RQGEOM_WEAK_ALL, &fp2); } if(!region_fitrep(st->reg, par, &fp2)){ warn(TR("Error reparenting %s."), region_name(st->reg)); region_detach_manager(st->reg); } }