Filter Win32 windows for XDND by class name

Instead of ignoring all windows that have an associated X11 window. That
would otherwise treat standalone applications like yabridge GUI
wrappers.
This commit is contained in:
Robbert van der Helm
2021-07-26 14:28:15 +02:00
parent 34cbf43459
commit 186a6c01a2
2 changed files with 21 additions and 14 deletions
+13 -14
View File
@@ -44,7 +44,7 @@ using namespace std::literals::string_literals;
* The name of the Win32 window class we'll use for the Win32 window that the
* plugin can embed itself in.
*/
constexpr char window_class_name[] = "yabridge plugin";
constexpr char yabridge_window_class_name[] = "yabridge plugin";
/**
* The Win32 timer ID we'll use to periodically call the VST2 `effeditidle`
@@ -1237,7 +1237,7 @@ ATOM get_window_class() noexcept {
window_class.lpfnWndProc = window_proc;
window_class.hInstance = GetModuleHandle(nullptr);
window_class.hCursor = arrow_cursor;
window_class.lpszClassName = window_class_name;
window_class.lpszClassName = yabridge_window_class_name;
window_class_handle = RegisterClassEx(&window_class);
}
@@ -1252,19 +1252,18 @@ bool is_cursor_in_wine_window() noexcept {
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
// 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) {
// when we hover over an area to the right or to the bottom of a
// plugin GUI. We can easily detect by just checking the window
// class name.
std::array<char, 64> window_class_name{0};
GetClassName(windows_window, window_class_name.data(),
window_class_name.size());
if (strcmp(window_class_name.data(), yabridge_window_class_name) != 0) {
return true;
}
}