Comments (12)
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.
Ah - no, on fiddling a bit more, that gtk function does seem to be respected after all!
from labwc.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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)
- Mouse action not working on client when context Set to None HOT 5
- Disabling root menu HOT 1
- Hotplug event and output restore functionality doesn't seem to restore output's scale on Kanshi event HOT 2
- `zwlr_foreign_toplevel_handle_v1::output_enter` is not sent when xwayland surface is re-mapped HOT 2
- lab_wlr_scene_output_commit should update after wltoots 0.18 update HOT 2
- magnifier: Scale geometry of magnifier with output scale HOT 1
- magnifier: Repaint check for cursor position should be checked against cursor + half magnifier width HOT 1
- New labwc release: 0.8.0
- Wezterm's window cannot be resized in upper-left direction with `<resize drawContents="no">` HOT 3
- Exclusive zone not respected if lxqt-panel is less than 100% and not centered HOT 5
- latest commits on master break gtk2 applications conky but gtk3 still work HOT 20
- Change "FocusOuput" to be more in-line with "MoveToOutput" HOT 1
- `[../src/ssd/ssd.c:239] view width is smaller than its minimal value` when resizing `foot` window to minimal size HOT 1
- desk*.xbm (omnipresent) buttons cannot be styled/colorized HOT 5
- RFC: nomenclature for "Omnipresent" button and its theming HOT 3
- document new ssd buttons HOT 5
- Perhaps in the CI `scdoc` should be added.
- [Feature request] Allow pressing ESC to leave magnifier HOT 2
- [Question] Keeping my monitors off after inactivity HOT 18
- [Request] Add support for ~/Desktop icons HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from labwc.