kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
23.77k stars 959 forks source link

Native window decorations for GNOME Wayland #3284

Closed DiegoMagdaleno closed 8 months ago

DiegoMagdaleno commented 3 years ago

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.

kovidgoyal commented 3 years ago

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.

DiegoMagdaleno commented 3 years ago

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

kovidgoyal commented 3 years ago

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

ljrk0 commented 3 years ago

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

kovidgoyal commented 3 years ago

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.

DragonSWDev commented 3 years ago

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.

kovidgoyal commented 3 years ago

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.

DragonSWDev commented 3 years ago

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.

kovidgoyal commented 3 years ago

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

molaeiali commented 3 years ago

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

kovidgoyal commented 3 years ago

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.

ljrk0 commented 3 years ago

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 :)

RedDocMD commented 3 years ago

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?)

kovidgoyal commented 3 years ago

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.

RedDocMD commented 3 years ago

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

feyzee commented 3 years ago

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?

metal3d commented 3 years ago

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

RedDocMD commented 3 years ago

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

metal3d commented 3 years ago

OK...

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

Sorry for this :) Didn't seen this comment

slrtbtfs commented 3 years ago

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.

feyzee commented 3 years ago

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

kovidgoyal commented 3 years ago

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!

topazus commented 3 years ago

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

Luflosi commented 3 years ago

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

topazus commented 3 years ago

@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

Luflosi commented 3 years ago

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.

kovidgoyal commented 3 years ago

No you cant center the window title

vdrandom commented 3 years ago

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.

kovidgoyal commented 3 years ago

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

vdrandom commented 3 years ago

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.

berkentekin commented 3 years ago

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.

Hey, this may be off-topic but as a novice (university sophomore) programmer I would like to work on this. I have a basic knowledge of C. What resources should I look into in order to learn how to implement libdecoration?

kovidgoyal commented 3 years ago

On Thu, Jul 22, 2021 at 09:23:59AM -0700, Berken Tekin wrote:

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.

Hey, this may be off-topic but as a novice (university sophomore) programmer I would like to work on this. I have a basic knowledge of C. What resources should I look into in order to learn how to implement libdecoration?

First understand how client side decorations are drawn in kitty (mostly wl_client_side_decorations.c, wl_window.c and wl_init.c) then look at the libdecoration examples/source code.

kovidgoyal commented 3 years ago

And note that libdecor doesn't actually do native decorations either, since GTK doesn't provide the needed hooks to do that. So while you will get some decorations with libdecor they wont be native. https://gitlab.gnome.org/jadahl/libdecor/-/issues/6

berkentekin commented 3 years ago

@kovidgoyal Thanks for your advice, I'll see what I can do.

renatolfc commented 3 years ago

There you go: 62656b2 And man, GNOME is a gift that just keeps on giving!

Actually, this is quite useful on Windows with WSLg, since it uses Wayland under the hood. So thanks for implementing!

rmader commented 3 years ago

And note that libdecor doesn't actually do native decorations either, since GTK doesn't provide the needed hooks to do that. So while you will get some decorations with libdecor they wont be native. https://gitlab.gnome.org/jadahl/libdecor/-/issues/6

Native GTK-like styling is planned for release 0.2 of libdecor, see https://gitlab.gnome.org/jadahl/libdecor/-/merge_requests/43

sharpenedblade commented 2 years ago

I think client side decorations are not important, if gnome is detected, the titlebar could always be drawn, without any decorations, especialy since client side decorations is broken in a number of tilling wm, sticking to ssd works and looks native every where except gnome

demizer commented 2 years ago

Ugh. Suffered for many months with this issue in Gnome Wayland, just found the time to fix it and come to find out it is a Gnome problem... sigh... Thanks to @kovidgoyal for the excellent explanation of the problem and actively helping to make it better (within reason). This is excellently maintained software. Thank you.

I have encountered an additional problem of the CSD title bar becoming unclickable with the mouse if the window is resized or moved from screen to screen. The mouse clicks just pass through the title bar. I switched to xwayland and it's fixed. Hopefully proper support can land some day! I'll buy whomever makes that happen a nice dinner! :D

kovidgoyal commented 2 years ago

I dont have multiple screens to test with but resizing the window doesnt prevent right clicking on the title bar from working under GNOME for me.

ghost commented 2 years ago

I had the same problem with titlebar in gnome wayland, but I don't know what triggered it, because i rarely drag windows around.

adamwojt commented 2 years ago

Had same issue with white, minimal window after Updating to Ubuntu 22.04. It's incredible how much love and attention this library gets and how promptly issues are resolved. I want to thank you @kovidgoyal

kovidgoyal commented 2 years ago

You are welcome

numToStr commented 2 years ago

I am using KDE Plasma w/ Wayland and hide_window_decorations yes doesn't seem to have any effect. Is this also one of the wayland quirks?

kovidgoyal commented 2 years ago

On Sun, Jun 19, 2022 at 12:31:43AM -0700, Vikas Raj wrote:

I am using KDE Plasma w/ Wayland and hide_window_decorations yes doesn't seem to have any effect. Is this also one of the wayland quirks?

yes, hide_window_decorations will only work when using client side decorations. Plasma uses server side decorations, so you should configure hiding of decorations there.

noizo commented 2 years ago

When i use X11 decorations, and quake-mode gnome extension to show slide down kitty window, after few slides window becomes invisible. I know it has slide down, but it's completely transparent and unusable. As soon as i switch back to auto or wayland window becomes visible as usual.

ceed0 commented 2 years ago

Try to disable remember_window_size option.

noizo commented 2 years ago

Thanks, i guess it did a trick.

noizo commented 2 years ago

And how about native wayland decorations? Just asking @kovidgoyal

lukurde commented 1 year ago

libdecor (library for client-side decorators on Wayland) just merged support for using GTK decorators!

https://gitlab.gnome.org/jadahl/libdecor/-/merge_requests/43

hykilpikonna commented 1 year ago

After enabling linux_display_server x11, the close button shows but not the minimize/maximize buttons, which were present when I launch Gnome in X11. Is there a solution for this?

image