From 8ef3bba286571d49e5b3c67e02c5ea5a82b0b5b2 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 9 Jun 2024 08:34:31 +1000 Subject: [PATCH] Mac classic: Support resizing and fix not compiling with multiversal headers --- .github/workflows/build_mac32.yml | 2 +- src/Window_MacClassic.c | 25 +++++++++++++++++++++++-- src/Window_cocoa.m | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_mac32.yml b/.github/workflows/build_mac32.yml index 6e7d6f437..e0193b199 100644 --- a/.github/workflows/build_mac32.yml +++ b/.github/workflows/build_mac32.yml @@ -13,7 +13,7 @@ concurrency: jobs: build: - if: ${{ inputs.WEBHOOK_URL != '' }} + if: ${{ inputs.WEBHOOK_URL != '' }} runs-on: ubuntu-latest container: image: ghcr.io/classicube/minimal-osxcross:latest diff --git a/src/Window_MacClassic.c b/src/Window_MacClassic.c index ecb50c4ac..2f2057ee2 100644 --- a/src/Window_MacClassic.c +++ b/src/Window_MacClassic.c @@ -116,6 +116,15 @@ void Console_Write(const char* msg, int len) { #endif typedef unsigned long MAC_FourCharCode; typedef SInt16 MAC_WindowPartCode; +typedef UInt16 MAC_EventMask; + +// Workaround issue in multiversal headers +#if defined M68K_INLINE && TARGET_CPU_68K + +// Availability: in InterfaceLib 7.1 and later +MAC_SYSAPI(void) _SetEventMask(MAC_EventMask value) MAC_TWOWORDINLINE(0x31DF, 0x0144); +#define SetEventMask _SetEventMask +#endif /*########################################################################################################################* *--------------------------------------------------Public implementation--------------------------------------------------* @@ -258,7 +267,7 @@ static void HandleMouseDown(EventRecord* event) { MAC_WindowPartCode part; WindowPtr window; Point localPoint; - + long res; int x, y; part = FindWindow(event->where, &window); @@ -273,6 +282,7 @@ static void HandleMouseDown(EventRecord* event) { case inContent: SetPt(&localPoint, event->where.h, event->where.v); GlobalToLocal(&localPoint); + if (window != win) break; x = localPoint.h; y = localPoint.v; @@ -287,10 +297,21 @@ static void HandleMouseDown(EventRecord* event) { Window_RequestClose(); Window_Main.Exists = false; } + break; + case inGrow: + res = GrowWindow(window, event->where, &qd.screenBits.bounds); + x = res & 0xFFFF; + y = res >> 16; + SizeWindow(window, x, y, false); + if (window != win) break; + + Window_Main.Width = x; + Window_Main.Height = y; + Event_RaiseVoid(&WindowEvents.Resized); + break; } } - static void HandleMouseUp(EventRecord* event) { Input_SetReleased(CCMOUSE_L); } diff --git a/src/Window_cocoa.m b/src/Window_cocoa.m index 246d8c315..8ceea0e5b 100644 --- a/src/Window_cocoa.m +++ b/src/Window_cocoa.m @@ -866,8 +866,9 @@ void GLContext_GetApiInfo(cc_string* info) { GLinteger nRenders = 0; CGLRendererInfoObj rend; CGLQueryRendererInfo(-1, &rend, &nRenders); + int i; - for (int i = 0; i < nRenders; i++) + for (i = 0; i < nRenders; i++) { GLinteger curID = -1; CGLDescribeRenderer(rend, i, kCGLRPRendererID, &curID);