mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 09:06:55 -04:00
Implement Window_IsObscured for macOS
This commit is contained in:
parent
db9ee23a86
commit
e9a6edf9cd
@ -543,7 +543,11 @@ cc_result Window_ExitFullscreen(void) {
|
||||
return res;
|
||||
}
|
||||
|
||||
int Window_IsObscured(void) { return 0; }
|
||||
int Window_IsObscured(void) {
|
||||
/* TODO: This isn't a complete fix because it doesn't check for occlusion - */
|
||||
/* so you'll still get 100% CPU usage when window is hidden in background */
|
||||
return IsWindowCollapsed(win_handle);
|
||||
}
|
||||
|
||||
void Window_Show(void) {
|
||||
ShowWindow(win_handle);
|
||||
|
@ -10,6 +10,7 @@ static int windowX, windowY;
|
||||
static NSApplication* appHandle;
|
||||
static NSWindow* winHandle;
|
||||
static NSView* viewHandle;
|
||||
static cc_bool canCheckOcclusion;
|
||||
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------Shared with Carbon----------------------------------------------------*
|
||||
@ -287,6 +288,8 @@ static void DoCreateWindow(int width, int height) {
|
||||
RefreshWindowBounds();
|
||||
MakeContentView();
|
||||
ApplyIcon();
|
||||
|
||||
canCheckOcclusion = [winHandle respondsToSelector:@selector(occlusionState)];
|
||||
}
|
||||
void Window_Create2D(int width, int height) { DoCreateWindow(width, height); }
|
||||
void Window_Create3D(int width, int height) { DoCreateWindow(width, height); }
|
||||
@ -323,7 +326,16 @@ cc_result Window_ExitFullscreen(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Window_IsObscured(void) { return 0; }
|
||||
// NOTE: Only defined since macOS 10.9 SDK
|
||||
#define _NSWindowOcclusionStateVisible (1 << 1)
|
||||
int Window_IsObscured(void) {
|
||||
if (!canCheckOcclusion)
|
||||
return [winHandle isMiniaturized];
|
||||
|
||||
// covers both minimised and hidden behind another window
|
||||
int flags = [winHandle occlusionState];
|
||||
return !(flags & _NSWindowOcclusionStateVisible);
|
||||
}
|
||||
|
||||
void Window_Show(void) {
|
||||
[winHandle makeKeyAndOrderFront:appHandle];
|
||||
|
Loading…
x
Reference in New Issue
Block a user