Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to permanently move topbar to second monitor. #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,19 @@ class Extension {

if (primary_monitor.inFullscreen) {
this.move_all(unfullscreen_monitor);
} else {
}
else {
this.move_all(primary_monitor);
}
}

get_second_monitor() {
for (const monitor of LM.monitors) {
if (monitor !== LM.primaryMonitor) {
return monitor;
}
}
}

move_all(monitor) {
if (this._panel_monitor_index !== monitor.index) {
Expand Down Expand Up @@ -61,15 +70,21 @@ class Extension {
LM._updateHotCorners();
LM.primaryIndex = old_index;
}

move_notifications(monitor) {
if (!this._settings.get_boolean('move-notifications')) {
return;
}

MT._constraint.index = monitor.index;
if (MT._constraint) {
MT._constraint.index = monitor.index;
}
else {
this.create_notifications_constraint(monitor);
}
}


create_notifications_constraint(monitor) {
const constraint = MT.get_constraints()[0];
if (constraint) {
Expand Down Expand Up @@ -136,22 +151,30 @@ class Extension {
this._original_getDraggableWindowForPosition = Main.panel._getDraggableWindowForPosition;
this._settings = ExtensionUtils.getSettings();
this._panel_monitor_index = LM.primaryIndex;
this._on_fullscreen = Display.connect('in-fullscreen-changed', this.fullscreen_changed.bind(this));

if (!this._settings.get_boolean('permanent-move')) {
this._on_fullscreen = Display.connect('in-fullscreen-changed', this.fullscreen_changed.bind(this));
}
else {
this.move_all(this.get_second_monitor());
}

this.create_notifications_constraint(LM.primaryMonitor);
this.patch_updateState();
this.patch_getDraggableWindowForPosition();
}

disable() {
this.move_all(LM.primaryMonitor);
Display.disconnect(this._on_fullscreen);
MT._updateState = this._original_updateState;
Main.panel._getDraggableWindowForPosition = this._original_getDraggableWindowForPosition;
delete MT._constraint;
this._settings.run_dispose();
}
}
}

function init() {
ExtensionUtils.initTranslations();
return new Extension();
}
}
1 change: 1 addition & 0 deletions src/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function buildPrefsWidget() {

box.append(buildSwitcher(settings, 'move-hot-corners', _('Move Hot Corners:')));
box.append(buildSwitcher(settings, 'move-notifications', _('Move Notifications:')));
box.append(buildSwitcher(settings, 'permanent-move', _('Permanently Move Topbar:')));

return box;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<default>true</default>
<summary>Move Notifications</summary>
<description>Move Notifications</description>
</key>
<key name="permanent-move" type="b">
<default>false</default>
<summary>Permanently Move Topbar</summary>
<description>Permanently Move Topbar</description>
</key>
</schema>
</schemalist>