aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FbWinFrame.cc49
-rw-r--r--src/FbWinFrame.hh4
-rw-r--r--src/Keys.cc2
-rw-r--r--src/Window.cc58
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 @@
35#include "Screen.hh" 35#include "Screen.hh"
36#include "FocusableTheme.hh" 36#include "FocusableTheme.hh"
37#include "IconButton.hh" 37#include "IconButton.hh"
38#include "RectangleUtil.hh"
38 39
39#include <algorithm> 40#include <algorithm>
40#include <X11/X.h> 41#include <X11/X.h>
41 42
43#include "Keys.hh"
44
42using std::max; 45using std::max;
43using std::mem_fun; 46using std::mem_fun;
44using std::string; 47using std::string;
@@ -1727,3 +1730,49 @@ bool FbWinFrame::insideTitlebar(Window win) const {
1727 gripRight().window() != win && 1730 gripRight().window() != win &&
1728 window().window() != win; 1731 window().window() != win;
1729} 1732}
1733
1734int FbWinFrame::getContext(Window win, int x, int y, int last_x, int last_y, bool doBorders) {
1735 int context = 0;
1736 if (gripLeft().window() == win) return Keys::ON_LEFTGRIP;
1737 if (gripRight().window() == win) return Keys::ON_RIGHTGRIP;
1738 if (doBorders) {
1739 using RectangleUtil::insideBorder;
1740 int borderw = window().borderWidth();
1741 if ( // if mouse is currently on the window border, ignore it
1742 (
1743 ! insideBorder(window(), x, y, borderw)
1744 && ( externalTabMode()
1745 || ! insideBorder(tabcontainer(), x, y, borderw) )
1746 )
1747 || // or if mouse was on border when it was last clicked
1748 (
1749 ! insideBorder(window(), last_x, last_y, borderw)
1750 && ( externalTabMode()
1751 || ! insideBorder(tabcontainer(), last_x, last_y, borderw ) )
1752 )
1753 ) context = Keys::ON_WINDOWBORDER;
1754 }
1755
1756 if (window().window() == win) return context | Keys::ON_WINDOW;
1757 // /!\ old code: handle = titlebar in motionNotifyEvent but only there !
1758 // handle() as border ??
1759 if (handle().window() == win) return Keys::ON_WINDOWBORDER | Keys::ON_WINDOW;
1760 if (titlebar().window() == win) return context | Keys::ON_TITLEBAR;
1761 if (label().window() == win) return context | Keys::ON_TITLEBAR;
1762 // internal tabs are on title bar
1763 if (tabcontainer().window() == win)
1764 return context | Keys::ON_TAB | (externalTabMode()?0:Keys::ON_TITLEBAR);
1765
1766
1767 FbTk::Container::ItemList::iterator it = tabcontainer().begin();
1768 FbTk::Container::ItemList::iterator it_end = tabcontainer().end();
1769 for (; it != it_end; ++it) {
1770 if ((*it)->window() == win)
1771 break;
1772 }
1773 // internal tabs are on title bar
1774 if (it != it_end)
1775 return context | Keys::ON_TAB | (externalTabMode()?0:Keys::ON_TITLEBAR);
1776
1777 return context;
1778}
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:
236 /// assuming window is an event window that was generated for this frame. 236 /// assuming window is an event window that was generated for this frame.
237 bool insideTitlebar(Window win) const; 237 bool insideTitlebar(Window win) const;
238 238
239 /// @returns context for window,
240 /// assuming window is an event window that was generated for this frame.
241 int getContext(Window win, int x=0, int y=0, int last_x=0, int last_y=0, bool doBorders=false);
242
239 //@} 243 //@}
240 244
241private: 245private:
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) {
405 context |= ON_LEFTGRIP; 405 context |= ON_LEFTGRIP;
406 else if (arg == "onrightgrip") 406 else if (arg == "onrightgrip")
407 context |= ON_RIGHTGRIP; 407 context |= ON_RIGHTGRIP;
408 else if (arg == "ontab")
409 context |= ON_TAB;
408 else if (arg == "double") 410 else if (arg == "double")
409 isdouble = true; 411 isdouble = true;
410 else if (arg != "none") { 412 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) {
2324 m_last_button_y = be.y_root; 2324 m_last_button_y = be.y_root;
2325 m_last_pressed_button = be.button; 2325 m_last_pressed_button = be.button;
2326 2326
2327 bool onTitlebar =
2328 frame().insideTitlebar( be.window ) &&
2329 frame().handle().window() != be.window;
2330
2331 Keys *k = Fluxbox::instance()->keys(); 2327 Keys *k = Fluxbox::instance()->keys();
2332 if ((onTitlebar && k->doAction(be.type, be.state, be.button, Keys::ON_TITLEBAR, &winClient(), be.time)) || 2328 int context = frame().getContext(be.window);
2333 k->doAction(be.type, be.state, be.button, Keys::ON_WINDOW, &winClient(), be.time)) { 2329 if (k->doAction(be.type, be.state, be.button,
2334 2330 context, &winClient(), be.time)) {
2335 return; 2331 return;
2336 } 2332 }
2337 2333
@@ -2382,60 +2378,16 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2382 me.window = frame().window().window(); 2378 me.window = frame().window().window();
2383 } 2379 }
2384 2380
2385 bool inside_titlebar = frame().insideTitlebar( me.window ); 2381 int context = frame().getContext(me.window, me.x_root, me.y_root, m_last_button_x, m_last_button_y, true);
2386 bool inside_grips = (me.window == frame().gripRight() || me.window == frame().gripLeft());
2387 bool inside_border = false;
2388
2389 if (!inside_grips)
2390 {
2391 using RectangleUtil::insideBorder;
2392 int borderw = frame().window().borderWidth();
2393
2394
2395 //!! TODO(tabs): the below test ought to be in FbWinFrame
2396
2397 inside_border =
2398
2399 // if mouse is currently on the window border, ignore it
2400 (
2401 ! insideBorder(frame(), me.x_root, me.y_root, borderw)
2402 && ( !frame().externalTabMode()
2403 || ! insideBorder(frame().tabcontainer(), me.x_root, me.y_root, borderw) )
2404
2405 )
2406
2407 || // or if mouse was on border when it was last clicked
2408
2409 (
2410 ! insideBorder(frame(), m_last_button_x, m_last_button_y, borderw)
2411 &&
2412 ( ! frame().externalTabMode()
2413 || ! insideBorder(frame().tabcontainer(), m_last_button_x, m_last_button_y, borderw )
2414 )
2415 );
2416 }
2417 2382
2418 if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0 2383 if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0
2419 && !(isMoving() || isResizing())) { 2384 && !(isMoving() || isResizing())) {
2420 2385
2421 if (inside_border) { 2386 if (context & Keys::ON_WINDOWBORDER) {
2422 return; 2387 return;
2423 } 2388 }
2424 } 2389 }
2425 2390
2426
2427 int context = Keys::ON_WINDOW;
2428 if (inside_titlebar) {
2429 context = Keys::ON_TITLEBAR;
2430 } else if (inside_border) {
2431 context = Keys::ON_WINDOWBORDER;
2432 } else if (me.window == frame().gripRight()) {
2433 context = Keys::ON_RIGHTGRIP;
2434 } else if (me.window == frame().gripLeft()) {
2435 context = Keys::ON_LEFTGRIP;
2436 }
2437
2438
2439 // in case someone put MoveX :StartMoving etc into keys, we have 2391 // in case someone put MoveX :StartMoving etc into keys, we have
2440 // to activate it before doing the actual motionNotify code 2392 // to activate it before doing the actual motionNotify code
2441 Fluxbox::instance()->keys()->doAction(me.type, me.state, m_last_pressed_button, context, &winClient(), me.time); 2393 Fluxbox::instance()->keys()->doAction(me.type, me.state, m_last_pressed_button, context, &winClient(), me.time);