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

Kitty full screen mode wayland cut off #5677

Closed
noirnero opened this issue Nov 16, 2022 · 26 comments
Closed

Kitty full screen mode wayland cut off #5677

noirnero opened this issue Nov 16, 2022 · 26 comments
Labels

Comments

@noirnero
Copy link

noirnero commented Nov 16, 2022

Describe the bug
When using kitty in full screen mode on Wayland the size is too big and some parts are cut off (the pictures show nvim as an example).
It seems like the whole 'window' is shifted to the left and towards the top (you can see black bars on the right and the bottom of the full screen screenshot)
normal window
full screen

To Reproduce
Steps to reproduce the behavior:

  1. Run updated Arch Linux with Gnome (Wayland)
  2. Switch kitty to full screen mode (Ctrl+Shift+F11)
  3. Parts are cut off (not visible on the screen)

Environment details
Arch Linux with Gnome running on Wayland

Additional context
Using 'kitty --config NONE' doesn't help.
Neither does changing the screen resolution, however when switching the Gnome session to X11 the bug doesn't persist.

@noirnero noirnero added the bug label Nov 16, 2022
@kovidgoyal
Copy link
Owner

Doesn't reproduce for me on GNOME+Wayland on fully updated Arch Linux running kitty from master.

Starting kitty as

kitty --config=NONE

This is likely something specific to your GNOME config. If you can isolate what that is and post a reproducer I'll take another look.

@noirnero
Copy link
Author

noirnero commented Nov 16, 2022

First of all thank you very much for your effort and your work.

I just saw the following errors pop up when I switched to full screen (running with 'kitty --config NONE') in the terminal:

[glfw error 65548]: Wayland: The platform does not provide the window position
[glfw error 65548]: Wayland: The platform does not support setting the window position

Installing 'glfw-wayland' didn't help.
I will try to do some more googling later.

@kovidgoyal
Copy link
Owner

That's to be expected, wayland doesnt allow setting window position, so
glfw prints out those errors. And kitty comes with its own copy of glfw,
you dont need to install glfw.

@noirnero
Copy link
Author

Thanks, well I couldn't find much more.

For anybody having the same problem, as a temporary fix you can set 'linux_display_server X11' in kitty.conf (this makes kitty run under XWayland as far as I understand).

Googling 'wayland fullscreen off centered' returns some results which may help but of course I understand that if the issue is not reproducible / doesn't affect anybody else, it doesn't make sense to invest more time.

Thank you for this amazing project and the help you provided.
Maybe somebody else will know what the problem is.

@kron4eg
Copy link

kron4eg commented Nov 20, 2022

Using fedora 37. After very recent update of mutter from 43.0-4 to 43.1-2 this issue became relevant for me too. Downgrading mutter fixes the problem: sudo dnf install mutter-43.0.

@kron4eg
Copy link

kron4eg commented Nov 20, 2022

But other programs are unaffected, including other terminals.

@kovidgoyal
Copy link
Owner

If its a change in mutter that broke it report it there, hopefully they will tell us what the root cause is. I still cannto replicate with mutter 43.1 and kitty from master using --config=NONE

@kron4eg
Copy link

kron4eg commented Nov 21, 2022

Since no other program has been shifted a bit off the screen, I guess the problem is not in the mutter and there is nothing to fix in their side.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Nov 21, 2022

By that logic, no other compositor but mutter 43.1 has this problem, so there is nothing to fix in kitty. It's a mutter update that broke it, mutter is where you need to report it.

@kron4eg
Copy link

kron4eg commented Nov 21, 2022

WAYLAND_DEBUG=1 kitty --config NONE --debug-rendering logs the following, is this looks good to you?

