GithubHelp home page GithubHelp logo

Comments (12)

johanmalm avatar johanmalm commented on September 26, 2024 2

Ha ha... I can't keep up with you 😄

As @ahesford said, we support both xdg-decoration and kde-server-decoration protocols.

Gtk only use the kde varient however, which is the only reason we support that one (KDE support xdg).

When a Gtk (3 or 4) application is started, it creates a server-side decoration object and then tells labwc whether it wants allows server-side decorations or will provide client-side decorations. We respect either way.

I think that the Gtk set_titlebar method makes the kde-server-decoration negotiation settle on CSD (so we hide the SSD). If you then also call set_decorated(False) that will turn off the CSD, so you're left with no decoration at all. See example below:

#!/usr/bin/env python3

import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gio


class HeaderBarWindow(Gtk.Window):
    def __init__(self):
        super().__init__(title="foo")
        self.set_border_width(5)
        self.set_default_size(512, 256)
        hb = Gtk.HeaderBar()
        hb.set_show_close_button(True)
        hb.props.title = "bar"
        self.set_titlebar(hb)
        self.add(Gtk.TextView())

win = HeaderBarWindow()
win.connect("destroy", Gtk.main_quit)

# Comment this out to see the window with the forced headerbar
win.set_decorated(False)

win.show_all()
Gtk.main()

For reference, the issue below contains a Qt script that opens a window with no deco. It also contains some analysis on decoration that I did some time ago.

from labwc.

spl237 avatar spl237 commented on September 26, 2024 1

Ah - no, on fiddling a bit more, that gtk function does seem to be respected after all!

from labwc.

spl237 avatar spl237 commented on September 26, 2024 1

Many thanks for that - that's given me a bunch of things to try! I'll have a play next week and report back.

from labwc.

spl237 avatar spl237 commented on September 26, 2024

OK, this is odd...

I use gtk_window_set_decorated (...., FALSE) to turn off the display of titlebars on some windows - the greeter and its background, and various modal dialogs used to indicate that short-lived processes are ongoing.

In the greeter, this works as intended - the greeter and its background are drawn with header bars unless I call set_decorated immediately after they are shown, when the header bars are hidden.

But when running in the main desktop, calling set_decorated in exactly the same way doesn't hide the header bars on the modal dialogs - they get a headerbar irrespective of whether or not I call that function. Setting the decorated property of the relevant windows to false in the UI file also has no effect.

So it seems that under some circumstances, disabling decorations is not respected by the window manager, and in others it is, but I can't work out what the difference is.

Any suggestions as to what I could try to work out what is going on here, please?

from labwc.

spl237 avatar spl237 commented on September 26, 2024

I've worked out what is happening.

As far as I can tell, gtk_window_set_decorate has no effect at all in labwc; nor does setting the decorated parameter for the window in the Glade or UI file.

But all windows which are inited as layer-shell windows get no headerbar, in both wayfire and labwc, and this is why the greeter windows have no headerbars in labwc. (So I can use this mechanism to turn off decoration when I need it instead of using gtk_window_set_decorated as a workaround, but this shouldn't be necessary.)

In wayfire, gtk_window_set_decorated is respected (with the proviso that it has to be called after the window is shown, not before) for non-layer-shell windows.

So I think this is a bug in labwc - gtk_window_set_decorated has no effect, and I think it should, based on the behaviour of other wlroots-based compositors.

from labwc.

spl237 avatar spl237 commented on September 26, 2024

Thinking about it - this presumably works in wayfire because the window decorations are client-side - so it is a GTK headerbar which would be drawn, and a GTK setting to not draw it.

So the question is - probably along the lines of the other issue I reported with headerbar buttons not reflecting GTK settings in terms of being able to resize windows - is there some way for the window manager to find out that the client application has requested no decorations, and hence to respect it?

from labwc.

ahesford avatar ahesford commented on September 26, 2024

I'm a bit shaky on this, but labwc supports the XDG and KDE decoration protocols. Clients inform the compositor whether they would prefer client-side or server-side decorations, and labwc takes that into consideration (along with explicit request by, e.g., window rules).

I'm not sure what causes GTK applications to send these requests. I have a few GTK applications---gedit, simple-scan and evince---that behave as expected with respect to client-side decorations. Looking at the source code for simple-scan reveals no calls to gtk_window_set_decorate and a UI definition seemingly defined in XML, so there are some levels that I'm overlooking.

[Edit: sorry about the accidental closure; typing on a phone can be hazardous.]

from labwc.

spl237 avatar spl237 commented on September 26, 2024

Looking at the gtk_window_set_decoration function, it calls down to gdk_window_set_decorations. This in turn calls the appropriate function in the relevant backend, which would be gdk_wayland_window_set_decorations - which does nothing at all; it is an empty function. (By comparison, the relevant function in the X11 backend sets some Motif window hints which are interpreted by the window manager.)

So it looks as if this only works in wayfire because it is all handled as part of the client-side decorations, and that it doesn't, at first look, appear to be supported with server-side decorations under wayland. Unless (as is entirely possible) I am missing something!

This is on GTK3, btw - it may be better supported in GTK4 - will have a look when I get a chance. If it is properly supported on the GTK4 backend, it may just be a question of copying the relevant backend function from GTK4 into GTK3 - we have numerous local patches and changes to the version of GTK3 we ship, so adding another wouldn't be a problem.

from labwc.

spl237 avatar spl237 commented on September 26, 2024

OK, just checked the GTK4 code, and it looks as if setting decorated is a no-op on there too - it sets the "decorated" property in the GDK toplevel for the window, and then the Wayland backend ignores that setting.

I'll raise an issue on the GTK repo and see if / how they intend this to work.

from labwc.

spl237 avatar spl237 commented on September 26, 2024

Yes, that works for me - just setting set_titlebar and then turning off decorations works perfectly. In fact, I can even do both in the UI file and don't need to do anything in the code at all; and the same UI file then displays correctly under wayfire and X as well.

Many thanks for the help!

from labwc.

johanmalm avatar johanmalm commented on September 26, 2024

Yes, that works for me - just setting set_titlebar and then turning off decorations works perfectly. In fact, I can even do both in the UI file and don't need to do anything in the code at all; and the same UI file then displays correctly under wayfire and X as well.

Many thanks for the help!

Glad it worked.

Out of interest, what tools do you use for Gtk UI? Or do you do it by hand?

from labwc.

spl237 avatar spl237 commented on September 26, 2024

Out of interest, what tools do you use for Gtk UI? Or do you do it by hand?

If it is something really small, I'll just do it in straight C calls and not bother with a UI file, but I mostly use Glade, with the occasional bit of tweaking of the XML in a text editor when Glade is doing something stupid, which it does from time to time! (For example, in this specific case, Glade will not allow you to set a window to both have client-side decorations and to be undecorated, so I had to fix that in the XML by hand.)

from labwc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.