internal/uidriver/glfw: Bug fix: FPS is dropped when pressing the green button

Updates #1745
This commit is contained in:
Hajime Hoshi 2021-09-18 22:11:26 +09:00
parent 1a7cf7b3b8
commit 188e80d2f7
4 changed files with 24 additions and 3 deletions

View File

@ -776,6 +776,8 @@ func (u *UserInterface) registerWindowSetSizeCallback() {
return
}
u.adjustViewSize()
if u.window.GetAttrib(glfw.Resizable) == glfw.False {
return
}
@ -1228,6 +1230,8 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) {
windowRecreated := u.setWindowSizeImpl(width, height, fullscreen)
u.adjustViewSize()
// As width might be updated, update windowWidth/Height here.
u.windowWidth = width
u.windowHeight = height

View File

@ -63,17 +63,24 @@ package glfw
// if (!origResizable) {
// window.styleMask &= ~NSWindowStyleMaskResizable;
// }
// }
//
// static void adjustViewSize(uintptr_t windowPtr) {
// NSWindow* window = (NSWindow*)windowPtr;
// if ((window.styleMask & NSWindowStyleMaskFullScreen) == 0) {
// return;
// }
//
// // Reduce the view height (#1745).
// // https://stackoverflow.com/questions/27758027/sprite-kit-serious-fps-issue-in-full-screen-mode-on-os-x
// CGSize windowSize = [window frame].size;
// NSView* view = [window contentView];
// CGSize size = [view frame].size;
// size.width--;
// [view setFrameSize:size];
// CGSize viewSize = [view frame].size;
// if (windowSize.width != viewSize.width || windowSize.height != viewSize.height) {
// return;
// }
// viewSize.width--;
// [view setFrameSize:viewSize];
//
// // NSColor.blackColor (0, 0, 0, 1) didn't work.
// // Use the transparent color instead.
@ -179,3 +186,7 @@ func (u *UserInterface) setNativeFullscreen(fullscreen bool) {
glfw.WaitEventsTimeout(1)
C.setNativeFullscreen(C.uintptr_t(u.window.GetCocoaWindow()), C.bool(fullscreen))
}
func (u *UserInterface) adjustViewSize() {
C.adjustViewSize(C.uintptr_t(u.window.GetCocoaWindow()))
}

View File

@ -156,3 +156,6 @@ func (u *UserInterface) isNativeFullscreenAvailable() bool {
func (u *UserInterface) setNativeFullscreen(fullscreen bool) {
panic(fmt.Sprintf("glfw: setNativeFullscreen is not implemented in this environment: %s", runtime.GOOS))
}
func (u *UserInterface) adjustViewSize() {
}

View File

@ -203,3 +203,6 @@ func (u *UserInterface) isNativeFullscreenAvailable() bool {
func (u *UserInterface) setNativeFullscreen(fullscreen bool) {
panic(fmt.Sprintf("glfw: setNativeFullscreen is not implemented in this environment: %s", runtime.GOOS))
}
func (u *UserInterface) adjustViewSize() {
}