not using any old blackbox classes anymore!

This commit is contained in:
Dana Jansens 2002-11-11 10:05:06 +00:00
parent fb0dd6cf9a
commit cee3052446
8 changed files with 79 additions and 18 deletions

View file

@ -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

View file

@ -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;

View file

@ -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);
}

View file

@ -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 <X11/cursorfont.h>
@ -41,6 +44,8 @@ extern "C" {
#define _(str) gettext(str)
}
#include <algorithm>
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);
@ -107,6 +127,10 @@ Openbox::Openbox(int argc, char **argv)
_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
}
@ -119,6 +143,8 @@ Openbox::~Openbox()
while (!_clients.empty())
_xeventhandler.unmanageWindow(_clients.begin()->second);
std::for_each(_screens.begin(), _screens.end(), otk::PointerAssassin());
// close the X display
otk::OBDisplay::destroy();
}

View file

@ -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
@ -62,6 +65,9 @@ public:
//! A map for looking up a specific client class from the window id
typedef std::map<Window, OBClient *> ClientMap;
//! A list of OBScreen classes
typedef std::vector<OBScreen *> ScreenList;
private:
// stuff that can be passed on the command line
//! Path to the config file to use/in use
@ -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; }

View file

@ -9,6 +9,11 @@ extern "C" {
# include <stdio.h>
#endif // HAVE_STDIO_H
#ifdef HAVE_UNISTD_H
# include <sys/types.h>
# include <unistd.h>
#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!
}
}

View file

@ -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 <string>
@ -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;
@ -108,6 +113,10 @@ public:
//! 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; }
};
}

View file

@ -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 <X11/Xlib.h>
#include <X11/Xutil.h>
@ -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);