expose and fix ActivateTabCmd

The function failed if the last event window was actually the tab.
This commit is contained in:
Thomas Lübking 2016-09-01 22:16:03 +02:00
parent 0d1b204121
commit 3254816b6b
2 changed files with 24 additions and 24 deletions

View file

@ -167,6 +167,23 @@ void CurrentWindowCmd::real_execute() {
(fbwindow().*m_action)();
}
void ActivateTabCmd::real_execute() {
Window root, last = 0,
tab = Fluxbox::instance()->lastEvent().xany.window;
int junk; unsigned int ujunk;
WinClient *winclient = fbwindow().winClientOfLabelButtonWindow(tab);
Display *dpy = Fluxbox::instance()->display();
while (!winclient && tab && tab != last) {
last = tab;
XQueryPointer(dpy, tab, &root, &tab, &junk, &junk, &junk, &junk, &ujunk);
winclient = fbwindow().winClientOfLabelButtonWindow(tab);
}
if (winclient && winclient != &fbwindow().winClient()) {
fbwindow().setCurrentClient(*winclient, true);
}
}
namespace {
FbTk::Command<void> *parseIntCmd(const string &command, const string &args,
@ -222,30 +239,6 @@ REGISTER_COMMAND_PARSER(activate, parseFocusCmd, void);
REGISTER_COMMAND_PARSER(focus, parseFocusCmd, void);
class ActivateTabCmd: public WindowHelperCmd {
public:
explicit ActivateTabCmd() { }
protected:
void real_execute() {
Window root, last = 0,
tab = Fluxbox::instance()->lastEvent().xany.window;
int junk; unsigned int ujunk;
WinClient *winclient = 0;
Display *dpy = Fluxbox::instance()->display();
while (!winclient && tab && tab != last) {
last = tab;
XQueryPointer(dpy, tab, &root, &tab, &junk, &junk, &junk, &junk, &ujunk);
winclient = fbwindow().winClientOfLabelButtonWindow(tab);
}
if (winclient && winclient != &fbwindow().winClient()) {
fbwindow().setCurrentClient(*winclient, true);
}
}
};
REGISTER_COMMAND(activatetab, ActivateTabCmd, void);
class SetXPropCmd: public WindowHelperCmd {

View file

@ -282,4 +282,11 @@ private:
ClientPattern m_pat;
};
class ActivateTabCmd: public WindowHelperCmd {
public:
explicit ActivateTabCmd() { }
protected:
void real_execute();
};
#endif // CURRENTWINDOWCMD_HH