gui preferences: adw prefs dialog with tiling mode (conky-align / fixed fraction) and fraction spinrow, backed by gsettings schema
This commit is contained in:
1 parent
3def53e0d8
commit
a8a4c20f5e
7 files changed
+98
-21
No files matched your search
+16
-14
@@ -4,13 +4,12 @@ import Shell from 'gi://Shell';
|
||||
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
|
||||
// fallback width when the conky window is not found
|
||||
const TILE_FRACTION = 2 / 3;
|
||||
// ignore the conky window as alignment target if the tile would get narrower
|
||||
const MIN_FRACTION = 0.5;
|
||||
|
||||
export default class WideTileExtension extends Extension {
|
||||
enable() {
|
||||
this._settings = this.getSettings();
|
||||
this._handlers = new Map();
|
||||
for (const [binding, dir] of [['toggle-tiled-left', -1],
|
||||
['toggle-tiled-right', 1]]) {
|
||||
@@ -28,6 +27,7 @@ export default class WideTileExtension extends Extension {
|
||||
Shell.ActionMode.NORMAL, null);
|
||||
this._handlers = null;
|
||||
this._prevRects = null;
|
||||
this._settings = null;
|
||||
}
|
||||
|
||||
_tileSide(dir) {
|
||||
@@ -38,18 +38,20 @@ export default class WideTileExtension extends Extension {
|
||||
const wa = win.get_work_area_current_monitor();
|
||||
const mon = global.display.get_monitor_geometry(win.get_monitor());
|
||||
|
||||
// target width: up to the left edge of the conky window on this
|
||||
// monitor, falling back to a fraction of the work area
|
||||
let width = Math.floor(wa.width * TILE_FRACTION);
|
||||
const monIndex = win.get_monitor();
|
||||
for (const actor of global.get_window_actors()) {
|
||||
const mw = actor.meta_window;
|
||||
if (mw.get_wm_class() === 'conky' &&
|
||||
mw.get_monitor() === monIndex) {
|
||||
const w = mw.get_frame_rect().x - wa.x;
|
||||
if (w >= wa.width * MIN_FRACTION)
|
||||
width = w;
|
||||
break;
|
||||
// target width: conky-aligned or a fraction of the work area
|
||||
const fraction = this._settings.get_double('fraction');
|
||||
let width = Math.floor(wa.width * fraction);
|
||||
if (this._settings.get_string('mode') === 'conky') {
|
||||
const monIndex = win.get_monitor();
|
||||
for (const actor of global.get_window_actors()) {
|
||||
const mw = actor.meta_window;
|
||||
if (mw.get_wm_class() === 'conky' &&
|
||||
mw.get_monitor() === monIndex) {
|
||||
const w = mw.get_frame_rect().x - wa.x;
|
||||
if (w >= wa.width * MIN_FRACTION)
|
||||
width = w;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user