mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[client] x11: generate synthetic EnterNotify event on cursor leave
If the cursor was grabbed the window the cursor moves over when it is ungrabbed will recieve an EnterNotify event with the mode of NotifyUngrab, unfortunatly some window manages such as i3 will ignore this message and as such focus follows mouse will not function correctly. This patch injects a normal EnterNotify to work around this issue.
This commit is contained in:
parent
91b0cba145
commit
894b8b0c22
@ -1171,6 +1171,46 @@ static void x11XInputEvent(XGenericEventCookie *cookie)
|
|||||||
app_updateCursorPos(xie->event_x, xie->event_y);
|
app_updateCursorPos(xie->event_x, xie->event_y);
|
||||||
app_handleEnterEvent(false);
|
app_handleEnterEvent(false);
|
||||||
x11.entered = false;
|
x11.entered = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Because there is a race with the pointer ungrab the enter event for the
|
||||||
|
* next window is sometimes sent with the mode NotifyUngrab, unfortunatly
|
||||||
|
* some window managers such as i3 will ignore these which breaks focus
|
||||||
|
* follows mouse mode. To correct this we generate and send a normal
|
||||||
|
* EnterNotify event.
|
||||||
|
*/
|
||||||
|
int root_x, root_y, win_x, win_y;
|
||||||
|
Window root_win, child_win;
|
||||||
|
unsigned int mask;
|
||||||
|
XQueryPointer(x11.display, DefaultRootWindow(x11.display), &root_win,
|
||||||
|
&child_win, &root_x, &root_y, &win_x, &win_y, &mask);
|
||||||
|
|
||||||
|
int target_x, target_y;
|
||||||
|
Window target_root;
|
||||||
|
XTranslateCoordinates(x11.display, DefaultRootWindow(x11.display),
|
||||||
|
child_win, root_x, root_y, &target_x, &target_y, &target_root);
|
||||||
|
|
||||||
|
XEvent event;
|
||||||
|
memset(&event, 0, sizeof(event));
|
||||||
|
event.type = EnterNotify;
|
||||||
|
event.xcrossing.serial = 0;
|
||||||
|
event.xcrossing.send_event = True;
|
||||||
|
event.xcrossing.display = x11.display;
|
||||||
|
event.xcrossing.window = child_win;
|
||||||
|
event.xcrossing.root = root_win;
|
||||||
|
event.xcrossing.subwindow = child_win;
|
||||||
|
event.xcrossing.time = CurrentTime;
|
||||||
|
event.xcrossing.mode = NotifyNormal;
|
||||||
|
event.xcrossing.detail = NotifyNonlinear;
|
||||||
|
event.xcrossing.same_screen = True;
|
||||||
|
event.xcrossing.focus = False;
|
||||||
|
event.xcrossing.x = target_x;
|
||||||
|
event.xcrossing.y = target_y;
|
||||||
|
event.xcrossing.x_root = root_x;
|
||||||
|
event.xcrossing.y_root = root_y;
|
||||||
|
|
||||||
|
XSendEvent(x11.display, child_win, True, EnterWindowMask, &event);
|
||||||
|
XFlush(x11.display);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user