Move check for cursor within Wine window to editor

We'll reuse this for the LeaveNotify check instead to avoid having to
ignore all `NonVirtual` events.
This commit is contained in:
Robbert van der Helm
2021-07-26 13:59:55 +02:00
parent 0523a06ed7
commit 85264a759d
3 changed files with 40 additions and 23 deletions
+27
View File
@@ -1245,4 +1245,31 @@ ATOM get_window_class() noexcept {
return window_class_handle;
}
bool is_cursor_in_wine_window() noexcept {
static const HWND windows_desktop_window = GetDesktopWindow();
POINT windows_pointer_pos;
GetCursorPos(&windows_pointer_pos);
if (HWND windows_window = WindowFromPoint(windows_pointer_pos);
windows_window && windows_window != windows_desktop_window) {
// NOTE: Because resizing reparented Wine windows without XEmbed is
// a bit janky, yabridge creates windows with client areas
// large enough to fit the entire screen, and the plugin then
// embeds its own GUI in a portion of that. The result is that
// `WindowFromPoint()` will still return that same huge window
// when we hover over an area to the right or to the bottom of
// a plugin GUI. We can easily detect and skip that though,
// since the embedded plugin windows won't have an X11 window
// ID property.
const xcb_window_t x11_window =
static_cast<xcb_window_t>(reinterpret_cast<size_t>(
GetProp(windows_window, "__wine_x11_whole_window")));
if (x11_window == XCB_NONE) {
return true;
}
}
return false;
}
#undef THROW_X11_ERROR