kitty icon indicating copy to clipboard operation
kitty copied to clipboard

Native window decorations for GNOME Wayland

Open DiegoMagdaleno opened this issue 3 years ago • 49 comments

Hi, im a developer, and Im interested in kitty, I was sad when I saw it doesn't support client side decorations, since im a wayland gnome user, I would love to say I have other options, but sadly with my HiDPI monitor, it looks like wayland is my only option.

I would be glad to try to get to some extent some client side decorations working, what is kitty missing to support this feature? is it possible? is the possibility of supporting this good?

Thanks! And of course thank you for your awesome software, it makes using the terminal much much better.

DiegoMagdaleno avatar Feb 02 '21 01:02 DiegoMagdaleno

It supports client side decorations already, they are just simple white borders without any functionality other than dragging/resizing. If you want decorations with more functionality you would need to actually implement it in wl_window.c. Possibly using something like libdecoration, or since GNOME is the only window manager stupid enough to not implement server side decorations, just directly use gtk libraries. But note that I am not willing to have kitty require GTK as a hard dependency at either build or run time. That means putting the code into a separate .so module that is built only if gtk is found in setup.py via pkg-config and that is loaded dynamically at runtime via dlopen.

kovidgoyal avatar Feb 02 '21 02:02 kovidgoyal

Thanks, I get into it! And yeah I respect your decision and it was actually what I had in mind!

DiegoMagdaleno avatar Feb 02 '21 14:02 DiegoMagdaleno

Cool, all the best. Feel free to ask questions if you need clarification, although I am no Wayland expert.

kovidgoyal avatar Feb 02 '21 14:02 kovidgoyal

Note that there's work on adding glfw CSD support via libdecoration already: https://github.com/glfw/glfw/pull/1693

ljrk0 avatar Mar 09 '21 16:03 ljrk0

I looked into this and libdecoration is half baked, at best. It currently supports only a simple titlebar drawn using cairo, which is pointless since it wont be native anyway. And it hasn't even been released, ever.

If I were you I'd skip libdecoration entirely and just draw the titlebar using gtk libraries. Or better, stop using GNOME.

kovidgoyal avatar Mar 25 '21 03:03 kovidgoyal

It currently supports only a simple titlebar drawn using cairo, which is pointless since it wont be native anyway

There is some work in progress to implement GTK plugin for libdecoration which should integrate with desktop pretty nicely. Even without it it's probably still better to have simple cairo titlebar than non functional or even no titlebar at all.

There is also some interest in SDL to pickup libdecoration. When it will happen libdecoration probably will be available in repositories of popular distributions.

DragonSWDev avatar Mar 28 '21 23:03 DragonSWDev

Is this work happening in a public repository somewhere? And there is no need for libcairo just to draw a title. kitty already includes both harfbuzz and fontconfig/freetype that are together perfectly capable of doing simple single line text layout/rendering. In fact, I think I will just add support for rendering titles to the current empty titlebar. Should be a day or so of work.

kovidgoyal avatar Mar 29 '21 04:03 kovidgoyal

There is merge request about this on libdecoration GitLab. I also tested this and it worked pretty reliably. Not perfect but gives some preview how it should work in future.

Your solution seems nice for now. libdecoration is fine (at least for me) but it's still WIP so maybe waiting for official support on GLFW side isn't bad idea.

DragonSWDev avatar Mar 29 '21 11:03 DragonSWDev

In master now kitty has fully functional though non native decorations on GNOME.

kovidgoyal avatar Apr 10 '21 09:04 kovidgoyal

After updating to 0.20.0 today on Arch Gnome 40, My window decorations are gone, is this related? Is this a feature or a bug? Is there any way to bring them back in the config? Screenshot from 2021-04-19 19-19-45

molaeiali avatar Apr 19 '21 14:04 molaeiali

They arent gone they are just not native. If you want native set linux_display_server to x11 in kitty.conf which was what it used to default to.

kovidgoyal avatar Apr 19 '21 14:04 kovidgoyal

After updating to 0.20.0 today on Arch Gnome 40, My window decorations are gone, is this related? Is this a feature or a bug? Is there any way to bring them back in the config?

These are window decorations! They are "non native" in the sense of they aren't GNOME themed, but they are "there" ;)

Basically there are two camps when it comes to window decorations: client side and server side. The latter is the more classical approach of having the window decorations be drawn by the desktop environment and the application itself is only responsible for the "content". This was what everyone did in the X11 world, even GNOME.

With Wayland, GNOME deprecated support for server side decorations in their own software. There are wayland compositors that allow for SSDs, Mutter doesn't. That means, each Wayland application must draw its own CSDs in GNOME.

Before the latest update you ran kitty as XWayland application, and thus GNOME added SSDs due to backwards compatibility. Kitty now defaults to wayland directly and brings their own CSDs which are more minimal than what GNOMEs X11 SSDs provided.

You can either switch back to Xwayland, implement "proper" CSDs in kitty yourself or nag the GNOME team to support SSDs again in Wayland :)

ljrk0 avatar Apr 19 '21 15:04 ljrk0

You can either switch back to Xwayland, implement "proper" CSDs in kitty yourself or nag the GNOME team to support SSDs again in Wayland :)

Yeah XWayland sounds good to me, as it is half of the applications that I use do that.

In master now kitty has fully functional though non native decorations on GNOME.

How do I close the terminal? I don't see a close button or something like that. Is there a way to add that? (like what do I do to add that?)

RedDocMD avatar Apr 20 '21 04:04 RedDocMD

On Mon, Apr 19, 2021 at 09:15:15PM -0700, Deep Majumder wrote:

In master now kitty has fully functional though non native decorations on GNOME.

