Openbox *openbox;
-Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
- : BaseDisplay(m_argv[0], dpy_name) {
+Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc,
+ char *menu) : BaseDisplay(m_argv[0], dpy_name) {
grab();
if (! XSupportsLocale())
::openbox = this;
argc = m_argc;
argv = m_argv;
- if (rc == NULL) {
+ if (rc == NULL || menu == NULL) {
char *homedir = getenv("HOME");
-
- rc_file = new char[strlen(homedir) + strlen("/.openbox/rc") + 1];
- sprintf(rc_file, "%s/.openbox", homedir);
-
+ char *configdir = new char[strlen(homedir) + strlen("/.openbox") + 1];
+ sprintf(configdir, "%s/.openbox", homedir);
// try to make sure the ~/.openbox directory exists
- mkdir(rc_file, S_IREAD | S_IWRITE | S_IEXEC | S_IRGRP | S_IWGRP | S_IXGRP |
+ mkdir(configdir, S_IREAD | S_IWRITE | S_IEXEC |
+ S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IWOTH | S_IXOTH);
- sprintf(rc_file, "%s/.openbox/rc", homedir);
- } else {
- rc_file = bstrdup(rc);
+
+ if (rc == NULL) {
+ rc_file = new char[strlen(configdir) + strlen("/rc") + 1];
+ sprintf(rc_file, "%s/rc", configdir);
+ } else
+ rc_file = bstrdup(rc);
+
+ if (menu == NULL) {
+ menu_file = new char[strlen(configdir) + strlen("/menu") + 1];
+ sprintf(menu_file, "%s/menu", configdir);
+ } else
+ menu_file = bstrdup(menu);
+
+ delete [] configdir;
}
config.setFile(rc_file);
-
+
no_focus = False;
- resource.menu_file = resource.style_file = NULL;
+ resource.style_file = NULL;
resource.titlebar_layout = NULL;
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
openbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
#endif // HAVE_GETPID
- for (unsigned int s = 0; s < getNumberOfScreens(); s++) {
+ for (unsigned int s = 0; s < numberOfScreens(); s++) {
BScreen *screen = new BScreen(*this, s, config);
if (! screen->isScreenManaged()) {
for_each(menuTimestamps.begin(), menuTimestamps.end(),
PointerAssassin());
- if (resource.menu_file)
- delete [] resource.menu_file;
-
if (resource.style_file)
delete [] resource.style_file;
delete timer;
delete [] rc_file;
+ delete [] menu_file;
}
// save all values as they are so that the defaults will be written to the rc
// file
- config.setValue("session.menuFile", getMenuFilename());
config.setValue("session.colorsPerChannel",
resource.colors_per_channel);
config.setValue("session.styleFile", resource.style_file);
std::string s;
long l;
- if (resource.menu_file)
- delete [] resource.menu_file;
- if (config.getValue("session.menuFile", "Session.MenuFile", s))
- resource.menu_file = bstrdup(s.c_str());
- else
- resource.menu_file = bstrdup(DEFAULTMENU);
-
if (config.getValue("session.colorsPerChannel", "Session.ColorsPerChannel",
l))
resource.colors_per_channel = (l < 2 ? 2 : (l > 6 ? 6 : l)); // >= 2, <= 6
else
resource.double_click_interval = 250;
- if (!config.getValue("session.autoRaiseDelay", "Session.AutoRaiseDelay", l))
+ if (config.getValue("session.autoRaiseDelay", "Session.AutoRaiseDelay", l))
resource.auto_raise_delay.tv_usec = l;
else
resource.auto_raise_delay.tv_usec = 400;
}
+void Openbox::addMenuTimestamp(const char *filename) {
+ bool found = false;
+
+ MenuTimestampList::iterator it;
+ for (it = menuTimestamps.begin(); it != menuTimestamps.end(); ++it)
+ if (! strcmp((*it)->filename, filename)) {
+ found = true;
+ break;
+ }
+ if (!found) {
+ struct stat buf;
+
+ if (! stat(filename, &buf)) {
+ MenuTimestamp *ts = new MenuTimestamp;
+
+ ts->filename = bstrdup(filename);
+ ts->timestamp = buf.st_ctime;
+
+ menuTimestamps.push_back(ts);
+ }
+ }
+}
+
void Openbox::rereadMenu() {
reread_menu_wait = True;
}
-void Openbox::setMenuFilename(const char *filename) {
- bool found = false;
-
- MenuTimestampList::iterator it;
- for (it = menuTimestamps.begin(); it != menuTimestamps.end(); ++it)
- if (! strcmp((*it)->filename, filename)) {
- found = true;
- break;
- }
- if (!found) {
- struct stat buf;
-
- if (! stat(filename, &buf)) {
- MenuTimestamp *ts = new MenuTimestamp;
-
- ts->filename = bstrdup(filename);
- ts->timestamp = buf.st_ctime;
-
- menuTimestamps.push_back(ts);
- }
- }
-}
-
-
void Openbox::timeout() {
if (reconfigure_wait)
real_reconfigure();