X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fopenbox.cc;h=3325bf382596cf0bb4bf61e06cacae3a1bd8e33b;hb=57fb41c8060eaa2f29b25b08e3813b3dc140f165;hp=86baec6e3c02d4dfc4d338e375bf5036c466df77;hpb=7440ad2e6fe345d0fbc037c690913705bc351e68;p=chaz%2Fopenbox diff --git a/src/openbox.cc b/src/openbox.cc index 86baec6e..3325bf38 100644 --- a/src/openbox.cc +++ b/src/openbox.cc @@ -182,11 +182,11 @@ Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc) no_focus = False; - resource.menu_file = resource.style_file = (char *) 0; - resource.titlebar_layout = (char *) NULL; + resource.menu_file = resource.style_file = NULL; + resource.titlebar_layout = NULL; resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0; - focused_window = masked_window = (OpenboxWindow *) 0; + masked_window = NULL; masked = None; windowSearchList = new LinkedList; @@ -225,6 +225,7 @@ Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc) "Openbox::Openbox: no managable screens found, aborting.\n")); ::exit(3); } + focused_screen = screenList->first(); // save current settings and default values save(); @@ -261,6 +262,9 @@ Openbox::~Openbox() { if (resource.style_file) delete [] resource.style_file; + if (resource.titlebar_layout) + delete [] resource.titlebar_layout; + delete timer; delete screenList; @@ -280,11 +284,10 @@ Openbox::~Openbox() { void Openbox::process_event(XEvent *e) { - if ((masked == e->xany.window) && masked_window && + if ((masked == e->xany.window && masked_window) && (e->type == MotionNotify)) { last_time = e->xmotion.time; masked_window->motionNotifyEvent(&e->xmotion); - return; } @@ -500,8 +503,6 @@ void Openbox::process_event(XEvent *e) { if ((win = searchWindow(e->xunmap.window))) { win->unmapNotifyEvent(&e->xunmap); - if (focused_window == win) - focused_window = (OpenboxWindow *) 0; #ifdef SLIT } else if ((slit = searchSlit(e->xunmap.window))) { slit->removeClient(e->xunmap.window); @@ -521,8 +522,6 @@ void Openbox::process_event(XEvent *e) { if ((win = searchWindow(e->xdestroywindow.window))) { win->destroyNotifyEvent(&e->xdestroywindow); - if (focused_window == win) - focused_window = (OpenboxWindow *) 0; #ifdef SLIT } else if ((slit = searchSlit(e->xdestroywindow.window))) { slit->removeClient(e->xdestroywindow.window, False); @@ -672,8 +671,8 @@ void Openbox::process_event(XEvent *e) { break; OpenboxWindow *win = searchWindow(e->xfocus.window); - if (win && ! win->isFocused()) - setFocusedWindow(win); + if (win && !win->isFocused()) + focusWindow(win); break; } @@ -979,6 +978,8 @@ void Openbox::save() { config.setValue("session.menuFile", getMenuFilename()); config.setValue("session.colorsPerChannel", resource.colors_per_channel); + config.setValue("session.styleFile", resource.style_file); + config.setValue("session.titlebarLayout", resource.titlebar_layout); config.setValue("session.doubleClickInterval", (long)resource.double_click_interval); config.setValue("session.autoRaiseDelay", @@ -986,13 +987,14 @@ void Openbox::save() { (resource.auto_raise_delay.tv_usec / 1000))); config.setValue("session.cacheLife", (long)resource.cache_life / 60000); config.setValue("session.cacheMax", (long)resource.cache_max); - config.setValue("session.styleFile", resource.style_file); LinkedListIterator it(screenList); for (BScreen *s = it.current(); s != NULL; it++, s = it.current()) { s->save(); s->getToolbar()->save(); +#ifdef SLIT s->getSlit()->save(); +#endif // SLIT } config.setAutoSave(true); @@ -1180,42 +1182,44 @@ void Openbox::timeout() { } -void Openbox::setFocusedWindow(OpenboxWindow *win) { - BScreen *old_screen = (BScreen *) 0, *screen = (BScreen *) 0; - OpenboxWindow *old_win = (OpenboxWindow *) 0; +OpenboxWindow *Openbox::focusedWindow() { + if (focused_screen == (BScreen *) 0) + return (OpenboxWindow *) 0; + return focused_screen->getCurrentWorkspace()->focusedWindow(); +} + + +void Openbox::focusWindow(OpenboxWindow *win) { + BScreen *old_screen = (BScreen *) 0; Toolbar *old_tbar = (Toolbar *) 0, *tbar = (Toolbar *) 0; Workspace *old_wkspc = (Workspace *) 0, *wkspc = (Workspace *) 0; - if (focused_window) { - old_win = focused_window; + OpenboxWindow *old_win = focusedWindow(); + if (old_win != (OpenboxWindow *) 0) { old_screen = old_win->getScreen(); - old_tbar = old_screen->getToolbar(); old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber()); + old_tbar = old_screen->getToolbar(); old_win->setFocusFlag(False); - old_wkspc->getMenu()->setItemSelected(old_win->getWindowNumber(), False); + old_wkspc->focusWindow((OpenboxWindow *) 0); } - if (win && ! win->isIconic()) { - screen = win->getScreen(); - tbar = screen->getToolbar(); - wkspc = screen->getWorkspace(win->getWorkspaceNumber()); - - focused_window = win; - - win->setFocusFlag(True); - wkspc->getMenu()->setItemSelected(win->getWindowNumber(), True); - } else { - focused_window = (OpenboxWindow *) 0; + if (win && !win->isIconic()) { + focused_screen = win->getScreen(); + tbar = focused_screen->getToolbar(); + wkspc = focused_screen->getWorkspace(win->getWorkspaceNumber()); + win->setFocusFlag(true); + wkspc->focusWindow(win); + + if (tbar) + tbar->redrawWindowLabel(true); + focused_screen->updateNetizenWindowFocus(); + //} else { + // focused_window = (OpenboxWindow *) 0; } - if (tbar) - tbar->redrawWindowLabel(True); - if (screen) - screen->updateNetizenWindowFocus(); - if (old_tbar && old_tbar != tbar) - old_tbar->redrawWindowLabel(True); - if (old_screen && old_screen != screen) + old_tbar->redrawWindowLabel(true); + if (old_screen && old_screen != focused_screen) old_screen->updateNetizenWindowFocus(); }