slint icon indicating copy to clipboard operation
slint copied to clipboard

Window resizing issue on wayland

Open lethargy123 opened this issue 1 year ago • 9 comments

See https://github.com/slint-ui/slint/issues/4069#issuecomment-1848684932

Original description:

After executing "cargo r", I'm unable to resize the window using the up, down, left, or right arrows. However, it works fine for resizing the window within the Slin extension in Visual Studio Code. ui_test.zip

lethargy123 avatar Dec 02 '23 18:12 lethargy123

After executing "cargo r", I'm unable to resize the window using the up, down, left, or right arrows. However, it works fine for resizing the window within the Slin extension in Visual Studio Code. ui_test.zip

I consider myself a novice in Slint, but I don't believe there are any significant issues with the code I have written. If it's possible and convenient for you, could you kindly provide any feedback or suggestions on potential areas for improvement? I would greatly appreciate it.

lethargy123 avatar Dec 02 '23 19:12 lethargy123

I do not see anything in your code trigger on key presses (maybe I missed something?).

The resize overall is limited by the width and height in the GridLayout: That gives that element a fixed size. So the VerticalLayout also becomes fixed as there is nothing in it that can actually scale. That makes the Window fixed.

For such a simple case as this: You can leave out both Layouts and all the sizes and it should work better with less code.

Wrt. the preview: You found an interesting bug there: The preview will always use the preferred size, and assumes it to be between the minimum and maximum size. That is not the case in your example (you explicitly set the preferred size). I'll open a bug report on that: We should at least warn or maybe even error out in this case. That's #4075 for your reference.

hunger avatar Dec 04 '23 14:12 hunger

I am not clear what you mean by "resize the window using the up/down/left/right arrow keys". I do not see any code in the example that listens to key events, so I assume that those keys are handled by your GUI environment (which one is that by the way?).

hunger avatar Dec 04 '23 14:12 hunger

Setup:

Ubuntu 23.10 without Qt installed (need to use App without it).

Steps to reproduce :

  • clone slint
  • in fullscreen Gnome Terminal cd into slint dir than run cargo run --release --bin todo
  • move mouse in and out todo App Window

What is wrong:

  • Cursor not changing from Insert Bar once Cursor leaves window and reenters the Window
  • Resizing border areas are not changing cursor to any of Resize Icons. But when left button is pressed in the right area then it's possible to resize and the Cursor changes to Resize Icon.
  • When close button pressed and after PopupBox confirmed window is not closing.

After recreating todo as separate project :

  • no matter what I do I can not set window position programmatically from fn main(), even when winit::Window used
  • config.toml file:
[env]
SLINT_NO_QT=1
SLINT_STYLE="native"
SLINT_BACKEND = "winit-femtovg"
SLINT_FULLSCREEN = true
  • Close button is working. After PopupBox confirmed App is closing.
  • Cursor and resize problems still exist.
  • When window gets focus it almost invisible. Probably could be fixed with Theme and some boilerplate code??

D0bhareach avatar Dec 09 '23 21:12 D0bhareach

I can reproduce some of these on Ubuntu 23.10. AFAICS these are basically issues with wayland support, for which we use winit. It works when unsetting WAYLAND_DISPLAY and connecting to xwayland instead.

  • Cursor shape isn't changing when the cursor enters/leaves the window
  • Resize handles are not (reliably) indicated when the mouse is at the window edges

For me the window closes though when confirming the popup.

tronical avatar Dec 11 '23 07:12 tronical

unsetting WAYLAND_DISPLAY and connecting to xwayland

Could you show how can I unset WAYLAND_DISPLAY and connect to xwayland, please.

D0bhareach avatar Dec 11 '23 08:12 D0bhareach

You can for example make it empty: export WAYLAND_DISPLAY=

tronical avatar Dec 11 '23 09:12 tronical

Not sure if it is the same issue, but is also reproducing on Ubuntu 22.04, with cargo-ui project.

Screenshot from 2023-12-25 22-09-24

setting export WAYLAND_DISPLAY= seams to solve the problem.

mariusSincovici avatar Dec 26 '23 07:12 mariusSincovici

Regarding the test case from @lethargy123, it seems the window has a fixed layout, so that explain why it cannot be resized.

I've been trying with the weston compositor, and it seems that the minimum and maxium size are not working properly on wayland. I can reproduce the same problem with the winit resizable example from the winit repository. It is supposed to have a minimum size, but it doesn't work. Not sure if bug in weston or in winit.

ogoffart avatar Jan 17 '24 15:01 ogoffart