How do I close the terminal? I don't see a close button or something like that. Is there a way to add that? (like what do I do to add that?)

This is a terminal, for use by keyboard afficionados. Type the close window shortcut, or type exit and press enter. Or type ctrl+d. Or if you really must use the mouse, right click the titlebar to access the control.

kovidgoyal avatar Apr 20 '21 05:04 kovidgoyal

Is there any real advantage of using native Wayland over XWayland, as far as Kitty is concerned?

RedDocMD avatar Apr 20 '21 16:04 RedDocMD

After updating to 0.20.0 today on Arch Gnome 40, My window decorations are gone, is this related? Is this a feature or a bug? Is there any way to bring them back in the config? Screenshot from 2021-04-19 19-19-45

Is there a way to change the white colour for window decoration?

feyzee avatar Apr 24 '21 07:04 feyzee

Yes, really, please, give us a way to come back to the Gnome title... I loved kitty because It was really easy to integrate with colors and font, but this white bar is very ugly here... image

metal3d avatar Apr 24 '21 08:04 metal3d

They arent gone they are just not native. If you want native set linux_display_server to x11 in kitty.conf which was what it used to default to.

This is what I think you are looking for @metal3d and @stellarexplosions

RedDocMD avatar Apr 24 '21 08:04 RedDocMD

OK...

# in ~/.config/kitty/kitty.conf
linux_display_server x11

Sorry for this :) Didn't seen this comment

metal3d avatar Apr 24 '21 08:04 metal3d

Is there any real advantage of using native Wayland over XWayland, as far as Kitty is concerned?

The most visible advantage of using Wayland is that the window properly scales on HiDPI screens.

When using Xwayland, kitty will look blurry if window scaling is enabled.

slrtbtfs avatar Apr 24 '21 09:04 slrtbtfs

They arent gone they are just not native. If you want native set linux_display_server to x11 in kitty.conf which was what it used to default to.

This is what I think you are looking for @metal3d and @stellarexplosions

It works, but I want to keep using Wayland. I just want to change the color of window decoration from white to something dark. AFAIK in Wayland window decorations are implemented by compositor and Gnome's Mutter only implements CSD. Is there like a setting that i can use to override the window decoration color?

image

feyzee avatar Apr 25 '21 04:04 feyzee

On Sat, Apr 24, 2021 at 09:18:22PM -0700, Faizal Musthafa wrote:

They arent gone they are just not native. If you want native set linux_display_server to x11 in kitty.conf which was what it used to default to.

This is what I think you are looking for @metal3d and @stellarexplosions

It works, but I want to keep using Wayland. I just want to change the color of window decoration from white to something dark. AFAIK in Wayland window decorations are implemented by compositor and Gnome's Mutter only implements CSD. Is there like a setting that i can use to override the window decoration color?

image

There you go: https://github.com/kovidgoyal/kitty/commit/62656b24eb8a0e25610e2c37db9aa518098136f3

And man, GNOME is a gift that just keeps on giving!

kovidgoyal avatar Apr 25 '21 05:04 kovidgoyal

In my Gnome wayland, I can't scroll cursor mutiple line by the mouse wheel. It only scroll cusor one line at a time.

topazus avatar Apr 26 '21 09:04 topazus

See https://sw.kovidgoyal.net/kitty/conf.html#opt-kitty.touch_scroll_multiplier.

Luflosi avatar Apr 26 '21 09:04 Luflosi

@Luflosi after setting touch_scroll_multiplier 5.0 in Gnome Wayland, the problem of scrolling cursor mutiple line by the mouse wheel is solved. but I wonder that the configuration parameter said that it Modify the amount scrolled by a touchpad. not mouse wheel.

btw, Is there a way to get the window title to mid position image

topazus avatar Apr 26 '21 10:04 topazus

There are basically high precision and low precision scroll inputs. The two different config options are for each one respectively. High precision scroll inputs tell an application (kitty in this case) how many pixels to scroll, possibly with an accuracy better than one pixel. Low precision ones just tell the application how many lines to scroll (I think). Which input is high precision or low precision is determined by some part of the OS. I don't know the situation on Wayland but on macOS, all input devices I have encountered were reported as being high precision by the OS, no matter if it's a touch pad or a regular mouse with discrete "steps" in the scroll wheel. This is done because macOS provides scroll acceleration. The faster one scrolls, the more scrolling is accelerated. Scroll acceleration would not really be possible when the OS reports the device as being low precision.

@kovidgoyal needs to answer the question about the window title.

Luflosi avatar Apr 26 '21 11:04 Luflosi

No you cant center the window title

kovidgoyal avatar Apr 26 '21 11:04 kovidgoyal

I have this weird issue when opening more than one kitty instance on Gnome 40: csd becomes very glitchy, clicks go through, graphic artifacts galore when moving the window.

Same issue can be reprodced with Alacritty, so it may well be not kitty's problem, but in case there is a common bug, it might be worth investigating?

PS. Great job developing and maintaining kitty, btw! Innovating and improving on a standard as ancient as terminal emulator is very much commendable.

vdrandom avatar Apr 28 '21 12:04 vdrandom

Doesn't happen for me on GNOME 40, with two kitty instances.

kovidgoyal avatar Apr 28 '21 15:04 kovidgoyal

Interesting. Launching multiple instances of kitty via command line (or even gnome's Alt+F2) does not result in the same glitch. But if I launch them from the mutter launcher, the second, third and so on instance reliably results in glitchy csd behaviour.

Seems like a gnome bug, especially since the application file does not launch kitty in any different way, Exec=kitty. Sorry to bother.

vdrandom avatar Apr 28 '21 16:04 vdrandom