From ce7489049f9dc2110f99f2d63e18aeea1f6243db Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Tue, 23 May 2023 10:32:24 +0800 Subject: [PATCH 1/8] put window on top --- src/public/app/widgets/title_bar_buttons.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/public/app/widgets/title_bar_buttons.js b/src/public/app/widgets/title_bar_buttons.js index e125e555b..832ddfef1 100644 --- a/src/public/app/widgets/title_bar_buttons.js +++ b/src/public/app/widgets/title_bar_buttons.js @@ -33,6 +33,7 @@ const TPL = ` +
@@ -47,10 +48,24 @@ export default class TitleBarButtonsWidget extends BasicWidget { this.$widget = $(TPL); this.contentSized(); + const $topBtn = this.$widget.find(".top-btn"); const $minimizeBtn = this.$widget.find(".minimize-btn"); const $maximizeBtn = this.$widget.find(".maximize-btn"); const $closeBtn = this.$widget.find(".close-btn"); + $topBtn.on('click', () => { + $topBtn.trigger('blur'); + const remote = utils.dynamicRequire('@electron/remote'); + const focusedWindow = remote.BrowserWindow.getFocusedWindow(); + const isAlwaysOnTop = focusedWindow.isAlwaysOnTop() + if (isAlwaysOnTop) { + focusedWindow.setAlwaysOnTop(false) + $topBtn.css("background-color", ""); + } else { + focusedWindow.setAlwaysOnTop(true); + $topBtn.css("background-color", "var(--accented-background-color)"); + } + }); $minimizeBtn.on('click', () => { $minimizeBtn.trigger('blur'); const remote = utils.dynamicRequire('@electron/remote'); From 63be25f5bb12679b62577e0333ea52d4bd61404a Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Tue, 23 May 2023 11:14:23 +0800 Subject: [PATCH 2/8] put window on top --- src/public/app/widgets/title_bar_buttons.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/public/app/widgets/title_bar_buttons.js b/src/public/app/widgets/title_bar_buttons.js index 832ddfef1..beb7aa1e7 100644 --- a/src/public/app/widgets/title_bar_buttons.js +++ b/src/public/app/widgets/title_bar_buttons.js @@ -52,7 +52,14 @@ export default class TitleBarButtonsWidget extends BasicWidget { const $minimizeBtn = this.$widget.find(".minimize-btn"); const $maximizeBtn = this.$widget.find(".maximize-btn"); const $closeBtn = this.$widget.find(".close-btn"); - + + //When the window is restarted, the window will not be reset when it is set to the top, so get the window status and set the icon background + (function() { + const remote = utils.dynamicRequire('@electron/remote'); + if (remote.BrowserWindow.getFocusedWindow().isAlwaysOnTop()) { + $topBtn.css("background-color", "var(--accented-background-color)"); + } + }()); $topBtn.on('click', () => { $topBtn.trigger('blur'); const remote = utils.dynamicRequire('@electron/remote'); @@ -66,6 +73,7 @@ export default class TitleBarButtonsWidget extends BasicWidget { $topBtn.css("background-color", "var(--accented-background-color)"); } }); + $minimizeBtn.on('click', () => { $minimizeBtn.trigger('blur'); const remote = utils.dynamicRequire('@electron/remote'); From 039959a48b46131de15a65685a2bff2a62b4ec2e Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Tue, 23 May 2023 15:44:26 +0800 Subject: [PATCH 3/8] Put this window top. --- src/public/app/widgets/title_bar_buttons.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/public/app/widgets/title_bar_buttons.js b/src/public/app/widgets/title_bar_buttons.js index beb7aa1e7..0ba59ffb7 100644 --- a/src/public/app/widgets/title_bar_buttons.js +++ b/src/public/app/widgets/title_bar_buttons.js @@ -33,7 +33,7 @@ const TPL = ` -
+
@@ -58,6 +58,7 @@ export default class TitleBarButtonsWidget extends BasicWidget { const remote = utils.dynamicRequire('@electron/remote'); if (remote.BrowserWindow.getFocusedWindow().isAlwaysOnTop()) { $topBtn.css("background-color", "var(--accented-background-color)"); + $topBtn.attr("title","The window has been pinned. "); } }()); $topBtn.on('click', () => { @@ -68,9 +69,11 @@ export default class TitleBarButtonsWidget extends BasicWidget { if (isAlwaysOnTop) { focusedWindow.setAlwaysOnTop(false) $topBtn.css("background-color", ""); + $topBtn.attr("title","Put this window top. "); } else { focusedWindow.setAlwaysOnTop(true); $topBtn.css("background-color", "var(--accented-background-color)"); + $topBtn.attr("title","The window has been pinned. "); } }); From dc4983a013015ca52439e65e785bc28e026ed3fa Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Tue, 23 May 2023 15:49:03 +0800 Subject: [PATCH 4/8] Bring this window to the top --- src/public/app/widgets/title_bar_buttons.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/public/app/widgets/title_bar_buttons.js b/src/public/app/widgets/title_bar_buttons.js index 0ba59ffb7..fe09669e3 100644 --- a/src/public/app/widgets/title_bar_buttons.js +++ b/src/public/app/widgets/title_bar_buttons.js @@ -33,7 +33,7 @@ const TPL = ` -
+
@@ -58,7 +58,7 @@ export default class TitleBarButtonsWidget extends BasicWidget { const remote = utils.dynamicRequire('@electron/remote'); if (remote.BrowserWindow.getFocusedWindow().isAlwaysOnTop()) { $topBtn.css("background-color", "var(--accented-background-color)"); - $topBtn.attr("title","The window has been pinned. "); + $topBtn.attr("title","The window is already on top. "); } }()); $topBtn.on('click', () => { @@ -69,11 +69,11 @@ export default class TitleBarButtonsWidget extends BasicWidget { if (isAlwaysOnTop) { focusedWindow.setAlwaysOnTop(false) $topBtn.css("background-color", ""); - $topBtn.attr("title","Put this window top. "); + $topBtn.attr("title","Bring this window to the top. "); } else { focusedWindow.setAlwaysOnTop(true); $topBtn.css("background-color", "var(--accented-background-color)"); - $topBtn.attr("title","The window has been pinned. "); + $topBtn.attr("title","The window is already on top. "); } }); From 66c25e7f2966c7a47b6f9469b587c75f13b5e075 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Tue, 23 May 2023 15:55:35 +0800 Subject: [PATCH 5/8] Bring this window to the top --- src/public/app/widgets/title_bar_buttons.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/public/app/widgets/title_bar_buttons.js b/src/public/app/widgets/title_bar_buttons.js index fe09669e3..a2f35937b 100644 --- a/src/public/app/widgets/title_bar_buttons.js +++ b/src/public/app/widgets/title_bar_buttons.js @@ -58,7 +58,6 @@ export default class TitleBarButtonsWidget extends BasicWidget { const remote = utils.dynamicRequire('@electron/remote'); if (remote.BrowserWindow.getFocusedWindow().isAlwaysOnTop()) { $topBtn.css("background-color", "var(--accented-background-color)"); - $topBtn.attr("title","The window is already on top. "); } }()); $topBtn.on('click', () => { @@ -69,11 +68,9 @@ export default class TitleBarButtonsWidget extends BasicWidget { if (isAlwaysOnTop) { focusedWindow.setAlwaysOnTop(false) $topBtn.css("background-color", ""); - $topBtn.attr("title","Bring this window to the top. "); } else { focusedWindow.setAlwaysOnTop(true); $topBtn.css("background-color", "var(--accented-background-color)"); - $topBtn.attr("title","The window is already on top. "); } }); From 79dca12274b31d3dc681742b5ed0ea792bedbfc2 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Tue, 23 May 2023 20:50:03 +0800 Subject: [PATCH 6/8] top --- .vscode/settings.json | 2 +- src/public/app/widgets/title_bar_buttons.js | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0e4b77b5c..b1cee4342 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "[javascript]": { - "editor.defaultFormatter": "dbaeumer.vscode-eslint" + "editor.defaultFormatter": "vscode.typescript-language-features" }, "[json]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" diff --git a/src/public/app/widgets/title_bar_buttons.js b/src/public/app/widgets/title_bar_buttons.js index a2f35937b..24188d9ce 100644 --- a/src/public/app/widgets/title_bar_buttons.js +++ b/src/public/app/widgets/title_bar_buttons.js @@ -30,6 +30,9 @@ const TPL = ` height: 40px; width: 40px; } + .title-bar-buttons .top-btn.active{ + background-color:var(--accented-background-color); + } @@ -52,12 +55,12 @@ export default class TitleBarButtonsWidget extends BasicWidget { const $minimizeBtn = this.$widget.find(".minimize-btn"); const $maximizeBtn = this.$widget.find(".maximize-btn"); const $closeBtn = this.$widget.find(".close-btn"); - + //When the window is restarted, the window will not be reset when it is set to the top, so get the window status and set the icon background - (function() { + (function () { const remote = utils.dynamicRequire('@electron/remote'); if (remote.BrowserWindow.getFocusedWindow().isAlwaysOnTop()) { - $topBtn.css("background-color", "var(--accented-background-color)"); + $topBtn.addClass('active'); } }()); $topBtn.on('click', () => { @@ -67,13 +70,13 @@ export default class TitleBarButtonsWidget extends BasicWidget { const isAlwaysOnTop = focusedWindow.isAlwaysOnTop() if (isAlwaysOnTop) { focusedWindow.setAlwaysOnTop(false) - $topBtn.css("background-color", ""); + $topBtn.removeClass('active'); } else { focusedWindow.setAlwaysOnTop(true); - $topBtn.css("background-color", "var(--accented-background-color)"); + $topBtn.addClass('active'); } }); - + $minimizeBtn.on('click', () => { $minimizeBtn.trigger('blur'); const remote = utils.dynamicRequire('@electron/remote'); From 01b2887b36c44f2ca519c299dd1b72f6e9aadcd3 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Sat, 27 May 2023 14:18:26 +0800 Subject: [PATCH 7/8] Keep this window on top. --- src/public/app/widgets/title_bar_buttons.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/widgets/title_bar_buttons.js b/src/public/app/widgets/title_bar_buttons.js index 24188d9ce..6a4f73ad5 100644 --- a/src/public/app/widgets/title_bar_buttons.js +++ b/src/public/app/widgets/title_bar_buttons.js @@ -36,7 +36,7 @@ const TPL = ` -
+
From 1a2beb941e8f77b7bf59586289bfa10bf1327e14 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Sat, 27 May 2023 14:23:50 +0800 Subject: [PATCH 8/8] keep this window on top --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index b1cee4342..0e4b77b5c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "[javascript]": { - "editor.defaultFormatter": "vscode.typescript-language-features" + "editor.defaultFormatter": "dbaeumer.vscode-eslint" }, "[json]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint"