From ecd355115ce0dfba65f793123778d7ad660c52bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Thu, 13 Feb 2020 14:51:12 +0100 Subject: [PATCH] top bar: Add only show on primary preference Introduces `TopBar.panelMonitor` which points to the monitor currently holding the top bar. --- Settings.ui | 40 ++++++++ prefs.js | 8 ++ schemas/gschemas.compiled | Bin 5960 -> 6008 bytes ....shell.extensions.org-scrollwm.gschema.xml | 5 + settings.js | 2 +- tiling.js | 8 +- topbar.js | 91 +++++++++++------- 7 files changed, 114 insertions(+), 40 deletions(-) diff --git a/Settings.ui b/Settings.ui index 3e48e40..11a407c 100644 --- a/Settings.ui +++ b/Settings.ui @@ -597,6 +597,46 @@ + + + True + True + + + True + False + 12 + 12 + 6 + 6 + 32 + + + True + False + True + Make topbar follow monitor focus + 0 + + + 0 + 0 + + + + + True + True + + + 1 + 0 + + + + + + diff --git a/prefs.js b/prefs.js index 917bf34..c9eeeb1 100644 --- a/prefs.js +++ b/prefs.js @@ -135,6 +135,14 @@ class SettingsWidget { state); }); + let topbarFollowFocus = this.builder.get_object('topbar-follow-focus'); + topbarFollowFocus.state = + this._settings.get_boolean('topbar-follow-focus'); + topbarFollowFocus.connect('state-set', (obj, state) => { + this._settings.set_boolean('topbar-follow-focus', + state); + }); + // Workspaces diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index c5fec9433911c744d05e4aeec066694cb0b9a501..4d59a53328b3f40d3833a3bd6169e57e1457caed 100644 GIT binary patch delta 1350 zcmYjRTS!z<6g^{Vn&XT!-kGV)Fe(_$Yi}xOR7ygks0bmVkFGOU=iE7!Ltg(+M zs1M;3Ss?{IEGbGNdQcHPXnrCg1c{73>mx8Kdi>N{Q$`0CYt1^3z0aJzZ?^7x-N4?> zWj-Ma0z&-4aD#=|BFOWAJyZ7eJUG;~qFFS9m7ox_*A3RuAA(*6e+*n3k`H|=M&Dd5 zb%kVQpkhuT7R&^Sfm#2dL_Y9TW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4vG0Sw5 z1KMEH&KM?Jiy!IJ>$8oNYgndiQA6^AKcXzyj&3@JYYZ9gh+N|j$;!I^0x>6PQ=WKF{S*`qX9c_ki~T zSL^N+^Qn;^7ab5?!0FJ53}2vTBWJ<9o6?4@r(DY(K}^VS@O^@}6sHs+OaUx41U0wd V1GiG+6WA!!+;SVZUB*HO{{i-;1xo+` diff --git a/schemas/org.gnome.shell.extensions.org-scrollwm.gschema.xml b/schemas/org.gnome.shell.extensions.org-scrollwm.gschema.xml index abc7ce5..13d7da2 100644 --- a/schemas/org.gnome.shell.extensions.org-scrollwm.gschema.xml +++ b/schemas/org.gnome.shell.extensions.org-scrollwm.gschema.xml @@ -336,6 +336,11 @@ Show the top bar on workspaces by default + + true + Make the top bar follow the focused monitor + + 0.25 Duration of animations in seconds diff --git a/settings.js b/settings.js index 45fc8d5..31187df 100644 --- a/settings.js +++ b/settings.js @@ -34,7 +34,7 @@ var prefs = {}; ['window-gap', 'vertical-margin', 'vertical-margin-bottom', 'horizontal-margin', 'workspace-colors', 'default-background', 'animation-time', 'use-workspace-name', 'pressure-barrier', 'default-show-top-bar', 'swipe-sensitivity', 'swipe-friction', - 'cycle-width-steps', 'cycle-height-steps'] + 'cycle-width-steps', 'cycle-height-steps', 'topbar-follow-focus'] .forEach((k) => setState(null, k)); function setVerticalMargin() { diff --git a/tiling.js b/tiling.js index cc7a533..7c166da 100644 --- a/tiling.js +++ b/tiling.js @@ -387,9 +387,11 @@ class Space extends Array { this._inLayout = false; return; } + let topBarAdjustment = this.showTopBar && (prefs.topbar_follow_focus || this.monitor === Main.layoutManager.primaryMonitor) ? + panelBox.height : 0; let availableHeight = (workArea.y - this.monitor.y + workArea.height - - (panelBox.height)*this.showTopBar - prefs.vertical_margin - prefs.vertical_margin_bottom); - let y0 = (panelBox.height)*this.showTopBar + prefs.vertical_margin; + topBarAdjustment - prefs.vertical_margin - prefs.vertical_margin_bottom); + let y0 = topBarAdjustment + prefs.vertical_margin; let fixPointAttempCount = 0; for (let i=0; i { - for (let [workspace, space] of Tiling.spaces) { - space.label.set_position(panelActor.x + Math.round(r.x), panelActor.y + Math.round(r.y)); - let fontDescription = label.clutter_text.font_description; - space.label.clutter_text.set_font_description(fontDescription); - }}) + for (let [workspace, space] of Tiling.spaces) { + space.label.set_position(panelActor.x + Math.round(r.x), panelActor.y + Math.round(r.y)); + let fontDescription = label.clutter_text.font_description; + space.label.clutter_text.set_font_description(fontDescription); + } } - fixLabel(menu._label); - signals.connect(menu._label, 'notify::allocation', fixLabel); Main.panel.addToStatusArea('WorkspaceMenu', menu, 0, 'left'); menu.actor.show(); @@ -534,24 +532,29 @@ function enable () { hide(); }); + signals.connect(Settings.settings, 'changed::topbar-follow-focus', (settings, key) => { + let monitors = Tiling.spaces.monitors; + let to = setMonitor(Main.layoutManager.focusMonitor); + let space = monitors.get(to); + updateWorkspaceIndicator(space.workspace.index()); + for (let [workspace, space] of Tiling.spaces) { + space.layout(); + } + + }); + signals.connect(panelBox, 'show', () => { - let focus = display.focus_window; - if (focus && focus.fullscreen - && !Main.overview.visible && !Tiling.inPreview) - hide(); - else - show(); + show(); }); signals.connect(panelBox, 'hide', () => { - if (!Tiling.spaces.selectedSpace.showTopBar) - return; - - if (display.focus_window && display.focus_window.fullscreen) { - hide(); - } else { - panelBox.show(); - } + hide(); }); + + fixLabel(menu._label); + signals.connect(menu._label, 'notify::allocation', fixLabel); + signals.connectOneShot(menu._label, 'notify::allocation', () => { + setMonitor(Main.layoutManager.primaryMonitor); + }) } function disable() { @@ -570,10 +573,11 @@ function disable() { } function show() { - let hideTopBar = !(Tiling.spaces && Tiling.spaces.selectedSpace.showTopBar); - if (hideTopBar && - !Main.overview.visible && - !Tiling.inPreview) { + let focus = display.focus_window; + let normal = !Main.overview.visible && !Tiling.inPreview + let fullscreen = focus && focus.fullscreen && focus.get_monitor() === panelMonitor.index + let hideTopBar = !(Tiling.spaces && Tiling.spaces.monitors.get(panelMonitor).showTopBar) + if (normal && (hideTopBar || fullscreen)) { hide(); return; } @@ -583,23 +587,34 @@ function show() { } function hide() { - panelBox.hide(); - let hideTopBar = !(Tiling.spaces && Tiling.spaces.selectedSpace.showTopBar); - if (hideTopBar && - !Main.overview.visible && - !Tiling.inPreview) { + let normal = !Main.overview.visible && !Tiling.inPreview + let hideTopBar = !(Tiling.spaces && Tiling.spaces.monitors.get(panelMonitor).showTopBar) + if (normal && hideTopBar) { // Update the workarea to support hide top bar panelBox.scale_y = 0; + panelBox.hide(); + return; + } + let focus = display.focus_window; + let fullscreen = focus && focus.fullscreen && focus.get_monitor() === panelMonitor.index + if (normal && !fullscreen) { + show(); } } + + /** Override the activities label with the workspace name. let workspaceIndex = 0 */ function updateWorkspaceIndicator (index) { - let space = Tiling.spaces.spaceOf(workspaceManager.get_workspace_by_index(index)); - setWorkspaceName(space.name); + let spaces = Tiling.spaces; + let space = spaces && spaces.spaceOf(workspaceManager.get_workspace_by_index(index)); + let onMonitor = space && space.monitor === panelMonitor; + let nav = Navigator.navigator + if (onMonitor || (Tiling.inPreview && nav && nav.from.monitor === panelMonitor)) + setWorkspaceName(space.name); }; function setWorkspaceName (name) { @@ -607,8 +622,12 @@ function setWorkspaceName (name) { } function setMonitor(monitor) { + if (!prefs.topbar_follow_focus) + monitor = Main.layoutManager.primaryMonitor; let panelBox = Main.layoutManager.panelBox; + panelMonitor = monitor; panelBox.set_position(monitor.x, monitor.y); panelBox.width = monitor.width; show(); + return monitor; }