From 3254816b6b0bbcf0e5b85ea8eb836ce9bac96bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Thu, 1 Sep 2016 22:16:03 +0200 Subject: expose and fix ActivateTabCmd The function failed if the last event window was actually the tab. --- src/CurrentWindowCmd.cc | 41 +++++++++++++++++------------------------ src/CurrentWindowCmd.hh | 7 +++++++ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index 3e4ef38..2ba4123 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/CurrentWindowCmd.cc @@ -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 *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 { diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh index 95175f2..36f76ec 100644 --- a/src/CurrentWindowCmd.hh +++ b/src/CurrentWindowCmd.hh @@ -282,4 +282,11 @@ private: ClientPattern m_pat; }; +class ActivateTabCmd: public WindowHelperCmd { +public: + explicit ActivateTabCmd() { } +protected: + void real_execute(); +}; + #endif // CURRENTWINDOWCMD_HH -- cgit v0.11.2