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

Wayland Scaling support: sizes and distances are scaled wrong #2850

Closed
WhyNotHugo opened this issue Mar 15, 2022 · 7 comments
Closed

Wayland Scaling support: sizes and distances are scaled wrong #2850

WhyNotHugo opened this issue Mar 15, 2022 · 7 comments
Assignees
Labels
blocker Items that would block a forthcoming release bug Something isn't working OS:Linux Tickets affecting only Linux

Comments

@WhyNotHugo
Copy link

Describe the bug:

I'm using desktop scaling, and elements and distances are not scaled correctly. The mouse cursor is also twice the regular size.

Hovering and clicking on items does not work correctly. To click on a button one must click in a very different position (as far as I can tell, the position where the button WOULD be if the window is scale properly).

However, because rendering and mouse events aren't consistent, UIs are entirely unusable with a mouse.

To Reproduce:

On a desktop with scaling enabled, run the example code (see below).

Screenshots:

With scaling:

image

The same sample ran via XWayland, where scaling is not done by the client. the compositor stretches the image instead (hence the blurryness):

image

Example code:

Use go run -tags wayland ./main.go:

package main

import (
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
)

func main() {
	a := app.New()
	w := a.NewWindow("Hello")

	hello := widget.NewLabel("Hello Fyne!")
	w.SetContent(container.NewVBox(
		hello,
		widget.NewButton("Hi!", func() {
			hello.SetText("Welcome :)")
		}),
	))

	w.ShowAndRun()
}

Device (please complete the following information):

  • OS: Linux 5.16.12-arch1-1 GNU/Linux
  • Go version: go version go1.17.8 linux/amd64
  • Fyne version: v2.1.3

I'm using swaywm as a wayland compositor. I haven't tried GNOME.

@WhyNotHugo WhyNotHugo added the unverified A bug that has been reported but not verified label Mar 15, 2022
@andydotxyz andydotxyz added the OS:Linux Tickets affecting only Linux label Mar 15, 2022
@andydotxyz andydotxyz changed the title Scaling support: sizes and distances are scaled wrong Wayland Scaling support: sizes and distances are scaled wrong Mar 15, 2022
@andydotxyz
Copy link
Member

On a desktop with scaling enabled, run the example code (see below).

Because of how fragmented Linux is we would need more information. Can you please be specific about how the settings are found, and applied?

@WhyNotHugo
Copy link
Author

It's part of the core Wayland protocol. The compositor will announce the scaling factor for an output using wl_output::scale.

Looking at the logs, it seems that my sample code above actually receives the event, and replies indicating that its surface will have scaling applied by using wl_surface::set_buffer_scale:

$ WAYLAND_DEBUG=1 go run -tags wayland ./main.go 2>&1 | grep scale
[4188969.808] wl_output@15.scale(2)
[4189209.683]  -> wl_surface@21.set_buffer_scale(2)

Configuring the scaling factor is compositor-specific. I believe GNOME and KDE have a GUI for that. I can't find any documentation for either online so can't provide better pointers. Sway uses the output WL-1 scale 3 command.

Sway can be run nested inside another compositor, so might be a better target for experimentation.

@andydotxyz
Copy link
Member

Thanks this is very helpful. I guess our wayland code does not pick it up yet, as we use the older X11 based DPI detection to get the appropriate scale.

@metal3d
Copy link
Contributor

metal3d commented Apr 7, 2022

see #2897 for my solution
Houps sorry no...

@Jacalz Jacalz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Sep 30, 2022
@andydotxyz andydotxyz added the blocker Items that would block a forthcoming release label Oct 4, 2022
@andydotxyz andydotxyz self-assigned this Nov 21, 2022
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Nov 21, 2022
@andydotxyz
Copy link
Member

Fixed on develop

@nickjwhite
Copy link

Just tested, works great and looks so much better on HiDPI screens on Wayland now, great job!

@andydotxyz
Copy link
Member

Excellent, thanks for checking :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Items that would block a forthcoming release bug Something isn't working OS:Linux Tickets affecting only Linux
Projects
None yet
Development

No branches or pull requests

5 participants