]> Dogcows Code - chaz/openbox/blob - otk/appwidget.cc
113998feed5f37d6875a8dac0e63fb9a29134017
[chaz/openbox] / otk / appwidget.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #include "config.h"
4
5 #include "appwidget.hh"
6 #include "application.hh"
7 #include "property.hh"
8 #include "renderstyle.hh"
9
10 extern "C" {
11 #include <X11/Xlib.h>
12 }
13
14 namespace otk {
15
16 AppWidget::AppWidget(Application *app, Direction direction, int bevel)
17 : Widget(app->screen(), app, direction, bevel),
18 _application(app)
19 {
20 assert(app);
21
22 // set WM Protocols on the window
23 Atom protocols[2];
24 protocols[0] = Property::atoms.wm_protocols;
25 protocols[1] = Property::atoms.wm_delete_window;
26 XSetWMProtocols(**display, window(), protocols, 2);
27 }
28
29 AppWidget::~AppWidget()
30 {
31 }
32
33 void AppWidget::render()
34 {
35 XSetWindowBackground(**display, window(),
36 RenderStyle::style(screen())->
37 titlebarUnfocusBackground()->color().pixel());
38 Widget::render();
39 }
40
41 void AppWidget::show()
42 {
43 Widget::show(true);
44
45 _application->_appwidget_count++;
46 }
47
48 void AppWidget::hide()
49 {
50 Widget::hide();
51
52 _application->_appwidget_count--;
53 }
54
55 void AppWidget::clientMessageHandler(const XClientMessageEvent &e)
56 {
57 EventHandler::clientMessageHandler(e);
58 if (e.message_type == Property::atoms.wm_protocols &&
59 static_cast<Atom>(e.data.l[0]) == Property::atoms.wm_delete_window)
60 hide();
61 }
62
63 }
This page took 0.034968 seconds and 3 git commands to generate.