diff --git a/src/public/app/widgets/title_bar_buttons.js b/src/public/app/widgets/title_bar_buttons.js index e125e555b..6a4f73ad5 100644 --- a/src/public/app/widgets/title_bar_buttons.js +++ b/src/public/app/widgets/title_bar_buttons.js @@ -30,9 +30,13 @@ const TPL = ` height: 40px; width: 40px; } + .title-bar-buttons .top-btn.active{ + background-color:var(--accented-background-color); + } +
@@ -47,10 +51,32 @@ 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"); + //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.addClass('active'); + } + }()); + $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.removeClass('active'); + } else { + focusedWindow.setAlwaysOnTop(true); + $topBtn.addClass('active'); + } + }); + $minimizeBtn.on('click', () => { $minimizeBtn.trigger('blur'); const remote = utils.dynamicRequire('@electron/remote');