[gnote: 1/2] Use $XDG_CURRENT_DESKTOP for CSD decision
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote: 1/2] Use $XDG_CURRENT_DESKTOP for CSD decision
- Date: Sun, 22 Mar 2020 13:55:08 +0000 (UTC)
commit 0102c770052fe6e6ad25fb5a2b8e44ceb7a76e9e
Author: Will Thompson <wjt endlessm com>
Date: Sat Mar 14 22:14:14 2020 +0000
Use $XDG_CURRENT_DESKTOP for CSD decision
Previously, the automatic decision for whether to use client-side
decorations was made by examining the $DESKTOP_SESSION variable. This
entails adding new entries to the default value for any new desktop,
even if it is derived from one already on the list.
$XDG_CURRENT_DESKTOP is defined by the Desktop Entry Specification[0],
in passing, while defining the OnlyShowIn/NotShowIn keys:
> If $XDG_CURRENT_DESKTOP is set then it contains a colon-separated list
> of strings. In order, each string is considered. If a matching entry is
> found in OnlyShowIn then the desktop file is shown. If an entry is
> found in NotShowIn then the desktop file is not shown. If none of the
> strings match then the default action is taken (as above).
On Ubuntu, $XDG_CURRENT_DESKTOP is "ubuntu:GNOME". Similarly, in Endless
OS 3.8.0, it will be "endless:GNOME". This is a more scalable way to
detect a "GNOME-like" desktop than a gradually-expanding list of
substring matches on the desktop session name.
With this change, Gnote correctly displays without server-side
decorations on Endless OS 3.8.0.
[0]
https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys
src/mainwindow.cpp | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 92cbe078..e415bca4 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -120,13 +120,17 @@ bool MainWindow::use_client_side_decorations(Preferences & prefs)
s_use_client_side_decorations = 0;
std::vector<Glib::ustring> desktops;
sharp::string_split(desktops, setting, ",");
- const char *current_desktop = std::getenv("DESKTOP_SESSION");
+ const char *current_desktop = std::getenv("XDG_CURRENT_DESKTOP");
if (current_desktop) {
- Glib::ustring current_de = Glib::ustring(current_desktop).lowercase();
- for(const Glib::ustring & de : desktops) {
- Glib::ustring denv = Glib::ustring(de).lowercase();
- if(current_de.find(denv) != Glib::ustring::npos) {
- s_use_client_side_decorations = 1;
+ std::vector<Glib::ustring> current_desktops;
+ sharp::string_split(current_desktops, current_desktop, ":");
+ for(const Glib::ustring & cd : current_desktops) {
+ Glib::ustring current_de = cd.lowercase();
+ for(const Glib::ustring & de : desktops) {
+ if (current_de == de) {
+ s_use_client_side_decorations = 1;
+ return s_use_client_side_decorations;
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]