all repos — openbox @ fa34ea5250511e37180ea2ddd85919516f25248d

openbox fork - make it a bit more like ryudo

don't try pass focus off to windows that dont take it
Dana Jansens danakj@orodu.net
commit

fa34ea5250511e37180ea2ddd85919516f25248d

parent

49c04eaf57fc20efe95c431b78b2c08d6403dee2

3 files changed, 40 insertions(+), 17 deletions(-)

jump to
M util/epist/screen.ccutil/epist/screen.cc

@@ -489,11 +489,10 @@ if (sameclass && classname.empty() && _active != _clients.end())

classname = (*_active)->appClass(); WindowList::const_iterator target = _active, - first = _active, begin = _clients.begin(), end = _clients.end(); - do { + while (1) { if (forward) { if (target == end) { target = begin;

@@ -509,18 +508,22 @@ --target;

} // must be no window to focus - if (target == first) + if (target == _active) return; - } while ((*target)->iconic() || - (! allscreens && (*target)->getScreen() != this) || - (! alldesktops && - (*target)->desktop() != _active_desktop && - (*target)->desktop() != 0xffffffff) || - (sameclass && ! classname.empty() && - (*target)->appClass() != classname)); - - if (target != _clients.end()) - (*target)->focus(); + + // determine if this window is invalid for cycling to + const XWindow *t = *target; + if (t->iconic()) continue; + if (! allscreens && t->getScreen() != this) continue; + if (! alldesktops && ! (t->desktop() == _active_desktop || + t->desktop() == 0xffffffff)) continue; + if (sameclass && ! classname.empty() && + t->appClass() != classname) continue; + if (! t->canFocus()) continue; + + // found a good window! + t->focus(); + } }
M util/epist/window.ccutil/epist/window.cc

@@ -44,7 +44,8 @@

XSelectInput(_epist->getXDisplay(), _window, PropertyChangeMask | StructureNotifyMask); - updateHints(); + updateNormalHints(); + updateWMHints(); updateDimentions(); updateState(); updateDesktop();

@@ -77,7 +78,7 @@ _rect.setRect(0, 0, 1, 1);

} -void XWindow::updateHints() { +void XWindow::updateNormalHints() { XSizeHints size; long ret;

@@ -101,6 +102,19 @@ }

} +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 +184,9 @@ updateDimentions();

break; case PropertyNotify: if (e.xproperty.atom == XA_WM_NORMAL_HINTS) - updateHints(); + updateNormalHints(); + if (e.xproperty.atom == XA_WM_HINTS) + updateWMHints(); else if (e.xproperty.atom == _xatom->getAtom(XAtom::net_wm_state)) updateState(); else if (e.xproperty.atom == _xatom->getAtom(XAtom::net_wm_desktop))

@@ -219,6 +235,7 @@ }

void XWindow::focus() const { + cout << "Focusing window: 0x" << hex << _window << dec << endl; // this will cause the window to be uniconified also _xatom->sendClientMessage(_screen->rootWindow(), XAtom::net_active_window, _window);
M util/epist/window.hhutil/epist/window.hh

@@ -60,6 +60,7 @@ Rect _rect;

int _inc_x, _inc_y; // resize increments int _base_x, _base_y; // base size int _gravity; + bool _can_focus; // states bool _shaded;

@@ -70,7 +71,8 @@

bool _unmapped; void updateDimentions(); - void updateHints(); + void updateNormalHints(); + void updateWMHints(); void updateState(); void updateDesktop(); void updateTitle();

@@ -87,6 +89,7 @@ inline unsigned int desktop() const { return _desktop; }

inline const std::string &title() const { return _title; } inline const std::string &appName() const { return _app_name; } inline const std::string &appClass() const { return _app_class; } + inline bool canFocus() const { return _can_focus; } inline bool shaded() const { return _shaded; } inline bool iconic() const { return _iconic; }