Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window with list flickers in Wayland #5133

Open
2 tasks done
Fethbita opened this issue Sep 11, 2024 · 0 comments
Open
2 tasks done

Window with list flickers in Wayland #5133

Fethbita opened this issue Sep 11, 2024 · 0 comments
Labels
unverified A bug that has been reported but not verified Wayland Issues related to Wayland support

Comments

@Fethbita
Copy link

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

If an application with a window is resized, it flickers and is unusable in Wayland. This sometimes happens when the window is not resized as well.

How to reproduce

  1. Build the app with
fyne release -os linux -tags wayland
  1. Run the app.
  2. Resize the app until it starts to flicker

Screenshots

2024-09-11.13-27-17.mp4

Example code

package main

import (
	"log"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/data/binding"
	"fyne.io/fyne/v2/layout"
	"fyne.io/fyne/v2/theme"
	"fyne.io/fyne/v2/widget"
)

type TestStruct struct {
	syncHours   binding.Float  `json:"-"`
	syncComment binding.String `json:"-"`
	syncBinding binding.Bool   `json:"-"`

	TestHours   float64
	TestType    string
	TestName    string
	TestComment string
	TestCheck   bool
}

const longTemplate = "Some long template that is quite long"

func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)

	TestStructList := []TestStruct{
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
		{TestHours: 12.34, TestType: "some type", TestName: "some name", TestComment: "some comment", TestCheck: true},
	}

	for i := range TestStructList {
		TestStructList[i].syncHours = binding.BindFloat(&TestStructList[i].TestHours)
		TestStructList[i].syncComment = binding.BindString(&TestStructList[i].TestComment)
		TestStructList[i].syncBinding = binding.BindBool(&TestStructList[i].TestCheck)
	}

	a := app.New()
	w := a.NewWindow("Test window")

	list := widget.NewList(
		func() int {
			return len(TestStructList)
		},
		func() fyne.CanvasObject {
			listItem := container.New(layout.NewHBoxLayout())
			listItem.Add(widget.NewLabelWithStyle(longTemplate, fyne.TextAlignLeading, fyne.TextStyle{Bold: true}))
			listItem.Add(
				widget.NewCheck("", func(value bool) {
					log.Println("Check set to", value)
				}),
			)
			listItem.Add(layout.NewSpacer())
			testNameSize := fyne.MeasureText(longTemplate, theme.TextSize(), fyne.TextStyle{})
			testNameSize.Width = testNameSize.Width + widget.NewEntry().MinSize().Width + theme.InnerPadding()
			testNameSize.Height = widget.NewEntry().MinSize().Height
			listItem.Add(container.New(
				layout.NewGridWrapLayout(testNameSize),
				widget.NewEntry(),
			))
			listItem.Add(
				container.New(
					layout.NewGridWrapLayout(fyne.NewSize(120, widget.NewEntry().MinSize().Height)),
					widget.NewEntry(),
				),
			)
			return listItem
		},
		func(i widget.ListItemID, o fyne.CanvasObject) {
			objectLen := len(o.(*fyne.Container).Objects)
			testLabelWidget := o.(*fyne.Container).Objects[0].(*widget.Label)
			testCheckWidget := o.(*fyne.Container).Objects[1].(*widget.Check)
			testTimeWidget := o.(*fyne.Container).Objects[objectLen-1].(*fyne.Container).Objects[0].(*widget.Entry)
			commentEditWidget := o.(*fyne.Container).Objects[objectLen-2].(*fyne.Container).Objects[0].(*widget.Entry)

			test := TestStructList[i]
			testLabelWidget.SetText(test.TestType)
			testCheckWidget.Text = test.TestName
			testCheckWidget.Bind(test.syncBinding)
			testCheckWidget.Refresh()
			testTimeWidget.Bind(binding.FloatToStringWithFormat(test.syncHours, "%.2f"))

			commentEditWidget.PlaceHolder = test.TestComment
			commentEditWidget.Bind(test.syncComment)

		})

	w.SetMaster()
	w.SetContent(container.NewBorder(nil, nil, nil, nil, list))

	width := list.MinSize().Width + w.Canvas().Size().Width
	height := list.MinSize().Height*float32(list.Length()) + w.Canvas().Size().Height

	w.Show()
	w.Resize(fyne.NewSize(width, height))
	a.Run()
}

Fyne version

2.5.1

Go compiler version

1.22.0

Operating system and version

Arch Linux

Additional Information

Sometimes flickering is even worse than shown in the video. It's not very difficult to reproduce by running the app multiple times. I use sway with Wayland.

@Fethbita Fethbita added the unverified A bug that has been reported but not verified label Sep 11, 2024
@dweymouth dweymouth added the Wayland Issues related to Wayland support label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified Wayland Issues related to Wayland support
Projects
None yet
Development

No branches or pull requests

2 participants