diff options
-rw-r--r-- | src/FbWinFrame.cc | 7 | ||||
-rw-r--r-- | src/FbWinFrame.hh | 3 | ||||
-rw-r--r-- | src/RectangleUtil.hh | 30 | ||||
-rw-r--r-- | src/Window.cc | 54 |
4 files changed, 62 insertions, 32 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 5b91218..fc35ae1 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -1717,3 +1717,10 @@ void FbWinFrame::displaySize(unsigned int width, unsigned int height) const { | |||
1717 | width, height - titlebarHeight() - handleHeight()); | 1717 | width, height - titlebarHeight() - handleHeight()); |
1718 | m_screen.showGeometry(i, j); | 1718 | m_screen.showGeometry(i, j); |
1719 | } | 1719 | } |
1720 | |||
1721 | bool FbWinFrame::insideTitlebar(Window win) const { | ||
1722 | return | ||
1723 | gripLeft().window() != win && | ||
1724 | gripRight().window() != win && | ||
1725 | window().window() != win; | ||
1726 | } | ||
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index fcbe11e..ff9c19e 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh | |||
@@ -236,6 +236,9 @@ public: | |||
236 | 236 | ||
237 | const FbTk::Subject &frameExtentSig() const { return m_frame_extent_sig; } | 237 | const FbTk::Subject &frameExtentSig() const { return m_frame_extent_sig; } |
238 | FbTk::Subject &frameExtentSig() { return m_frame_extent_sig; } | 238 | FbTk::Subject &frameExtentSig() { return m_frame_extent_sig; } |
239 | /// @returns true if the window is inside titlebar, | ||
240 | /// assuming window is an event window that was generated for this frame. | ||
241 | bool insideTitlebar(Window win) const; | ||
239 | 242 | ||
240 | //@} | 243 | //@} |
241 | 244 | ||
diff --git a/src/RectangleUtil.hh b/src/RectangleUtil.hh new file mode 100644 index 0000000..88c3a33 --- /dev/null +++ b/src/RectangleUtil.hh | |||
@@ -0,0 +1,30 @@ | |||
1 | #ifndef RECTANGLEUTIL_HH | ||
2 | #define RECTANGLEUTIL_HH | ||
3 | |||
4 | namespace RectangleUtil { | ||
5 | |||
6 | |||
7 | /* | ||
8 | * Determines if a point is inside a rectangle-like objects border. | ||
9 | * @param rect A rectangle-like object that has accessors for x, y, width, and | ||
10 | * height. | ||
11 | * @param x | ||
12 | * @param y | ||
13 | * @param border_width The size of the border. | ||
14 | * @returns true if point is inside the rectangle-like object. | ||
15 | */ | ||
16 | template <typename RectangleLike> | ||
17 | bool insideBorder(const RectangleLike& rect, | ||
18 | int x, int y, | ||
19 | int border_width) { | ||
20 | return | ||
21 | x >= rect.x() + border_width && | ||
22 | x < rect.x() + (int)rect.width() + border_width && | ||
23 | y >= rect.y() + border_width && | ||
24 | y < rect.y() + (int)rect.height() + border_width; | ||
25 | } | ||
26 | |||
27 | } // namespace RectangleUtil | ||
28 | |||
29 | |||
30 | #endif // RECTANGLEUTIL_HH | ||
diff --git a/src/Window.cc b/src/Window.cc index 16334c6..5d50fcf 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -41,6 +41,7 @@ | |||
41 | #include "FocusControl.hh" | 41 | #include "FocusControl.hh" |
42 | #include "IconButton.hh" | 42 | #include "IconButton.hh" |
43 | #include "ScreenPlacement.hh" | 43 | #include "ScreenPlacement.hh" |
44 | #include "RectangleUtil.hh" | ||
44 | 45 | ||
45 | #include "FbTk/StringUtil.hh" | 46 | #include "FbTk/StringUtil.hh" |
46 | #include "FbTk/Compose.hh" | 47 | #include "FbTk/Compose.hh" |
@@ -2362,10 +2363,9 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) { | |||
2362 | m_last_button_x = be.x_root; | 2363 | m_last_button_x = be.x_root; |
2363 | m_last_button_y = be.y_root; | 2364 | m_last_button_y = be.y_root; |
2364 | 2365 | ||
2365 | bool onTitlebar = frame().gripLeft().window() != be.window && | 2366 | bool onTitlebar = |
2366 | frame().gripRight().window() != be.window && | 2367 | frame().insideTitlebar( be.window ) && |
2367 | frame().handle().window() != be.window && | 2368 | frame().handle().window() != be.window; |
2368 | frame().window() != be.window; | ||
2369 | 2369 | ||
2370 | if (onTitlebar && be.button == 1) | 2370 | if (onTitlebar && be.button == 1) |
2371 | raise(); | 2371 | raise(); |
@@ -2422,41 +2422,31 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2422 | me.window = frame().window().window(); | 2422 | me.window = frame().window().window(); |
2423 | } | 2423 | } |
2424 | 2424 | ||
2425 | bool inside_titlebar = frame().gripLeft().window() != me.window && | 2425 | bool inside_titlebar = frame().insideTitlebar( me.window ); |
2426 | frame().gripRight().window() != me.window && | ||
2427 | frame().window() != me.window; | ||
2428 | 2426 | ||
2429 | if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0 | 2427 | if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0 |
2430 | && !(isMoving() || isResizing())) { | 2428 | && !(isMoving() || isResizing())) { |
2429 | |||
2430 | using RectangleUtil::insideBorder; | ||
2431 | |||
2431 | int borderw = frame().window().borderWidth(); | 2432 | int borderw = frame().window().borderWidth(); |
2432 | //!! TODO(tabs): the below test ought to be in FbWinFrame | 2433 | //!! TODO(tabs): the below test ought to be in FbWinFrame |
2433 | // if mouse is currently on the window border, ignore it | 2434 | // if mouse is currently on the window border, ignore it |
2434 | if ((me.x_root < (frame().x() + borderw) || | 2435 | if ( ! insideBorder(frame(), |
2435 | me.y_root < (frame().y() + borderw) || | 2436 | me.x_root, me.y_root, borderw) && |
2436 | me.x_root >= (frame().x() + (int)frame().width() + borderw) || | 2437 | ( !frame().externalTabMode() || |
2437 | me.y_root >= (frame().y() + (int)frame().height() + borderw)) | 2438 | ! insideBorder(frame().tabcontainer(), |
2438 | && (!frame().externalTabMode() || | 2439 | me.x_root, me.y_root, borderw) ) |
2439 | (me.x_root < (frame().tabcontainer().x() + borderw) || | 2440 | |
2440 | me.y_root < (frame().tabcontainer().y() + borderw) || | 2441 | || // or if mouse was on border when it was last clicked |
2441 | me.x_root >= (frame().tabcontainer().x() + | 2442 | |
2442 | (int)frame().tabcontainer().width() + borderw) || | 2443 | ! insideBorder(frame(), |
2443 | me.y_root >= (frame().tabcontainer().y() + | 2444 | m_last_button_x, m_last_button_y, borderw) && |
2444 | (int)frame().tabcontainer().height() + borderw))) | 2445 | ( ! frame().externalTabMode() || |
2445 | // or if mouse was on border when it was last clicked | 2446 | ! insideBorder(frame().tabcontainer(), |
2446 | || (m_last_button_x < (frame().x() + borderw) || | 2447 | m_last_button_x, m_last_button_y, borderw ) ) ) { |
2447 | m_last_button_y < (frame().y() + borderw) || | ||
2448 | m_last_button_x >= (frame().x() + | ||
2449 | (int)frame().width() + borderw) || | ||
2450 | m_last_button_y >= (frame().y() + | ||
2451 | (int)frame().height() + borderw)) | ||
2452 | && (!frame().externalTabMode() || | ||
2453 | (m_last_button_x < (frame().tabcontainer().x() + borderw) || | ||
2454 | m_last_button_y < (frame().tabcontainer().y() + borderw) || | ||
2455 | m_last_button_x >= (frame().tabcontainer().x() + | ||
2456 | (int)frame().tabcontainer().width() + borderw) || | ||
2457 | m_last_button_y >= (frame().tabcontainer().y() + | ||
2458 | (int)frame().tabcontainer().height() + borderw)))) | ||
2459 | return; | 2448 | return; |
2449 | } | ||
2460 | } | 2450 | } |
2461 | 2451 | ||
2462 | if (moving || ((me.state & Button1Mask) && functions.move && | 2452 | if (moving || ((me.state & Button1Mask) && functions.move && |