Skip to content

Commit 2314943

Browse files
author
yaoyaozijing
committed
优化Flatpak和SNAP行为
1 parent 428655a commit 2314943

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

linux/my_application.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ static void intent_method_call_handler(FlMethodChannel* channel,
4343

4444
static bool ReadShowSystemTitlebar() {
4545
const char* home = getenv("HOME");
46-
if (!home) return false;
47-
48-
std::string filepath = std::string(home) + "/.local/share/io.github.Predidit.Kazumi/showSystemTitlebar";
46+
const char* xdgdata = getenv("XDG_DATA_HOME");
47+
if (xdgdata){
48+
std::string filepath = std::string(xdgdata) + "/io.github.Predidit.Kazumi/showSystemTitlebar";
49+
} else if(home){
50+
std::string filepath = std::string(home) + "/.local/share/io.github.Predidit.Kazumi/showSystemTitlebar";
51+
} else return false;
4952

5053
std::ifstream file(filepath);
5154
if (!file.is_open()) return false;
@@ -57,7 +60,7 @@ static bool ReadShowSystemTitlebar() {
5760
if (content == "true") return true;
5861
if (content == "false") return false;
5962

60-
return false; // 默认值
63+
return false;
6164
}
6265

6366
// Implements GApplication::activate.
@@ -67,7 +70,7 @@ static void my_application_activate(GApplication* application) {
6770
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
6871

6972

70-
// 根据文件决定是否显示系统标题栏
73+
// showSystemTitlebar
7174
bool showSystemTitlebar = ReadShowSystemTitlebar();
7275
if (!showSystemTitlebar) {
7376
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());

0 commit comments

Comments
 (0)