xdg-desktop-portal icon indicating copy to clipboard operation
xdg-desktop-portal copied to clipboard

Button placement key

Open orowith2os opened this issue 2 years ago • 38 comments

Closes https://github.com/flatpak/xdg-desktop-portal/issues/956

This only handles the layout of window decorations, the window decorations visuals themselves would probably best be handled separately, if at all.

Client implementations:

  • [ ] GTK
  • [ ] QT
  • [ ] Electron + ArmCord
  • [ ] Firefox

Portal implementations:

  • [ ] GNOME: https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/95
  • [ ] KDE: https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/issues/14
  • [ ] Cosmic, maybe?
  • [ ] Pantheon: https://github.com/elementary/portals/issues/87

orowith2os avatar Mar 29 '23 06:03 orowith2os

I'm not entirely sure why workflows are failing, help would be appreciated there.

orowith2os avatar Mar 29 '23 06:03 orowith2os

I made https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/200 to add the appropriate mode to xdg-decoration.

orowith2os avatar Mar 29 '23 07:03 orowith2os

Update: still waiting on more input on how I should define this. The Wayland merge request is also useless here, was just a misunderstanding; server-side means apps shouldn't draw decorations at all, client-side means apps should draw them themselves. A none mode wasn't needed.

orowith2os avatar May 04 '23 23:05 orowith2os

Going to update and rework this just a bit, since I've learned quite a bit more about how the GTK preference works and cross-toolkit-ness.

orowith2os avatar Jun 25 '23 04:06 orowith2os

This seems fine to add to me, it could be useful for hide e.g. minimize where it doesn't matter etc. What I'd like to point out is that it won't solve potential "annoyances" that people have with CSD apps hiding things so they can get another "frame" placed around them. Arguably the value for this settings entry in those DE:s should still be so that CSD-only applications can, if they want, add the appropriate window controls, so that if the DE uses the "minimize" concept a lot, the app knows it should add a minimize button. Maybe this was something you already had in mind already.

jadahl avatar Jul 06 '23 09:07 jadahl

The description of the setting is probably too strong. It tells clients exactly which buttons should be drawn in which order. It would probably be make more sense for it to be a hint: these actions make sense in the current environment. And then let the client figure out where to draw what buttons.

That also sidesteps issues with RTL layouts.

swick avatar Jul 06 '23 13:07 swick

It would probably be make more sense for it to be a hint: these actions make sense in the current environment. And then let the client figure out where to draw what buttons.

I was thinking about this when reimplementing the button-layout logic from Tweaks, and yeah, a list of ideal actions would be better. I do think telling them where they should be drawn should be done though, so that on Pantheon you can get a close button on the left and on GNOME you get a close button on the right - while having no decorations on Sway and all decorations on the right on KDE.

orowith2os avatar Jul 06 '23 20:07 orowith2os

Updated, and accounted for some potential configurations such that they're invalid, when they would be valid before.

Now it should work for setups such as: Sway, KDE, Pantheon, and GNOME.

orowith2os avatar Jul 07 '23 11:07 orowith2os

Docs are finally building! Glad to see it making some more progress forward from where it was last time.

orowith2os avatar Jul 07 '23 11:07 orowith2os

@ebassi would you mind giving this an updated review, please? I'd like to see if there's anything else to nab before I start implementing it.

orowith2os avatar Jul 24 '23 01:07 orowith2os

Bugged @danirabbit on the Elementary Slack about it, so I think Elementary can be considered mostly neutral or in favor of this - they'd just hardcode (["close"],["maximize"]) on their side of things. Here's a portal issue for them: https://github.com/elementary/portals/issues/87

Someone needs to handle it for KDE too: https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/issues/14

GNOME should be more or less fine, but someone needs to first expose a ([],["close"]) on the GNOME portal, then can possibly look at converting the gsettings key to that.

GTK should be able to implement the client side of this without adding or breaking the API.

orowith2os avatar Aug 13 '23 18:08 orowith2os

btw, only GTK from client implementations mentioned in the PR seems realistic as both Firefox and Electron would rather use GtkSettings I believe and Qt has no concept of titlebar settings. Qt has only a dummy decoration for the cases when xdg-decoration is not present but then it's better to spend time on adding libdecor support I believe what ends with GTK client implementation again.

ilya-fedin avatar Aug 13 '23 18:08 ilya-fedin

@orowith2os don't merge main into this branch, this repository uses a linear history.

jadahl avatar Aug 24 '23 09:08 jadahl

Fair enough, I can force push such that there's only one commit if/when this is ready to be merged :)

orowith2os avatar Aug 24 '23 09:08 orowith2os

