]> icculus.org git repositories - mikachu/openbox.git/blob - otk/appwidget.cc
rm prefixes for all elements in the otk namepsace
[mikachu/openbox.git] / otk / appwidget.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #ifdef HAVE_CONFIG_H
4 # include "../config.h"
5 #endif
6
7 #include "appwidget.hh"
8 #include "application.hh"
9
10 extern "C" {
11 #include <X11/Xlib.h>
12 }
13
14 namespace otk {
15
16 AppWidget::AppWidget(Application *app, Direction direction,
17                            Cursor cursor, int bevel_width)
18   : Widget(app, app->getStyle(), direction, cursor, bevel_width),
19     _application(app)
20 {
21   assert(app);
22
23   _wm_protocols = XInternAtom(Display::display, "WM_PROTOCOLS", false);
24   _wm_delete = XInternAtom(Display::display, "WM_DELETE_WINDOW", false);
25
26   // set WM Protocols on the window
27   Atom protocols[2];
28   protocols[0] = _wm_protocols;
29   protocols[1] = _wm_delete;
30   XSetWMProtocols(Display::display, window(), protocols, 2);
31 }
32
33 AppWidget::~AppWidget()
34 {
35 }
36
37 void AppWidget::show(void)
38 {
39   Widget::show(true);
40
41   _application->_appwidget_count++;
42 }
43
44 void AppWidget::hide(void)
45 {
46   Widget::hide();
47
48   _application->_appwidget_count--;
49 }
50
51 void AppWidget::clientMessageHandler(const XClientMessageEvent &e)
52 {
53   EventHandler::clientMessageHandler(e);
54   if (e.message_type == _wm_protocols &&
55       static_cast<Atom>(e.data.l[0]) == _wm_delete)
56     hide();
57 }
58
59 }