_stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0),
_bcolor(0), _bwidth(0), _rect(0, 0, 1, 1), _screen(parent->screen()),
_fixed_width(false), _fixed_height(false),
+ _event_mask(ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
+ ExposureMask | StructureNotifyMask),
_surface(0),
_event_dispatcher(parent->eventDispatcher())
{
_stretchable_vert(false), _stretchable_horz(false), _texture(0),
_bg_pixmap(0), _bg_pixel(0), _bcolor(0), _bwidth(0), _rect(0, 0, 1, 1),
_screen(style->screen()), _fixed_width(false), _fixed_height(false),
+ _event_mask(ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
+ ExposureMask | StructureNotifyMask),
_surface(0),
_event_dispatcher(event_dispatcher)
{
if (_visible)
hide();
+ if (_surface)
+ delete _surface;
+
_event_dispatcher->clearHandler(_window);
std::for_each(_children.begin(), _children.end(), PointerAssassin());
attrib_create.background_pixmap = None;
attrib_create.colormap = scr_info->colormap();
- attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask |
- ButtonMotionMask | ExposureMask | StructureNotifyMask;
+ attrib_create.event_mask = _event_mask;
if (override_redirect) {
create_mask |= CWOverrideRedirect;
_ignore_config++;
}
+void Widget::setEventMask(long e)
+{
+ XSelectInput(**display, _window, e);
+ _event_mask = e;
+}
+
void Widget::setWidth(int w)
{
assert(w > 0);
_rect = Rect(x, y, width, height);
_dirty = true;
+ // make all parents dirty too
+ Widget *p = _parent;
+ while (p) {
+ p->_dirty = true;
+ p = p->_parent;
+ }
+
// don't use an XMoveResizeWindow here, because it doesn't seem to move
// windows with StaticGravity? This works, that didn't.
XResizeWindow(**display, _window, width, height);
void Widget::render(void)
{
- if (!_texture) return;
+ if (!_texture) {
+ XSetWindowBackgroundPixmap(**display, _window, ParentRelative);
+ return;
+ }
Surface *s = _surface; // save the current surface
XSetWindowBackgroundPixmap(**display, _window, _surface->pixmap());
- delete s; // delete the old surface *after* its pixmap isn't in use anymore
+ if (s)
+ delete s; // delete the old surface *after* its pixmap isn't in use anymore
}
void Widget::adjust(void)
prev_widget = tmp;
}
-
internalResize(width, tallest + _bevel_width * 2);
}
(*str_it)->setHeight(str_height > _bevel_width ?
str_height - _bevel_width : _bevel_width);
}
+ if (stretchable.size() > 0)
+ height = _rect.height();
Widget *prev_widget = 0;
internalResize(widest + _bevel_width * 2, height);
}
-void Widget::update(void)
+void Widget::update()
{
+ WidgetList::iterator it = _children.begin(), end = _children.end();
+ for (; it != end; ++it)
+ (*it)->update();
+
if (_dirty) {
adjust();
render();
XClearWindow(**display, _window);
}
- WidgetList::iterator it = _children.begin(), end = _children.end();
- for (; it != end; ++it)
- (*it)->update();
-
_dirty = false;
}
{
assert(w > 0 && h > 0);
- if (! _fixed_width && ! _fixed_height)
+ bool fw = _fixed_width, fh = _fixed_height;
+
+ if (! fw && ! fh)
resize(w, h);
- else if (! _fixed_width)
+ else if (! fw)
resize(w, _rect.height());
- else if (! _fixed_height)
+ else if (! fh)
resize(_rect.width(), h);
+
+ _fixed_width = fw;
+ _fixed_height = fh;
}
void Widget::addChild(Widget *child, bool front)