>From ak|ra -- posting to the correct bug
---------- Forwarded message ----------
From: Mathias Gumz <[email protected]>
Date: Fri, Aug 20, 2010 at 6:12 AM
Subject: Re: Bug#592904: Tab activation
To: Paul Tagliamonte <[email protected]>
Cc: "Chanoch (Ken) Bloom" <[email protected]>
--
[uid] mathias gumz [mail] akira at fluxbox dot org [pgp] 1024D/F6F6B18C
[www] http://www.darkshed.net/ [irc] ak|ra (#fluxbox at freenode.org)
ebar .)
add something like
OnTitlebar Mouse1 :MacroCmd {ActivateTab} {StartMoving}
to your .fluxbox/keys and see if it works. i tried it here (and it
works for me, with external and internal tabs) but i want to test it a
bit more by "real" users before i want to push it.
cheers,
mathias
--
[uid] mathias gumz [mail] akira at fluxbox dot org [pgp] 1024D/F6F6B18C
[www] http://www.darkshed.net/ [irc] ak|ra (#fluxbox at freenode.org)
--
#define sizeof(x) rand()
:wq
this patch tries to solve the "click to titlebar and activate a tab" bug
add something like this to your .fluxbox/keys file:
OnTitlebar Mouse1 :MacroCmd {ActivateTab} {StartMoving}
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc
index 713c32a..4d25d54 100644
--- a/src/CurrentWindowCmd.cc
+++ b/src/CurrentWindowCmd.cc
@@ -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() {
diff --git a/src/Keys.cc b/src/Keys.cc
index e8e2ab7..1703874 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -354,7 +354,7 @@ void Keys::loadDefaults() {
addBinding("OnDesktop Mouse2 :WorkspaceMenu");
addBinding("OnDesktop Mouse3 :RootMenu");
addBinding("OnTitlebar Mouse3 :WindowMenu");
- addBinding("OnTitlebar Move1 :StartMoving");
+ addBinding("OnTitlebar Move1 :MacroCmd {ActivateTab} {StartMoving}");
addBinding("OnLeftGrip Move1 :StartResizing bottomleft");
addBinding("OnRightGrip Move1 :StartResizing bottomright");
addBinding("OnWindowBorder Move1 :StartMoving");
diff --git a/src/Window.cc b/src/Window.cc
index 56cbd96..974124b 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<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);
}
-void FluxboxWindow::startTabbing(const XButtonEvent &be) {
-
- if (s_num_grabs > 0)
- return;
-
- m_attaching_tab = 0;
- // determine if we're in titlebar
+WinClient* FluxboxWindow::winClientOfLabelButtonWindow(Window window) {
+ WinClient* result = 0;
Client2ButtonMap::iterator it =
find_if(m_labelbuttons.begin(),
m_labelbuttons.end(),
- Compose(bind2nd(equal_to<Window>(), be.window),
- Compose(mem_fun(&TextButton::window),
+ Compose(bind2nd(equal_to<Window>(), window),
+ Compose(mem_fun(&FbTk::Button::window),
Select2nd<Client2ButtonMap::value_type>())));
if (it != m_labelbuttons.end())
- m_attaching_tab = it->first;
+ result = it->first;
+
+ return result;
+}
+
+void FluxboxWindow::startTabbing(const XButtonEvent &be) {
+
+ if (s_num_grabs > 0)
+ return;
+
+ m_attaching_tab = winClientOfLabelButtonWindow(be.window);
// start drag'n'drop for tab
grabPointer(be.window, False, ButtonMotionMask |
diff --git a/src/Window.hh b/src/Window.hh
index 5554ad3..d7fd812 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(); }