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:
authorCampbell Barton <campbell@blender.org>2022-06-16 08:16:04 +0300
committerCampbell Barton <campbell@blender.org>2022-06-16 08:22:46 +0300
commit65b1b1cd349f3bd813392e76eab5b610efba7428 (patch)
tree2c5bbc151b54ceb581235497980d48de7ea8831c
parenta17f74ab341b026387fef6b741e3c0901780526c (diff)
GHOST/Wayland: workaround inability to access window position
Wayland doesn't support accessing the position making functionality that would map events to other windows fail, sometimes considering windows overlapping when they weren't (as all window positions were zeroed). Disable dragging between windows when accessing the window the position isn't supported.
-rw-r--r--intern/ghost/GHOST_C-api.h5
-rw-r--r--intern/ghost/GHOST_ISystem.h5
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp6
-rw-r--r--intern/ghost/intern/GHOST_System.cpp5
-rw-r--r--intern/ghost/intern/GHOST_System.h1
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.cpp8
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.h1
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.cc7
8 files changed, 37 insertions, 1 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 388d6eb96d2..c92e6ba78c1 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -907,6 +907,11 @@ extern int GHOST_UseNativePixels(void);
extern int GHOST_SupportsCursorWarp(void);
/**
+ * Support positioning windows (when false `wmWindow.x,y` are meaningless).
+ */
+extern int GHOST_SupportsWindowPosition(void);
+
+/**
* Assign the callback which generates a back-trace (may be NULL).
*/
extern void GHOST_SetBacktraceHandler(GHOST_TBacktraceFn backtrace_fn);
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 436ff7a723e..d946d2d882a 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -313,6 +313,11 @@ class GHOST_ISystem {
virtual bool supportsCursorWarp() = 0;
/**
+ * Return true getting/setting the window position is supported.
+ */
+ virtual bool supportsWindowPosition() = 0;
+
+ /**
* Focus window after opening, or put them in the background.
*/
virtual void useWindowFocus(const bool use_focus) = 0;
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 3bb7a7618c4..b1a15fdf4d7 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -835,6 +835,12 @@ int GHOST_SupportsCursorWarp(void)
return system->supportsCursorWarp();
}
+int GHOST_SupportsWindowPosition(void)
+{
+ GHOST_ISystem *system = GHOST_ISystem::getSystem();
+ return system->supportsWindowPosition();
+}
+
void GHOST_SetBacktraceHandler(GHOST_TBacktraceFn backtrace_fn)
{
GHOST_ISystem::setBacktraceFn(backtrace_fn);
diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp
index 2aad4f2ea29..c8308b3586b 100644
--- a/intern/ghost/intern/GHOST_System.cpp
+++ b/intern/ghost/intern/GHOST_System.cpp
@@ -395,6 +395,11 @@ bool GHOST_System::supportsCursorWarp()
return true;
}
+bool GHOST_System::supportsWindowPosition()
+{
+ return true;
+}
+
void GHOST_System::initDebug(GHOST_Debug debug)
{
m_is_debug_enabled = debug.flags & GHOST_kDebugDefault;
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 9f2fba1a2c6..b60ce09f743 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -152,6 +152,7 @@ class GHOST_System : public GHOST_ISystem {
bool m_nativePixel;
bool supportsCursorWarp(void);
+ bool supportsWindowPosition(void);
/**
* Focus window after opening, or put them in the background.
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 93d85f33dda..d8fbe875f67 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -2682,6 +2682,14 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorVisibility(bool visible)
bool GHOST_SystemWayland::supportsCursorWarp()
{
+ /* WAYLAND doesn't support setting the cursor position directly,
+ * this is an intentional choice, forcing us to use a software cursor in this case. */
+ return false;
+}
+
+bool GHOST_SystemWayland::supportsWindowPosition()
+{
+ /* WAYLAND doesn't support accessing the window position. */
return false;
}
diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h
index 3be108b1f88..762ceb80e38 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.h
+++ b/intern/ghost/intern/GHOST_SystemWayland.h
@@ -125,6 +125,7 @@ class GHOST_SystemWayland : public GHOST_System {
GHOST_TSuccess setCursorVisibility(bool visible);
bool supportsCursorWarp();
+ bool supportsWindowPosition();
GHOST_TSuccess setCursorGrab(const GHOST_TGrabCursorMode mode,
const GHOST_TGrabCursorMode mode_current,
diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc
index 658e643508e..e44016948fc 100644
--- a/source/blender/windowmanager/intern/wm_event_system.cc
+++ b/source/blender/windowmanager/intern/wm_event_system.cc
@@ -4942,7 +4942,11 @@ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *g
/* Imperfect but probably usable... draw/enable drags to other windows. */
static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *event)
{
- int mval[2] = {event->xy[0], event->xy[1]};
+ /* If GHOST doesn't support window positioning, don't use this feature at all. */
+ const static int8_t supports_window_position = GHOST_SupportsWindowPosition();
+ if (!supports_window_position) {
+ return nullptr;
+ }
if (wm->windows.first == wm->windows.last) {
return nullptr;
@@ -4951,6 +4955,7 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi
/* In order to use window size and mouse position (pixels), we have to use a WM function. */
/* Check if outside, include top window bar. */
+ int mval[2] = {event->xy[0], event->xy[1]};
if (mval[0] < 0 || mval[1] < 0 || mval[0] > WM_window_pixels_x(win) ||
mval[1] > WM_window_pixels_y(win) + 30) {
/* Let's skip windows having modal handlers now. */