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

SetSize repositions the window at 0,0 with Cocoa #349

Open
xDuck opened this issue Apr 15, 2020 · 1 comment · May be fixed by #350
Open

SetSize repositions the window at 0,0 with Cocoa #349

xDuck opened this issue Apr 15, 2020 · 1 comment · May be fixed by #350

Comments

@xDuck
Copy link

xDuck commented Apr 15, 2020

What OS are you using (uname -a, or Windows version)?

MacOS

What programming language are you using (C/C++/Go/Rust)?

go version go1.12.10 darwin/amd64

What did you expect to see and what you saw instead?

Using SetSize I expected the window to resize and keep it's position. Instead it resized to the right size but went to position 0,0.

In webview.h the code is set to specifically align the the view to 0,0 and set the new size.

objc_msgSend(m_window, "setFrame:display:animate:"_sel,
                   CGRectMake(0, 0, width, height), 1, 0);

The call to CGRectMake(0, 0, width, height) should really be something like CGRectMake(frame.origin.x, frame.origin.y, width, height). Unfortunately I don't quite understand the code well enough to get the frame object, although I have found all the relevant objective C docs and stack overflows:

https://developer.apple.com/documentation/appkit/nswindow/1419697-frame
https://stackoverflow.com/questions/12438224/set-nswindow-size-programmatically

I believe the only thing missing is getting the window's frame and then you can either set the width and height of that or use the x and y in the new frame. If anyone knows how to do this or where to point me so I can figure it out, I'm willing to make a PR for it but I don't have all week to figure this out and I assume its rather trivial if you know what you're doing (or maybe not)

@xDuck
Copy link
Author

xDuck commented Apr 16, 2020

I was able to make it work following this stack overflow:

https://stackoverflow.com/questions/35106971/get-objective-c-property-from-pure-c

I will go ahead and make a PR for the change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant