From 2f924789995964d2245f0d527b1ea4531e791dc1 Mon Sep 17 00:00:00 2001 From: msojocs Date: Sat, 16 Nov 2024 18:18:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0Wayland=E4=B8=93?= =?UTF-8?q?=E7=94=A8=E7=BD=AE=E9=A1=B6=E6=A0=87=E8=AF=86=20`[Wayland?= =?UTF-8?q?=E7=BD=AE=E9=A1=B6]`=20#136?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.MD | 6 ++++++ res/scripts/injectExt.js | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 7b2d275..a63d109 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,3 +1,9 @@ +# 🌈 v1.15.2-3 / 2024-11- + +## 🚀 功能 + +- 置顶: 添加Wayland专用置顶标识 `[Wayland置顶]`. + # 🌈 v1.15.2-2 / 2024-11-09 ## 🚀 功能 diff --git a/res/scripts/injectExt.js b/res/scripts/injectExt.js index 3fcfd4a..addd3ae 100644 --- a/res/scripts/injectExt.js +++ b/res/scripts/injectExt.js @@ -99,6 +99,25 @@ Module._load = (...args) => { } } +if (process.env.XDG_SESSION_TYPE === 'wayland' || process.env.WAYLAND_DISPLAY) { + const _setAlwaysOnTop = BrowserWindow.prototype.setAlwaysOnTop; + const key = '[Wayland置顶]' + BrowserWindow.prototype.setAlwaysOnTop = function(...args) { + let title = this.getTitle() + if (args[0] && !title.startsWith(key)) { + // 置顶 + title = `${key}${title}` + this.setTitle(title) + } + else if(!args[0] && title.startsWith(key)) + { + title = title.replace(key, '') + this.setTitle(title) + } + return _setAlwaysOnTop.apply(this, args) + } +} + const originloadURL = BrowserWindow.prototype.loadURL; BrowserWindow.prototype.loadURL = function(){ this.setMinimumSize(300, 300);