Update GetRelative/AbsolutePosition to take border size into account

This commit is contained in:
Lea Anthony 2024-04-25 15:59:33 +10:00
commit 5d0a58cc6a
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405

View file

@ -90,7 +90,10 @@ func (w *windowsWebviewWindow) setAbsolutePosition(x int, y int) {
func (w *windowsWebviewWindow) absolutePosition() (int, int) {
rect := w32.GetWindowRect(w.hwnd)
left, right := w.scaleToDefaultDPI(int(rect.Left), int(rect.Right))
borderSizes := w.getBorderSizes()
x := int(rect.Left) + borderSizes.Left
y := int(rect.Top) + borderSizes.Top
left, right := w.scaleToDefaultDPI(x, y)
return left, right
}
@ -415,6 +418,10 @@ func (w *windowsWebviewWindow) relativePosition() (int, int) {
x := int(rect.Left) - int(monitorInfo.RcWork.Left)
y := int(rect.Top) - int(monitorInfo.RcWork.Top)
borderSize := w.getBorderSizes()
x += borderSize.Left
y += borderSize.Top
return w.scaleToDefaultDPI(x, y)
}