Fix unsent WINDOW_EVENT_MOUSE_ENTER event on mouse_mode-change
coauthor: @bruvzg On linuxbsd and macOS the WINDOW_EVENT_MOUSE_ENTER was not sent, when the mouse became visible again after a mouse_mode-change.
This commit is contained in:
parent
dca5cb8e40
commit
52d75c9b35
2 changed files with 25 additions and 6 deletions
|
@ -376,10 +376,18 @@ void DisplayServerX11::mouse_set_mode(MouseMode p_mode) {
|
|||
}
|
||||
|
||||
// The only modes that show a cursor are VISIBLE and CONFINED
|
||||
bool showCursor = (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED);
|
||||
bool show_cursor = (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED);
|
||||
bool previously_shown = (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED);
|
||||
|
||||
if (show_cursor && !previously_shown) {
|
||||
WindowID window_id = get_window_at_screen_position(mouse_get_position());
|
||||
if (window_id != INVALID_WINDOW_ID) {
|
||||
_send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER);
|
||||
}
|
||||
}
|
||||
|
||||
for (const KeyValue<WindowID, WindowData> &E : windows) {
|
||||
if (showCursor) {
|
||||
if (show_cursor) {
|
||||
XDefineCursor(x11_display, E.value.x11_window, cursors[current_cursor]); // show cursor
|
||||
} else {
|
||||
XDefineCursor(x11_display, E.value.x11_window, null_cursor); // hide cursor
|
||||
|
|
|
@ -1843,11 +1843,22 @@ void DisplayServerMacOS::mouse_set_mode(MouseMode p_mode) {
|
|||
window_id = MAIN_WINDOW_ID;
|
||||
}
|
||||
WindowData &wd = windows[window_id];
|
||||
|
||||
bool show_cursor = (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED);
|
||||
bool previously_shown = (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED);
|
||||
|
||||
if (show_cursor && !previously_shown) {
|
||||
WindowID window_id = get_window_at_screen_position(mouse_get_position());
|
||||
if (window_id != INVALID_WINDOW_ID) {
|
||||
send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER);
|
||||
}
|
||||
}
|
||||
|
||||
if (p_mode == MOUSE_MODE_CAPTURED) {
|
||||
// Apple Docs state that the display parameter is not used.
|
||||
// "This parameter is not used. By default, you may pass kCGDirectMainDisplay."
|
||||
// https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/Quartz_Services_Ref/Reference/reference.html
|
||||
if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
|
||||
if (previously_shown) {
|
||||
CGDisplayHideCursor(kCGDirectMainDisplay);
|
||||
}
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
|
@ -1858,7 +1869,7 @@ void DisplayServerMacOS::mouse_set_mode(MouseMode p_mode) {
|
|||
CGPoint lMouseWarpPos = { pointOnScreen.x, CGDisplayBounds(CGMainDisplayID()).size.height - pointOnScreen.y };
|
||||
CGWarpMouseCursorPosition(lMouseWarpPos);
|
||||
} else if (p_mode == MOUSE_MODE_HIDDEN) {
|
||||
if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
|
||||
if (previously_shown) {
|
||||
CGDisplayHideCursor(kCGDirectMainDisplay);
|
||||
}
|
||||
[wd.window_object setMovable:YES];
|
||||
|
@ -1868,7 +1879,7 @@ void DisplayServerMacOS::mouse_set_mode(MouseMode p_mode) {
|
|||
[wd.window_object setMovable:NO];
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
} else if (p_mode == MOUSE_MODE_CONFINED_HIDDEN) {
|
||||
if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
|
||||
if (previously_shown) {
|
||||
CGDisplayHideCursor(kCGDirectMainDisplay);
|
||||
}
|
||||
[wd.window_object setMovable:NO];
|
||||
|
@ -1884,7 +1895,7 @@ void DisplayServerMacOS::mouse_set_mode(MouseMode p_mode) {
|
|||
warp_events.clear();
|
||||
mouse_mode = p_mode;
|
||||
|
||||
if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
|
||||
if (show_cursor) {
|
||||
cursor_update_shape();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue