don't try pass focus off to windows that dont take it

This commit is contained in:
Dana Jansens 2002-07-24 17:49:57 +00:00
parent 49c04eaf57
commit fa34ea5250
3 changed files with 40 additions and 17 deletions

View file

@ -489,11 +489,10 @@ void screen::cycleWindow(const bool forward, const bool allscreens,
classname = (*_active)->appClass(); classname = (*_active)->appClass();
WindowList::const_iterator target = _active, WindowList::const_iterator target = _active,
first = _active,
begin = _clients.begin(), begin = _clients.begin(),
end = _clients.end(); end = _clients.end();
do { while (1) {
if (forward) { if (forward) {
if (target == end) { if (target == end) {
target = begin; target = begin;
@ -509,18 +508,22 @@ void screen::cycleWindow(const bool forward, const bool allscreens,
} }
// must be no window to focus // must be no window to focus
if (target == first) if (target == _active)
return; return;
} while ((*target)->iconic() ||
(! allscreens && (*target)->getScreen() != this) || // determine if this window is invalid for cycling to
(! alldesktops && const XWindow *t = *target;
(*target)->desktop() != _active_desktop && if (t->iconic()) continue;
(*target)->desktop() != 0xffffffff) || if (! allscreens && t->getScreen() != this) continue;
(sameclass && ! classname.empty() && if (! alldesktops && ! (t->desktop() == _active_desktop ||
(*target)->appClass() != classname)); t->desktop() == 0xffffffff)) continue;
if (sameclass && ! classname.empty() &&
if (target != _clients.end()) t->appClass() != classname) continue;
(*target)->focus(); if (! t->canFocus()) continue;
// found a good window!
t->focus();
}
} }

View file

@ -44,7 +44,8 @@ XWindow::XWindow(epist *epist, screen *screen, Window window)
XSelectInput(_epist->getXDisplay(), _window, XSelectInput(_epist->getXDisplay(), _window,
PropertyChangeMask | StructureNotifyMask); PropertyChangeMask | StructureNotifyMask);
updateHints(); updateNormalHints();
updateWMHints();
updateDimentions(); updateDimentions();
updateState(); updateState();
updateDesktop(); updateDesktop();
@ -77,7 +78,7 @@ void XWindow::updateDimentions() {
} }
void XWindow::updateHints() { void XWindow::updateNormalHints() {
XSizeHints size; XSizeHints size;
long ret; long ret;
@ -101,6 +102,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() { void XWindow::updateState() {
// set the defaults // set the defaults
_shaded = _iconic = _max_vert = _max_horz = false; _shaded = _iconic = _max_vert = _max_horz = false;
@ -170,7 +184,9 @@ void XWindow::processEvent(const XEvent &e) {
break; break;
case PropertyNotify: case PropertyNotify:
if (e.xproperty.atom == XA_WM_NORMAL_HINTS) 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)) else if (e.xproperty.atom == _xatom->getAtom(XAtom::net_wm_state))
updateState(); updateState();
else if (e.xproperty.atom == _xatom->getAtom(XAtom::net_wm_desktop)) else if (e.xproperty.atom == _xatom->getAtom(XAtom::net_wm_desktop))
@ -219,6 +235,7 @@ void XWindow::iconify() const {
void XWindow::focus() const { void XWindow::focus() const {
cout << "Focusing window: 0x" << hex << _window << dec << endl;
// this will cause the window to be uniconified also // this will cause the window to be uniconified also
_xatom->sendClientMessage(_screen->rootWindow(), XAtom::net_active_window, _xatom->sendClientMessage(_screen->rootWindow(), XAtom::net_active_window,
_window); _window);

View file

@ -60,6 +60,7 @@ private:
int _inc_x, _inc_y; // resize increments int _inc_x, _inc_y; // resize increments
int _base_x, _base_y; // base size int _base_x, _base_y; // base size
int _gravity; int _gravity;
bool _can_focus;
// states // states
bool _shaded; bool _shaded;
@ -70,7 +71,8 @@ private:
bool _unmapped; bool _unmapped;
void updateDimentions(); void updateDimentions();
void updateHints(); void updateNormalHints();
void updateWMHints();
void updateState(); void updateState();
void updateDesktop(); void updateDesktop();
void updateTitle(); void updateTitle();
@ -87,6 +89,7 @@ public:
inline const std::string &title() const { return _title; } inline const std::string &title() const { return _title; }
inline const std::string &appName() const { return _app_name; } inline const std::string &appName() const { return _app_name; }
inline const std::string &appClass() const { return _app_class; } inline const std::string &appClass() const { return _app_class; }
inline bool canFocus() const { return _can_focus; }
inline bool shaded() const { return _shaded; } inline bool shaded() const { return _shaded; }
inline bool iconic() const { return _iconic; } inline bool iconic() const { return _iconic; }