mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 09:49:21 +00:00
UI/AppKit: Convert window origins sent from WebDriver to AppKit's origin
Window origins in AppKit are the bottom-left position of the NSWindow, relative to the bottom-left of the screen. So we must do some alignment of the top-left position received from WebDriver.
This commit is contained in:
parent
102a125ea5
commit
00a486d072
Notes:
github-actions[bot]
2024-10-29 11:05:10 +00:00
Author: https://github.com/trflynn89
Commit: 00a486d072
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2028
Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 7 additions and 6 deletions
|
@ -1004,19 +1004,20 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
|
||||||
[[self window] orderFront:nil];
|
[[self window] orderFront:nil];
|
||||||
};
|
};
|
||||||
|
|
||||||
m_web_view_bridge->on_reposition_window = [weak_self](auto const& position) {
|
m_web_view_bridge->on_reposition_window = [weak_self](auto position) {
|
||||||
LadybirdWebView* self = weak_self;
|
LadybirdWebView* self = weak_self;
|
||||||
if (self == nil) {
|
if (self == nil) {
|
||||||
return Gfx::IntPoint {};
|
return Gfx::IntPoint {};
|
||||||
}
|
}
|
||||||
auto frame = [[self window] frame];
|
|
||||||
frame.origin = Ladybird::gfx_point_to_ns_point(position);
|
|
||||||
[[self window] setFrame:frame display:YES];
|
|
||||||
|
|
||||||
return Ladybird::ns_point_to_gfx_point([[self window] frame].origin);
|
position = Ladybird::compute_origin_relative_to_window([self window], position);
|
||||||
|
[[self window] setFrameOrigin:Ladybird::gfx_point_to_ns_point(position)];
|
||||||
|
|
||||||
|
position = Ladybird::ns_point_to_gfx_point([[self window] frame].origin);
|
||||||
|
return Ladybird::compute_origin_relative_to_window([self window], position);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_web_view_bridge->on_resize_window = [weak_self](auto const& size) {
|
m_web_view_bridge->on_resize_window = [weak_self](auto size) {
|
||||||
LadybirdWebView* self = weak_self;
|
LadybirdWebView* self = weak_self;
|
||||||
if (self == nil) {
|
if (self == nil) {
|
||||||
return Gfx::IntSize {};
|
return Gfx::IntSize {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue