From cee305244662d352a7ad5ab7ae22f6221c064d3d Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 11 Nov 2002 10:05:06 +0000 Subject: [PATCH] not using any old blackbox classes anymore! --- src/Makefile.am | 3 +-- src/bbscreen.cc | 1 - src/main.cc | 6 +++--- src/openbox.cc | 26 ++++++++++++++++++++++++++ src/openbox.hh | 19 +++++++++++++++++++ src/screen.cc | 19 +++++++++++++++++-- src/screen.hh | 11 ++++++++++- src/xeventhandler.cc | 12 +++--------- 8 files changed, 79 insertions(+), 18 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 6fe76c90..8034df0e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,8 +15,7 @@ bin_PROGRAMS= openbox3 openbox3_LDADD=../otk/libotk.a @LIBINTL@ -openbox3_SOURCES= client.cc frame.cc bbscreen.cc openbox.cc screen.cc \ - bbwindow.cc workspace.cc blackbox.cc \ +openbox3_SOURCES= client.cc frame.cc openbox.cc screen.cc \ main.cc xeventhandler.cc MAINTAINERCLEANFILES= Makefile.in diff --git a/src/bbscreen.cc b/src/bbscreen.cc index ebfceb98..fb930317 100644 --- a/src/bbscreen.cc +++ b/src/bbscreen.cc @@ -141,7 +141,6 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) { // XXX: ugh resource.wstyle.setImageControl(image_control); - resource.wstyle.setScreenNumber(scrn); LoadStyle(); XGCValues gcv; diff --git a/src/main.cc b/src/main.cc index 3bab740a..6b131b92 100644 --- a/src/main.cc +++ b/src/main.cc @@ -24,11 +24,11 @@ int main(int argc, char **argv) { bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - //ob::Openbox openbox(argc, argv); - ob::Blackbox blackbox(argc, argv, 0); + ob::Openbox openbox(argc, argv); + //ob::Blackbox blackbox(argc, argv, 0); //Blackbox blackbox(argv, session_display, rc_file); - blackbox.eventLoop(); + openbox.eventLoop(); return(0); } diff --git a/src/openbox.cc b/src/openbox.cc index 6f42bc20..9d040e14 100644 --- a/src/openbox.cc +++ b/src/openbox.cc @@ -6,8 +6,11 @@ #include "../version.h" #include "openbox.hh" +#include "screen.hh" #include "otk/property.hh" #include "otk/display.hh" +#include "otk/assassin.hh" +#include "otk/util.hh" // TEMPORARY extern "C" { #include @@ -41,6 +44,8 @@ extern "C" { #define _(str) gettext(str) } +#include + namespace ob { Openbox *Openbox::instance = (Openbox *) 0; @@ -79,9 +84,24 @@ Openbox::Openbox(int argc, char **argv) _displayreq = (char*) 0; _argv0 = argv[0]; _doshutdown = false; + _rcfilepath = otk::expandTilde("~/.openbox/rc3"); parseCommandLine(argc, argv); + // TEMPORARY: using the xrdb rc3 + _config.setFile(_rcfilepath); + if (!_config.load()) { + printf("failed to load rc file %s\n", _config.file().c_str()); + ::exit(2); + } + std::string s; + _config.getValue("session.styleFile", s); + _config.setFile(s); + if (!_config.load()) { + printf("failed to load style %s\n", _config.file().c_str()); + ::exit(2); + } + // open the X display (and gets some info about it, and its screens) otk::OBDisplay::initialize(_displayreq); assert(otk::OBDisplay::display); @@ -106,6 +126,10 @@ Openbox::Openbox(int argc, char **argv) _cursors.lr_angle = XCreateFontCursor(otk::OBDisplay::display, XC_lr_angle); _cursors.ul_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ul_angle); _cursors.ur_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ur_angle); + + // initialize all the screens + _screens.push_back(new OBScreen(0)); + _screens[0]->loadStyle(_config); _state = State_Normal; // done starting } @@ -118,6 +142,8 @@ Openbox::~Openbox() // unmanage all windows while (!_clients.empty()) _xeventhandler.unmanageWindow(_clients.begin()->second); + + std::for_each(_screens.begin(), _screens.end(), otk::PointerAssassin()); // close the X display otk::OBDisplay::destroy(); diff --git a/src/openbox.hh b/src/openbox.hh index ccf2b80a..a257cb24 100644 --- a/src/openbox.hh +++ b/src/openbox.hh @@ -17,11 +17,14 @@ extern "C" { #include "otk/screeninfo.hh" #include "otk/timerqueuemanager.hh" #include "otk/property.hh" +#include "otk/configuration.hh" #include "xeventhandler.hh" #include "client.hh" namespace ob { +class OBScreen; + //! The main class for the Openbox window manager. /*! Only a single instance of the Openbox class may be used in the application. A @@ -61,6 +64,9 @@ public: //! A map for looking up a specific client class from the window id typedef std::map ClientMap; + + //! A list of OBScreen classes + typedef std::vector ScreenList; private: // stuff that can be passed on the command line @@ -82,6 +88,9 @@ private: //! A list of all managed clients ClientMap _clients; + //! A list of all the managed screens + ScreenList _screens; + //! Manages all timers for the application /*! Use of the otk::OBTimerQueueManager::fire funtion in this object ensures @@ -109,6 +118,9 @@ private: //! When set to true, the Openbox::eventLoop function will stop and return bool _doshutdown; + //! The configuration of the application. TEMPORARY + otk::Configuration _config; + //! Parses the command line used when executing this application void parseCommandLine(int argv, char **argv); //! Displays the version string to stdout @@ -139,8 +151,15 @@ public: */ inline otk::OBTimerQueueManager *timerManager() { return &_timermanager; } + //! Returns the otk::OBProperty instance for the window manager inline const otk::OBProperty *property() const { return _property; } + //! Returns a managed screen + inline const OBScreen *screen(int num) const { + assert(num >= 0); assert(num < (signed)_screens.size()); + return _screens[num]; + } + //! Returns the mouse cursors used throughout Openbox inline const Cursors &cursors() const { return _cursors; } diff --git a/src/screen.cc b/src/screen.cc index 845014a9..51e3aa16 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -9,6 +9,11 @@ extern "C" { # include #endif // HAVE_STDIO_H +#ifdef HAVE_UNISTD_H +# include +# include +#endif // HAVE_UNISTD_H + #include "gettext.h" #define _(str) gettext(str) } @@ -49,12 +54,10 @@ OBScreen::OBScreen(int screen) printf(_("Managing screen %d: visual 0x%lx, depth %d\n"), _number, XVisualIDFromVisual(_info->getVisual()), _info->getDepth()); -#ifdef HAVE_GETPID Openbox::instance->property()->set(_info->getRootWindow(), otk::OBProperty::openbox_pid, otk::OBProperty::Atom_Cardinal, (unsigned long) getpid()); -#endif // HAVE_GETPID // set the mouse cursor for the root window (the default cursor) XDefineCursor(otk::OBDisplay::display, _info->getRootWindow(), @@ -65,6 +68,8 @@ OBScreen::OBScreen(int screen) _image_control->installRootColormap(); _root_cmap_installed = True; + _style.setImageControl(_image_control); + // Set the netwm atoms for geomtery and viewport unsigned long geometry[] = { _size.x(), @@ -304,4 +309,14 @@ void OBScreen::setWorkArea() { } +void OBScreen::loadStyle(const otk::Configuration &config) +{ + _style.load(config); + if (Openbox::instance->state() == Openbox::State_Starting) + return; + + // XXX: make stuff redraw! +} + + } diff --git a/src/screen.hh b/src/screen.hh index 6068e04b..d4d42a7c 100644 --- a/src/screen.hh +++ b/src/screen.hh @@ -14,6 +14,8 @@ extern "C" { #include "otk/strut.hh" #include "otk/rect.hh" #include "otk/point.hh" +#include "otk/style.hh" +#include "otk/configuration.hh" // TEMPORARY #include @@ -53,6 +55,9 @@ private: //! The Image Control used for rendering on the screen otk::BImageControl *_image_control; + //! The style with which to render on the screen + otk::Style _style; + //! Is the root colormap currently installed? bool _root_cmap_installed; @@ -107,7 +112,11 @@ public: void addStrut(otk::Strut *strut); //! Removes a window's strut from the screen's list of reserved spaces void removeStrut(otk::Strut *strut); - + + //! Loads a new style on the screen + void loadStyle(const otk::Configuration &config); + + inline const otk::Style *style() const { return &_style; } }; } diff --git a/src/xeventhandler.cc b/src/xeventhandler.cc index afa5ecee..560aace2 100644 --- a/src/xeventhandler.cc +++ b/src/xeventhandler.cc @@ -8,13 +8,10 @@ #include "client.hh" #include "frame.hh" #include "openbox.hh" +#include "screen.hh" #include "otk/display.hh" #include "otk/rect.hh" -// XXX: REMOVE THIS SOON!!#! -#include "blackbox.hh" -#include "bbscreen.hh" - extern "C" { #include #include @@ -168,12 +165,9 @@ void OBXEventHandler::manageWindow(int screen, Window window) // XXX: position the window intelligenty } - // XXX: store a style somewheres cooler!! - otk::Style *style = ((Blackbox*)Openbox::instance)-> - searchScreen(RootWindow(otk::OBDisplay::display, screen))-> - getWindowStyle(); // create the decoration frame for the client window - client->frame = new OBFrame(client, style); + client->frame = new OBFrame(client, + Openbox::instance->screen(screen)->style()); // add all the client's decoration windows as event handlers for the client Openbox::instance->addClient(client->frame->window(), client); -- 2.45.2