mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 17:47:12 -04:00
Cocoa: Fix legacy fullscreen mode not adjusting window size state and variables
This commit is contained in:
parent
a8ba05adea
commit
a7893ca0ec
@ -141,11 +141,20 @@ void Window_Init(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void RefreshWindowBounds(void) {
|
static void RefreshWindowBounds(void) {
|
||||||
NSRect win, view;
|
if (legacy_fullscreen) {
|
||||||
int viewY;
|
CGRect rect = CGDisplayBounds(CGMainDisplayID());
|
||||||
|
windowX = (int)rect.origin.x; // usually 0
|
||||||
|
windowY = (int)rect.origin.y; // usually 0
|
||||||
|
// TODO is it correct to use display bounds and not just 0?
|
||||||
|
|
||||||
win = [winHandle frame];
|
WindowInfo.Width = (int)rect.size.width;
|
||||||
view = [viewHandle frame];
|
WindowInfo.Height = (int)rect.size.height;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSRect win = [winHandle frame];
|
||||||
|
NSRect view = [viewHandle frame];
|
||||||
|
int viewY;
|
||||||
|
|
||||||
// For cocoa, the 0,0 origin is the bottom left corner of windows/views/screen.
|
// For cocoa, the 0,0 origin is the bottom left corner of windows/views/screen.
|
||||||
// To get window's real Y screen position, first need to find Y of top. (win.y + win.height)
|
// To get window's real Y screen position, first need to find Y of top. (win.y + win.height)
|
||||||
@ -167,7 +176,7 @@ static void RefreshWindowBounds(void) {
|
|||||||
- (void)keyDown:(NSEvent *)event { }
|
- (void)keyDown:(NSEvent *)event { }
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface CCWindowDelegate : NSObject { }
|
@interface CCWindowDelegate : NSObject<NSWindowDelegate> { }
|
||||||
@end
|
@end
|
||||||
@implementation CCWindowDelegate
|
@implementation CCWindowDelegate
|
||||||
- (void)windowDidResize:(NSNotification *)notification {
|
- (void)windowDidResize:(NSNotification *)notification {
|
||||||
@ -352,7 +361,7 @@ void Window_Close(void) {
|
|||||||
[winHandle close];
|
[winHandle close];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MapNativeMouse(int button) {
|
static int MapNativeMouse(NSInteger button) {
|
||||||
if (button == 0) return KEY_LMOUSE;
|
if (button == 0) return KEY_LMOUSE;
|
||||||
if (button == 1) return KEY_RMOUSE;
|
if (button == 1) return KEY_RMOUSE;
|
||||||
if (button == 2) return KEY_MMOUSE;
|
if (button == 2) return KEY_MMOUSE;
|
||||||
@ -747,13 +756,14 @@ cc_result Window_EnterFullscreen(void) {
|
|||||||
Platform_LogConst("Falling back to legacy fullscreen..");
|
Platform_LogConst("Falling back to legacy fullscreen..");
|
||||||
legacy_fullscreen = true;
|
legacy_fullscreen = true;
|
||||||
[ctxHandle clearDrawable];
|
[ctxHandle clearDrawable];
|
||||||
|
CGDisplayCapture(CGMainDisplayID());
|
||||||
|
|
||||||
// setFullScreen doesn't return an error code, which is unfortunate
|
// setFullScreen doesn't return an error code, which is unfortunate
|
||||||
// because if setFullScreen fails, you're left with a blank window
|
// because if setFullScreen fails, you're left with a blank window
|
||||||
// that's still rendering thousands of frames per second
|
// that's still rendering thousands of frames per second
|
||||||
//[ctxHandle setFullScreen];
|
//[ctxHandle setFullScreen];
|
||||||
//return 0;
|
//return 0;
|
||||||
|
|
||||||
|
|
||||||
// CGLSetFullScreenOnDisplay is the preferable API, because it
|
// CGLSetFullScreenOnDisplay is the preferable API, because it
|
||||||
// works properly on macOS 10.7 and all later versions
|
// works properly on macOS 10.7 and all later versions
|
||||||
// However, because this API was only introduced in 10.7, it
|
// However, because this API was only introduced in 10.7, it
|
||||||
@ -768,8 +778,10 @@ cc_result Window_EnterFullscreen(void) {
|
|||||||
// fail to work (CGLSetFullScreenOnDisplay still works) though
|
// fail to work (CGLSetFullScreenOnDisplay still works) though
|
||||||
// So make sure you compile ClassiCube with an older SDK version
|
// So make sure you compile ClassiCube with an older SDK version
|
||||||
cc_result res = CGLSetFullScreen([ctxHandle CGLContextObj]);
|
cc_result res = CGLSetFullScreen([ctxHandle CGLContextObj]);
|
||||||
// TODO do we need to capture the display?
|
|
||||||
if (res) Window_ExitFullscreen();
|
if (res) Window_ExitFullscreen();
|
||||||
|
RefreshWindowBounds();
|
||||||
|
Event_RaiseVoid(&WindowEvents.Resized);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -780,8 +792,12 @@ cc_result Window_ExitFullscreen(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
legacy_fullscreen = false;
|
legacy_fullscreen = false;
|
||||||
|
CGDisplayRelease(CGMainDisplayID());
|
||||||
[ctxHandle clearDrawable];
|
[ctxHandle clearDrawable];
|
||||||
[ctxHandle setView:viewHandle];
|
[ctxHandle setView:viewHandle];
|
||||||
|
|
||||||
|
RefreshWindowBounds();
|
||||||
|
Event_RaiseVoid(&WindowEvents.Resized);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user