4 * Copyright (c) Tuomo Valkonen 2004-2007.
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[]=ION_API_VERSION;
42 /*{{{ Manage callback */
45 static bool sm_do_manage(WClientWin *cwin, const WManageParams *param)
47 int transient_mode=TRANSIENT_MODE_OFF;
54 ph=mod_sm_match_cwin_to_saved(cwin);
58 ret=pholder_attach(ph, 0, (WRegion*)cwin);
60 destroy_obj((Obj*)ph);
72 static void mod_sm_set_sessiondir()
74 const char *smdir=NULL, *id=NULL;
78 smdir=getenv("SM_SAVE_DIR");
79 id=getenv("GNOME_DESKTOP_SESSION_ID");
81 /* Running under SM, try to use a directory specific
85 tmp=scat3(smdir, "/", libtu_progbasename());
87 tmp=scat("gnome-session-", id);
91 p=strpbrk(p, "/ :?*");
99 tmp=scopy("default-session-sm");
103 ok=extl_set_sessiondir(tmp);
108 warn(TR("Failed to set session directory."));
115 ioncore_set_smhook(NULL);
117 hook_remove(clientwin_do_manage_alt, (WHookDummy*)sm_do_manage);
119 ioncore_set_sm_callbacks(NULL, NULL);
121 mod_sm_unregister_exports();
129 if(ioncore_g.sm_client_id!=NULL)
130 mod_sm_set_ion_id(ioncore_g.sm_client_id);
132 if(!mod_sm_init_session())
135 if(extl_sessiondir()==NULL)
136 mod_sm_set_sessiondir();
138 if(!mod_sm_register_exports())
141 ioncore_set_sm_callbacks(mod_sm_add_match, mod_sm_get_configuration);
143 hook_add(clientwin_do_manage_alt, (WHookDummy*)sm_do_manage);
145 ioncore_set_smhook(mod_sm_smhook);