mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 04:20:13 +02:00
Create a window for the X11 proxy
This commit is contained in:
@@ -57,9 +57,43 @@ void CALLBACK dnd_winevent_callback(HWINEVENTHOOK hWinEventHook,
|
||||
DWORD idEventThread,
|
||||
DWORD dwmsEventTime);
|
||||
|
||||
ProxyWindow::ProxyWindow(std::shared_ptr<xcb_connection_t> x11_connection)
|
||||
: x11_connection(x11_connection),
|
||||
window(xcb_generate_id(x11_connection.get())) {
|
||||
const xcb_screen_t* screen =
|
||||
xcb_setup_roots_iterator(xcb_get_setup(x11_connection.get())).data;
|
||||
|
||||
xcb_create_window(x11_connection.get(), XCB_COPY_FROM_PARENT, window,
|
||||
screen->root, 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_ONLY,
|
||||
XCB_COPY_FROM_PARENT, 0, nullptr);
|
||||
xcb_flush(x11_connection.get());
|
||||
}
|
||||
|
||||
ProxyWindow::~ProxyWindow() noexcept {
|
||||
if (!is_moved) {
|
||||
xcb_destroy_window(x11_connection.get(), window);
|
||||
xcb_flush(x11_connection.get());
|
||||
}
|
||||
}
|
||||
|
||||
ProxyWindow::ProxyWindow(ProxyWindow&& o) noexcept
|
||||
: x11_connection(std::move(o.x11_connection)), window(std::move(o.window)) {
|
||||
o.is_moved = true;
|
||||
}
|
||||
ProxyWindow& ProxyWindow::operator=(ProxyWindow&& o) noexcept {
|
||||
if (&o != this) {
|
||||
x11_connection = std::move(o.x11_connection);
|
||||
window = std::move(o.window);
|
||||
|
||||
o.is_moved = true;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
WineXdndProxy::WineXdndProxy()
|
||||
: x11_connection(xcb_connect(nullptr, nullptr), xcb_disconnect),
|
||||
proxy_window(xcb_generate_id(x11_connection.get())),
|
||||
proxy_window(x11_connection),
|
||||
hook_handle(
|
||||
SetWinEventHook(EVENT_OBJECT_CREATE,
|
||||
EVENT_OBJECT_CREATE,
|
||||
@@ -68,15 +102,7 @@ WineXdndProxy::WineXdndProxy()
|
||||
0,
|
||||
0,
|
||||
WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS),
|
||||
UnhookWinEvent) {
|
||||
//
|
||||
}
|
||||
|
||||
WineXdndProxy::~WineXdndProxy() noexcept {
|
||||
// TODO: Move this to a RAII wrapper
|
||||
xcb_destroy_window(x11_connection.get(), proxy_window);
|
||||
xcb_flush(x11_connection.get());
|
||||
}
|
||||
UnhookWinEvent) {}
|
||||
|
||||
WineXdndProxy::Handle::Handle(WineXdndProxy* proxy) : proxy(proxy) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user