X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=util%2Fepist%2Fwindow.cc;h=505a0f87c393c18353c312c740615a2fb8184ea7;hb=5dc5cc32b0c00c3bfba8ea5727599f49b56ae817;hp=c8cdf012a4cca4d5e82b3c82302045a2571a4428;hpb=d8967bd534ff10a234fed17059fb92d985be9176;p=chaz%2Fopenbox diff --git a/util/epist/window.cc b/util/epist/window.cc index c8cdf012..505a0f87 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. +// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- +// 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 @@ -34,7 +34,14 @@ using std::dec; #include "epist.hh" #include "screen.hh" #include "window.hh" -#include "../../src/XAtom.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,6 +51,7 @@ XWindow::XWindow(epist *epist, screen *screen, Window window) XSelectInput(_epist->getXDisplay(), _window, PropertyChangeMask | StructureNotifyMask); + updateBlackboxAttributes(); updateNormalHints(); updateWMHints(); updateDimentions(); @@ -78,6 +86,23 @@ void XWindow::updateDimentions() { } +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; @@ -105,12 +130,13 @@ void XWindow::updateNormalHints() { void XWindow::updateWMHints() { XWMHints *hints; + // assume a window takes input if it doesnt specify + _can_focus = True; + if ((hints = XGetWMHints(_epist->getXDisplay(), _window)) != NULL) { - _can_focus = hints->input; + if (hints->flags & InputHint) + _can_focus = hints->input; XFree(hints); - } else { - // assume a window takes input if it doesnt specify - _can_focus = True; } } @@ -185,8 +211,10 @@ void XWindow::processEvent(const XEvent &e) { case PropertyNotify: if (e.xproperty.atom == XA_WM_NORMAL_HINTS) updateNormalHints(); - if (e.xproperty.atom == XA_WM_HINTS) + 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)) @@ -234,12 +262,15 @@ void XWindow::iconify() const { } -void XWindow::focus() const { +void XWindow::focus(bool raise) const { // this will cause the window to be uniconified also - _xatom->sendClientMessage(_screen->rootWindow(), XAtom::net_active_window, - _window); - - //XSetInputFocus(_epist->getXDisplay(), _window, None, CurrentTime); + + if (raise) { + _xatom->sendClientMessage(_screen->rootWindow(), XAtom::net_active_window, + _window); + } else { + XSetInputFocus(_epist->getXDisplay(), _window, None, CurrentTime); + } } @@ -336,34 +367,18 @@ void XWindow::move(int x, int y) const { } -void XWindow::resize(int dwidth, int dheight) const { +void XWindow::resizeRel(int dwidth, int dheight) const { // resize in increments if requested by the window - - unsigned int wdest = _rect.width() + (dwidth * _inc_x) / - _inc_x * _inc_x + _base_x; - unsigned int hdest = _rect.height() + (dheight * _inc_y) / - _inc_y * _inc_y + _base_y; - - if (width > wdest) { - while (width > wdest) - wdest += _inc_x; - } else { - while (width < wdest) - wdest -= _inc_x; - } - if (height > hdest) { - while (height > hdest) - hdest += _inc_y; - } else { - while (height < hdest) - hdest -= _inc_y; - } + 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::resize(unsigned int width, unsigned int height) const { +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; @@ -452,3 +467,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)); +}