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 c5fec94..4d59a53 100644 Binary files a/schemas/gschemas.compiled and b/schemas/gschemas.compiled differ 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; }