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

Fix linux resize issue #453

Closed
wants to merge 3 commits into from
Closed

Conversation

akiradk
Copy link

@akiradk akiradk commented Aug 4, 2024

Pull request for issue #452

The idea is to go ahead and just do the resizing if the delta is not returning true.

You can see when the app open that the ui scales to fit the window, but its a small price to pay for it to fit correctly at startup :)

Hope i did the PR correctly, first time doing a PR :P

@dweymouth
Copy link
Owner

dweymouth commented Aug 6, 2024

I had a user test this on Ubuntu 22.04 and their response was:

did the "open 10 times" test - 8 times the window was fine, 9th time it had the rendering problem

Is this actually more reliable for you than the initial workaround, since it seems to be pretty much doing the same thing? Maybe we need to try a larger size difference when we subtract down the desired size, like 4 pixels?

@akiradk
Copy link
Author

akiradk commented Aug 6, 2024

I had a user test this on Ubuntu 22.04 and their response was:

did the "open 10 times" test - 8 times the window was fine, 9th time it had the rendering problem

Is this actually more reliable for you than the initial workaround, since it seems to be pretty much doing the same thing? Maybe we need to try a larger size difference when we subtract down the desired size, like 4 pixels?

Hmmmm well i think that would just push the issue in front of us 🤔 since the loop brakes on 5 tries if the window is not within delta at that point something else is keeping it from getting there 🤔

Perhaps the call to x11 is no getting trough to the daemon in some scenario 🤔 ??

Just out of interest, what desktop resolution and window size of the program was the user running? could perhaps be some strange +/- half a pixel that the system cant quite delta itself out of or something to that effect??

@dweymouth
Copy link
Owner

@akiradk Can you test this on your system and see if it works reliably? #460

@akiradk
Copy link
Author

akiradk commented Aug 7, 2024

@akiradk Can you test this on your system and see if it works reliably? #460

@dweymouth no dice sadly, still the same issue :( but i do like the approach i must admit :)

I went and did a go install after i pulled the branch, let me know if you need me to do anything else than that to get i working like you intend :)

@dweymouth
Copy link
Owner

@akiradk If you don't mind and feel up to it, since you are setup to build from source, you could try adding a short sleep or retry logic similarly to the original workaround - I dug into Fyne code and found that the ProcessResized call is the first Fyne code invoked by the windowing system in response to the X11 resize event. So bypassing the X11 hack should be just as effective, with appropriate sleep/retries (and should hopefully work for native Wayland too)

The issue does not reproduce on my Ubuntu system, which does make it very frustrating to debug :(

@akiradk
Copy link
Author

akiradk commented Aug 7, 2024

@dweymouth i will give it a try tomorrow if i have the time, but what i have gotten to work is a reeeealy silly workaround 😅

I ran a script that opened a built version with this diff in it then closing it again after 3 sec and the looping over that 10 times, it worked every time for a multiple of times, think i have opened that build about 50 times or so and it worked fine every time 😃

Try it and see what you find 😃

diff --git a/main.go b/main.go
index ba54ce3..0faa941 100644
--- a/main.go
+++ b/main.go
@@ -11,6 +11,7 @@ import (
 	"github.com/dweymouth/supersonic/res"
 	"github.com/dweymouth/supersonic/ui"
 
+	"fyne.io/fyne/v2"
 	"fyne.io/fyne/v2/app"
 	"fyne.io/fyne/v2/lang"
 )
@@ -62,14 +63,12 @@ func main() {
 	// slightly hacky workaround for https://github.com/fyne-io/fyne/issues/4964
 	workaroundWindowSize := sync.OnceFunc(func() {
 		s := mainWindow.DesiredSize()
-		scale := mainWindow.Window.Canvas().Scale()
-		s.Width *= scale
-		s.Height *= scale
-		// exported in Supersonic Fyne fork
-		mainWindow.Window.ProcessResized(int(s.Width), int(s.Height))
+		mainWindow.Window.Resize(fyne.NewSize(s.Width+1,s.Height)) //+1 width
+		mainWindow.Window.Resize(fyne.NewSize(s.Width-1,s.Height)) // back to desired size
 	})
 	fyneApp.Lifecycle().SetOnEnteredForeground(func() {
 		workaroundWindowSize()
 	})
 	mainWindow.ShowAndRun()

@dweymouth
Copy link
Owner

At this point, really silly workarounds are great if they work! I updated the other PR #460 with this approach, plus adding sleeps because the above diff didn't seem to work on another user's system.. I'm awaiting testing results from them but we'll see...

@dweymouth
Copy link
Owner

Adding sleeps between the resizes in your diff above worked for the other user too, so I think we're good for now!

@dweymouth dweymouth closed this Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants