[Scummvm-git-logs] scummvm master -> 4a86b0be1c3f76c187c4ddf1c4b1e7492c6d495a
eriktorbjorn
noreply at scummvm.org
Sat Oct 5 08:17:33 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4a86b0be1c SCUMM: MACGUI: Fix beam cursor crash
Commit: 4a86b0be1c3f76c187c4ddf1c4b1e7492c6d495a
https://github.com/scummvm/scummvm/commit/4a86b0be1c3f76c187c4ddf1c4b1e7492c6d495a
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2024-10-05T10:13:09+02:00
Commit Message:
SCUMM: MACGUI: Fix beam cursor crash
This would happen if, while selecting text in an editable text widget,
you dragged the cursor too far down and outside of the dialog box. There
is no sensible reason to do this, but I was trying to mimic the original
behavior.
This was a regression from when the Mac screen height was increased from
400 to 480 pixels. The beam cursor is drawn manually, rather than by the
backend, because it's supposed to invert the background it's drawn over.
I did notice another regression, albeit a minor one: If you drag the
beam cursor to the top of the screen, it will corrupt the menu bar. I
think this is because the menu bar isn't drawn on the Mac screen. To
fix, we would have to copy the actual screen buffer instead, but I think
the only way of doing this is using lockScreen() and that's inefficient.
At least it shouldn't crash any more.
Changed paths:
engines/scumm/macgui/macgui_dialogwindow.cpp
diff --git a/engines/scumm/macgui/macgui_dialogwindow.cpp b/engines/scumm/macgui/macgui_dialogwindow.cpp
index 04a3e4a55d8..2ff2dbebbbf 100644
--- a/engines/scumm/macgui/macgui_dialogwindow.cpp
+++ b/engines/scumm/macgui/macgui_dialogwindow.cpp
@@ -222,7 +222,9 @@ void MacGuiImpl::MacDialogWindow::drawBeamCursor() {
int x1 = x0 + _beamCursor->w;
int y1 = y0 + _beamCursor->h;
- _beamCursor->copyRectToSurface(*(_gui->surface()), 0, 0, Common::Rect(x0, y0, x1, y1));
+ Graphics::Surface *screen = _gui->surface();
+
+ _beamCursor->copyRectToSurface(*screen, 0, 0, Common::Rect(x0, y0, x1, y1));
const byte beam[] = {
0, 0, 1, 0, 5, 0, 6, 0, 2, 1, 4, 1, 3, 2, 3, 3,
@@ -256,14 +258,14 @@ void MacGuiImpl::MacDialogWindow::drawBeamCursor() {
x0 = 0;
}
- x1 = MIN(x1, 640);
+ x1 = MIN<int>(x1, screen->w);
if (y0 < 0) {
srcY = -y0;
y0 = 0;
}
- y1 = MIN(y1, 400);
+ y1 = MIN<int>(y1, screen->h);
_system->copyRectToScreen(_beamCursor->getBasePtr(srcX, srcY), _beamCursor->pitch, x0, y0, x1 - x0, y1 - y0);
}
@@ -274,12 +276,12 @@ void MacGuiImpl::MacDialogWindow::undrawBeamCursor() {
int x1 = x0 + _beamCursor->w;
int y1 = y0 + _beamCursor->h;
+ Graphics::Surface *screen = _gui->surface();
+
x0 = MAX(x0, 0);
- x1 = MIN(x1, 640);
+ x1 = MIN<int>(x1, screen->w);
y0 = MAX(y0, 0);
- y1 = MIN(y1, 400);
-
- Graphics::Surface *screen = _gui->surface();
+ y1 = MIN<int>(y1, screen->h);
_system->copyRectToScreen(screen->getBasePtr(x0, y0), screen->pitch, x0, y0, x1 - x0, y1 - y0);
}
More information about the Scummvm-git-logs
mailing list