diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-15 20:12:25 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-15 20:12:25 +0200 |
commit | c2babb65580d4dce3a0fc8834dd05fe177227b6e (patch) | |
tree | d313ea8efbb29b032a1f3205b4fc49201e667a39 /platform | |
parent | 76b41bde3c231d80ebe080678cdcec3c861c771f (diff) | |
parent | 734b89124ec525d22c8431032f98f7569a052ef7 (diff) |
Merge pull request #65831 from bruvzg/vlk_edge_lag
[macOS] Fix redraw lag at the edge of the resizing window.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/macos/display_server_macos.h | 2 | ||||
-rw-r--r-- | platform/macos/godot_content_view.mm | 18 | ||||
-rw-r--r-- | platform/macos/godot_window_delegate.mm | 4 |
3 files changed, 23 insertions, 1 deletions
diff --git a/platform/macos/display_server_macos.h b/platform/macos/display_server_macos.h index 769cba2de5..bb5dce641a 100644 --- a/platform/macos/display_server_macos.h +++ b/platform/macos/display_server_macos.h @@ -85,6 +85,8 @@ public: Size2i max_size; Size2i size; + NSRect last_frame_rect; + bool im_active = false; Size2i im_position; diff --git a/platform/macos/godot_content_view.mm b/platform/macos/godot_content_view.mm index f93ef48f6c..cb70a5db86 100644 --- a/platform/macos/godot_content_view.mm +++ b/platform/macos/godot_content_view.mm @@ -61,6 +61,24 @@ @implementation GodotContentView - (void)setFrameSize:(NSSize)newSize { + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); + if (ds && ds->has_window(window_id)) { + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); + NSRect frameRect = [wd.window_object frame]; + bool left = (wd.last_frame_rect.origin.x != frameRect.origin.x); + bool top = (wd.last_frame_rect.origin.y == frameRect.origin.y); + if (left && top) { + self.layerContentsPlacement = NSViewLayerContentsPlacementBottomRight; + } else if (left && !top) { + self.layerContentsPlacement = NSViewLayerContentsPlacementTopRight; + } else if (!left && top) { + self.layerContentsPlacement = NSViewLayerContentsPlacementBottomLeft; + } else { + self.layerContentsPlacement = NSViewLayerContentsPlacementTopLeft; + } + wd.last_frame_rect = frameRect; + } + [super setFrameSize:newSize]; [self.layer setNeedsDisplay]; // Force "drawRect" call. } diff --git a/platform/macos/godot_window_delegate.mm b/platform/macos/godot_window_delegate.mm index 2d9329ab3c..e1034c9993 100644 --- a/platform/macos/godot_window_delegate.mm +++ b/platform/macos/godot_window_delegate.mm @@ -151,7 +151,9 @@ - (void)windowWillStartLiveResize:(NSNotification *)notification { DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); - if (ds) { + if (ds && ds->has_window(window_id)) { + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); + wd.last_frame_rect = [wd.window_object frame]; ds->set_is_resizing(true); } } |