mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
app/internal/window: [wasm] fix insets on Firefox
Insets must not be included if the `visualViewport` isn't available. Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
This commit is contained in:
@@ -38,7 +38,7 @@ type window struct {
|
|||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
size f32.Point
|
size f32.Point
|
||||||
viewport f32.Point
|
inset f32.Point
|
||||||
scale float32
|
scale float32
|
||||||
animating bool
|
animating bool
|
||||||
}
|
}
|
||||||
@@ -486,7 +486,8 @@ func (w *window) resize() {
|
|||||||
w.size.Y = float32(rect.Get("height").Float()) * w.scale
|
w.size.Y = float32(rect.Get("height").Float()) * w.scale
|
||||||
|
|
||||||
if vx, vy := w.visualViewport.Get("width"), w.visualViewport.Get("height"); !vx.IsUndefined() && !vy.IsUndefined() {
|
if vx, vy := w.visualViewport.Get("width"), w.visualViewport.Get("height"); !vx.IsUndefined() && !vy.IsUndefined() {
|
||||||
w.viewport.X, w.viewport.Y = float32(vx.Float())*w.scale, float32(vy.Float())*w.scale
|
w.inset.X = w.size.X - float32(vx.Float())*w.scale
|
||||||
|
w.inset.Y = w.size.Y - float32(vy.Float())*w.scale
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.size.X == 0 || w.size.Y == 0 {
|
if w.size.X == 0 || w.size.Y == 0 {
|
||||||
@@ -522,8 +523,8 @@ func (w *window) config() (int, int, system.Insets, unit.Metric) {
|
|||||||
defer w.mu.Unlock()
|
defer w.mu.Unlock()
|
||||||
|
|
||||||
return int(w.size.X + .5), int(w.size.Y + .5), system.Insets{
|
return int(w.size.X + .5), int(w.size.Y + .5), system.Insets{
|
||||||
Bottom: unit.Px(w.size.Y - w.viewport.Y),
|
Bottom: unit.Px(w.inset.Y),
|
||||||
Right: unit.Px(w.size.X - w.viewport.X),
|
Right: unit.Px(w.inset.X),
|
||||||
}, unit.Metric{
|
}, unit.Metric{
|
||||||
PxPerDp: w.scale,
|
PxPerDp: w.scale,
|
||||||
PxPerSp: w.scale,
|
PxPerSp: w.scale,
|
||||||
|
|||||||
Reference in New Issue
Block a user