Check the windows IDs when handling X11 events

This seems like a good idea now that we're listening to more and more
events.
This commit is contained in:
Robbert van der Helm
2021-07-20 00:56:38 +02:00
parent 906ead26fd
commit 0f75461379
+30 -18
View File
@@ -458,7 +458,9 @@ void Editor::handle_x11_events() noexcept {
generic_event.get()); generic_event.get());
std::cerr << "DEBUG: ReparentNotify for window " std::cerr << "DEBUG: ReparentNotify for window "
<< event->window << std::endl; << event->window << " to new parent "
<< event->parent << ", generated from "
<< event->event << std::endl;
redetect_host_window(); redetect_host_window();
} break; } break;
@@ -478,8 +480,11 @@ void Editor::handle_x11_events() noexcept {
std::cerr << "DEBUG: ConfigureNotify for window " std::cerr << "DEBUG: ConfigureNotify for window "
<< event->window << std::endl; << event->window << std::endl;
if (!use_xembed) { if (event->window == host_window ||
fix_local_coordinates(); event->window == parent_window) {
if (!use_xembed) {
fix_local_coordinates();
}
} }
} break; } break;
// Start the XEmbed procedure when the window becomes visible, // Start the XEmbed procedure when the window becomes visible,
@@ -493,8 +498,11 @@ void Editor::handle_x11_events() noexcept {
std::cerr << "DEBUG: VisibilityNotify for window " std::cerr << "DEBUG: VisibilityNotify for window "
<< event->window << std::endl; << event->window << std::endl;
if (use_xembed) { if (event->window == host_window ||
do_xembed(); event->window == parent_window) {
if (use_xembed) {
do_xembed();
}
} }
} break; } break;
// We want to grab keyboard input focus when the user hovers // We want to grab keyboard input focus when the user hovers
@@ -511,18 +519,20 @@ void Editor::handle_x11_events() noexcept {
fix_local_coordinates(); fix_local_coordinates();
} }
const xcb_window_t window =
event_type == XCB_ENTER_NOTIFY
? reinterpret_cast<xcb_enter_notify_event_t*>(
generic_event.get())
->child
: reinterpret_cast<xcb_focus_in_event_t*>(
generic_event.get())
->event;
if (event_type == XCB_ENTER_NOTIFY) { if (event_type == XCB_ENTER_NOTIFY) {
std::cerr std::cerr << "DEBUG: EnterNotify for window " << window
<< "DEBUG: EnterNotify for window " << std::endl;
<< reinterpret_cast<xcb_enter_notify_event_t*>(
generic_event.get())
->event
<< std::endl;
} else { } else {
std::cerr << "DEBUG: FocusIn for window " std::cerr << "DEBUG: FocusIn for window " << window
<< reinterpret_cast<xcb_focus_in_event_t*>(
generic_event.get())
->event
<< std::endl; << std::endl;
} }
@@ -530,7 +540,8 @@ void Editor::handle_x11_events() noexcept {
// `_NET_ACTIVE_WINDOW`, a more naive focus grabbing method // `_NET_ACTIVE_WINDOW`, a more naive focus grabbing method
// implemented in the `WM_PARENTNOTIFY` handler will be // implemented in the `WM_PARENTNOTIFY` handler will be
// used. // used.
if (supports_ewmh_active_window() && if (window == wine_window &&
supports_ewmh_active_window() &&
is_wine_window_active()) { is_wine_window_active()) {
set_input_focus(true); set_input_focus(true);
} }
@@ -548,7 +559,7 @@ void Editor::handle_x11_events() noexcept {
generic_event.get()); generic_event.get());
std::cerr << "DEBUG: LeaveNotify for window " std::cerr << "DEBUG: LeaveNotify for window "
<< event->event << std::endl; << event->child << std::endl;
// This extra check for the `NonlinearVirtual` detail is // This extra check for the `NonlinearVirtual` detail is
// important (see // important (see
@@ -560,7 +571,8 @@ void Editor::handle_x11_events() noexcept {
// with an actual Win32 dropdown menu). Without this check // with an actual Win32 dropdown menu). Without this check
// these fake dropdowns would immediately close when // these fake dropdowns would immediately close when
// hovering over them. // hovering over them.
if (event->detail != XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL && if (event->child == wine_window &&
event->detail != XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL &&
supports_ewmh_active_window() && supports_ewmh_active_window() &&
is_wine_window_active()) { is_wine_window_active()) {
set_input_focus(false); set_input_focus(false);