[dasher/relicence] Revert "Changed IsPointVisible to IsWindowUnderCursor. This change was done because"



commit 1ccc8257598b208052364aa2671c6b917d86466e
Author: Gavin Henderson <gavin henderson hotmail co uk>
Date:   Thu Mar 3 12:08:23 2022 +0000

    Revert "Changed IsPointVisible to IsWindowUnderCursor. This change was done because"
    
    This reverts commit 0f9a05ac069b44652707f90e25de745ea70a7f1c.

 Src/DasherCore/CircleStartHandler.cpp |  2 +-
 Src/DasherCore/DasherScreen.h         |  4 ++--
 Src/DasherCore/TwoBoxStartHandler.cpp |  2 +-
 Src/Gtk2/Canvas.cpp                   | 11 -----------
 Src/Gtk2/Canvas.h                     |  4 ++--
 Src/Win32/Widgets/Screen.cpp          |  6 +++---
 Src/Win32/Widgets/Screen.h            |  4 ++--
 7 files changed, 11 insertions(+), 22 deletions(-)
---
diff --git a/Src/DasherCore/CircleStartHandler.cpp b/Src/DasherCore/CircleStartHandler.cpp
index ed5c50a2..85d68b13 100644
--- a/Src/DasherCore/CircleStartHandler.cpp
+++ b/Src/DasherCore/CircleStartHandler.cpp
@@ -82,7 +82,7 @@ void CCircleStartHandler::Timer(unsigned long iTime, dasherint mouseX, dasherint
   screenint x,y;
   pView->Dasher2Screen(mouseX, mouseY, x, y);
   int dx=x-ctr.x, dy=y-ctr.y;
-  const bool inCircleNow = dx*dx + dy*dy <= (m_iScreenRadius * m_iScreenRadius) && 
pView->Screen()->IsWindowUnderCursor();
+  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 e79d9e0b..edb9b622 100644
--- a/Src/DasherCore/DasherScreen.h
+++ b/Src/DasherCore/DasherScreen.h
@@ -170,8 +170,8 @@ public:
   /// \param pColourScheme A colour scheme that should be used
   virtual void SetColourScheme(const Dasher::CColourIO::ColourInfo *pColourScheme) = 0;
   
-  // Returns true if cursor is over visible part of this window.
-  virtual bool IsWindowUnderCursor() = 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
diff --git a/Src/DasherCore/TwoBoxStartHandler.cpp b/Src/DasherCore/TwoBoxStartHandler.cpp
index dfef7b6b..ec870ac3 100644
--- a/Src/DasherCore/TwoBoxStartHandler.cpp
+++ b/Src/DasherCore/TwoBoxStartHandler.cpp
@@ -44,7 +44,7 @@ void CTwoBoxStartHandler::Timer(unsigned long iTime, dasherint iDasherX, dasheri
 
   if ((iNewScreenY >= iBoxMin) && (iNewScreenY <= iBoxMax) 
          && (iNewScreenX >= 8) && (iNewScreenX <= pView->Screen()->GetWidth() - 16)
-         && pView->Screen()->IsWindowUnderCursor()) {
+         && pView->Screen()->IsPointVisible(iNewScreenX, iNewScreenY)) {
     if(m_iBoxEntered == std::numeric_limits<long>::max()) {
       m_iBoxEntered = iTime;
     }
diff --git a/Src/Gtk2/Canvas.cpp b/Src/Gtk2/Canvas.cpp
index 4e5dee39..68803ff7 100644
--- a/Src/Gtk2/Canvas.cpp
+++ b/Src/Gtk2/Canvas.cpp
@@ -5,7 +5,6 @@
 
 #include "../DasherCore/DasherTypes.h"
 
-
 using namespace Dasher;
 
 CCanvas::CCanvas(GtkWidget *pCanvas)
@@ -66,16 +65,6 @@ void CCanvas::resize(screenint w,screenint h) {
   InitSurfaces();
 } 
 
-bool CCanvas::IsWindowUnderCursor() {
-  GdkDisplay * gdkDisplay = gdk_display_get_default();
-  gint winx,winy;
-  // unfortunately under X we cannot arbritrarily find which window
-  // lives at a location. Only underneath the cursor.
-  GdkWindow * window = gdk_display_get_window_at_pointer(gdkDisplay, &winx, &winy);  
-  return window == gtk_widget_get_window(m_pCanvas);
-}
-
-
 void CCanvas::Display() {
   // FIXME - Some of this stuff is probably not needed
   //  GdkRectangle update_rect;
diff --git a/Src/Gtk2/Canvas.h b/Src/Gtk2/Canvas.h
index a6459e44..845671dc 100644
--- a/Src/Gtk2/Canvas.h
+++ b/Src/Gtk2/Canvas.h
@@ -159,8 +159,8 @@ public:
 
   // Redeclare to make public and adjust cairo/gdk surface sizes
   void resize(screenint w,screenint h);
-  // Returns true if cursor is over visible part of this window.
-  bool IsWindowUnderCursor() override;
+  // 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 377342d8..3a401bcb 100644
--- a/Src/Win32/Widgets/Screen.cpp
+++ b/Src/Win32/Widgets/Screen.cpp
@@ -210,9 +210,9 @@ void CScreen::Polygon(point *Points, int Number, int fillColour, int outlineColo
 }
 
 /////////////////////////////////////////////////////////////////////////////
-bool CScreen::IsWindowUnderCursor() {
-  POINT pt;
-  GetCursorPos(&pt);
+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 6c9fe6fa..68d3322c 100644
--- a/Src/Win32/Widgets/Screen.h
+++ b/Src/Win32/Widgets/Screen.h
@@ -69,8 +69,8 @@ public:
 
   void SendMarker(int iMarker) override;
 
-  // Returns true if cursor is over visible part of this window.
-  bool IsWindowUnderCursor() override;
+  // Returns true if point on screen is not obscured by another window
+  bool IsPointVisible(screenint x, screenint y) override;
 
   void RealDisplay(HDC hDC, RECT r);
   void resize(screenint w, screenint h);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]