OBBackgroundWidget::OBBackgroundWidget(otk::OtkWidget *parent,
OBWidget::WidgetType type)
- : otk::OtkFocusWidget(parent),
+ : otk::OtkWidget(parent),
OBWidget(type)
{
}
}
-void OBBackgroundWidget::setStyle(otk::Style *style)
+void OBBackgroundWidget::setTextures()
{
switch (type()) {
case Type_Titlebar:
- setTexture(style->getTitleFocus());
- setUnfocusTexture(style->getTitleUnfocus());
- setBorderColor(style->getBorderColor());
+ if (_focused)
+ setTexture(_style->getTitleFocus());
+ else
+ setTexture(_style->getTitleUnfocus());
break;
case Type_Handle:
- setTexture(style->getHandleFocus());
- setUnfocusTexture(style->getHandleUnfocus());
- setBorderColor(style->getBorderColor());
+ if (_focused)
+ setTexture(_style->getHandleFocus());
+ else
+ setTexture(_style->getHandleUnfocus());
break;
case Type_Plate:
- setBorderColor(&style->getFrameFocus()->color());
- setUnfocusBorderColor(&style->getFrameUnfocus()->color());
+ if (_focused)
+ setBorderColor(&_style->getFrameFocus()->color());
+ else
+ setBorderColor(&_style->getFrameUnfocus()->color());
break;
default:
assert(false); // there's no other background widgets!
}
+}
- otk::OtkFocusWidget::setStyle(style);
+
+void OBBackgroundWidget::setStyle(otk::Style *style)
+{
+ OtkWidget::setStyle(style);
+ setTextures();
+ switch (type()) {
+ case Type_Titlebar:
+ case Type_Handle:
+ setBorderColor(_style->getBorderColor());
+ break;
+ case Type_Plate:
+ break;
+ default:
+ assert(false); // there's no other background widgets!
+ }
+}
+
+
+void OBBackgroundWidget::focus()
+{
+ otk::OtkWidget::focus();
+ setTextures();
+}
+
+
+void OBBackgroundWidget::unfocus()
+{
+ otk::OtkWidget::unfocus();
+ setTextures();
}
void OBBackgroundWidget::adjust()
{
- otk::OtkFocusWidget::adjust();
+ // nothing to adjust here. its done in OBFrame::adjustSize
+}
- // XXX: adjust shit
+void OBBackgroundWidget::grabButtons(bool grab)
+{
+ if (grab) {
+ // grab simple button clicks on the client, but pass them through too
+ otk::OBDisplay::grabButton(Button1, 0, _window, true,
+ ButtonPressMask, GrabModeSync, GrabModeSync,
+ _window, None, false);
+ otk::OBDisplay::grabButton(Button2, 0, _window, true,
+ ButtonPressMask, GrabModeSync, GrabModeSync,
+ _window, None, false);
+ otk::OBDisplay::grabButton(Button3, 0, _window, true,
+ ButtonPressMask, GrabModeSync, GrabModeSync,
+ _window, None, false);
+ otk::OBDisplay::grabButton(Button4, 0, _window, true,
+ ButtonPressMask, GrabModeSync, GrabModeSync,
+ _window, None, false);
+ otk::OBDisplay::grabButton(Button5, 0, _window, true,
+ ButtonPressMask, GrabModeSync, GrabModeSync,
+ _window, None, false);
+ } else {
+ otk::OBDisplay::ungrabButton(Button1, 0, _window);
+ otk::OBDisplay::ungrabButton(Button2, 0, _window);
+ otk::OBDisplay::ungrabButton(Button3, 0, _window);
+ otk::OBDisplay::ungrabButton(Button4, 0, _window);
+ otk::OBDisplay::ungrabButton(Button5, 0, _window);
+ }
}
+void OBBackgroundWidget::buttonPressHandler(const XButtonEvent &e)
+{
+ if (type() == OBWidget::Type_Plate)
+ XAllowEvents(otk::OBDisplay::display, ReplayPointer, e.time);
+}
}