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:
Elias Naur
2022-01-31 16:56:52 +01:00
parent 69a6b47f7b
commit 6fba94e573
+2 -7
View File
@@ -187,7 +187,6 @@ type window struct {
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
@@ -328,7 +327,6 @@ func (d *wlDisplay) createNativeWindow(options []Option) (*window, error) {
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),
@@ -338,6 +336,7 @@ func (d *wlDisplay) createNativeWindow(options []Option) (*window, error) {
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
} }