all repos — fluxbox @ 9f519ec0fcb7cd0dec61a4c31d246800f9a73cb3

custom fork of the fluxbox windowmanager

some minor code cleaning.
Henrik Kinnunen fluxgen@fluxbox.org
commit

9f519ec0fcb7cd0dec61a4c31d246800f9a73cb3

parent

de8275f68860f8088c582f0e02494b5a46c871d5

4 files changed, 62 insertions(+), 32 deletions(-)

jump to
M src/FbWinFrame.ccsrc/FbWinFrame.cc

@@ -1717,3 +1717,10 @@ sizeHints().displaySize(i, j,

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; +}
M src/FbWinFrame.hhsrc/FbWinFrame.hh

@@ -236,6 +236,9 @@ FbTk::XLayerItem &layerItem() { return m_layeritem; }

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; //@}
A src/RectangleUtil.hh

@@ -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
M src/Window.ccsrc/Window.cc

@@ -41,6 +41,7 @@ #include "MenuCreator.hh"

#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 @@ if (isMoving() && me.window == parent()) {

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 &&