]> Dogcows Code - chaz/openbox/blob - src/backgroundwidget.cc
clicks on the client work as they should
[chaz/openbox] / src / backgroundwidget.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 "backgroundwidget.hh"
8
9 namespace ob {
10
11 OBBackgroundWidget::OBBackgroundWidget(otk::OtkWidget *parent,
12 OBWidget::WidgetType type)
13 : otk::OtkWidget(parent),
14 OBWidget(type)
15 {
16 }
17
18
19 OBBackgroundWidget::~OBBackgroundWidget()
20 {
21 }
22
23
24 void OBBackgroundWidget::setTextures()
25 {
26 switch (type()) {
27 case Type_Titlebar:
28 if (_focused)
29 setTexture(_style->getTitleFocus());
30 else
31 setTexture(_style->getTitleUnfocus());
32 break;
33 case Type_Handle:
34 if (_focused)
35 setTexture(_style->getHandleFocus());
36 else
37 setTexture(_style->getHandleUnfocus());
38 break;
39 case Type_Plate:
40 if (_focused)
41 setBorderColor(&_style->getFrameFocus()->color());
42 else
43 setBorderColor(&_style->getFrameUnfocus()->color());
44 break;
45 default:
46 assert(false); // there's no other background widgets!
47 }
48 }
49
50
51 void OBBackgroundWidget::setStyle(otk::Style *style)
52 {
53 OtkWidget::setStyle(style);
54 setTextures();
55 switch (type()) {
56 case Type_Titlebar:
57 case Type_Handle:
58 setBorderColor(_style->getBorderColor());
59 break;
60 case Type_Plate:
61 break;
62 default:
63 assert(false); // there's no other background widgets!
64 }
65 }
66
67
68 void OBBackgroundWidget::focus()
69 {
70 otk::OtkWidget::focus();
71 setTextures();
72 }
73
74
75 void OBBackgroundWidget::unfocus()
76 {
77 otk::OtkWidget::unfocus();
78 setTextures();
79 }
80
81
82 void OBBackgroundWidget::adjust()
83 {
84 // nothing to adjust here. its done in OBFrame::adjustSize
85 }
86
87 void OBBackgroundWidget::grabButtons(bool grab)
88 {
89 if (grab) {
90 // grab simple button clicks on the client, but pass them through too
91 otk::OBDisplay::grabButton(Button1, 0, _window, true,
92 ButtonPressMask, GrabModeSync, GrabModeSync,
93 _window, None, false);
94 otk::OBDisplay::grabButton(Button2, 0, _window, true,
95 ButtonPressMask, GrabModeSync, GrabModeSync,
96 _window, None, false);
97 otk::OBDisplay::grabButton(Button3, 0, _window, true,
98 ButtonPressMask, GrabModeSync, GrabModeSync,
99 _window, None, false);
100 otk::OBDisplay::grabButton(Button4, 0, _window, true,
101 ButtonPressMask, GrabModeSync, GrabModeSync,
102 _window, None, false);
103 otk::OBDisplay::grabButton(Button5, 0, _window, true,
104 ButtonPressMask, GrabModeSync, GrabModeSync,
105 _window, None, false);
106 } else {
107 otk::OBDisplay::ungrabButton(Button1, 0, _window);
108 otk::OBDisplay::ungrabButton(Button2, 0, _window);
109 otk::OBDisplay::ungrabButton(Button3, 0, _window);
110 otk::OBDisplay::ungrabButton(Button4, 0, _window);
111 otk::OBDisplay::ungrabButton(Button5, 0, _window);
112 }
113 }
114
115 void OBBackgroundWidget::buttonPressHandler(const XButtonEvent &e)
116 {
117 if (type() == OBWidget::Type_Plate)
118 XAllowEvents(otk::OBDisplay::display, ReplayPointer, e.time);
119 }
120
121 }
This page took 0.043247 seconds and 5 git commands to generate.