4 * Copyright (c) Tuomo Valkonen 2004-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
15 #include <libtu/misc.h>
16 #include <libtu/parser.h>
17 #include <libtu/tokenizer.h>
19 #include <ioncore/common.h>
20 #include <ioncore/global.h>
21 #include <ioncore/clientwin.h>
22 #include <ioncore/saveload.h>
23 #include <ioncore/property.h>
24 #include <libextl/readconfig.h>
25 #include <ioncore/manage.h>
26 #include <ioncore/ioncore.h>
27 #include <ioncore/exec.h>
28 #include "sm_matchwin.h"
29 #include "sm_session.h"
33 /*{{{ Module information */
36 #include "../version.h"
38 char mod_sm_ion_api_version[]=ION_API_VERSION;
44 /*{{{ Manage callback */
47 static bool sm_do_manage(WClientWin *cwin, const WManageParams *param)
49 int transient_mode=TRANSIENT_MODE_OFF;
56 ph=mod_sm_match_cwin_to_saved(cwin);
60 ret=pholder_attach(ph, 0, (WRegion*)cwin);
62 destroy_obj((Obj*)ph);
74 static void mod_sm_set_sessiondir()
76 const char *smdir=NULL, *id=NULL;
80 smdir=getenv("SM_SAVE_DIR");
81 id=getenv("GNOME_DESKTOP_SESSION_ID");
83 /* Running under SM, try to use a directory specific
87 tmp=scat(smdir, "/ion3"); /* TODO: pwm<=>ion! */
89 tmp=scat("gnome-session-", id);
93 p=strpbrk(p, "/ :?*");
101 tmp=scopy("default-session-sm");
105 ok=extl_set_sessiondir(tmp);
110 warn(TR("Failed to set session directory."));
117 ioncore_set_smhook(NULL);
119 hook_remove(clientwin_do_manage_alt, (WHookDummy*)sm_do_manage);
121 ioncore_set_sm_callbacks(NULL, NULL);
123 mod_sm_unregister_exports();
131 if(ioncore_g.sm_client_id!=NULL)
132 mod_sm_set_ion_id(ioncore_g.sm_client_id);
134 if(!mod_sm_init_session())
137 if(extl_sessiondir()==NULL)
138 mod_sm_set_sessiondir();
140 if(!mod_sm_register_exports())
143 ioncore_set_sm_callbacks(mod_sm_add_match, mod_sm_get_configuration);
145 hook_add(clientwin_do_manage_alt, (WHookDummy*)sm_do_manage);
147 ioncore_set_smhook(mod_sm_smhook);