diff --git a/src/wine-host/editor.cpp b/src/wine-host/editor.cpp index 7e54847c..471ec094 100644 --- a/src/wine-host/editor.cpp +++ b/src/wine-host/editor.cpp @@ -1259,12 +1259,16 @@ ATOM get_window_class() noexcept { return window_class_handle; } -bool is_cursor_in_wine_window() noexcept { +bool is_cursor_in_wine_window( + std::optional windows_pointer_pos) noexcept { static const HWND windows_desktop_window = GetDesktopWindow(); - POINT windows_pointer_pos; - GetCursorPos(&windows_pointer_pos); - if (HWND windows_window = WindowFromPoint(windows_pointer_pos); + if (!windows_pointer_pos) { + windows_pointer_pos.emplace(); + 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 diff --git a/src/wine-host/editor.h b/src/wine-host/editor.h index 2f5926ac..f0da55e2 100644 --- a/src/wine-host/editor.h +++ b/src/wine-host/editor.h @@ -75,8 +75,13 @@ xcb_atom_t get_atom_by_name(xcb_connection_t& x11_connection, * area of yabridge windows. (so it will consider other Wine windows to the * right or to the bottom of a yabridge plugin editor, but not the extended * client area itself) + * + * @param windows_pointer_pos The screen coordinates to use for the query. If + * this is left at a nullopt, we will simply use `GetCursorPos()`. Note that + * this value only updates once every 100 milliseconds. */ -bool is_cursor_in_wine_window() noexcept; +bool is_cursor_in_wine_window( + std::optional windows_pointer_pos = std::nullopt) noexcept; /** * Used to store the maximum width and height of a screen.