X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=util%2Fepist%2Fwindow.cc;h=854297197012012b7bb7721a8f437a83032a406b;hb=8a48fff773dea20ab93ee8f22b281e852b51242e;hp=0d33a2f6d641487409bd5621e5e9039a9b6eb391;hpb=0adf54b0ca8f723dd25645d414b48a9a74e115d6;p=chaz%2Fopenbox diff --git a/util/epist/window.cc b/util/epist/window.cc index 0d33a2f6..85429719 100644 --- a/util/epist/window.cc +++ b/util/epist/window.cc @@ -1,5 +1,5 @@ // -*- mode: C++; indent-tabs-mode: nil; -*- -// window.cc for Epistophy - a key handler for NETWM/EWMH window managers. +// window.cc for Epistrophy - a key handler for NETWM/EWMH window managers. // Copyright (c) 2002 - 2002 Ben Jansens // // Permission is hereby granted, free of charge, to any person obtaining a @@ -36,6 +36,13 @@ using std::dec; #include "window.hh" #include "../../src/XAtom.hh" + // defined by black/openbox +const unsigned long XWindow::PropBlackboxAttributesElements; +const unsigned long XWindow::AttribDecoration; +const unsigned long XWindow::DecorNone; +const unsigned long XWindow::DecorNormal; + + XWindow::XWindow(epist *epist, screen *screen, Window window) : _epist(epist), _screen(screen), _xatom(epist->xatom()), _window(window) { @@ -44,7 +51,9 @@ XWindow::XWindow(epist *epist, screen *screen, Window window) XSelectInput(_epist->getXDisplay(), _window, PropertyChangeMask | StructureNotifyMask); - updateHints(); + updateBlackboxAttributes(); + updateNormalHints(); + updateWMHints(); updateDimentions(); updateState(); updateDesktop(); @@ -77,7 +86,24 @@ void XWindow::updateDimentions() { } -void XWindow::updateHints() { +void XWindow::updateBlackboxAttributes() { + unsigned long *data; + unsigned long num = PropBlackboxAttributesElements; + + _decorated = true; + + if (_xatom->getValue(_window, + XAtom::blackbox_attributes, XAtom::blackbox_attributes, + num, &data)) { + if (num == PropBlackboxAttributesElements) + if (data[0] & AttribDecoration) + _decorated = (data[4] != DecorNone); + delete data; + } +} + + +void XWindow::updateNormalHints() { XSizeHints size; long ret; @@ -101,6 +127,19 @@ void XWindow::updateHints() { } +void XWindow::updateWMHints() { + XWMHints *hints; + + if ((hints = XGetWMHints(_epist->getXDisplay(), _window)) != NULL) { + _can_focus = hints->input; + XFree(hints); + } else { + // assume a window takes input if it doesnt specify + _can_focus = True; + } +} + + void XWindow::updateState() { // set the defaults _shaded = _iconic = _max_vert = _max_horz = false; @@ -170,7 +209,11 @@ void XWindow::processEvent(const XEvent &e) { break; case PropertyNotify: if (e.xproperty.atom == XA_WM_NORMAL_HINTS) - updateHints(); + updateNormalHints(); + else if (e.xproperty.atom == XA_WM_HINTS) + updateWMHints(); + else if (e.xproperty.atom == _xatom->getAtom(XAtom::blackbox_attributes)) + updateBlackboxAttributes(); else if (e.xproperty.atom == _xatom->getAtom(XAtom::net_wm_state)) updateState(); else if (e.xproperty.atom == _xatom->getAtom(XAtom::net_wm_desktop)) @@ -320,7 +363,18 @@ void XWindow::move(int x, int y) const { } -void XWindow::resize(unsigned int width, unsigned int height) const { +void XWindow::resizeRel(int dwidth, int dheight) const { + // resize in increments if requested by the window + unsigned int width = _rect.width(), height = _rect.height(); + + unsigned int wdest = width + (dwidth * _inc_x) / _inc_x * _inc_x + _base_x; + unsigned int hdest = height + (dheight * _inc_y) / _inc_y * _inc_y + _base_y; + + XResizeWindow(_epist->getXDisplay(), _window, wdest, hdest); +} + + +void XWindow::resizeAbs(unsigned int width, unsigned int height) const { // resize in increments if requested by the window unsigned int wdest = width / _inc_x * _inc_x + _base_x; @@ -409,3 +463,11 @@ void XWindow::maximize(Max max) const { break; } } + + +void XWindow::decorate(bool d) const { + _xatom->sendClientMessage(_screen->rootWindow(), + XAtom::blackbox_change_attributes, + _window, AttribDecoration, + 0, 0, 0, (d ? DecorNormal : DecorNone)); +}