]> Dogcows Code - chaz/openbox/blob - otk/appwidget.cc
bd1acbf83d38592ed2c7484e6f6780cec66b4b64
[chaz/openbox] / 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 OtkAppWidget::OtkAppWidget(OtkApplication *app, Direction direction,
17 Cursor cursor, int bevel_width)
18 : OtkWidget(app, app->getStyle(), direction, cursor, bevel_width),
19 _application(app)
20 {
21 assert(app);
22
23 _wm_protocols = XInternAtom(OBDisplay::display, "WM_PROTOCOLS", false);
24 _wm_delete = XInternAtom(OBDisplay::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(OBDisplay::display, getWindow(), protocols, 2);
31 }
32
33 OtkAppWidget::~OtkAppWidget()
34 {
35 }
36
37 void OtkAppWidget::show(void)
38 {
39 OtkWidget::show(true);
40
41 _application->_appwidget_count++;
42 }
43
44 void OtkAppWidget::hide(void)
45 {
46 OtkWidget::hide();
47
48 _application->_appwidget_count--;
49 }
50
51 void OtkAppWidget::clientMessageHandler(const XClientMessageEvent &e)
52 {
53 OtkEventHandler::clientMessageHandler(e);
54 if (e.message_type == _wm_protocols &&
55 static_cast<Atom>(e.data.l[0]) == _wm_delete)
56 hide();
57 }
58
59 }
This page took 0.035489 seconds and 4 git commands to generate.