[dasher: 128/217] win32 - prevent dasher from starting when obscured by other window.
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 128/217] win32 - prevent dasher from starting when obscured by other window.
- Date: Sat, 27 Feb 2016 12:11:05 +0000 (UTC)
commit 51978d3d0660f324b38fd3d3c030ffe8c22b3f01
Author: ipomoena <amajorek google com>
Date: Wed Nov 18 17:18:21 2015 -0800
win32 - prevent dasher from starting when obscured by other window.
Fixes https://github.com/ipomoena/dasher/issues/57
Src/DasherCore/CircleStartHandler.cpp | 4 ++--
Src/DasherCore/DasherScreen.h | 3 +++
Src/Gtk2/Canvas.h | 2 ++
Src/Win32/Widgets/Screen.cpp | 21 ++++++---------------
Src/Win32/Widgets/Screen.h | 11 ++---------
5 files changed, 15 insertions(+), 26 deletions(-)
---
diff --git a/Src/DasherCore/CircleStartHandler.cpp b/Src/DasherCore/CircleStartHandler.cpp
index b5edc5a..85d68b1 100644
--- a/Src/DasherCore/CircleStartHandler.cpp
+++ b/Src/DasherCore/CircleStartHandler.cpp
@@ -81,8 +81,8 @@ void CCircleStartHandler::Timer(unsigned long iTime, dasherint mouseX, dasherint
CDasherScreen::point ctr = CircleCenter(pView);
screenint x,y;
pView->Dasher2Screen(mouseX, mouseY, x, y);
- x-=ctr.x; y-=ctr.y;
- const bool inCircleNow = x*x + y*y <= (m_iScreenRadius * m_iScreenRadius);
+ int dx=x-ctr.x, dy=y-ctr.y;
+ const bool inCircleNow = dx*dx + dy*dy <= (m_iScreenRadius * m_iScreenRadius) &&
pView->Screen()->IsPointVisible(x,y);
if (inCircleNow) {
if (m_bInCircle) {
diff --git a/Src/DasherCore/DasherScreen.h b/Src/DasherCore/DasherScreen.h
index 48e7ae0..edb9b62 100644
--- a/Src/DasherCore/DasherScreen.h
+++ b/Src/DasherCore/DasherScreen.h
@@ -170,6 +170,9 @@ public:
/// \param pColourScheme A colour scheme that should be used
virtual void SetColourScheme(const Dasher::CColourIO::ColourInfo *pColourScheme) = 0;
+ // Returns true if point on screen is not obscured by another window
+ virtual bool IsPointVisible(screenint x, screenint y) = 0;
+
private:
//! Width and height of the screen
screenint m_iWidth, m_iHeight;
diff --git a/Src/Gtk2/Canvas.h b/Src/Gtk2/Canvas.h
index 05217c7..e505640 100644
--- a/Src/Gtk2/Canvas.h
+++ b/Src/Gtk2/Canvas.h
@@ -185,6 +185,8 @@ public:
// Redeclare to make public and adjust cairo/gdk surface sizes
void resize(screenint w,screenint h);
+ // Returns true if point on screen is not obscured by another window
+ bool IsPointVisible(screenint x, screenint y) override { return true; }
private:
diff --git a/Src/Win32/Widgets/Screen.cpp b/Src/Win32/Widgets/Screen.cpp
index 4379efe..6c34d3e 100644
--- a/Src/Win32/Widgets/Screen.cpp
+++ b/Src/Win32/Widgets/Screen.cpp
@@ -29,19 +29,9 @@ static char THIS_FILE[] = __FILE__;
CScreen::CScreen(HDC hdc, HWND hWnd, Dasher::screenint iWidth, Dasher::screenint iHeight)
:CLabelListScreen(iWidth, iHeight), m_hdc(hdc) {
- // set up the off-screen buffers
- // HDC hdc = GetDC(mainwindow);
-
m_hWnd = hWnd;
CreateBuffers();
-
- CodePage = GetUserCodePage();
-
-// m_hDCScreen = ::GetDC(m_hwnd);
-// TCHAR debug[256];
-// _stprintf(debug, TEXT("GetDC: hwnd %x hdc %x\n"), m_hwnd, m_hDCScreen);
-// OutputDebugString(debug);
}
void CScreen::CreateBuffers() {
@@ -205,11 +195,6 @@ pair<screenint,screenint> CScreen::TextSize_Impl(CScreen::Label *label, unsigned
}
/////////////////////////////////////////////////////////////////////////////
-
-/*void CScreen::Polygon(point *Points, int Number, int iColour) {
- CScreen::Polygon( Points, Number, iColour, 1);
-}*/
-
void CScreen::Polygon(point *Points, int Number, int fillColour, int outlineColour, int iWidth) {
HGDIOBJ hpOld;
hpOld = (HPEN) SelectObject(m_hDCBuffer, CScreen::GetPen(fillColour, iWidth));
@@ -224,3 +209,9 @@ void CScreen::Polygon(point *Points, int Number, int fillColour, int outlineColo
}
/////////////////////////////////////////////////////////////////////////////
+bool CScreen::IsPointVisible(screenint x, screenint y) {
+ POINT pt = { x, y };
+ ClientToScreen(m_hWnd, &pt);
+ HWND h = WindowFromPoint(pt);
+ return h == m_hWnd;
+}
diff --git a/Src/Win32/Widgets/Screen.h b/Src/Win32/Widgets/Screen.h
index f9a0673..e563057 100644
--- a/Src/Win32/Widgets/Screen.h
+++ b/Src/Win32/Widgets/Screen.h
@@ -38,8 +38,6 @@ public:
void SetFont(const std::string &strFont);
- void DrawMousePosBox(int which, int iMousePosDist,int layer=0);
-
/// Make label from UTF8-encoded string
/// \param iWrapSize 0 => single-line label (for nodes); any other value => wrapped to screen width
/// (we wrap the text in whatever fontsize it's DrawString/TextSize'd in, even tho we don't have to)
@@ -54,12 +52,6 @@ public:
void CScreen::DrawCircle(screenint iCX, screenint iCY, screenint iR, int iFillColour, int iLineColour, int
iThickness);
- // Draw a line of fixed colour (usually black). Intended for static UI elements such as a cross-hair
- //! Draw a line between each of the points in the array
- //
- //! \param Number the number of points in the array
- //void Polyline(point * Points, int Number, int iWidth);
-
// Draw a line of arbitrary colour.
//! Draw a line between each of the points in the array
//
@@ -90,6 +82,8 @@ public:
void SendMarker(int iMarker);
void resize(screenint w,screenint h);
+ // Returns true if point on screen is not obscured by another window
+ bool IsPointVisible(screenint x, screenint y) override;
private:
const void point2POINT(const point * In, POINT * Out, int Number);
@@ -105,7 +99,6 @@ private:
HBITMAP m_hbmBitDecorations; // Offscreen buffer for decorations
HGDIOBJ m_prevhbmBitBackground;
HGDIOBJ m_prevhbmBitDecorations;
- UINT CodePage;
const Dasher::CColourIO::ColourInfo *m_pColours;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]