Skip to content

Commit

Permalink
Cleanup focus handling code on propagation
Browse files Browse the repository at this point in the history
Signed-off-by: Tin <[email protected]>
  • Loading branch information
Caellian committed Nov 10, 2023
1 parent 8f98f68 commit d16d977
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1371,25 +1371,29 @@ void propagate_x11_event(XEvent &ev) {
i_ev->common.y = i_ev->common.y_root;
}
XSendEvent(display, window.desktop, False, window.event_mask, &ev);
// FIXME (before-merge): Should we be setting input focus after forwarding
// events?
if (false && ev.type == ButtonPress) {
XSetInputFocus(display, window.desktop, RevertToNone, i_ev->common.time);
} else if (false && ev.type == MotionNotify) {
XSetInputFocus(display, window.window, RevertToParent, i_ev->common.time);

int _revert_to;
Window focused;
XGetInputFocus(display, &focused, &_revert_to);
if (focused == window.window) {
Time time = CurrentTime;
if (i_ev != nullptr) {
time = i_ev->common.time;
}
XSetInputFocus(display, window.desktop, RevertToPointerRoot, time);
}
}

#ifdef BUILD_MOUSE_EVENTS
// Assuming parent has a simple linear stack of descendants, this function
// returns the last leaf on the graph.
inline Window last_descendant(Display* display, Window parent) {
Window ignored, *children;
Window _ignored, *children;
uint32_t count;

Window current = parent;

while (XQueryTree(display, current, &ignored, &ignored, &children, &count) && count != 0) {
while (XQueryTree(display, current, &_ignored, &_ignored, &children, &count) && count != 0) {
current = children[count - 1];
XFree(children);
}
Expand Down

0 comments on commit d16d977

Please sign in to comment.