Adds the OnTab keyword for the keys file Adding the following lines to the keys file restore the old behaviour to use Mouse2 on tabs to start tabbing, and keep OnTitlebar Mouse2 to lower the window. OnTab Mouse2 :StartTabbing OnTab Move1 :StartMoving Note: Internal tabs are triggering both OnTab and OnTitlebar events.
Julien Viard de Galbert julien@vdg.blogsite.org
4 files changed,
60 insertions(+),
53 deletions(-)
M
src/FbWinFrame.cc
→
src/FbWinFrame.cc
@@ -35,9 +35,12 @@ #include "FbWinFrameTheme.hh"
#include "Screen.hh" #include "FocusableTheme.hh" #include "IconButton.hh" +#include "RectangleUtil.hh" #include <algorithm> #include <X11/X.h> + +#include "Keys.hh" using std::max; using std::mem_fun;@@ -1727,3 +1730,49 @@ gripLeft().window() != win &&
gripRight().window() != win && window().window() != win; } + +int FbWinFrame::getContext(Window win, int x, int y, int last_x, int last_y, bool doBorders) { + int context = 0; + if (gripLeft().window() == win) return Keys::ON_LEFTGRIP; + if (gripRight().window() == win) return Keys::ON_RIGHTGRIP; + if (doBorders) { + using RectangleUtil::insideBorder; + int borderw = window().borderWidth(); + if ( // if mouse is currently on the window border, ignore it + ( + ! insideBorder(window(), x, y, borderw) + && ( externalTabMode() + || ! insideBorder(tabcontainer(), x, y, borderw) ) + ) + || // or if mouse was on border when it was last clicked + ( + ! insideBorder(window(), last_x, last_y, borderw) + && ( externalTabMode() + || ! insideBorder(tabcontainer(), last_x, last_y, borderw ) ) + ) + ) context = Keys::ON_WINDOWBORDER; + } + + if (window().window() == win) return context | Keys::ON_WINDOW; + // /!\ old code: handle = titlebar in motionNotifyEvent but only there ! + // handle() as border ?? + if (handle().window() == win) return Keys::ON_WINDOWBORDER | Keys::ON_WINDOW; + if (titlebar().window() == win) return context | Keys::ON_TITLEBAR; + if (label().window() == win) return context | Keys::ON_TITLEBAR; + // internal tabs are on title bar + if (tabcontainer().window() == win) + return context | Keys::ON_TAB | (externalTabMode()?0:Keys::ON_TITLEBAR); + + + FbTk::Container::ItemList::iterator it = tabcontainer().begin(); + FbTk::Container::ItemList::iterator it_end = tabcontainer().end(); + for (; it != it_end; ++it) { + if ((*it)->window() == win) + break; + } + // internal tabs are on title bar + if (it != it_end) + return context | Keys::ON_TAB | (externalTabMode()?0:Keys::ON_TITLEBAR); + + return context; +}
M
src/FbWinFrame.hh
→
src/FbWinFrame.hh
@@ -236,6 +236,10 @@ /// @returns true if the window is inside titlebar,
/// assuming window is an event window that was generated for this frame. bool insideTitlebar(Window win) const; + /// @returns context for window, + /// assuming window is an event window that was generated for this frame. + int getContext(Window win, int x=0, int y=0, int last_x=0, int last_y=0, bool doBorders=false); + //@} private:
M
src/Keys.cc
→
src/Keys.cc
@@ -405,6 +405,8 @@ else if (arg == "onleftgrip")
context |= ON_LEFTGRIP; else if (arg == "onrightgrip") context |= ON_RIGHTGRIP; + else if (arg == "ontab") + context |= ON_TAB; else if (arg == "double") isdouble = true; else if (arg != "none") {
M
src/Window.cc
→
src/Window.cc
@@ -2324,14 +2324,10 @@ m_last_button_x = be.x_root;
m_last_button_y = be.y_root; m_last_pressed_button = be.button; - bool onTitlebar = - frame().insideTitlebar( be.window ) && - frame().handle().window() != be.window; - Keys *k = Fluxbox::instance()->keys(); - 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)) { - + int context = frame().getContext(be.window); + if (k->doAction(be.type, be.state, be.button, + context, &winClient(), be.time)) { return; }@@ -2382,59 +2378,15 @@ if (isMoving() && me.window == parent()) {
me.window = frame().window().window(); } - bool inside_titlebar = frame().insideTitlebar( me.window ); - bool inside_grips = (me.window == frame().gripRight() || me.window == frame().gripLeft()); - bool inside_border = false; - - if (!inside_grips) - { - using RectangleUtil::insideBorder; - int borderw = frame().window().borderWidth(); - - - //!! TODO(tabs): the below test ought to be in FbWinFrame - - inside_border = - - // if mouse is currently on the window border, ignore it - ( - ! insideBorder(frame(), me.x_root, me.y_root, borderw) - && ( !frame().externalTabMode() - || ! insideBorder(frame().tabcontainer(), me.x_root, me.y_root, borderw) ) - - ) - - || // or if mouse was on border when it was last clicked - - ( - ! insideBorder(frame(), m_last_button_x, m_last_button_y, borderw) - && - ( ! frame().externalTabMode() - || ! insideBorder(frame().tabcontainer(), m_last_button_x, m_last_button_y, borderw ) - ) - ); - } + int context = frame().getContext(me.window, me.x_root, me.y_root, m_last_button_x, m_last_button_y, true); if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0 && !(isMoving() || isResizing())) { - if (inside_border) { + if (context & Keys::ON_WINDOWBORDER) { return; } } - - - int context = Keys::ON_WINDOW; - if (inside_titlebar) { - context = Keys::ON_TITLEBAR; - } else if (inside_border) { - context = Keys::ON_WINDOWBORDER; - } else if (me.window == frame().gripRight()) { - context = Keys::ON_RIGHTGRIP; - } else if (me.window == frame().gripLeft()) { - context = Keys::ON_LEFTGRIP; - } - // in case someone put MoveX :StartMoving etc into keys, we have // to activate it before doing the actual motionNotify code