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

Resizing Window Changes Widget Size #1319

Open
DapperMongoose opened this issue Nov 17, 2024 · 8 comments
Open

Resizing Window Changes Widget Size #1319

DapperMongoose opened this issue Nov 17, 2024 · 8 comments
Labels
bug Something isn't working correctly confirmed This bug has been confirmed
Milestone

Comments

@DapperMongoose
Copy link

Describe the bug

On Linux when resizing the window the size of all widgets gets changed.

How to reproduce

Launch the program and resize with drag handles

CogentResizeBug.mp4

Example code

package main

import (
	"cogentcore.org/core/core"
	"cogentcore.org/core/events"
	"fmt"
)

func main() {
	b := core.NewBody()
	core.NewText(b).SetText("Minimal Reproduction")
	textField := core.NewTextField(b)
	textField.StartFocus()

	btn := core.NewButton(b).SetText("Submit")

	btn.OnClick(func(e events.Event) {
		core.MessageSnackbar(b, fmt.Sprintf("button click, text content: %v", textField.Text()))
		textField.SetText("")
	})

	//btn.SetKey(keymap.Enter)
	//btn.SetShortcut(keymap.Enter.Chord())
	btn.SetShortcut("Command+S")

	b.RunMainWindow()
}

Relevant output

See screen recording

Platform

Linux

@DapperMongoose DapperMongoose added the bug Something isn't working correctly label Nov 17, 2024
@DapperMongoose
Copy link
Author

Also interesting, in my real app if I intentionally fail login the widgets inside the center frame start shrinking within their parent. This behavior no longer occurs if I resize the window before testing failed attempts. If it would be helpful I can try and put together a minimal repro of that specific behavior.

@kkoreilly
Copy link
Member

Thank you for reporting this. I believe that the cause of this is incorrect updating when moving a window between monitors, which is an issue that we know about and plan to fix soon. It doesn't look like we have another issue with this precise situation, so we can leave this one open (#603, #940, #947, and #997 are related). It should be doable to fix all of these multi-monitor issues soon.

@kkoreilly kkoreilly added the confirmed This bug has been confirmed label Nov 17, 2024
@kkoreilly kkoreilly added this to the v0.4 milestone Nov 17, 2024
@DapperMongoose
Copy link
Author

In case it is helpful, I am running a multi monitor setup, but in the recording above, and in my testing, the window is being launched and resized solely on my primary monitor. It's also an ultrawide screen if that has any bearing.

@kkoreilly
Copy link
Member

Thank you for that information. That is strange. Every time you run the app the widgets have a different size initially until you resize? If possible, when the widgets are still the initial size, can you open the inspector, then click Inspect app -> App -> Screens and send a screenshot of that page? Then, close the inspector, open it again, resize it such that it has the new size, and get another screenshot of the same screens page.

If it is easier to do this or the process above changes the size of the widgets too soon, you could also just add this line of code to your button click event handler, and then send the output from clicking on the button before and after resizing:

fmt.Printf("%#v\n", core.TheApp.Screen(0))

Either option will work. Thank you!

@DapperMongoose
Copy link
Author

As far as I am aware it's every time. Initially I thought it was just a high res display issue that I'd need to address eventually as part of themes.

Happy to grab the screenshots, I used the minimal repro app to grab them.

Here's before resizing:
BeforeResize

And after (which looks the same to me):
AfterResize

With a bonus cursor bug that only sometimes happens on resize, and didn't happen during the initial recording:
DoubledCursor

I notice that Cogent isn't sure what orientation my screens are, so FYI they're both landscape, and set to side by side in Display Manager currently. I have done all the above on my primary machine which is running Arch with KDE Plasma as my DE. I haven't really done anything strange or exotic in configuring it either.

If it's useful I can test this on a laptop running Pop OS as well.

@kkoreilly
Copy link
Member

Thank you for providing that information. We don't track orientation on desktop platforms (it is only really relevant on mobile), so that isn't the issue. It is possible that it is getting confused with the ultrawide monitor. If possible, it would be helpful if you could temporarily switch your primary monitor to the other one and see if it fixes the issue. If you want to try turning the other monitor off temporarily so that it is only a single-monitor setup, that could also help narrow down the issue. Testing it on your laptop would also be great. If any of those steps are too inconvenient, that is fine. Thank you!

We have seen a similar infrequent cursor bug with text editors before, and we should be able to fix it soon.

@DapperMongoose
Copy link
Author

Sure thing, here's the results of my testing. Side note: my secondary monitor is also an ultrawide, it's just smaller.

Turning off secondary monitor:
Widgets do not re-size when window does

Setting secondary monitor as primary:
Cogent window opens on new primary window always. Widgets do not re-size when window does
If I drag the window over to my new secondary monitor widgets do not change. Re-sizing afterwards DOES change widget size (likely as you expect)

Laptop with Pop auto tiling enabled:
Widgets do not re-size when window does, Cogent does not apply dark theme despite OS being set to use dark theme.

Laptop with Pop auto tiling disabled:
Widgets do not re-size when window does, Cogent does not apply dark theme despite OS being set to use dark theme.

Here's where things get a little weird. Normally my secondary monitor is on the left of my Primary. I switched it to be on the right on a hunch. Widgets do not re-size when window does.

My secondary monitor is a smaller size than the primary, and the coordinates displayed when setting up monitors in the display configuration window seem to indicate that something under the hood considers 0,0 to be in the top left corner. Perhaps it's getting sizing information from the secondary screen on startup and that gets updated to reflect the current screen on resize?

@kkoreilly kkoreilly moved this to Todo in Bugs Nov 18, 2024
@kkoreilly kkoreilly added this to Bugs Nov 18, 2024
@kkoreilly
Copy link
Member

Thank you for all of the helpful information. We now know enough to try to fix this bug soon (likely next Sunday).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly confirmed This bug has been confirmed
Projects
Status: Todo
Development

No branches or pull requests

2 participants