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());
|
width, height - titlebarHeight() - handleHeight());
|
||||||
m_screen.showGeometry(i, j);
|
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; }
|
const FbTk::Subject &frameExtentSig() const { return m_frame_extent_sig; }
|
||||||
FbTk::Subject &frameExtentSig() { 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 "FocusControl.hh"
|
||||||
#include "IconButton.hh"
|
#include "IconButton.hh"
|
||||||
#include "ScreenPlacement.hh"
|
#include "ScreenPlacement.hh"
|
||||||
|
#include "RectangleUtil.hh"
|
||||||
|
|
||||||
#include "FbTk/StringUtil.hh"
|
#include "FbTk/StringUtil.hh"
|
||||||
#include "FbTk/Compose.hh"
|
#include "FbTk/Compose.hh"
|
||||||
|
@ -2362,10 +2363,9 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
|
||||||
m_last_button_x = be.x_root;
|
m_last_button_x = be.x_root;
|
||||||
m_last_button_y = be.y_root;
|
m_last_button_y = be.y_root;
|
||||||
|
|
||||||
bool onTitlebar = frame().gripLeft().window() != be.window &&
|
bool onTitlebar =
|
||||||
frame().gripRight().window() != be.window &&
|
frame().insideTitlebar( be.window ) &&
|
||||||
frame().handle().window() != be.window &&
|
frame().handle().window() != be.window;
|
||||||
frame().window() != be.window;
|
|
||||||
|
|
||||||
if (onTitlebar && be.button == 1)
|
if (onTitlebar && be.button == 1)
|
||||||
raise();
|
raise();
|
||||||
|
@ -2422,41 +2422,31 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
|
||||||
me.window = frame().window().window();
|
me.window = frame().window().window();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inside_titlebar = frame().gripLeft().window() != me.window &&
|
bool inside_titlebar = frame().insideTitlebar( me.window );
|
||||||
frame().gripRight().window() != me.window &&
|
|
||||||
frame().window() != me.window;
|
|
||||||
|
|
||||||
if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0
|
if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0
|
||||||
&& !(isMoving() || isResizing())) {
|
&& !(isMoving() || isResizing())) {
|
||||||
|
|
||||||
|
using RectangleUtil::insideBorder;
|
||||||
|
|
||||||
int borderw = frame().window().borderWidth();
|
int borderw = frame().window().borderWidth();
|
||||||
//!! TODO(tabs): the below test ought to be in FbWinFrame
|
//!! TODO(tabs): the below test ought to be in FbWinFrame
|
||||||
// if mouse is currently on the window border, ignore it
|
// if mouse is currently on the window border, ignore it
|
||||||
if ((me.x_root < (frame().x() + borderw) ||
|
if ( ! insideBorder(frame(),
|
||||||
me.y_root < (frame().y() + borderw) ||
|
me.x_root, me.y_root, borderw) &&
|
||||||
me.x_root >= (frame().x() + (int)frame().width() + borderw) ||
|
( !frame().externalTabMode() ||
|
||||||
me.y_root >= (frame().y() + (int)frame().height() + borderw))
|
! insideBorder(frame().tabcontainer(),
|
||||||
&& (!frame().externalTabMode() ||
|
me.x_root, me.y_root, borderw) )
|
||||||
(me.x_root < (frame().tabcontainer().x() + borderw) ||
|
|
||||||
me.y_root < (frame().tabcontainer().y() + borderw) ||
|
|| // or if mouse was on border when it was last clicked
|
||||||
me.x_root >= (frame().tabcontainer().x() +
|
|
||||||
(int)frame().tabcontainer().width() + borderw) ||
|
! insideBorder(frame(),
|
||||||
me.y_root >= (frame().tabcontainer().y() +
|
m_last_button_x, m_last_button_y, borderw) &&
|
||||||
(int)frame().tabcontainer().height() + borderw)))
|
( ! frame().externalTabMode() ||
|
||||||
// or if mouse was on border when it was last clicked
|
! insideBorder(frame().tabcontainer(),
|
||||||
|| (m_last_button_x < (frame().x() + borderw) ||
|
m_last_button_x, m_last_button_y, 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))))
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moving || ((me.state & Button1Mask) && functions.move &&
|
if (moving || ((me.state & Button1Mask) && functions.move &&
|
||||||
|
|
Loading…
Reference in a new issue