Explicitly handle no and pointer root input focus

This will never happen under normal X11. Apparently Crostini isn't
normal X11.

See #167.
This commit is contained in:
Robbert van der Helm
2022-03-05 00:38:02 +01:00
parent 3e04a6b61c
commit c528a9ef49
2 changed files with 12 additions and 2 deletions
+10 -2
View File
@@ -839,10 +839,18 @@ void Editor::set_input_focus(bool grab) const {
// we don't just check whether `current_focus` and `focus_target` are the
// same window but we'll also allow `current_focus` to be a child of
// `focus_target`.
// NOTE: To make matters even more complicated, the focused window can also
// be `None` or `PoointerRoot`. In a normal Xorg setup this will never
// happen, but apparently Crostini does some strange things and it can
// happen there. Since those flags aren't valid windows, we must avoid
// calling `is_child_window_or_same()` in those cases.
// https://github.com/robbert-vdh/yabridge/issues/167
const xcb_window_t current_focus = focus_reply->focus;
if (current_focus == focus_target ||
(grab && is_child_window_or_same(*x11_connection_, current_focus,
focus_target))) {
(grab && current_focus != XCB_INPUT_FOCUS_NONE &&
current_focus != XCB_INPUT_FOCUS_POINTER_ROOT &&
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) {