1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
|
/*
* ion/ioncore/group-cw.c
*
* Copyright (c) Tuomo Valkonen 1999-2007.
*
* See the included file LICENSE for details.
*/
#include <string.h>
#include <libtu/objp.h>
#include <libmainloop/defer.h>
#include "common.h"
#include "group-cw.h"
#include "clientwin.h"
#include "regbind.h"
#include "bindmaps.h"
#include "frame.h"
#include "resize.h"
#include "pholder.h"
#include "names.h"
#include "framedpholder.h"
#include "grouppholder.h"
#define DFLT_SZPLCY SIZEPOLICY_FREE_GLUE__SOUTH
/*{{{ Add/remove managed */
static WPHolder *groupcw_transient_pholder(WGroupCW *cwg,
const WClientWin *UNUSED(cwin),
const WManageParams *mp)
{
WGroupAttachParams param=GROUPATTACHPARAMS_INIT;
WFramedParam fp=FRAMEDPARAM_INIT;
WPHolder *ph;
param.level_set=1;
param.level=STACKING_LEVEL_MODAL1;
param.szplcy_set=1;
param.szplcy=cwg->transient_szplcy;
param.switchto_set=1;
param.switchto=1;
param.geom_weak_set=1;
param.geom_weak=REGION_RQGEOM_WEAK_ALL;
if(!ioncore_g.framed_transients){
param.geom_set=TRUE;
param.geom=mp->geom;
return (WPHolder*)create_grouppholder(&cwg->grp, NULL, ¶m);
}else{
fp.inner_geom_gravity_set=1;
fp.inner_geom=mp->geom;
fp.gravity=ForgetGravity;
fp.mode=FRAME_MODE_TRANSIENT;
ph=(WPHolder*)create_grouppholder(&cwg->grp, NULL, ¶m);
return pholder_either((WPHolder*)create_framedpholder(ph, &fp), ph);
}
}
WPHolder *groupcw_prepare_manage(WGroupCW *cwg, const WClientWin *cwin,
const WManageParams *param, int priority)
{
if(!MANAGE_PRIORITY_OK(priority, MANAGE_PRIORITY_GROUP))
return NULL;
/* Only catch windows with transient mode set to current here. */
if(clientwin_get_transient_mode(cwin)!=TRANSIENT_MODE_CURRENT)
return NULL;
return groupcw_transient_pholder(cwg, cwin, param);
}
static bool groupcw_should_manage_transient(WGroupCW *cwg,
WClientWin *tfor)
{
WRegion *mgr;
if(group_find_stacking(&cwg->grp, (WRegion*)tfor))
return TRUE;
mgr=REGION_MANAGER(tfor);
if(mgr!=NULL && ioncore_g.framed_transients && OBJ_IS(mgr, WFrame))
return (group_find_stacking(&cwg->grp, mgr)!=NULL);
return FALSE;
}
WPHolder *groupcw_prepare_manage_transient(WGroupCW *cwg,
const WClientWin *transient,
const WManageParams *param,
int unused)
{
WPHolder *ph=region_prepare_manage_transient_default((WRegion*)cwg,
transient,
param,
unused);
if(ph==NULL && groupcw_should_manage_transient(cwg, param->tfor))
ph=groupcw_transient_pholder(cwg, transient, param);
return ph;
}
/*}}}*/
/*{{{ Misc. */
/*_EXTL_DOC
* Toggle transients managed by \var{cwin} between top/bottom
* of the window.
*/
EXTL_EXPORT_MEMBER
void groupcw_toggle_transients_pos(WGroupCW *cwg)
{
WStacking *st;
WGroupIterTmp tmp;
if((cwg->transient_szplcy&SIZEPOLICY_VERT_MASK)==SIZEPOLICY_VERT_TOP){
cwg->transient_szplcy&=~SIZEPOLICY_VERT_MASK;
cwg->transient_szplcy|=SIZEPOLICY_VERT_BOTTOM;
}else{
cwg->transient_szplcy&=~SIZEPOLICY_VERT_MASK;
cwg->transient_szplcy|=SIZEPOLICY_VERT_TOP;
}
FOR_ALL_NODES_IN_GROUP(&cwg->grp, st, tmp){
st->szplcy&=~SIZEPOLICY_VERT_MASK;
st->szplcy|=(cwg->transient_szplcy&SIZEPOLICY_VERT_MASK);
if(st->reg!=NULL){
WFitParams fp;
fp.g=REGION_GEOM(cwg);
sizepolicy(&st->szplcy, st->reg, NULL,
REGION_RQGEOM_WEAK_ALL, &fp);
region_fitrep(st->reg, NULL, &fp);
}
}
}
const char *groupcw_displayname(WGroupCW *cwg)
{
const char *name=NULL;
if(cwg->grp.bottom!=NULL && cwg->grp.bottom->reg!=NULL)
name=region_name(cwg->grp.bottom->reg);
if(name==NULL)
name=region_name((WRegion*)cwg);
return name;
}
void groupcw_managed_notify(WGroupCW *cwg, WRegion *reg, WRegionNotify how)
{
if(group_bottom(&cwg->grp)==reg && how==ioncore_g.notifies.name){
/* Title has changed */
region_notify_change((WRegion*)cwg, how);
}
group_managed_notify(&cwg->grp, reg, how);
}
/*}}}*/
/*{{{ WGroupCW class */
bool groupcw_init(WGroupCW *cwg, WWindow *parent, const WFitParams *fp)
{
cwg->transient_szplcy=DFLT_SZPLCY;
if(!group_init(&(cwg->grp), parent, fp, "Notion GroupCW"))
return FALSE;
region_add_bindmap((WRegion*)cwg, ioncore_groupcw_bindmap);
return TRUE;
}
WGroupCW *create_groupcw(WWindow *parent, const WFitParams *fp)
{
CREATEOBJ_IMPL(WGroupCW, groupcw, (p, parent, fp));
}
void groupcw_deinit(WGroupCW *cwg)
{
group_deinit(&(cwg->grp));
}
WRegion *groupcw_load(WWindow *par, const WFitParams *fp, ExtlTab tab)
{
WGroupCW *ws;
ExtlTab substab, subtab;
int i, n;
ws=create_groupcw(par, fp);
if(ws==NULL)
return NULL;
if(!extl_table_gets_t(tab, "managed", &substab))
return (WRegion*)ws;
n=extl_table_get_n(substab);
for(i=1; i<=n; i++){
if(extl_table_geti_t(substab, i, &subtab)){
group_attach_new(&ws->grp, subtab);
extl_unref_table(subtab);
}
}
extl_unref_table(substab);
if(ws->grp.managed_list==NULL){
destroy_obj((Obj*)ws);
return NULL;
}
return (WRegion*)ws;
}
static DynFunTab groupcw_dynfuntab[]={
{(DynFun*)region_prepare_manage,
(DynFun*)groupcw_prepare_manage},
{(DynFun*)region_prepare_manage_transient,
(DynFun*)groupcw_prepare_manage_transient},
/*
{(DynFun*)region_handle_drop,
(DynFun*)groupcw_handle_drop},
{(DynFun*)group_do_add_managed,
(DynFun*)groupcw_do_add_managed},
*/
/*
{(DynFun*)region_get_rescue_pholder_for,
(DynFun*)groupcw_get_rescue_pholder_for},
*/
{(DynFun*)region_prepare_manage,
(DynFun*)groupcw_prepare_manage},
{(DynFun*)region_prepare_manage_transient,
(DynFun*)groupcw_prepare_manage_transient},
{(DynFun*)region_displayname,
(DynFun*)groupcw_displayname},
{region_managed_notify,
groupcw_managed_notify},
END_DYNFUNTAB
};
EXTL_EXPORT
IMPLCLASS(WGroupCW, WGroup, groupcw_deinit, groupcw_dynfuntab);
/*}}}*/
|