shithub: pt2-clone

Download patch

ref: 96e8da63a3719f74c93b30117bed37da9ee15042
parent: f6f4566fb88896f4449d897fcd4e246cd42117da
author: Olav Sørensen <olav.sorensen@live.no>
date: Tue May 10 14:04:58 EDT 2022

Handle top-left corner as quit in fullscreen mode

Issue #25.

--- a/src/pt2_mouse.c
+++ b/src/pt2_mouse.c
@@ -280,6 +280,9 @@
 		mouse.buttonState = SDL_GetMouseState(&mx, &my);
 	}
 
+	mouse.rawX = mx;
+	mouse.rawY = my;
+
 	if (video.fullscreen)
 	{
 		// centered fullscreen mode (not stretched) needs further coord translation
@@ -2206,6 +2209,10 @@
 bool handleLeftMouseButton(void)
 {
 	int32_t guiButton;
+
+	// if in fullscreen mode and the image isn't filling the whole screen, handle top left corner as quit
+	if (video.fullscreen && (video.renderX > 0 || video.renderY > 0) && (mouse.rawX == 0 && mouse.rawY == 0))
+		return handleGUIButtons(PTB_QUIT);
 
 	if (editor.swapChannelFlag || ui.editTextFlag)
 		return false;
--- a/src/pt2_structs.h
+++ b/src/pt2_structs.h
@@ -120,7 +120,7 @@
 	volatile bool setPosFlag, resetCursorColorFlag;
 	bool buttonWaiting, leftButtonPressed, rightButtonPressed;
 	uint8_t repeatCounter, buttonWaitCounter;
-	int32_t x, y, lastMouseX, setPosX, setPosY, lastGUIButton, prevX, prevY;
+	int32_t rawX, rawY, x, y, lastMouseX, setPosX, setPosY, lastGUIButton, prevX, prevY;
 	int32_t lastSmpFilterButton, lastSamplingButton;
 	uint32_t buttonState;
 } mouse_t;