Fair enough, I can force push such that there's only one commit if/when this is ready to be merged :)

Just do so now, no reason to wait to clean up the branch.

jadahl avatar Aug 24 '23 10:08 jadahl

Done.

orowith2os avatar Aug 24 '23 10:08 orowith2os

Next step before this can land would be to create proof of concepts and "acks" in "enough" toolkits.

jadahl avatar Aug 24 '23 10:08 jadahl

I'm sure @lleyton should be able to handle the tauOS and libhelium side of things, and the work can easily be strapped onto the GNOME portal + GTK with @ItsJamie9494. I plan on making a Rust representation and reference for the GNOME portal soon, and tauOS can reuse it in their stuff.

orowith2os avatar Aug 24 '23 10:08 orowith2os

I can work with GTK and GNOME, but I have nothing to do with libhelium and/or tauOS anymore

ItsJamie9494 avatar Aug 24 '23 10:08 ItsJamie9494

What about Qt (and/or https://github.com/FedoraQt/QAdwaitaDecorations)? If it's GTK land only, then it's not gaining much compared to just forwarding the GTK gsetting, does it not?

Edit: wrong link to QtADwaitaDecorations.

jadahl avatar Aug 24 '23 10:08 jadahl

Sorry, sent the wrong link to QtAdwaitaDecorations.

jadahl avatar Aug 24 '23 10:08 jadahl

I don't have anybody at hand to manage QT, but AFAIK that's all done with the platform plugins. You'd need to go through and update each one individually.

If I/we can sort something out for a source code representation of this setting, I can release it as a library and reuse that, possibly. Or use it as a base for other implementations.

orowith2os avatar Aug 24 '23 10:08 orowith2os

I don't have anybody at hand to manage QT, but AFAIK that's all done with the platform plugins. You'd need to go through and update each one individually.

That's why I linked to QtAdwaitaDecorations. See https://jgrulich.cz/2023/08/22/qt-theming-in-fedora-workstation/.

If I/we can sort something out for a source code representation of this setting, I can release it as a library and reuse that, possibly. Or use it as a base for other implementations.

"implementing" the setting is most likely 99% toolkit specific plumbing, so prototyping a library outside of a toolkit likely isn't much help - I don't imagine GTK or Qt would have any use for it.

jadahl avatar Aug 24 '23 10:08 jadahl

In QAdwaitaDecorations I already use what's provided by org.gnome.desktop.wm.preferences (in particular button-layout key). There is not much I can gain changing that for something else since this project targets GNOME and this is expected to be provided all the time. For Qt in general, I can imagine this being part of the decoration plugin.

grulja avatar Aug 24 '23 11:08 grulja

QAdwaitaDecorations should probably still look to use this portal at some point, in the (possibly unlikely) event it's used someplace that's not GNOME, and the GNOME preferences aren't available to be read.

orowith2os avatar Aug 24 '23 11:08 orowith2os

You'd need to go through and update each one individually.

The proper way would be to add a hint here, then implement it here and consume in decoration plugins like this (the default one is here)

    if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
        const QVariant themeHint = theme->themeHint(QPlatformTheme::SystemIconThemeName);
        if (themeHint.isValid())
            return themeHint.toString();
    }

The one who would like to implement this will probably have to have a talk about that at [email protected] mailing list first.

ilya-fedin avatar Aug 24 '23 17:08 ilya-fedin

@grulja org.gnome.desktop.wm.preferences isn't something that's available inside the flatpak sandbox so this should help with providing the same data in a cross-platform way inside the sandbox.

swick avatar Oct 09 '24 17:10 swick

@grulja org.gnome.desktop.wm.preferences isn't something that's available inside the flatpak sandbox so this should help with providing the same data in a cross-platform way inside the sandbox.

Sure it is, you can get it through the settings portal already and it doesn't make a difference whether you make the call inside or outside the sandbox. I'm using it here for example.

grulja avatar Oct 10 '24 07:10 grulja

Huh, that's interesting. The portal documentation says

This interface provides read-only access to a small number of host settings required for toolkits similar to XSettings. It is not for general purpose settings.

Currently the interface provides the following keys:

And then goes on to list org.freedesktop.appearance color-scheme accent-color contrast.

Now I'm wondering if this is on purpose or a mistake.

swick avatar Oct 10 '24 11:10 swick

And then goes on to list org.freedesktop.appearance color-scheme accent-color contrast.

None of those settings provided via xsettings btw. org.gnome.desktop.wm.preferences.button-layout is provided (Gtk/DecorationLayout).

And if it really provided only those keys, gtk applications weren't following lots of settings such as font name/size, cursor theme/size.

ilya-fedin avatar Oct 10 '24 11:10 ilya-fedin