mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Perform some more diagnostics when reparent fails
This commit is contained in:
+68
-42
@@ -349,19 +349,53 @@ Editor::Editor(MainContext& main_context,
|
|||||||
// of using the XEmbed protocol, we'll register a few events and manage
|
// of using the XEmbed protocol, we'll register a few events and manage
|
||||||
// the child window ourselves. This is a hack to work around the issue's
|
// the child window ourselves. This is a hack to work around the issue's
|
||||||
// described in `Editor`'s docstring'.
|
// described in `Editor`'s docstring'.
|
||||||
xcb_void_cookie_t reparent_cookie = xcb_reparent_window_checked(
|
auto do_reparent = [&]() {
|
||||||
x11_connection.get(), wine_window, parent_window, 0, 0);
|
const xcb_void_cookie_t reparent_cookie =
|
||||||
if (std::unique_ptr<xcb_generic_error_t> error(
|
xcb_reparent_window_checked(x11_connection.get(), wine_window,
|
||||||
xcb_request_check(x11_connection.get(), reparent_cookie));
|
parent_window, 0, 0);
|
||||||
error) {
|
if (std::unique_ptr<xcb_generic_error_t> reparent_error(
|
||||||
std::cerr << "DEBUG: Reparent 1 failed:" << std::endl;
|
xcb_request_check(x11_connection.get(), reparent_cookie));
|
||||||
std::cerr << "Error code: " << error->error_code << std::endl;
|
reparent_error) {
|
||||||
std::cerr << "Major code: " << error->major_code << std::endl;
|
std::cerr << "DEBUG: Reparent failed:" << std::endl;
|
||||||
std::cerr << "Minor code: " << error->minor_code << std::endl;
|
std::cerr << "Error code: " << reparent_error->error_code
|
||||||
} else {
|
<< std::endl;
|
||||||
std::cerr << "DEBUG: Reparent 1 succeeded" << std::endl;
|
std::cerr << "Major code: " << reparent_error->major_code
|
||||||
}
|
<< std::endl;
|
||||||
xcb_flush(x11_connection.get());
|
std::cerr << "Minor code: " << reparent_error->minor_code
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
// Let's just check all of the reasons why the reparent could
|
||||||
|
// fail according to the spec in advance
|
||||||
|
xcb_generic_error_t* error = nullptr;
|
||||||
|
const xcb_query_pointer_cookie_t query_pointer_cookie =
|
||||||
|
xcb_query_pointer(x11_connection.get(), wine_window);
|
||||||
|
const std::unique_ptr<xcb_query_pointer_reply_t>
|
||||||
|
query_pointer_reply(xcb_query_pointer_reply(
|
||||||
|
x11_connection.get(), query_pointer_cookie, &error));
|
||||||
|
if (error) {
|
||||||
|
free(error);
|
||||||
|
std::cerr << "DEBUG: Could not query pointer location"
|
||||||
|
<< std::endl;
|
||||||
|
} else {
|
||||||
|
if (query_pointer_reply->same_screen) {
|
||||||
|
std::cerr
|
||||||
|
<< "DEBUG: Pointer is on the same screen as the "
|
||||||
|
"Wine window, good"
|
||||||
|
<< std::endl;
|
||||||
|
} else {
|
||||||
|
std::cerr
|
||||||
|
<< "DEBUG: Pointer is not on the same screen as "
|
||||||
|
"the Wine window, oh no"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr << "DEBUG: Reparent succeeded" << std::endl;
|
||||||
|
}
|
||||||
|
xcb_flush(x11_connection.get());
|
||||||
|
};
|
||||||
|
|
||||||
|
do_reparent();
|
||||||
|
|
||||||
// If we're using the double embedding option, then the child window
|
// If we're using the double embedding option, then the child window
|
||||||
// should only be created after the parent window is visible
|
// should only be created after the parent window is visible
|
||||||
@@ -387,19 +421,10 @@ Editor::Editor(MainContext& main_context,
|
|||||||
// trying!
|
// trying!
|
||||||
//
|
//
|
||||||
// https://github.com/robbert-vdh/yabridge/issues/40
|
// https://github.com/robbert-vdh/yabridge/issues/40
|
||||||
reparent_cookie = xcb_reparent_window_checked(
|
std::cerr
|
||||||
x11_connection.get(), wine_window, parent_window, 0, 0);
|
<< "DEBUG: Reparent 2 is allowed to fail if the first one succeeded"
|
||||||
if (std::unique_ptr<xcb_generic_error_t> error(
|
<< std::endl;
|
||||||
xcb_request_check(x11_connection.get(), reparent_cookie));
|
do_reparent();
|
||||||
error) {
|
|
||||||
std::cerr << "DEBUG: Reparent 2 failed:" << std::endl;
|
|
||||||
std::cerr << "Error code: " << error->error_code << std::endl;
|
|
||||||
std::cerr << "Major code: " << error->major_code << std::endl;
|
|
||||||
std::cerr << "Minor code: " << error->minor_code << std::endl;
|
|
||||||
} else {
|
|
||||||
std::cerr << "DEBUG: Reparent 2 succeeded" << std::endl;
|
|
||||||
}
|
|
||||||
xcb_flush(x11_connection.get());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,11 +453,12 @@ void Editor::handle_x11_events() noexcept {
|
|||||||
// check if the host's window has changed whenever the
|
// check if the host's window has changed whenever the
|
||||||
// parent window gets reparented.
|
// parent window gets reparented.
|
||||||
case XCB_REPARENT_NOTIFY: {
|
case XCB_REPARENT_NOTIFY: {
|
||||||
|
const auto event =
|
||||||
|
reinterpret_cast<xcb_reparent_notify_event_t*>(
|
||||||
|
generic_event.get());
|
||||||
|
|
||||||
std::cerr << "DEBUG: ReparentNotify for window "
|
std::cerr << "DEBUG: ReparentNotify for window "
|
||||||
<< reinterpret_cast<xcb_reparent_notify_event_t*>(
|
<< event->window << std::endl;
|
||||||
generic_event.get())
|
|
||||||
->window
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
redetect_host_window();
|
redetect_host_window();
|
||||||
} break;
|
} break;
|
||||||
@@ -445,12 +471,12 @@ void Editor::handle_x11_events() noexcept {
|
|||||||
// check is sometimes necessary for using multiple editor
|
// check is sometimes necessary for using multiple editor
|
||||||
// windows within a single plugin group.
|
// windows within a single plugin group.
|
||||||
case XCB_CONFIGURE_NOTIFY: {
|
case XCB_CONFIGURE_NOTIFY: {
|
||||||
std::cerr
|
const auto event =
|
||||||
<< "DEBUG: ConfigureNotify for window "
|
reinterpret_cast<xcb_configure_notify_event_t*>(
|
||||||
<< reinterpret_cast<xcb_configure_notify_event_t*>(
|
generic_event.get());
|
||||||
generic_event.get())
|
|
||||||
->window
|
std::cerr << "DEBUG: ConfigureNotify for window "
|
||||||
<< std::endl;
|
<< event->window << std::endl;
|
||||||
|
|
||||||
if (!use_xembed) {
|
if (!use_xembed) {
|
||||||
fix_local_coordinates();
|
fix_local_coordinates();
|
||||||
@@ -460,12 +486,12 @@ void Editor::handle_x11_events() noexcept {
|
|||||||
// since most hosts will only show the window after the plugin
|
// since most hosts will only show the window after the plugin
|
||||||
// has embedded itself into it.
|
// has embedded itself into it.
|
||||||
case XCB_VISIBILITY_NOTIFY: {
|
case XCB_VISIBILITY_NOTIFY: {
|
||||||
std::cerr
|
const auto event =
|
||||||
<< "DEBUG: VisibilityNotify for window "
|
reinterpret_cast<xcb_visibility_notify_event_t*>(
|
||||||
<< reinterpret_cast<xcb_visibility_notify_event_t*>(
|
generic_event.get());
|
||||||
generic_event.get())
|
|
||||||
->window
|
std::cerr << "DEBUG: VisibilityNotify for window "
|
||||||
<< std::endl;
|
<< event->window << std::endl;
|
||||||
|
|
||||||
if (use_xembed) {
|
if (use_xembed) {
|
||||||
do_xembed();
|
do_xembed();
|
||||||
|
|||||||
Reference in New Issue
Block a user