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;
- masked_window = NULL;
+ current_screen = (BScreen *) 0;
+ masked_window = (OpenboxWindow *) 0;
masked = None;
load();
openbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
#endif // HAVE_GETPID
- for (int i = 0; i < getNumberOfScreens(); i++) {
- BScreen *screen = new BScreen(*this, i, config);
+ for (unsigned int s = 0; s < numberOfScreens(); s++) {
+ BScreen *screen = new BScreen(*this, s, config);
if (! screen->isScreenManaged()) {
delete screen;
"Openbox::Openbox: no managable screens found, aborting.\n"));
::exit(3);
}
- focused_screen = screenList.front();
+ current_screen = screenList.front();
// save current settings and default values
save();
timer->fireOnce(True);
ungrab();
+
+ focusWindow(0);
}
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;
}
void Openbox::shutdown() {
BaseDisplay::shutdown();
- XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
-
std::for_each(screenList.begin(), screenList.end(),
std::mem_fun(&BScreen::shutdown));
+ focusWindow(0);
+
XSync(getXDisplay(), False);
}
// 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();
OpenboxWindow *Openbox::focusedWindow() {
- if (focused_screen == (BScreen *) 0)
- return (OpenboxWindow *) 0;
- Workspace *w = focused_screen->getCurrentWorkspace();
- if (w == (Workspace *) 0)
- return (OpenboxWindow *) 0;
- return w->focusedWindow();
+ Workspace *w;
+ if (current_screen)
+ if ((w = current_screen->getCurrentWorkspace()))
+ return w->focusedWindow();
+ return (OpenboxWindow *) 0;
}
old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber());
old_tbar = old_screen->getToolbar();
- old_win->setFocusFlag(False);
+ old_win->setFocusFlag(false);
old_wkspc->focusWindow((OpenboxWindow *) 0);
}
if (win && !win->isIconic()) {
- focused_screen = win->getScreen();
- tbar = focused_screen->getToolbar();
- wkspc = focused_screen->getWorkspace(win->getWorkspaceNumber());
+ current_screen = win->getScreen();
+ tbar = current_screen->getToolbar();
+ wkspc = current_screen->getWorkspace(win->getWorkspaceNumber());
win->setFocusFlag(true);
wkspc->focusWindow(win);
if (tbar)
tbar->redrawWindowLabel(true);
- focused_screen->updateNetizenWindowFocus();
- //} else {
- // focused_window = (OpenboxWindow *) 0;
+ current_screen->updateNetizenWindowFocus();
+ } else {
+ XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
}
if (old_tbar && old_tbar != tbar)
old_tbar->redrawWindowLabel(true);
- if (old_screen && old_screen != focused_screen)
+ if (old_screen && old_screen != current_screen)
old_screen->updateNetizenWindowFocus();
}