]> Dogcows Code - chaz/openbox/blob - otk/appwidget.cc
Brand spankin new widgets for otk (Label and Button).
[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 #include "property.hh"
10 #include "renderstyle.hh"
11
12 extern "C" {
13 #include <X11/Xlib.h>
14 }
15
16 namespace otk {
17
18 AppWidget::AppWidget(Application *app, Direction direction, int bevel)
19 : Widget(app->screen(), app, direction, bevel),
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::render()
36 {
37 XSetWindowBackground(**display, window(),
38 RenderStyle::style(screen())->
39 titlebarUnfocusBackground()->color().pixel());
40 Widget::render();
41 }
42
43 void AppWidget::show()
44 {
45 Widget::show(true);
46
47 _application->_appwidget_count++;
48 }
49
50 void AppWidget::hide()
51 {
52 Widget::hide();
53
54 _application->_appwidget_count--;
55 }
56
57 void AppWidget::clientMessageHandler(const XClientMessageEvent &e)
58 {
59 EventHandler::clientMessageHandler(e);
60 if (e.message_type == Property::atoms.wm_protocols &&
61 static_cast<Atom>(e.data.l[0]) == Property::atoms.wm_delete_window)
62 hide();
63 }
64
65 }
This page took 0.03343 seconds and 4 git commands to generate.