implemented 'ActivateTab' action to (re)allow activation of tabs via mouse

This commit is contained in:
Mathias Gumz 2010-08-20 19:01:25 +02:00
parent b4e65724ef
commit bc2b21547b
8 changed files with 77 additions and 73 deletions

View file

@ -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

View file

@ -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

View file

@ -223,6 +223,27 @@ FbTk::Command<void> *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() {

View file

@ -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");

View file

@ -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<Window>(), labelbutton),
Compose(mem_fun(&TextButton::window),
Select2nd<Client2ButtonMap::value_type>())));
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<signed>((*it).second->width()) / 2)
c);
if (x > static_cast<signed>(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<Window>(), labelbutton),
Compose(mem_fun(&TextButton::window),
Select2nd<Client2ButtonMap::value_type>())));
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<signed>((*it).second->width()) / 2)
moveClientRightOf(win, *it->first);
if (x > static_cast<signed>(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"<<endl;
XAllowEvents(display, ReplayPointer, be.time);
m_button_grab_x = be.x_root - frame().x() - frame().window().borderWidth();
m_button_grab_y = be.y_root - frame().y() - frame().window().borderWidth();
} else if (frame().handle() == be.window)
raise();
FbTk::Menu::hideShownMenu();
if (!m_focused && acceptsFocus() && m_click_focus) //check focus
focus();
}
XAllowEvents(display, ReplayPointer, be.time);
}
void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) {
@ -2650,15 +2613,7 @@ void FluxboxWindow::enterNotifyEvent(XCrossingEvent &ev) {
WinClient *client = 0;
if (screen().focusControl().isMouseTabFocus()) {
// determine if we're in a label button (tab)
Client2ButtonMap::iterator it =
find_if(m_labelbuttons.begin(),
m_labelbuttons.end(),
Compose(bind2nd(equal_to<Window>(), ev.window),
Compose(mem_fun(&TextButton::window),
Select2nd<Client2ButtonMap::value_type>())));
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>(), window),
Compose(mem_fun(&FbTk::Button::window),
Select2nd<Client2ButtonMap::value_type>())));
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<Window>(), be.window),
Compose(mem_fun(&TextButton::window),
Select2nd<Client2ButtonMap::value_type>())));
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<FbTk::Command<void> > 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));

View file

@ -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(); }

View file

@ -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<int> config_version(m_resourcemanager, 0,
"session.configVersion", "Session.ConfigVersion");
if (*config_version < CONFIG_VERSION) {

View file

@ -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;
}