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

View File

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