Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed set_size in cocoa to keep same window position when changing size #350

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,24 @@ using browser_engine = gtk_webkit_engine;

#define WKUserScriptInjectionTimeAtDocumentStart 0

typedef struct NSPoint
{
CGFloat x;
CGFloat y;
} NSPoint;

typedef struct NSSize
{
CGFloat width;
CGFloat height;
} NSSize;

typedef struct NSRect
{
NSPoint origin;
NSSize size;
} NSRect;

namespace webview {

// Helpers to avoid too much typing
Expand Down Expand Up @@ -684,8 +702,9 @@ class cocoa_wkwebview_engine {
size.height = height;
objc_msgSend(m_window, "setContentMaxSize:"_sel, size);
} else {
NSRect rect = ((NSRect(*)(id, SEL))objc_msgSend_stret)(m_window, "frame"_sel);
objc_msgSend(m_window, "setFrame:display:animate:"_sel,
CGRectMake(0, 0, width, height), 1, 0);
CGRectMake(rect.origin.x, rect.origin.y, width, height), 1, 0);
}
}
void navigate(const std::string url) {
Expand Down