summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--otk/button.cc1
-rw-r--r--otk/focuslabel.cc1
-rw-r--r--otk/focuswidget.cc40
-rw-r--r--otk/focuswidget.hh11
-rw-r--r--otk/label.cc2
-rw-r--r--otk/label.hh2
-rw-r--r--otk/widget.cc53
-rw-r--r--otk/widget.hh24
-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
14 files changed, 222 insertions, 72 deletions
diff --git a/otk/button.cc b/otk/button.cc
index fd23a569..2b174582 100644
--- a/otk/button.cc
+++ b/otk/button.cc
@@ -12,7 +12,6 @@ OtkButton::OtkButton(OtkWidget *parent)
: OtkFocusLabel(parent), _pressed(false), _pressed_focus_tx(0),
_pressed_unfocus_tx(0), _unpr_focus_tx(0), _unpr_unfocus_tx(0)
{
- setStyle(getStyle());
}
OtkButton::~OtkButton()
diff --git a/otk/focuslabel.cc b/otk/focuslabel.cc
index 007c7957..c4f124e6 100644
--- a/otk/focuslabel.cc
+++ b/otk/focuslabel.cc
@@ -16,7 +16,6 @@ OtkFocusLabel::OtkFocusLabel(OtkWidget *parent)
const ScreenInfo *info = OBDisplay::screenInfo(getScreen());
_xftdraw = XftDrawCreate(OBDisplay::display, getWindow(), info->getVisual(),
info->getColormap());
- setStyle(getStyle());
}
OtkFocusLabel::~OtkFocusLabel()
diff --git a/otk/focuswidget.cc b/otk/focuswidget.cc
index 22a6100b..f5b176bf 100644
--- a/otk/focuswidget.cc
+++ b/otk/focuswidget.cc
@@ -9,44 +9,44 @@
namespace otk {
OtkFocusWidget::OtkFocusWidget(OtkWidget *parent, Direction direction)
- : OtkWidget(parent, direction), _unfocus_texture(0), _focused(true)
+ : OtkWidget(parent, direction), _unfocus_texture(0), _unfocus_bcolor(0)
{
+ _focused = true;
_focus_texture = parent->getTexture();
+ _focus_bcolor = parent->getBorderColor();
}
OtkFocusWidget::~OtkFocusWidget()
{
}
+#include <stdio.h>
void OtkFocusWidget::focus(void)
{
- if (_focused)
+ if (!isVisible() || _focused)
return;
- // XXX: what about OtkWidget::focus()
+ printf("FOCUS\n");
+ OtkWidget::focus();
+
+ if (_focus_bcolor)
+ OtkWidget::setBorderColor(_focus_bcolor);
- assert(_focus_texture);
OtkWidget::setTexture(_focus_texture);
OtkWidget::update();
-
- OtkWidget::OtkWidgetList children = OtkWidget::getChildren();
-
- OtkWidget::OtkWidgetList::iterator it = children.begin(),
- end = children.end();
-
- OtkFocusWidget *tmp = 0;
- for (; it != end; ++it) {
- tmp = dynamic_cast<OtkFocusWidget*>(*it);
- if (tmp) tmp->focus();
- }
}
void OtkFocusWidget::unfocus(void)
{
- if (! _focused)
+ if (!isVisible() || !_focused)
return;
- assert(_unfocus_texture);
+ printf("UNFOCUS\n");
+ OtkWidget::unfocus();
+
+ if (_unfocus_bcolor)
+ OtkWidget::setBorderColor(_unfocus_bcolor);
+
OtkWidget::setTexture(_unfocus_texture);
OtkWidget::update();
@@ -68,4 +68,10 @@ void OtkFocusWidget::setTexture(BTexture *texture)
_focus_texture = texture;
}
+void OtkFocusWidget::setBorderColor(const BColor *color)
+{
+ OtkWidget::setBorderColor(color);
+ _focus_bcolor = color;
+}
+
}
diff --git a/otk/focuswidget.hh b/otk/focuswidget.hh
index d33d2abf..2a97c6aa 100644
--- a/otk/focuswidget.hh
+++ b/otk/focuswidget.hh
@@ -16,13 +16,19 @@ public:
virtual void focus(void);
virtual void unfocus(void);
- void setTexture(BTexture *texture);
+ virtual void setTexture(BTexture *texture);
+ virtual void setBorderColor(const BColor *color);
inline void setUnfocusTexture(BTexture *texture)
{ _unfocus_texture = texture; }
inline BTexture *getUnfocusTexture(void) const
{ return _unfocus_texture; }
+ inline void setUnfocusBorderColor(const BColor *color)
+ { _unfocus_bcolor = color; }
+ inline const BColor *getUnfocusBorderColor(void) const
+ { return _unfocus_bcolor; }
+
inline bool isFocused(void) const { return _focused; }
inline bool isUnfocused(void) const { return !_focused; }
@@ -31,7 +37,8 @@ private:
BTexture *_unfocus_texture;
BTexture *_focus_texture;
- bool _focused;
+ const BColor *_unfocus_bcolor;
+ const BColor *_focus_bcolor;
};
}
diff --git a/otk/label.cc b/otk/label.cc
index fa12a0fa..ceb6a49c 100644
--- a/otk/label.cc
+++ b/otk/label.cc
@@ -14,8 +14,6 @@ OtkLabel::OtkLabel(OtkWidget *parent)
const ScreenInfo *info = OBDisplay::screenInfo(getScreen());
_xftdraw = XftDrawCreate(OBDisplay::display, getWindow(), info->getVisual(),
info->getColormap());
-
- setStyle(getStyle());
}
OtkLabel::~OtkLabel()
diff --git a/otk/label.hh b/otk/label.hh
index 0dd81442..f80f76c7 100644
--- a/otk/label.hh
+++ b/otk/label.hh
@@ -19,7 +19,7 @@ public:
void update(void);
virtual void setStyle(Style *style);
-
+
private:
//! Object used by Xft to render to the drawable
XftDraw *_xftdraw;
diff --git a/otk/widget.cc b/otk/widget.cc
index 6423a7af..2c3c6058 100644
--- a/otk/widget.cc
+++ b/otk/widget.cc
@@ -16,38 +16,40 @@ namespace otk {
OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
: OtkEventHandler(),
- _dirty(false),
+ _dirty(false), _focused(false),
_parent(parent), _style(parent->getStyle()), _direction(direction),
_cursor(parent->getCursor()), _bevel_width(parent->getBevelWidth()),
_ignore_config(0),
- _visible(false), _focused(false), _grabbed_mouse(false),
+ _visible(false), _grabbed_mouse(false),
_grabbed_keyboard(false), _stretchable_vert(false),
_stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0),
- _screen(parent->getScreen()), _fixed_width(false), _fixed_height(false),
- _event_dispatcher(parent->getEventDispatcher()), _application(0)
+ _bcolor(0), _bwidth(0), _screen(parent->getScreen()), _fixed_width(false),
+ _fixed_height(false), _event_dispatcher(parent->getEventDispatcher())
{
assert(parent);
parent->addChild(this);
create();
_event_dispatcher->registerHandler(_window, this);
+ setStyle(_style); // let the widget initialize stuff
}
OtkWidget::OtkWidget(OtkEventDispatcher *event_dispatcher, Style *style,
Direction direction, Cursor cursor, int bevel_width)
: OtkEventHandler(),
- _dirty(false),
+ _dirty(false),_focused(false),
_parent(0), _style(style), _direction(direction), _cursor(cursor),
_bevel_width(bevel_width), _ignore_config(0), _visible(false),
- _focused(false), _grabbed_mouse(false), _grabbed_keyboard(false),
+ _grabbed_mouse(false), _grabbed_keyboard(false),
_stretchable_vert(false), _stretchable_horz(false), _texture(0),
- _bg_pixmap(0), _bg_pixel(0), _screen(style->getScreen()),
- _fixed_width(false), _fixed_height(false),
- _event_dispatcher(event_dispatcher), _application(0)
+ _bg_pixmap(0), _bg_pixel(0), _bcolor(0), _bwidth(0),
+ _screen(style->getScreen()), _fixed_width(false), _fixed_height(false),
+ _event_dispatcher(event_dispatcher)
{
assert(event_dispatcher);
assert(style);
create();
_event_dispatcher->registerHandler(_window, this);
+ setStyle(_style); // let the widget initialize stuff
}
OtkWidget::~OtkWidget()
@@ -185,11 +187,28 @@ void OtkWidget::hide(bool recursive)
void OtkWidget::focus(void)
{
- if (! _visible)
+/* if (! _visible)
return;
XSetInputFocus(otk::OBDisplay::display, _window, RevertToPointerRoot,
- CurrentTime);
+ CurrentTime);*/
+
+ _focused = true;
+
+ OtkWidget::OtkWidgetList::iterator it = _children.begin(),
+ end = _children.end();
+ for (; it != end; ++it)
+ (*it)->focus();
+}
+
+void OtkWidget::unfocus(void)
+{
+ _focused = false;
+
+ OtkWidget::OtkWidgetList::iterator it = _children.begin(),
+ end = _children.end();
+ for (; it != end; ++it)
+ (*it)->unfocus();
}
bool OtkWidget::grabMouse(void)
@@ -419,12 +438,22 @@ void OtkWidget::removeChild(OtkWidget *child)
if (it != _children.end())
_children.erase(it);
}
-
+#include <stdio.h>
void OtkWidget::setStyle(Style *style)
{
assert(style);
_style = style;
_dirty = true;
+
+ // reset textures/colors
+ if (_focused) {
+ unfocus();
+ focus();
+ } else {
+ focus();
+ unfocus();
+ }
+
OtkWidgetList::iterator it, end = _children.end();
for (it = _children.begin(); it != end; ++it)
(*it)->setStyle(style);
diff --git a/otk/widget.hh b/otk/widget.hh
index 249a4e28..5f1553c3 100644
--- a/otk/widget.hh
+++ b/otk/widget.hh
@@ -65,6 +65,7 @@ public:
inline bool isFocused(void) const { return _focused; };
virtual void focus(void);
+ virtual void unfocus(void);
inline bool hasGrabbedMouse(void) const { return _grabbed_mouse; }
bool grabMouse(void);
@@ -76,7 +77,19 @@ public:
inline BTexture *getTexture(void) const { return _texture; }
virtual void setTexture(BTexture *texture)
- { _texture = texture; _dirty = true; }
+ { _texture = texture; _dirty = true; }
+
+ inline const BColor *getBorderColor(void) const { return _bcolor; }
+ virtual void setBorderColor(const BColor *color) {
+ assert(color); _bcolor = color;
+ XSetWindowBorder(OBDisplay::display, _window, color->pixel());
+ }
+
+ inline int getBorderWidth(void) const { return _bwidth; }
+ void setBorderWidth(int width) {
+ _bwidth = width;
+ XSetWindowBorderWidth(OBDisplay::display, _window, width);
+ }
virtual void addChild(OtkWidget *child, bool front = false);
virtual void removeChild(OtkWidget *child);
@@ -112,11 +125,13 @@ public:
protected:
bool _dirty;
+ bool _focused;
+
+ virtual void adjust(void);
private:
void create(void);
- void adjust(void);
void adjustHorz(void);
void adjustVert(void);
void internalResize(int width, int height);
@@ -134,7 +149,6 @@ private:
int _ignore_config;
bool _visible;
- bool _focused;
bool _grabbed_mouse;
bool _grabbed_keyboard;
@@ -146,6 +160,9 @@ private:
Pixmap _bg_pixmap;
unsigned int _bg_pixel;
+ const BColor *_bcolor;
+ unsigned int _bwidth;
+
Rect _rect;
unsigned int _screen;
@@ -155,7 +172,6 @@ private:
bool _unmanaged;
OtkEventDispatcher *_event_dispatcher;
- OtkApplication *_application;
};
}
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