diff --git a/data/keys b/data/keys index d29e81b9..3bfca002 100644 --- a/data/keys +++ b/data/keys @@ -29,7 +29,8 @@ OnTitlebar Control Mouse1 :StartTabbing OnTitlebar Double Mouse1 :Shade # left click on the titlebar to move the window -OnTitlebar Mouse1 :StartMoving +OnTitlebar Mouse1 :MacroCmd {ActivateTab} {Raise} {Focus} +OnTitlebar Move1 :StartMoving # middle click on the titlebar to lower OnTitlebar Mouse2 :Lower diff --git a/doc/asciidoc/fluxbox-keys.txt b/doc/asciidoc/fluxbox-keys.txt index 3f3431db..41ad1e2a 100644 --- a/doc/asciidoc/fluxbox-keys.txt +++ b/doc/asciidoc/fluxbox-keys.txt @@ -184,6 +184,9 @@ Bottom BottomRight* *StartTabbing*:: Start dragging to add this window to another's tabgroup. +*ActivateTab*:: + Activates the tab underneath the mouse. + Window Commands ~~~~~~~~~~~~~~~ These commands ordinarily affect only the currently focused window. The diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index 713c32a2..4d25d545 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/CurrentWindowCmd.cc @@ -223,6 +223,27 @@ FbTk::Command *parseFocusCmd(const string &command, const string &args, REGISTER_COMMAND_PARSER(activate, parseFocusCmd, void); REGISTER_COMMAND_PARSER(focus, parseFocusCmd, void); + +class ActivateTabCmd: public WindowHelperCmd { +public: + ActivateTabCmd() { } +protected: + void real_execute(); +}; + + +void ActivateTabCmd::real_execute() { + + WinClient* winclient = fbwindow().winClientOfLabelButtonWindow( + Fluxbox::instance()->lastEvent().xany.window); + + if (winclient && winclient != &fbwindow().winClient()) { + fbwindow().setCurrentClient(*winclient, true); + } +} + +REGISTER_COMMAND(activatetab, ActivateTabCmd, void); + } // end anonymous namespace void SetHeadCmd::real_execute() { diff --git a/src/Keys.cc b/src/Keys.cc index e8e2ab7c..7cd77eb9 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -354,6 +354,8 @@ void Keys::loadDefaults() { addBinding("OnDesktop Mouse2 :WorkspaceMenu"); addBinding("OnDesktop Mouse3 :RootMenu"); addBinding("OnTitlebar Mouse3 :WindowMenu"); + addBinding("OnWindow Mouse1 :MacroCmd {Raise} {Focus} {StartMoving}"); + addBinding("OnTitlebar Mouse1 :MacroCmd {ActivateTab} {Raise} {Focus}"); addBinding("OnTitlebar Move1 :StartMoving"); addBinding("OnLeftGrip Move1 :StartResizing bottomleft"); addBinding("OnRightGrip Move1 :StartResizing bottomright"); diff --git a/src/Window.cc b/src/Window.cc index 56cbd965..bf100e27 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -812,16 +812,10 @@ FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x &labelbutton)) return m_clientlist.end(); - Client2ButtonMap::iterator it = - find_if(m_labelbuttons.begin(), - m_labelbuttons.end(), - Compose(bind2nd(equal_to(), labelbutton), - Compose(mem_fun(&TextButton::window), - Select2nd()))); - + WinClient* c = winClientOfLabelButtonWindow(labelbutton); // label button not found - if (it == m_labelbuttons.end()) + if (!c) return m_clientlist.end(); Window child_return=0; @@ -834,8 +828,8 @@ FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x ClientList::iterator client = find(m_clientlist.begin(), m_clientlist.end(), - it->first); - if (x > static_cast((*it).second->width()) / 2) + c); + if (x > static_cast(m_labelbuttons[c]->width()) / 2) client++; return client; @@ -853,15 +847,9 @@ void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) { &labelbutton)) return; - Client2ButtonMap::iterator it = - find_if(m_labelbuttons.begin(), - m_labelbuttons.end(), - Compose(bind2nd(equal_to(), labelbutton), - Compose(mem_fun(&TextButton::window), - Select2nd()))); + WinClient* client = winClientOfLabelButtonWindow(labelbutton); - // label button not found - if (it == m_labelbuttons.end()) + if (!client) return; Window child_return = 0; @@ -871,10 +859,10 @@ void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) { dest_x, dest_y, &x, &y, &child_return)) return; - if (x > static_cast((*it).second->width()) / 2) - moveClientRightOf(win, *it->first); + if (x > static_cast(m_labelbuttons[client]->width()) / 2) + moveClientRightOf(win, *client); else - moveClientLeftOf(win, *it->first); + moveClientLeftOf(win, *client); } @@ -2360,40 +2348,15 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) { frame().insideTitlebar( be.window ) && frame().handle().window() != be.window; -#if 0 // disabled - if (onTitlebar && be.button == 1) - raise(); -#endif - - // check keys file first Keys *k = Fluxbox::instance()->keys(); - if ((onTitlebar && k->doAction(be.type, be.state, be.button, - Keys::ON_TITLEBAR, m_client, be.time)) || - k->doAction(be.type, be.state, be.button, Keys::ON_WINDOW, m_client, - be.time)) { + if ((onTitlebar && k->doAction(be.type, be.state, be.button, Keys::ON_TITLEBAR, &winClient(), be.time)) || + k->doAction(be.type, be.state, be.button, Keys::ON_WINDOW, &winClient(), be.time)) { + return; } - frame().tabcontainer().tryButtonPressEvent(be); - if (be.button == 1) { - if (frame().window().window() == be.window || - frame().tabcontainer().window() == be.window) { - if (screen().clickRaises()) - raise(); - fbdbg<<"FluxboxWindow::buttonPressEvent: AllowEvent"<(), ev.window), - Compose(mem_fun(&TextButton::window), - Select2nd()))); - if (it != m_labelbuttons.end()) - client = (*it).first; - + client = winClientOfLabelButtonWindow(ev.window); } if (ev.window == frame().window() || @@ -3149,21 +3104,26 @@ void FluxboxWindow::stopResizing(bool interrupted) { ungrabPointer(CurrentTime); } +WinClient* FluxboxWindow::winClientOfLabelButtonWindow(Window window) { + WinClient* result = 0; + Client2ButtonMap::iterator it = + find_if(m_labelbuttons.begin(), + m_labelbuttons.end(), + Compose(bind2nd(equal_to(), window), + Compose(mem_fun(&FbTk::Button::window), + Select2nd()))); + if (it != m_labelbuttons.end()) + result = it->first; + + return result; +} + void FluxboxWindow::startTabbing(const XButtonEvent &be) { if (s_num_grabs > 0) return; - m_attaching_tab = 0; - // determine if we're in titlebar - Client2ButtonMap::iterator it = - find_if(m_labelbuttons.begin(), - m_labelbuttons.end(), - Compose(bind2nd(equal_to(), be.window), - Compose(mem_fun(&TextButton::window), - Select2nd()))); - if (it != m_labelbuttons.end()) - m_attaching_tab = it->first; + m_attaching_tab = winClientOfLabelButtonWindow(be.window); // start drag'n'drop for tab grabPointer(be.window, False, ButtonMotionMask | @@ -3704,8 +3664,6 @@ void FluxboxWindow::associateClient(WinClient &client) { frame().theme().unfocusedTheme()->iconbarTheme(), client); frame().createTab(*btn); - FbTk::RefCount > setcmd(new SetClientCmd(client)); - btn->setOnClick(setcmd, 1); btn->setTextPadding(Fluxbox::instance()->getTabsPadding()); btn->setPixmap(screen().getTabsUsePixmap()); @@ -3715,6 +3673,7 @@ void FluxboxWindow::associateClient(WinClient &client) { evm.add(*this, btn->window()); // we take care of button events for this evm.add(*this, client.window()); + client.setFluxboxWindow(this); join(client.titleSig(), FbTk::MemFun(*this, &FluxboxWindow::setTitle)); diff --git a/src/Window.hh b/src/Window.hh index 5554ad3f..d7fd8128 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -398,6 +398,8 @@ public: WinClient &winClient() { return *m_client; } const WinClient &winClient() const { return *m_client; } + WinClient* winClientOfLabelButtonWindow(Window w); + bool isTyping() const; const FbTk::XLayerItem &layerItem() const { return m_frame.layerItem(); } diff --git a/src/fluxbox.cc b/src/fluxbox.cc index e8445bbf..192b44c5 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -605,7 +605,7 @@ void Fluxbox::setupConfigFiles() { if (create_windowmenu) FbTk::FileUtil::copyFile(DEFAULT_WINDOWMENU, windowmenu_file.c_str()); -#define CONFIG_VERSION 11 +#define CONFIG_VERSION 12 FbTk::Resource config_version(m_resourcemanager, 0, "session.configVersion", "Session.ConfigVersion"); if (*config_version < CONFIG_VERSION) { diff --git a/util/fluxbox-update_configs.cc b/util/fluxbox-update_configs.cc index f4a2019f..129833c8 100644 --- a/util/fluxbox-update_configs.cc +++ b/util/fluxbox-update_configs.cc @@ -391,11 +391,27 @@ int run_updates(int old_version, FbTk::ResourceManager &rm) { new_keyfile += "OnWindowBorder Move1 :StartMoving\n\n"; new_keyfile += whole_keyfile; // don't forget user's old keybindings + new_keyfile += "\n"; // just for good looks write_file(keyfilename, new_keyfile); new_version = 11; } + if (old_version < 12) { // update keys for ActivateTab + + string whole_file = read_file(keyfilename); + string new_keyfile = ""; + + new_keyfile += "!mouse actions added by fluxbox-update_configs\n"; + new_keyfile += "OnTitlebar Mouse1 :MacroCmd {ActivateTab} {Raise} {Focus}\n"; + new_keyfile += whole_file; + + new_keyfile += "\n"; // just for good looks + write_file(keyfilename, new_keyfile); + + new_version = 12; + } + return new_version; }