Also resize the OpenGL view on macOS
This fixes resizing with OpenGL applications.
This commit is contained in:
parent
e0c79c58fb
commit
c7b61fa39b
|
@ -11,6 +11,7 @@ use cocoa::appkit::{
|
||||||
NSOpenGLProfileVersionLegacy, NSOpenGLView, NSView,
|
NSOpenGLProfileVersionLegacy, NSOpenGLView, NSView,
|
||||||
};
|
};
|
||||||
use cocoa::base::{id, nil, YES};
|
use cocoa::base::{id, nil, YES};
|
||||||
|
use cocoa::foundation::NSSize;
|
||||||
|
|
||||||
use core_foundation::base::TCFType;
|
use core_foundation::base::TCFType;
|
||||||
use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName};
|
use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName};
|
||||||
|
@ -134,6 +135,14 @@ impl GlContext {
|
||||||
let () = msg_send![self.view, setNeedsDisplay: YES];
|
let () = msg_send![self.view, setNeedsDisplay: YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// On macOS the `NSOpenGLView` needs to be resized separtely from our main view.
|
||||||
|
pub(crate) fn resize(&self, size: NSSize) {
|
||||||
|
unsafe { NSView::setFrameSize(self.view, size) };
|
||||||
|
unsafe {
|
||||||
|
let _: () = msg_send![self.view, setNeedsDisplay: YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for GlContext {
|
impl Drop for GlContext {
|
||||||
|
|
|
@ -106,4 +106,10 @@ impl GlContext {
|
||||||
pub fn swap_buffers(&self) {
|
pub fn swap_buffers(&self) {
|
||||||
self.context.swap_buffers();
|
self.context.swap_buffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// On macOS the `NSOpenGLView` needs to be resized separtely from our main view.
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
pub(crate) fn resize(&self, size: cocoa::foundation::NSSize) {
|
||||||
|
self.context.resize(size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue