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:
Jonathan G Rennison
2023-09-02 20:46:57 +01:00
24 changed files with 240 additions and 362 deletions

View File

@@ -390,7 +390,7 @@ bool VideoDriver_Allegro::PollEvent()
}
/* Mouse movement */
if (_cursor.UpdateCursorPosition(mouse_x, mouse_y, false)) {
if (_cursor.UpdateCursorPosition(mouse_x, mouse_y)) {
position_mouse(_cursor.pos.x, _cursor.pos.y);
}
if (_cursor.delta.x != 0 || _cursor.delta.y) mouse_action = true;

View File

@@ -661,7 +661,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
_cursor.UpdateCursorPositionRelative(event.deltaX * self.getContentsScale, event.deltaY * self.getContentsScale);
} else {
NSPoint pt = [ self mousePositionFromEvent:event ];
_cursor.UpdateCursorPosition(pt.x, pt.y, false);
_cursor.UpdateCursorPosition(pt.x, pt.y);
}
HandleMouseEvents();

View File

@@ -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;

View File

@@ -484,12 +484,25 @@ bool VideoDriver_SDL::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)) {
x = ev.motion.x;
y = ev.motion.y;
}
}
if (_cursor.UpdateCursorPosition(x, y)) {
SDL_WarpMouse(_cursor.pos.x, _cursor.pos.y);
}
HandleMouseEvents();
break;
}
case SDL_MOUSEBUTTONDOWN:
if (_rightclick_emulate && SDL_GetModState() & KMOD_CTRL) {

View File

@@ -491,7 +491,7 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
}
if (_cursor.UpdateCursorPosition(x, y, false)) {
if (_cursor.UpdateCursorPosition(x, y)) {
POINT pt;
pt.x = _cursor.pos.x;
pt.y = _cursor.pos.y;