Skip to content

Commit 627cfa2

Browse files
authored
Fix window frame calculation on macOS (#22)
1 parent 3e2622c commit 627cfa2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

webview/src/webview_darwin.mm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <dmsdk/dlib/array.h>
44
#include <dmsdk/dlib/log.h>
55
#include <dmsdk/dlib/mutex.h>
6+
#include <dmsdk/graphics/graphics_native.h>
67
#include <dmsdk/script/script.h>
78
#include <dmsdk/extension/extension.h>
89

@@ -175,10 +176,10 @@ int Platform_Create(lua_State* L, dmWebView::WebViewInfo* _info)
175176
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
176177
WKWebView *view = [[WKWebView alloc] initWithFrame:screen.bounds configuration:configuration];
177178
#elif defined(DM_PLATFORM_OSX)
178-
NSScreen* screen = [NSScreen mainScreen];
179+
CGRect gameFrame = [dmGraphics::GetNativeOSXNSView() frame];
179180

180181
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
181-
WKWebView *view = [[WKWebView alloc] initWithFrame:screen.visibleFrame configuration:configuration];
182+
WKWebView *view = [[WKWebView alloc] initWithFrame:gameFrame configuration:configuration];
182183
#endif
183184
WebViewDelegate* navigationDelegate = [WebViewDelegate alloc];
184185
navigationDelegate->m_WebViewID = webview_id;
@@ -298,7 +299,7 @@ int Platform_SetPosition(lua_State* L, int webview_id, int x, int y, int width,
298299
#if defined(DM_PLATFORM_IOS)
299300
CGRect screenRect = [[UIScreen mainScreen] bounds];
300301
#elif defined(DM_PLATFORM_OSX)
301-
CGRect screenRect = [[NSScreen mainScreen] visibleFrame];
302+
CGRect screenRect = [dmGraphics::GetNativeOSXNSView() frame];
302303
#endif
303304
g_WebView.m_WebViews[webview_id].frame = CGRectMake(x, y, width >= 0 ? width : screenRect.size.width, height >= 0 ? height : screenRect.size.height);
304305
return 0;

0 commit comments

Comments
 (0)