diff options
| author | Dana Jansens <danakj@orodu.net> | 2002-11-16 13:50:59 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2002-11-16 13:50:59 +0000 |
| commit | 81e1982744e1d692fbe54cc840e93099cbe974af (patch) | |
| tree | 1d381bce6c55a847b6c2823320ea76f90355a7b5 /otk/application.cc | |
| parent | 77342413efd183bd1c0681a57b68acc836022923 (diff) | |
set the close protocol on the app's main widget
Diffstat (limited to 'otk/application.cc')
| -rw-r--r-- | otk/application.cc | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/otk/application.cc b/otk/application.cc index 16b9e0f5..0a250ea3 100644 --- a/otk/application.cc +++ b/otk/application.cc @@ -1,7 +1,10 @@ #include "application.hh" #include "eventhandler.hh" +#include "widget.hh" extern "C" { +#include <X11/Xlib.h> + #ifdef HAVE_STDLIB_H # include <stdlib.h> #endif @@ -12,7 +15,7 @@ extern "C" { namespace otk { OtkApplication::OtkApplication(int argc, char **argv) - : OtkEventDispatcher(), _dockable(false) + : OtkEventDispatcher(), _main_widget(0), _dockable(false) { argc = argc; argv = argv; @@ -52,10 +55,31 @@ void OtkApplication::loadStyle(void) void OtkApplication::exec(void) { + if (!_main_widget) { + std::cerr << "No main widget set. You must create a main OtkWidget for " << + "the OtkApplication before calling OtkApplication::exec().\n"; + ::exit(1); + } while (1) { dispatchEvents(); _timer_manager->fire(); // fire pending events } } +bool OtkApplication::setMainWidget(const OtkWidget *main_widget) +{ + // ignore it if it has already been set + if (_main_widget) return false; + + _main_widget = main_widget; + + // set WM Protocols on the window + Atom protocols[2]; + protocols[0] = XInternAtom(OBDisplay::display, "WM_PROTOCOLS", false); + protocols[1] = XInternAtom(OBDisplay::display, "WM_DELETE_WINDOW", false); + XSetWMProtocols(OBDisplay::display, _main_widget->getWindow(), protocols, 2); + + return true; +} + } |
