Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2022-03-02 00:25:59 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2022-03-02 00:35:48 +0300
commitbfe37b7255e76b7c66e3f9cfd47bd0636ac142cf (patch)
tree2bcb56940efd532d7bcd8ac0b3fb67e466f4ffee /intern/ghost
parente1ec2d025142a35ce5a5302da0b9a71a279c61f2 (diff)
parent9bd586a01e6813a615eab05871803730603e2152 (diff)
Merge branch 'blender-v3.1-release'
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/GHOST_C-api.h10
-rw-r--r--intern/ghost/GHOST_ISystem.h8
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp10
-rw-r--r--intern/ghost/intern/GHOST_System.cpp19
-rw-r--r--intern/ghost/intern/GHOST_System.h8
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h8
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm14
-rw-r--r--intern/ghost/intern/GHOST_SystemNULL.h5
8 files changed, 82 insertions, 0 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 441c7315f1a..18439350238 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -249,6 +249,16 @@ extern GHOST_TSuccess GHOST_EndFullScreen(GHOST_SystemHandle systemhandle);
*/
extern int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle);
+/**
+ * Get the Window under the cursor.
+ * \param x: The x-coordinate of the cursor.
+ * \param y: The y-coordinate of the cursor.
+ * @return The window under the cursor or nullptr in none.
+ */
+extern GHOST_WindowHandle GHOST_GetWindowUnderCursor(GHOST_SystemHandle systemhandle,
+ int32_t x,
+ int32_t y);
+
/***************************************************************************************
* Event management functionality
***************************************************************************************/
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 837ec25d0f8..a33879522f4 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -309,6 +309,14 @@ class GHOST_ISystem {
*/
virtual void useWindowFocus(const bool use_focus) = 0;
+ /**
+ * Get the Window under the cursor.
+ * \param x: The x-coordinate of the cursor.
+ * \param y: The y-coordinate of the cursor.
+ * @return The window under the cursor or nullptr if none.
+ */
+ virtual GHOST_IWindow *getWindowUnderCursor(int32_t x, int32_t y) = 0;
+
/***************************************************************************************
* Event management functionality
***************************************************************************************/
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index a47d2468937..e3d01c24283 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -233,6 +233,16 @@ int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle)
return (int)system->getFullScreen();
}
+GHOST_WindowHandle GHOST_GetWindowUnderCursor(GHOST_SystemHandle systemhandle,
+ int32_t x,
+ int32_t y)
+{
+ GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
+ GHOST_IWindow *window = system->getWindowUnderCursor(x, y);
+
+ return (GHOST_WindowHandle)window;
+}
+
bool GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, bool waitForEvent)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp
index e9c63502f66..3df85e18bc7 100644
--- a/intern/ghost/intern/GHOST_System.cpp
+++ b/intern/ghost/intern/GHOST_System.cpp
@@ -189,6 +189,25 @@ bool GHOST_System::getFullScreen(void)
return fullScreen;
}
+GHOST_IWindow *GHOST_System::getWindowUnderCursor(int32_t x, int32_t y)
+{
+ /* TODO: This solution should follow the order of the activated windows (Z-order).
+ * It is imperfect but usable in most cases. */
+ for (GHOST_IWindow *iwindow : m_windowManager->getWindows()) {
+ if (iwindow->getState() == GHOST_kWindowStateMinimized) {
+ continue;
+ }
+
+ GHOST_Rect bounds;
+ iwindow->getClientBounds(bounds);
+ if (bounds.isInside(x, y)) {
+ return iwindow;
+ }
+ }
+
+ return NULL;
+}
+
void GHOST_System::dispatchEvents()
{
#ifdef WITH_INPUT_NDOF
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 8602dd94e8c..0911b35f617 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -157,6 +157,14 @@ class GHOST_System : public GHOST_ISystem {
void useWindowFocus(const bool use_focus);
bool m_windowFocus;
+ /**
+ * Get the Window under the cursor.
+ * \param x: The x-coordinate of the cursor.
+ * \param y: The y-coordinate of the cursor.
+ * @return The window under the cursor or nullptr if none.
+ */
+ GHOST_IWindow *getWindowUnderCursor(int32_t x, int32_t y);
+
/***************************************************************************************
* Event management functionality
***************************************************************************************/
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index a601d00561a..926d50b7942 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -109,6 +109,14 @@ class GHOST_SystemCocoa : public GHOST_System {
*/
GHOST_TSuccess disposeContext(GHOST_IContext *context);
+ /**
+ * Get the Window under the cursor.
+ * \param x: The x-coordinate of the cursor.
+ * \param y: The y-coordinate of the cursor.
+ * @return The window under the cursor or nullptr if none.
+ */
+ GHOST_IWindow *getWindowUnderCursor(int32_t x, int32_t y);
+
/***************************************************************************************
* Event management functionality
***************************************************************************************/
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index d3248a826e6..f0db6b6fdfc 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -772,6 +772,20 @@ GHOST_TSuccess GHOST_SystemCocoa::disposeContext(GHOST_IContext *context)
return GHOST_kSuccess;
}
+GHOST_IWindow *GHOST_SystemCocoa::getWindowUnderCursor(int32_t x, int32_t y)
+{
+ NSPoint scr_co = NSMakePoint(x, y);
+
+ int windowNumberAtPoint = [NSWindow windowNumberAtPoint:scr_co belowWindowWithWindowNumber:0];
+ NSWindow *nswindow = [NSApp windowWithWindowNumber:windowNumberAtPoint];
+
+ if (nswindow == nil) {
+ return nil;
+ }
+
+ return m_windowManager->getWindowAssociatedWithOSWindow((void *)nswindow);
+}
+
/**
* \note : returns coordinates in Cocoa screen coordinates
*/
diff --git a/intern/ghost/intern/GHOST_SystemNULL.h b/intern/ghost/intern/GHOST_SystemNULL.h
index 7b92d1d13a1..48973a00573 100644
--- a/intern/ghost/intern/GHOST_SystemNULL.h
+++ b/intern/ghost/intern/GHOST_SystemNULL.h
@@ -114,4 +114,9 @@ class GHOST_SystemNULL : public GHOST_System {
type,
((glSettings.flags & GHOST_glStereoVisual) != 0));
}
+
+ GHOST_IWindow *getWindowUnderCursor(int32_t x, int32_t y)
+ {
+ return NULL;
+ }
};