some minor code cleaning.
This commit is contained in:
parent
de8275f688
commit
9f519ec0fc
4 changed files with 62 additions and 32 deletions
|
@ -1717,3 +1717,10 @@ void FbWinFrame::displaySize(unsigned int width, unsigned int height) const {
|
|||
width, height - titlebarHeight() - handleHeight());
|
||||
m_screen.showGeometry(i, j);
|
||||
}
|
||||
|
||||
bool FbWinFrame::insideTitlebar(Window win) const {
|
||||
return
|
||||
gripLeft().window() != win &&
|
||||
gripRight().window() != win &&
|
||||
window().window() != win;
|
||||
}
|
||||
|
|
|
@ -236,6 +236,9 @@ public:
|
|||
|
||||
const FbTk::Subject &frameExtentSig() const { return m_frame_extent_sig; }
|
||||
FbTk::Subject &frameExtentSig() { return m_frame_extent_sig; }
|
||||
/// @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;
|
||||
|
||||
//@}
|
||||
|
||||
|
|
30
src/RectangleUtil.hh
Normal file
30
src/RectangleUtil.hh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef RECTANGLEUTIL_HH
|
||||
#define RECTANGLEUTIL_HH
|
||||
|
||||
namespace RectangleUtil {
|
||||
|
||||
|
||||
/*
|
||||
* Determines if a point is inside a rectangle-like objects border.
|
||||
* @param rect A rectangle-like object that has accessors for x, y, width, and
|
||||
* height.
|
||||
* @param x
|
||||
* @param y
|
||||
* @param border_width The size of the border.
|
||||
* @returns true if point is inside the rectangle-like object.
|
||||
*/
|
||||
template <typename RectangleLike>
|
||||
bool insideBorder(const RectangleLike& rect,
|
||||
int x, int y,
|
||||
int border_width) {
|
||||
return
|
||||
x >= rect.x() + border_width &&
|
||||
x < rect.x() + (int)rect.width() + border_width &&
|
||||
y >= rect.y() + border_width &&
|
||||
y < rect.y() + (int)rect.height() + border_width;
|
||||
}
|
||||
|
||||
} // namespace RectangleUtil
|
||||
|
||||
|
||||
#endif // RECTANGLEUTIL_HH
|
|
@ -41,6 +41,7 @@
|
|||
#include "FocusControl.hh"
|
||||
#include "IconButton.hh"
|
||||
#include "ScreenPlacement.hh"
|
||||
#include "RectangleUtil.hh"
|
||||
|
||||
#include "FbTk/StringUtil.hh"
|
||||
#include "FbTk/Compose.hh"
|
||||
|
@ -2362,10 +2363,9 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
|
|||
m_last_button_x = be.x_root;
|
||||
m_last_button_y = be.y_root;
|
||||
|
||||
bool onTitlebar = frame().gripLeft().window() != be.window &&
|
||||
frame().gripRight().window() != be.window &&
|
||||
frame().handle().window() != be.window &&
|
||||
frame().window() != be.window;
|
||||
bool onTitlebar =
|
||||
frame().insideTitlebar( be.window ) &&
|
||||
frame().handle().window() != be.window;
|
||||
|
||||
if (onTitlebar && be.button == 1)
|
||||
raise();
|
||||
|
@ -2422,41 +2422,31 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
|
|||
me.window = frame().window().window();
|
||||
}
|
||||
|
||||
bool inside_titlebar = frame().gripLeft().window() != me.window &&
|
||||
frame().gripRight().window() != me.window &&
|
||||
frame().window() != me.window;
|
||||
bool inside_titlebar = frame().insideTitlebar( me.window );
|
||||
|
||||
if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0
|
||||
&& !(isMoving() || isResizing())) {
|
||||
|
||||
using RectangleUtil::insideBorder;
|
||||
|
||||
int borderw = frame().window().borderWidth();
|
||||
//!! TODO(tabs): the below test ought to be in FbWinFrame
|
||||
// if mouse is currently on the window border, ignore it
|
||||
if ((me.x_root < (frame().x() + borderw) ||
|
||||
me.y_root < (frame().y() + borderw) ||
|
||||
me.x_root >= (frame().x() + (int)frame().width() + borderw) ||
|
||||
me.y_root >= (frame().y() + (int)frame().height() + borderw))
|
||||
&& (!frame().externalTabMode() ||
|
||||
(me.x_root < (frame().tabcontainer().x() + borderw) ||
|
||||
me.y_root < (frame().tabcontainer().y() + borderw) ||
|
||||
me.x_root >= (frame().tabcontainer().x() +
|
||||
(int)frame().tabcontainer().width() + borderw) ||
|
||||
me.y_root >= (frame().tabcontainer().y() +
|
||||
(int)frame().tabcontainer().height() + borderw)))
|
||||
// or if mouse was on border when it was last clicked
|
||||
|| (m_last_button_x < (frame().x() + borderw) ||
|
||||
m_last_button_y < (frame().y() + borderw) ||
|
||||
m_last_button_x >= (frame().x() +
|
||||
(int)frame().width() + borderw) ||
|
||||
m_last_button_y >= (frame().y() +
|
||||
(int)frame().height() + borderw))
|
||||
&& (!frame().externalTabMode() ||
|
||||
(m_last_button_x < (frame().tabcontainer().x() + borderw) ||
|
||||
m_last_button_y < (frame().tabcontainer().y() + borderw) ||
|
||||
m_last_button_x >= (frame().tabcontainer().x() +
|
||||
(int)frame().tabcontainer().width() + borderw) ||
|
||||
m_last_button_y >= (frame().tabcontainer().y() +
|
||||
(int)frame().tabcontainer().height() + borderw))))
|
||||
if ( ! 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 ) ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (moving || ((me.state & Button1Mask) && functions.move &&
|
||||
|
|
Loading…
Reference in a new issue