Skip to content

Commit

Permalink
native/macos: Re-re-implemented event loop
Browse files Browse the repository at this point in the history
- Reverted macos.rs to this implementation:
not-fl3#443 (it's probably better compare changes with this PR than with latest commit to understand what was added additionally)
- Now using own NSView with NSOpenGLContext instead of NSOpenGLView
- For metal backend using redraw instead setNeedsDisplay, because somehow it reduces cpu usage (Cannot find info about enabling vsync like this in MTKView docs)
- Fixed freezing on resize by drawing in draw_rect that called during "live resize"™. I don't like this approach, but it blocks main event loop while resizing, so it will not be some kind of concurency of opengl stuff i think
- Reducing CPU usage when window is occluded
- Added comments to hacky places, there are lots of them imo

Fixes:
- not-fl3#455
- not-fl3#470
  • Loading branch information
birhburh committed Aug 11, 2024
1 parent b4b7b84 commit 7aef5d0
Show file tree
Hide file tree
Showing 2 changed files with 263 additions and 394 deletions.
3 changes: 3 additions & 0 deletions src/native/apple/frameworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ extern "C" {
extern "C" {
pub static NSRunLoopCommonModes: ObjcId;
pub static NSDefaultRunLoopMode: ObjcId;
pub static NSEventTrackingRunLoopMode: ObjcId;
pub static NSProcessInfo: ObjcId;
pub fn NSStringFromClass(class: ObjcId) -> ObjcId;

Expand Down Expand Up @@ -422,6 +423,8 @@ pub enum NSWindowStyleMask {
NSFullSizeContentViewWindowMask = 1 << 15,
}

pub const NSWindowOcclusionStateVisible: u64 = 1 << 1;

#[repr(u64)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum NSApplicationActivationOptions {
Expand Down
Loading

0 comments on commit 7aef5d0

Please sign in to comment.