commit ee687af76506d42fafa843bf9d2cfb5da55337da
parent 7c50a0b1a85717149189755c8d9f5cae104ebff6
Author: cfillion <cfillion@users.noreply.github.com>
Date: Mon, 20 Jun 2016 20:17:12 -0400
mild refactoring – use PtInRect instead of custom logic
Diffstat:
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/dialog.cpp b/src/dialog.cpp
@@ -338,6 +338,9 @@ void Dialog::onContextMenu(HWND target, const int x, const int y)
if(!IsWindowVisible(ctrl->handle()))
continue;
+ // target HWND is not always accurate:
+ // on OS X it does not match the listview when hovering the column header
+
RECT rect;
GetWindowRect(ctrl->handle(), &rect);
@@ -346,12 +349,8 @@ void Dialog::onContextMenu(HWND target, const int x, const int y)
swap(rect.top, rect.bottom);
#endif
- // target HWND is not always accurate:
- // on OS X it does not match the listview when hovering the column header
- const bool inRect = y >= rect.top && y <= rect.bottom
- && x >= rect.left && x <= rect.right;
-
- if(target == ctrl->handle() || inRect) {
+ const POINT point{x, y};
+ if(target == ctrl->handle() || PtInRect(&rect, point)) {
if(ctrl->onContextMenu(m_handle, x, y))
return;
}