top-level configure event: size: 1920x1080 states: TOPLEVEL_STATE_MAXIMIZED TOPLEVEL_STATE_FULLSCREEN TOPLEVEL_STATE_ACTIVATED 
[2815220.901] xdg_surface@26.configure(394)
[2815220.913]  -> xdg_surface@26.ack_configure(394)
Calling wl_pointer_set_cursor in setCursorImage with surface: 0x55793cafeee0
[2815220.937]  -> wl_pointer@19.set_cursor(20335, wl_surface@3, 10, 11)
[2815220.948]  -> wl_surface@3.set_buffer_scale(2)
[2815220.954]  -> wl_surface@3.attach(wl_buffer@33, 0, 0)
[2815220.961]  -> wl_surface@3.damage(0, 0, 48, 48)
[2815220.968]  -> wl_surface@3.commit()
[2815221.056]  -> zwp_text_input_v3@17.enable()
[2815221.063]  -> zwp_text_input_v3@17.set_content_type(0, 13)
[2815221.070]  -> zwp_text_input_v3@17.commit()
[2815221.075]  -> zwp_text_input_v3@17.set_cursor_rectangle(19, 22, 9, 20)
[2815221.081]  -> zwp_text_input_v3@17.commit()
[2815221.094]  -> zwp_text_input_v3@17.enable()
[2815221.099]  -> zwp_text_input_v3@17.set_content_type(0, 13)
[2815221.105]  -> zwp_text_input_v3@17.commit()
[2815221.110]  -> zwp_text_input_v3@17.set_cursor_rectangle(19, 22, 9, 20)
[2815221.114]  -> zwp_text_input_v3@17.commit()
Resizing framebuffer to: 1920x1080 at scale: 2
[2815221.130]  -> wl_compositor@4.create_region(new id wl_region@51)
[2815221.136]  -> wl_region@51.add(0, 0, 1920, 1080)
[2815221.142]  -> wl_surface@21.set_opaque_region(wl_region@51)
[2815221.148]  -> wl_region@51.destroy()
CSD: old.size: 1920x1024 new.size: 1920x1080 needs_update: 1 size_changed: 1 buffer_destroyed: 1
[2815222.606]  -> wl_shm@5.create_pool(new id wl_shm_pool@55, fd 18, 3815424)
[2815222.621]  -> wl_shm_pool@55.create_buffer(new id wl_buffer@61, 0, 3840, 72, 15360, 0)
[2815222.631]  -> wl_shm_pool@55.create_buffer(new id wl_buffer@65, 1105920, 3840, 72, 15360, 0)
[2815222.640]  -> wl_shm_pool@55.create_buffer(new id wl_buffer@47, 2211840, 24, 2232, 96, 0)
[2815222.649]  -> wl_shm_pool@55.create_buffer(new id wl_buffer@45, 2426112, 24, 2232, 96, 0)
[2815222.655]  -> wl_shm_pool@55.create_buffer(new id wl_buffer@48, 2640384, 3888, 24, 15552, 0)
[2815222.660]  -> wl_shm_pool@55.create_buffer(new id wl_buffer@29, 3013632, 3888, 24, 15552, 0)
[2815222.667]  -> wl_shm_pool@55.create_buffer(new id wl_buffer@67, 3386880, 24, 2232, 96, 0)
[2815222.674]  -> wl_shm_pool@55.create_buffer(new id wl_buffer@58, 3601152, 24, 2232, 96, 0)
[2815222.682]  -> wl_shm_pool@55.destroy()
Created decoration buffers at scale: 2 vertical_height: 1116 horizontal_width: 1944
[2815224.642]  -> wl_surface@36.set_buffer_scale(2)
[2815224.644]  -> wl_subsurface@37.set_position(0, -36)
[2815224.646]  -> wl_surface@38.set_buffer_scale(2)
[2815224.647]  -> wl_subsurface@39.set_position(-12, -36) 
[2815224.648]  -> wl_surface@40.set_buffer_scale(2)
[2815224.650]  -> wl_subsurface@41.set_position(-12, 1080) <------------ comment by @kron4eg
[2815224.651]  -> wl_surface@42.set_buffer_scale(2)
[2815224.652]  -> wl_subsurface@43.set_position(1920, -36) <------------ comment by @kron4eg
[2815224.653]  -> wl_surface@36.attach(wl_buffer@61, 0, 0)
[2815224.655]  -> wl_surface@36.damage(0, 0, 3840, 72)
[2815224.656]  -> wl_surface@36.commit()
[2815224.657]  -> wl_surface@38.attach(wl_buffer@47, 0, 0)
[2815224.659]  -> wl_surface@38.damage(0, 0, 24, 2232)
[2815224.660]  -> wl_surface@38.commit()
[2815224.661]  -> wl_surface@40.attach(wl_buffer@48, 0, 0)
[2815224.662]  -> wl_surface@40.damage(0, 0, 3888, 24)
[2815224.663]  -> wl_surface@40.commit()
[2815224.664]  -> wl_surface@42.attach(wl_buffer@67, 0, 0)
[2815224.665]  -> wl_surface@42.damage(0, 0, 24, 2232)
[2815224.667]  -> wl_surface@42.commit()
final window content size: 1920x1080 resized: 1

@kovidgoyal
Copy link
Owner

Looks fine to me negative values are used by window decorations.

@kron4eg
Copy link

kron4eg commented Nov 21, 2022

But in fullscreen there are no window decorations, isn't it? Also if I run kitty --config NONE -o hide_window_decorations=y, fullscreen works perfectly fine.

@kovidgoyal
Copy link
Owner

First of all, in Wayland, applications cannot control window position,
only the compositor can set window position. The negative numbers you
see are for the window decoration sub-surfaces not the window surface
itself. These have to be positioned relative to the window surface, and
that is why they are negative.

Secondly, in full screen window decorations are irrelevant, since they
are off screen. mutter needs to position the window surface correctly in
full screen. I can have kitty not render the window decorations at all
in full screen mode, but that should not be necessary and was not
necessary until the latest mutter release, on your machine. They broke
it, the least they can do is provide some explanation for why. Since I
cant reproduce the issue trying to fix it is playing pin the tail on the
donkey. That said here's a one line patch you can try:

