1 #include "application.hh"
2 #include "eventhandler.hh"
17 OtkApplication::OtkApplication(int argc, char **argv)
18 : OtkEventDispatcher(), _main_widget(0), _dockable(false)
23 OBDisplay::initialize(0);
24 const ScreenInfo *s_info = OBDisplay::screenInfo(DefaultScreen(OBDisplay::display));
26 _timer_manager = new OBTimerQueueManager();
27 _img_ctrl = new BImageControl(_timer_manager, s_info, True, 4, 5, 200);
28 _style_conf = new Configuration(False);
29 _style = new Style(_img_ctrl);
34 OtkApplication::~OtkApplication()
38 delete _timer_manager;
44 void OtkApplication::loadStyle(void)
46 // find the style name as a property
47 std::string style = "/usr/local/share/openbox/styles/artwiz";
48 _style_conf->setFile(style);
49 if (!_style_conf->load()) {
50 std::cerr << "Unable to load style \"" << style << "\". Aborting.\n";
53 _style->load(*_style_conf);
56 void OtkApplication::exec(void)
59 std::cerr << "No main widget set. You must create a main OtkWidget for " <<
60 "the OtkApplication before calling OtkApplication::exec().\n";
65 _timer_manager->fire(); // fire pending events
69 bool OtkApplication::setMainWidget(const OtkWidget *main_widget)
71 // ignore it if it has already been set
73 std::cerr << "More than one main OtkWidget being created for the " <<
78 _main_widget = main_widget;
80 // set WM Protocols on the window
82 protocols[0] = XInternAtom(OBDisplay::display, "WM_PROTOCOLS", false);
83 protocols[1] = XInternAtom(OBDisplay::display, "WM_DELETE_WINDOW", false);
84 XSetWMProtocols(OBDisplay::display, _main_widget->getWindow(), protocols, 2);