Add the start of reparenting the editor windows

This commit is contained in:
Robbert van der Helm
2020-03-17 23:04:09 +01:00
parent f3bf7879c6
commit ede14ece3b
3 changed files with 45 additions and 10 deletions
+31 -6
View File
@@ -7,7 +7,7 @@ Editor::Editor(std::string window_class_name)
x11_connection(xcb_connect(nullptr, nullptr), &xcb_disconnect) {}
HWND Editor::open() {
window_handle =
win32_handle =
std::unique_ptr<std::remove_pointer_t<HWND>, decltype(&DestroyWindow)>(
CreateWindowEx(WS_EX_TOOLWINDOW,
reinterpret_cast<LPCSTR>(window_class),
@@ -15,24 +15,49 @@ HWND Editor::open() {
nullptr, GetModuleHandle(nullptr), nullptr),
&DestroyWindow);
return window_handle->get();
return win32_handle->get();
}
void Editor::close() {
// 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
// everything for us?
}
std::optional<xcb_window_t> Editor::get_x11_handle() {
if (!window_handle.has_value()) {
#include <iostream>
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 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) {