mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-06 19:40:10 +02:00
Add the start of reparenting the editor windows
This commit is contained in:
@@ -7,7 +7,7 @@ Editor::Editor(std::string window_class_name)
|
|||||||
x11_connection(xcb_connect(nullptr, nullptr), &xcb_disconnect) {}
|
x11_connection(xcb_connect(nullptr, nullptr), &xcb_disconnect) {}
|
||||||
|
|
||||||
HWND Editor::open() {
|
HWND Editor::open() {
|
||||||
window_handle =
|
win32_handle =
|
||||||
std::unique_ptr<std::remove_pointer_t<HWND>, decltype(&DestroyWindow)>(
|
std::unique_ptr<std::remove_pointer_t<HWND>, decltype(&DestroyWindow)>(
|
||||||
CreateWindowEx(WS_EX_TOOLWINDOW,
|
CreateWindowEx(WS_EX_TOOLWINDOW,
|
||||||
reinterpret_cast<LPCSTR>(window_class),
|
reinterpret_cast<LPCSTR>(window_class),
|
||||||
@@ -15,24 +15,49 @@ HWND Editor::open() {
|
|||||||
nullptr, GetModuleHandle(nullptr), nullptr),
|
nullptr, GetModuleHandle(nullptr), nullptr),
|
||||||
&DestroyWindow);
|
&DestroyWindow);
|
||||||
|
|
||||||
return window_handle->get();
|
return win32_handle->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::close() {
|
void Editor::close() {
|
||||||
// RAII does the rest for us
|
// RAII does the rest for us
|
||||||
window_handle = std::nullopt;
|
win32_handle = std::nullopt;
|
||||||
|
|
||||||
// TODO: Do we need to do something on the X11 side or does the host do
|
// TODO: Do we need to do something on the X11 side or does the host do
|
||||||
// everything for us?
|
// everything for us?
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<xcb_window_t> Editor::get_x11_handle() {
|
#include <iostream>
|
||||||
if (!window_handle.has_value()) {
|
|
||||||
|
bool Editor::embed_into(const size_t parent_window_handle) {
|
||||||
|
if (!win32_handle.has_value()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Swap the order if that works once everything else works so you
|
||||||
|
// don't get to see the Wine window
|
||||||
|
ShowWindow(win32_handle->get(), SW_SHOW);
|
||||||
|
UpdateWindow(win32_handle->get());
|
||||||
|
|
||||||
|
const size_t child_window_handle = get_x11_handle().value();
|
||||||
|
|
||||||
|
// TODO: Reparenting works, but the Wine window is not updating so that
|
||||||
|
// might cause it to look like it doesn't work
|
||||||
|
xcb_reparent_window(x11_connection.get(), child_window_handle,
|
||||||
|
parent_window_handle, 0, 0);
|
||||||
|
// TODO: Is this map needed?
|
||||||
|
xcb_map_window(x11_connection.get(), child_window_handle);
|
||||||
|
xcb_flush(x11_connection.get());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<size_t> Editor::get_x11_handle() {
|
||||||
|
if (!win32_handle.has_value()) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return reinterpret_cast<size_t>(
|
return reinterpret_cast<size_t>(
|
||||||
GetProp(window_handle.value().get(), "__wine_x11_whole_window"));
|
GetProp(win32_handle.value().get(), "__wine_x11_whole_window"));
|
||||||
}
|
}
|
||||||
|
|
||||||
ATOM register_window_class(std::string window_class_name) {
|
ATOM register_window_class(std::string window_class_name) {
|
||||||
|
|||||||
+13
-2
@@ -35,10 +35,21 @@ class Editor {
|
|||||||
HWND open();
|
HWND open();
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Embed the (open) window into a parent window.
|
||||||
|
*
|
||||||
|
* @param parent_window_handle The X11 window handle passed by the VST host
|
||||||
|
* for the editor to embed itself into.
|
||||||
|
*
|
||||||
|
* @return Whether the embedding was succesful. Will return false if the
|
||||||
|
* window is not open.
|
||||||
|
*/
|
||||||
|
bool embed_into(const size_t parent_window_handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the X11 window handle for the window if it's currently open.
|
* Return the X11 window handle for the window if it's currently open.
|
||||||
*/
|
*/
|
||||||
std::optional<xcb_window_t> get_x11_handle();
|
std::optional<size_t> get_x11_handle();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ATOM window_class;
|
ATOM window_class;
|
||||||
@@ -49,7 +60,7 @@ class Editor {
|
|||||||
*/
|
*/
|
||||||
std::optional<
|
std::optional<
|
||||||
std::unique_ptr<std::remove_pointer_t<HWND>, decltype(&DestroyWindow)>>
|
std::unique_ptr<std::remove_pointer_t<HWND>, decltype(&DestroyWindow)>>
|
||||||
window_handle;
|
win32_handle;
|
||||||
|
|
||||||
std::unique_ptr<xcb_connection_t, decltype(&xcb_disconnect)> x11_connection;
|
std::unique_ptr<xcb_connection_t, decltype(&xcb_disconnect)> x11_connection;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -142,9 +142,8 @@ PluginBridge::PluginBridge(std::string plugin_dll_path,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Embed the Win32 window into the X11 window
|
|
||||||
// handle
|
|
||||||
const auto x11_handle = reinterpret_cast<size_t>(data);
|
const auto x11_handle = reinterpret_cast<size_t>(data);
|
||||||
|
editor.embed_into(x11_handle);
|
||||||
|
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user