mirror of
https://github.com/gosticks/PaperWM.git
synced 2026-12-04 04:11:38 +00:00
top bar: Add only show on primary preference
Introduces `TopBar.panelMonitor` which points to the monitor currently holding the top bar.
This commit is contained in:
+40
@@ -597,6 +597,46 @@
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="workspace_grid8">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">12</property>
|
||||
<property name="margin_right">12</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="column_spacing">32</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="topbar_follow_focus_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="label" translatable="yes">Make topbar follow monitor focus</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="topbar-follow-focus">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Binary file not shown.
@@ -336,6 +336,11 @@
|
||||
<summary>Show the top bar on workspaces by default</summary>
|
||||
</key>
|
||||
|
||||
<key type="b" name="topbar-follow-focus">
|
||||
<default>true</default>
|
||||
<summary>Make the top bar follow the focused monitor</summary>
|
||||
</key>
|
||||
|
||||
<key type="d" name="animation-time">
|
||||
<default>0.25</default>
|
||||
<summary>Duration of animations in seconds</summary>
|
||||
|
||||
+1
-1
@@ -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() {
|
||||
|
||||
@@ -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<this.length; i++) {
|
||||
@@ -1001,7 +1003,7 @@ box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, .7);
|
||||
this.name = name;
|
||||
|
||||
if (this.workspace === workspaceManager.get_active_workspace()) {
|
||||
TopBar.setWorkspaceName(this.name);
|
||||
TopBar.updateWorkspaceIndicator(this.workspace.index());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,11 @@ var Tiling = Extension.imports.tiling;
|
||||
var Navigator = Extension.imports.navigator;
|
||||
var Utils = Extension.imports.utils;
|
||||
|
||||
var prefs = Extension.imports.settings.prefs;
|
||||
var Settings = Extension.imports.settings;
|
||||
var prefs = Settings.prefs;
|
||||
|
||||
var panelBox = Main.layoutManager.panelBox;
|
||||
var panelMonitor;
|
||||
|
||||
var workspaceManager = global.workspace_manager;
|
||||
var display = global.display;
|
||||
@@ -466,8 +468,7 @@ class WorkspaceMenu extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
workspaceSwitched(wm, fromIndex, toIndex) {
|
||||
let space = Tiling.spaces.spaceOf(workspaceManager.get_workspace_by_index(toIndex));
|
||||
this._label.set_text(space.name);
|
||||
updateWorkspaceIndicator(toIndex);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
@@ -504,15 +505,12 @@ function enable () {
|
||||
let point = new Clutter.Vertex({x: 0, y: 0});
|
||||
let r = label.apply_relative_transform_to_point(panelActor, point);
|
||||
|
||||
imports.mainloop.timeout_add(0, () => {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user