diff --git a/glfw/wl_window.c b/glfw/wl_window.c
index ab21f43a7..ede67bbc0 100644
--- a/glfw/wl_window.c
+++ b/glfw/wl_window.c
@@ -621,7 +621,7 @@ static void xdgSurfaceHandleConfigure(void* data,
         int width = window->wl.pending.width, height = window->wl.pending.height;
         set_csd_window_geometry(window, &width, &height);
         bool resized = dispatchChangesAfterConfigure(window, width, height);
-        if (window->wl.decorations.serverSide) {
+        if (window->wl.decorations.serverSide || window->wl.current.toplevel_states & TOPLEVEL_STATE_FULLSCREEN) {
             free_csd_surfaces(window);
         } else {
             ensure_csd_resources(window);

This will explicitly disable the CSD when a surface configure event is
received after an XDG toplevel configure event that sets the window to full
screen. Whether that will actually fix your issue, I have no idea. And
frankly I am very tired of wasting time on Wayland issues with every
new GNOME release.

@kron4eg
Copy link

kron4eg commented Nov 21, 2022

For those who will hit this problem too:

hide_window_decorations y in config fixes the problem. Of course that means no windows decorations, which works fine for most usecases anyway 😂

@kron4eg
Copy link

kron4eg commented Nov 21, 2022

And frankly I am very tired of wasting time on Wayland issues with every new GNOME release

Please don't get mad at me :) I clearly have no idea what I'm talking about. I'm just a simple user that hit a bug a trying to find a solution. Yes, mutter could have broken something, yet even with this breakage all other programs enter fullscreen correctly, that's why from my uneducated PoV kitty is the first suspect.

@kovidgoyal
Copy link
Owner

I'm not mad at you, I am just saying, you should report this to mutter
and see what they have to say.

@noirnero
Copy link
Author

I opened an issue: Mutter Gitlab

Thanks to both of you!

@tim77
Copy link

tim77 commented Nov 22, 2022

I'm not mad at you, I am just saying, you should report this to mutter and see what they have to say.

Translate to human language: upstream doesn't care about Linux and you shouldn't use this app as Linux user.

@kovidgoyal
Copy link
Owner

@tim77 ROFL go read the kitty changelog for all the fixes I have had to make for the ever growing pile of shit that is GNOME+Wayland (hint there have been 13 in the last 3 months alone). I am simply fed up of wasting my time endlessly iterating on basic desktop windowing while the Wayland ecosystem tries and repeatedly fails to get its act together.

I am soooo looking forward to the days/weeks I will have to waste integrating support for libdecor in the near future because GNOME wont implement server side decorations, and couldnt be bothered to implement client side support for it in a standalone library for years, which means I had to implement support for it in kitty manually. And then rip it out and replace it with something else later, and be forced to depend on all of GTK for it. What a joke.

And then the days/weeks I will have to waste integrating support for fractional scaling because such basic things were out of scope for Wayland for nearly a decade and it took them YEARS to finally figure out how to implement it. Amateur hour.

And they still dont even have a way for non-blessed applications to draw panels/desktop backgrounds, across compositors which means, for instance, I cant implement the panel kitten on Wayland. Which in turn means I will personally never use Wayland.

And every single bit of churn in this god forsaken ecosystem is multiplied by 10 because there are ten different compositors, which means every single thing you do has to be tested 10 times over. It's like this PoS was designed to waste everybody's time, maximally.

And all this to solve the basic problem of drawing windows on screen, something computers have been doing successfully for 50 years.

@gitaarik
Copy link

What kind of desktop environment do you use @kovidgoyal? I ran into this issue too. I never experimented much with other things than GNOME, because it seems to work pretty fine with most applications. Are you doing some special things with kitty that are unusual and make it more difficult to implement in GNOME+Wayland? As I understand X11 is such a mess that nobody wants to keep building upon it, so that's why they started with Wayland. But then you say the people who are making it are a bunch of amateurs. So that doesn't sound very good haha. So yeah I wonder, where do you place your bets on?

@kovidgoyal
Copy link
Owner

I use X11 with i3 and my own session manager. As for Wayland, I wish
them all the best, but I have been burned too many times by it now, so I
have given up on it.

@gitaarik
Copy link

Aha ok cool, maybe I'll give i3 a try. I've been wanting to try a tiling window managers for some time now but somehow I am just a bit suspicious of how well it will work with a big variety of applications.

But will i3 stay on X11? Is X11 still gonna be maintained in the end?

I also have struggles with multiple monitors on Wayland. So you think Wayland is doomed? Is there any other hope?

@kovidgoyal
Copy link
Owner

kovidgoyal commented Nov 28, 2022 via email

@nushoin
Copy link

nushoin commented Nov 28, 2022

In this specific issue it seems that Kitty is not acting according to spec: https://gitlab.gnome.org/GNOME/mutter/-/issues/2524#note_1601492. The mutter devs will probably implement a workaround anyway in order to support screen resolution change, as mentioned in the linked comment, but I believe that kitty should still be fixed.

@kovidgoyal I'm sorry that Wayland conformance is causing you such a headache. FWIW Kitty works great for me on both GNOME Shell Wayland session, as well as on Sway. Thank you for the great software! Also, please don't give up on Wayland. Maybe it's not solving any issues for you - not yet, anyway - but it does solve a lot of issues for a lot of users.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Nov 28, 2022 via email

@kovidgoyal
Copy link
Owner

Actually someone posted a way to reproduce it on the mutter tracker, so here is a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants