]> icculus.org git repositories - mikachu/openbox.git/blob - otk/appwidget.cc
add an OtkAppWidget which are "root windows", i.e. the managed child of root, to...
[mikachu/openbox.git] / otk / appwidget.cc
1 #include "appwidget.hh"
2 #include "application.hh"
3
4 extern "C" {
5 #include <X11/Xlib.h>
6 }
7
8 namespace otk {
9
10 OtkAppWidget::OtkAppWidget(OtkApplication *app, Direction direction,
11                            Cursor cursor, int bevel_width)
12   : OtkWidget(app, app->getStyle(), direction, cursor, bevel_width),
13     _application(app)
14 {
15   assert(app);
16
17   _wm_protocols = XInternAtom(OBDisplay::display, "WM_PROTOCOLS", false);
18   _wm_delete = XInternAtom(OBDisplay::display, "WM_DELETE_WINDOW", false);
19
20   // set WM Protocols on the window
21   Atom protocols[2];
22   protocols[0] = _wm_protocols;
23   protocols[1] = _wm_delete;
24   XSetWMProtocols(OBDisplay::display, getWindow(), protocols, 2);
25 }
26
27 OtkAppWidget::~OtkAppWidget()
28 {
29 }
30
31 void OtkAppWidget::show(void)
32 {
33   OtkWidget::show();
34
35   _application->_appwidget_count++;
36 }
37
38 void OtkAppWidget::hide(void)
39 {
40   OtkWidget::hide();
41
42   _application->_appwidget_count--;
43 }
44
45 void OtkAppWidget::clientMessageHandler(const XClientMessageEvent &e)
46 {
47   OtkEventHandler::clientMessageHandler(e);
48   if (e.message_type == _wm_protocols &&
49       static_cast<Atom>(e.data.l[0]) == _wm_delete)
50     hide();
51 }
52
53 }