4 * Copyright (c) Tuomo Valkonen 2004-2009.
6 * See the included file LICENSE for details.
12 #include <libtu/misc.h>
13 #include <libtu/parser.h>
14 #include <libtu/tokenizer.h>
15 #include <libtu/util.h>
17 #include <ioncore/common.h>
18 #include <ioncore/global.h>
19 #include <ioncore/clientwin.h>
20 #include <ioncore/saveload.h>
21 #include <ioncore/property.h>
22 #include <libextl/readconfig.h>
23 #include <ioncore/manage.h>
24 #include <ioncore/ioncore.h>
25 #include <ioncore/exec.h>
26 #include "sm_matchwin.h"
27 #include "sm_session.h"
31 /*{{{ Module information */
34 #include "../version.h"
36 char mod_sm_ion_api_version
[]=NOTION_API_VERSION
;
42 /*{{{ Manage callback */
45 static bool sm_do_manage(WClientWin
*cwin
, const WManageParams
*param
)
53 ph
=mod_sm_match_cwin_to_saved(cwin
);
57 ret
=pholder_attach(ph
, 0, (WRegion
*)cwin
);
59 destroy_obj((Obj
*)ph
);
71 static void mod_sm_set_sessiondir()
73 const char *smdir
=NULL
, *id
=NULL
;
77 smdir
=getenv("SM_SAVE_DIR");
78 id
=getenv("GNOME_DESKTOP_SESSION_ID");
80 /* Running under SM, try to use a directory specific
84 tmp
=scat3(smdir
, "/", libtu_progbasename());
86 tmp
=scat("gnome-session-", id
);
90 p
=strpbrk(p
, "/ :?*");
98 tmp
=scopy("default-session-sm");
102 ok
=extl_set_sessiondir(tmp
);
107 warn(TR("Failed to set session directory."));
114 ioncore_set_smhook(NULL
);
116 hook_remove(clientwin_do_manage_alt
, (WHookDummy
*)sm_do_manage
);
118 ioncore_set_sm_callbacks(NULL
, NULL
);
120 mod_sm_unregister_exports();
128 if(ioncore_g
.sm_client_id
!=NULL
)
129 mod_sm_set_ion_id(ioncore_g
.sm_client_id
);
131 if(!mod_sm_init_session())
134 if(extl_sessiondir()==NULL
)
135 mod_sm_set_sessiondir();
137 if(!mod_sm_register_exports())
140 ioncore_set_sm_callbacks(mod_sm_add_match
, mod_sm_get_configuration
);
142 hook_add(clientwin_do_manage_alt
, (WHookDummy
*)sm_do_manage
);
144 ioncore_set_smhook(mod_sm_smhook
);