summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/backgroundwidget.cc57
-rw-r--r--src/backgroundwidget.hh25
-rw-r--r--src/frame.cc43
-rw-r--r--src/frame.hh7
-rw-r--r--src/widget.hh26
6 files changed, 128 insertions, 32 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index bc83bb6f..319a9fde 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,7 +16,7 @@ bin_PROGRAMS= openbox3
openbox3_LDADD=../otk/libotk.a @LIBINTL@
openbox3_SOURCES= actions.cc client.cc frame.cc openbox.cc screen.cc \
- main.cc rootwindow.cc
+ main.cc rootwindow.cc backgroundwidget.cc
MAINTAINERCLEANFILES= Makefile.in
diff --git a/src/backgroundwidget.cc b/src/backgroundwidget.cc
new file mode 100644
index 00000000..7d715f55
--- /dev/null
+++ b/src/backgroundwidget.cc
@@ -0,0 +1,57 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+#ifdef HAVE_CONFIG_H
+# include "../config.h"
+#endif
+
+#include "backgroundwidget.hh"
+
+namespace ob {
+
+OBBackgroundWidget::OBBackgroundWidget(otk::OtkWidget *parent,
+ OBWidget::WidgetType type)
+ : otk::OtkFocusWidget(parent),
+ OBWidget(type)
+{
+}
+
+
+OBBackgroundWidget::~OBBackgroundWidget()
+{
+}
+
+
+void OBBackgroundWidget::setStyle(otk::Style *style)
+{
+ switch (type()) {
+ case Type_Titlebar:
+ setTexture(style->getTitleFocus());
+ setUnfocusTexture(style->getTitleUnfocus());
+ setBorderColor(style->getBorderColor());
+ break;
+ case Type_Handle:
+ setTexture(style->getHandleFocus());
+ setUnfocusTexture(style->getHandleUnfocus());
+ setBorderColor(style->getBorderColor());
+ break;
+ case Type_Plate:
+ setBorderColor(&style->getFrameFocus()->color());
+ setUnfocusBorderColor(&style->getFrameUnfocus()->color());
+ break;
+ default:
+ assert(false); // there's no other background widgets!
+ }
+
+ otk::OtkFocusWidget::setStyle(style);
+}
+
+
+void OBBackgroundWidget::adjust()
+{
+ otk::OtkFocusWidget::adjust();
+
+ // XXX: adjust shit
+}
+
+
+}
diff --git a/src/backgroundwidget.hh b/src/backgroundwidget.hh
new file mode 100644
index 00000000..0cbfb3fa
--- /dev/null
+++ b/src/backgroundwidget.hh
@@ -0,0 +1,25 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+#ifndef __obbackgroundwidget_hh
+#define __obbackgroundwidget_hh
+
+#include "otk/focuswidget.hh"
+#include "widget.hh"
+
+namespace ob {
+
+class OBBackgroundWidget : public otk::OtkFocusWidget, public OBWidget
+{
+private:
+
+public:
+ OBBackgroundWidget(otk::OtkWidget *parent, OBWidget::WidgetType type);
+ virtual ~OBBackgroundWidget();
+
+ virtual void setStyle(otk::Style *style);
+
+ virtual void adjust();
+};
+
+}
+
+#endif // __obbackgroundwidget_hh
diff --git a/src/frame.cc b/src/frame.cc
index 15404f93..fc85d6d1 100644
--- a/src/frame.cc
+++ b/src/frame.cc
@@ -25,14 +25,14 @@ OBFrame::OBFrame(OBClient *client, otk::Style *style)
: otk::OtkWidget(Openbox::instance, style),
_client(client),
_screen(otk::OBDisplay::screenInfo(client->screen())),
- _plate(this),
- _titlebar(this),
+ _plate(this, OBWidget::Type_Plate),
+ _titlebar(this, OBWidget::Type_Titlebar),
_button_close(&_titlebar),
_button_iconify(&_titlebar),
_button_max(&_titlebar),
_button_stick(&_titlebar),
_label(&_titlebar),
- _handle(this),
+ _handle(this, OBWidget::Type_Handle),
_grip_left(&_handle),
_grip_right(&_handle),
_decorations(client->decorations())
@@ -57,8 +57,6 @@ OBFrame::OBFrame(OBClient *client, otk::Style *style)
_grip_left.setCursor(Openbox::instance->cursors().ll_angle);
_grip_right.setCursor(Openbox::instance->cursors().lr_angle);
- _plate.show();
-
_button_close.setText("X");
_button_iconify.setText("I");
_button_max.setText("M");
@@ -68,6 +66,10 @@ OBFrame::OBFrame(OBClient *client, otk::Style *style)
_style = 0;
setStyle(style);
+ //XXX: uncomment me unfocus(); // stuff starts out focused in otk
+
+ _plate.show(); // the other stuff is shown based on decor settings
+
grabClient();
}
@@ -93,11 +95,6 @@ void OBFrame::setStyle(otk::Style *style)
_grip_right.setPressedFocusTexture(style->getGripFocus());
_grip_right.setPressedUnfocusTexture(style->getGripUnfocus());
- _titlebar.setTexture(style->getTitleFocus());
- _titlebar.setUnfocusTexture(style->getTitleUnfocus());
- _handle.setTexture(style->getHandleFocus());
- _handle.setUnfocusTexture(style->getHandleUnfocus());
-
// if a style was previously set, then 'replace' is true, cause we're
// replacing a style
bool replace = (_style);
@@ -109,20 +106,13 @@ void OBFrame::setStyle(otk::Style *style)
_style = style;
// XXX: change when focus changes!
- XSetWindowBorder(otk::OBDisplay::display, _plate.getWindow(),
- _style->getFrameFocus()->color().pixel());
-
XSetWindowBorder(otk::OBDisplay::display, getWindow(),
_style->getBorderColor()->pixel());
- XSetWindowBorder(otk::OBDisplay::display, _titlebar.getWindow(),
- _style->getBorderColor()->pixel());
XSetWindowBorder(otk::OBDisplay::display, _grip_left.getWindow(),
_style->getBorderColor()->pixel());
XSetWindowBorder(otk::OBDisplay::display, _grip_right.getWindow(),
_style->getBorderColor()->pixel());
- XSetWindowBorder(otk::OBDisplay::display, _handle.getWindow(),
- _style->getBorderColor()->pixel());
-
+
// if !replace, then adjust() will get called after the client is grabbed!
if (replace) {
// size/position everything
@@ -151,17 +141,14 @@ void OBFrame::adjustSize()
cbwidth;
width = _client->area().width() + cbwidth * 2;
- XSetWindowBorderWidth(otk::OBDisplay::display, _plate.getWindow(), cbwidth);
-
- XSetWindowBorderWidth(otk::OBDisplay::display, getWindow(), bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _titlebar.getWindow(),
- bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _grip_left.getWindow(),
- bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _grip_right.getWindow(),
- bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _handle.getWindow(), bwidth);
+ _plate.setBorderWidth(cbwidth);
+ setBorderWidth(bwidth);
+ _titlebar.setBorderWidth(bwidth);
+ _grip_left.setBorderWidth(bwidth);
+ _grip_right.setBorderWidth(bwidth);
+ _handle.setBorderWidth(bwidth);
+
if (_decorations & OBClient::Decor_Titlebar) {
// set the titlebar size
_titlebar.setGeometry(-bwidth,
diff --git a/src/frame.hh b/src/frame.hh
index 7248c71f..450c8670 100644
--- a/src/frame.hh
+++ b/src/frame.hh
@@ -10,6 +10,7 @@ extern "C" {
}
#include "client.hh"
+#include "backgroundwidget.hh"
#include "otk/strut.hh"
#include "otk/rect.hh"
#include "otk/screeninfo.hh"
@@ -49,14 +50,14 @@ private:
otk::Strut _innersize;
// decoration windows
- otk::OtkFocusWidget _plate; // sits entirely under the client window
- otk::OtkFocusWidget _titlebar;
+ OBBackgroundWidget _plate; // sits entirely under the client window
+ OBBackgroundWidget _titlebar;
otk::OtkButton _button_close;
otk::OtkButton _button_iconify;
otk::OtkButton _button_max;
otk::OtkButton _button_stick;
otk::OtkFocusLabel _label;
- otk::OtkFocusWidget _handle;
+ OBBackgroundWidget _handle;
otk::OtkButton _grip_left;
otk::OtkButton _grip_right;
diff --git a/src/widget.hh b/src/widget.hh
new file mode 100644
index 00000000..c82c2862
--- /dev/null
+++ b/src/widget.hh
@@ -0,0 +1,26 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+#ifndef __obwidget_hh
+#define __obwidget_hh
+
+namespace ob {
+
+class OBWidget {
+public:
+ enum WidgetType {
+ Type_Titlebar,
+ Type_Handle,
+ Type_Plate
+ };
+
+private:
+ WidgetType _type;
+
+public:
+ OBWidget(WidgetType type) : _type(type) {}
+
+ inline WidgetType type() const { return _type; }
+};
+
+}
+
+#endif // __obwidget_hh