From 5c5ad62846f9041684458c0ed38c4b135b7f294d Mon Sep 17 00:00:00 2001 From: Julien Viard de Galbert Date: Tue, 6 Nov 2012 21:04:57 +0100 Subject: 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. --- src/FbWinFrame.cc | 49 ++++++++++++++++++++++++++++++++++++++++++++++ src/FbWinFrame.hh | 4 ++++ src/Keys.cc | 2 ++ src/Window.cc | 58 +++++-------------------------------------------------- 4 files changed, 60 insertions(+), 53 deletions(-) diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 53cecf7..937f87f 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -35,10 +35,13 @@ #include "Screen.hh" #include "FocusableTheme.hh" #include "IconButton.hh" +#include "RectangleUtil.hh" #include #include +#include "Keys.hh" + using std::max; using std::mem_fun; using std::string; @@ -1727,3 +1730,49 @@ bool FbWinFrame::insideTitlebar(Window win) const { 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; +} diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 347a668..46c6a7c 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -236,6 +236,10 @@ public: /// 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: diff --git a/src/Keys.cc b/src/Keys.cc index f91c92e..c4ad5ea 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -405,6 +405,8 @@ bool Keys::addBinding(const string &linebuffer) { 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") { diff --git a/src/Window.cc b/src/Window.cc index 2cf776e..1195127 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2324,14 +2324,10 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) { 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,60 +2378,16 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { 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 Fluxbox::instance()->keys()->doAction(me.type, me.state, m_last_pressed_button, context, &winClient(), me.time); -- cgit v0.11.2