use otk::Property properly, and the right atoms
[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 #include "property.hh"
10
11 extern "C" {
12 #include <X11/Xlib.h>
13 }
14
15 namespace otk {
16
17 AppWidget::AppWidget(Application *app, Direction direction,
18                            Cursor cursor, int bevel_width)
19   : Widget(app, app->getStyle(), direction, cursor, bevel_width),
20     _application(app)
21 {
22   assert(app);
23
24   // set WM Protocols on the window
25   Atom protocols[2];
26   protocols[0] = Property::atoms.wm_protocols;
27   protocols[1] = Property::atoms.wm_delete_window;
28   XSetWMProtocols(**display, window(), protocols, 2);
29 }
30
31 AppWidget::~AppWidget()
32 {
33 }
34
35 void AppWidget::show(void)
36 {
37   Widget::show(true);
38
39   _application->_appwidget_count++;
40 }
41
42 void AppWidget::hide(void)
43 {
44   Widget::hide();
45
46   _application->_appwidget_count--;
47 }
48
49 void AppWidget::clientMessageHandler(const XClientMessageEvent &e)
50 {
51   EventHandler::clientMessageHandler(e);
52   if (e.message_type == Property::atoms.wm_protocols &&
53       static_cast<Atom>(e.data.l[0]) == Property::atoms.wm_delete_window)
54     hide();
55 }
56
57 }