mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
app: [Wayland] update buffer scale immediately
Simpler, and makes sure buffer scaling is set correctly regardless of the CustomRenderer setting. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+9
-14
@@ -186,9 +186,8 @@ type window struct {
|
|||||||
animating bool
|
animating bool
|
||||||
redraw bool
|
redraw bool
|
||||||
// The most recent configure serial waiting to be ack'ed.
|
// The most recent configure serial waiting to be ack'ed.
|
||||||
serial C.uint32_t
|
serial C.uint32_t
|
||||||
newScale bool
|
scale int
|
||||||
scale int
|
|
||||||
// size is the unscaled window size (unlike config.Size which is scaled).
|
// size is the unscaled window size (unlike config.Size which is scaled).
|
||||||
size image.Point
|
size image.Point
|
||||||
config Config
|
config Config
|
||||||
@@ -326,18 +325,18 @@ func (d *wlDisplay) createNativeWindow(options []Option) (*window, error) {
|
|||||||
ppdp := detectUIScale()
|
ppdp := detectUIScale()
|
||||||
|
|
||||||
w := &window{
|
w := &window{
|
||||||
disp: d,
|
disp: d,
|
||||||
scale: scale,
|
scale: scale,
|
||||||
newScale: scale != 1,
|
ppdp: ppdp,
|
||||||
ppdp: ppdp,
|
ppsp: ppdp,
|
||||||
ppsp: ppdp,
|
wakeups: make(chan struct{}, 1),
|
||||||
wakeups: make(chan struct{}, 1),
|
|
||||||
}
|
}
|
||||||
w.surf = C.wl_compositor_create_surface(d.compositor)
|
w.surf = C.wl_compositor_create_surface(d.compositor)
|
||||||
if w.surf == nil {
|
if w.surf == nil {
|
||||||
w.destroy()
|
w.destroy()
|
||||||
return nil, errors.New("wayland: wl_compositor_create_surface failed")
|
return nil, errors.New("wayland: wl_compositor_create_surface failed")
|
||||||
}
|
}
|
||||||
|
C.wl_surface_set_buffer_scale(w.surf, C.int32_t(w.scale))
|
||||||
callbackStore(unsafe.Pointer(w.surf), w)
|
callbackStore(unsafe.Pointer(w.surf), w)
|
||||||
w.wmSurf = C.xdg_wm_base_get_xdg_surface(d.wm, w.surf)
|
w.wmSurf = C.xdg_wm_base_get_xdg_surface(d.wm, w.surf)
|
||||||
if w.wmSurf == nil {
|
if w.wmSurf == nil {
|
||||||
@@ -1567,7 +1566,7 @@ func (w *window) updateOutputs() {
|
|||||||
}
|
}
|
||||||
if found && scale != w.scale {
|
if found && scale != w.scale {
|
||||||
w.scale = scale
|
w.scale = scale
|
||||||
w.newScale = true
|
C.wl_surface_set_buffer_scale(w.surf, C.int32_t(w.scale))
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
w.setStage(system.StagePaused)
|
w.setStage(system.StagePaused)
|
||||||
@@ -1631,10 +1630,6 @@ func (w *window) display() *C.struct_wl_display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) surface() (*C.struct_wl_surface, int, int) {
|
func (w *window) surface() (*C.struct_wl_surface, int, int) {
|
||||||
if w.newScale {
|
|
||||||
C.wl_surface_set_buffer_scale(w.surf, C.int32_t(w.scale))
|
|
||||||
w.newScale = false
|
|
||||||
}
|
|
||||||
sz, _ := w.getConfig()
|
sz, _ := w.getConfig()
|
||||||
return w.surf, sz.X, sz.Y
|
return w.surf, sz.X, sz.Y
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user