Merge branch 'master' into jgrpp
# Conflicts: # src/console.cpp # src/os/os2/os2.cpp # src/os/unix/font_unix.cpp # src/strgen/strgen.h # src/strgen/strgen_base.cpp # src/table/settings/gui_settings.ini
This commit is contained in:
@@ -653,12 +653,25 @@ bool VideoDriver_SDL_Base::PollEvent()
|
||||
if (!SDL_PollEvent(&ev)) return false;
|
||||
|
||||
switch (ev.type) {
|
||||
case SDL_MOUSEMOTION:
|
||||
if (_cursor.UpdateCursorPosition(ev.motion.x, ev.motion.y, true)) {
|
||||
case SDL_MOUSEMOTION: {
|
||||
int32_t x = ev.motion.x;
|
||||
int32_t y = ev.motion.y;
|
||||
|
||||
if (_cursor.fix_at) {
|
||||
/* Get all queued mouse events now in case we have to warp the cursor. In the
|
||||
* end, we only care about the current mouse position and not bygone events. */
|
||||
while (SDL_PeepEvents(&ev, 1, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEMOTION)) {
|
||||
x = ev.motion.x;
|
||||
y = ev.motion.y;
|
||||
}
|
||||
}
|
||||
|
||||
if (_cursor.UpdateCursorPosition(x, y)) {
|
||||
SDL_WarpMouseInWindow(this->sdl_window, _cursor.pos.x, _cursor.pos.y);
|
||||
}
|
||||
HandleMouseEvents();
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_MOUSEWHEEL:
|
||||
if (ev.wheel.y > 0) {
|
||||
@@ -790,10 +803,8 @@ bool VideoDriver_SDL_Base::PollEvent()
|
||||
} else if (ev.window.event == SDL_WINDOWEVENT_ENTER) {
|
||||
// mouse entered the window, enable cursor
|
||||
_cursor.in_window = true;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
/* Ensure pointer lock will not occur. */
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
#endif
|
||||
} else if (ev.window.event == SDL_WINDOWEVENT_LEAVE) {
|
||||
// mouse left the window, undraw cursor
|
||||
UndrawMouseCursor();
|
||||
@@ -832,9 +843,6 @@ static const char *InitializeSDL()
|
||||
* UpdateWindowSurface() to update the window's texture instead of
|
||||
* its surface. */
|
||||
SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "0");
|
||||
#ifndef __EMSCRIPTEN__
|
||||
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1");
|
||||
#endif
|
||||
|
||||
/* Check if the video-driver is already initialized. */
|
||||
if (SDL_WasInit(SDL_INIT_VIDEO) != 0) return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user