Skip to content

Commit

Permalink
Merge pull request #81339 from bruvzg/macos_fix_mvk_live_resize
Browse files Browse the repository at this point in the history
[macOS] Fix live resize with the latest MoltenVK version.
  • Loading branch information
YuriSizov committed Sep 6, 2023
2 parents 4ac6b64 + 208b379 commit 0717663
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions platform/macos/godot_content_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@

@interface GodotContentLayerDelegate : NSObject <CALayerDelegate> {
DisplayServer::WindowID window_id;
bool need_redraw;
}

- (void)setWindowID:(DisplayServer::WindowID)wid;
- (void)setNeedRedraw:(bool)redraw;

@end

Expand Down
9 changes: 8 additions & 1 deletion platform/macos/godot_content_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,26 @@ @implementation GodotContentLayerDelegate
- (id)init {
self = [super init];
window_id = DisplayServer::INVALID_WINDOW_ID;
need_redraw = false;
return self;
}

- (void)setWindowID:(DisplayServerMacOS::WindowID)wid {
window_id = wid;
}

- (void)setNeedRedraw:(bool)redraw {
need_redraw = redraw;
}

- (void)displayLayer:(CALayer *)layer {
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
if (OS::get_singleton()->get_main_loop() && ds->get_is_resizing()) {
if (OS::get_singleton()->get_main_loop() && ds->get_is_resizing() && need_redraw) {
Main::force_redraw();
if (!Main::is_iterating()) { // Avoid cyclic loop.
Main::iteration();
}
need_redraw = false;
}
}

Expand Down Expand Up @@ -93,6 +99,7 @@ - (void)setFrameSize:(NSSize)newSize {
}

[super setFrameSize:newSize];
[layer_delegate setNeedRedraw:true];
[self.layer setNeedsDisplay]; // Force "drawRect" call.
}

Expand Down

0 comments on commit 0717663

Please sign in to comment.