diff --git a/CHANGELOG.md b/CHANGELOG.md index 69320e0c..1266dc10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Changed + +- Added more tracing for input focus handling when using the `+editor` + `YABRIDGE_DEBUG_LEVEL` flag. + ## [3.5.0] - 2021-06-23 ### Added diff --git a/src/wine-host/editor.cpp b/src/wine-host/editor.cpp index 944bad0b..2110e9e8 100644 --- a/src/wine-host/editor.cpp +++ b/src/wine-host/editor.cpp @@ -753,6 +753,21 @@ void Editor::set_input_focus(bool grab) const { if (current_focus == focus_target || (grab && is_child_window_or_same(*x11_connection, current_focus, focus_target))) { + logger.log_editor_trace([&]() { + std::string reason = "unknown reason"; + if (current_focus == focus_target) { + reason = "already focused"; + } else if (grab && + is_child_window_or_same(*x11_connection, current_focus, + focus_target)) { + reason = "current focus " + std::to_string(current_focus) + + " is a child of " + std::to_string(focus_target); + } + + return "DEBUG: Not grabbing input focus for window " + + std::to_string(focus_target) + "(" + reason + ")"; + }); + return; } @@ -770,6 +785,11 @@ void Editor::set_input_focus(bool grab) const { // `IPlugView::onKey{Down,Up}` should handle all keyboard events. But // in practice a lot of hosts don't use that, so we still need to grab // focus ourselves. + logger.log_editor_trace([&]() { + return "DEBUG: Setting input focus to window " + + std::to_string(focus_target); + }); + xcb_set_input_focus(x11_connection.get(), XCB_INPUT_FOCUS_PARENT, focus_target, XCB_CURRENT_TIME); xcb_flush(x11_connection.get());