Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a2c273a2b | |||
| 14357adb1e | |||
| 31a61478ad | |||
| 2eb304a16a | |||
| 8480e6ccaf | |||
| f7a86e51b1 | |||
| 1afeb816c4 | |||
| 83ceb4ce67 | |||
| 6e90d12ee9 | |||
| 717ef0b16b | |||
| 1896d992d0 | |||
| 749e3a0275 | |||
| 1daeb0e100 | |||
| defa7255df | |||
| 6031a36664 | |||
| 021c51040f | |||
| 98bfaaa3d5 | |||
| cb26f3aebb |
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2025 Dome
|
Copyright (c) 2025 Domoel (https://github.com/Domoel/)
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
###############################################################################
|
||||||
|
# Simple‑Tiling – Makefile
|
||||||
|
#
|
||||||
|
# make build → baut beide ZIP‑Pakete
|
||||||
|
# make build-legacy → nur Legacy‑ZIP (Shell 3.38‑44)
|
||||||
|
# make build-modern → nur Modern‑ZIP (Shell 45‑48)
|
||||||
|
# make clean → räumt auf
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
UUID := simple-tiling@domoel
|
||||||
|
VERSION := 6
|
||||||
|
|
||||||
|
# Dateien/Ordner, die in *beide* Pakete gehören
|
||||||
|
COMMON_FILES := schemas exceptions.txt locale *.css README.md LICENSE
|
||||||
|
|
||||||
|
# Pref‑Dateien (zwei Varianten)
|
||||||
|
LEGACY_PREFS := prefs_legacy.js
|
||||||
|
MODERN_PREFS := prefs_modern.js
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Helfer: copies <file list> <dest>
|
||||||
|
###############################################################################
|
||||||
|
define copies
|
||||||
|
@for f in $(1) ; do \
|
||||||
|
if [ -e $$f ] ; then \
|
||||||
|
cp -r $$f $(2)/ ; \
|
||||||
|
fi ; \
|
||||||
|
done
|
||||||
|
endef
|
||||||
|
|
||||||
|
.PHONY: build build-legacy build-modern clean
|
||||||
|
build: build-legacy build-modern
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Legacy‑Build
|
||||||
|
###############################################################################
|
||||||
|
build-legacy:
|
||||||
|
@echo "==> Building LEGACY package (3.38‑44)…"
|
||||||
|
@rm -rf build && mkdir -p build/$(UUID)
|
||||||
|
$(call copies,$(COMMON_FILES),build/$(UUID))
|
||||||
|
|
||||||
|
# Schema kompilieren
|
||||||
|
@glib-compile-schemas build/$(UUID)/schemas
|
||||||
|
|
||||||
|
# Haupt‑ und Pref‑Skript
|
||||||
|
@cp legacy.js build/$(UUID)/extension.js
|
||||||
|
@cp $(LEGACY_PREFS) build/$(UUID)/prefs.js
|
||||||
|
|
||||||
|
# metadata.json anpassen
|
||||||
|
@sed -e "s/__UUID__/$(UUID)/g" \
|
||||||
|
-e "s/__VERSION__/$(VERSION)/g" \
|
||||||
|
metadata_legacy.json.in > build/$(UUID)/metadata.json
|
||||||
|
|
||||||
|
# Zip‑Paket
|
||||||
|
@cd build && zip -qr ../$(UUID)-legacy-v$(VERSION).zip .
|
||||||
|
@rm -rf build
|
||||||
|
@echo "✓ created $(UUID)-legacy-v$(VERSION).zip"
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Modern‑Build
|
||||||
|
###############################################################################
|
||||||
|
build-modern:
|
||||||
|
@echo "==> Building MODERN package (45‑48)…"
|
||||||
|
@rm -rf build && mkdir -p build/$(UUID)
|
||||||
|
$(call copies,$(COMMON_FILES),build/$(UUID))
|
||||||
|
|
||||||
|
# Schema kompilieren
|
||||||
|
@glib-compile-schemas build/$(UUID)/schemas
|
||||||
|
|
||||||
|
# Haupt‑ und Pref‑Skript
|
||||||
|
@cp modern.js build/$(UUID)/extension.js
|
||||||
|
@cp $(MODERN_PREFS) build/$(UUID)/prefs.js
|
||||||
|
|
||||||
|
# metadata.json anpassen
|
||||||
|
@sed -e "s/__UUID__/$(UUID)/g" \
|
||||||
|
-e "s/__VERSION__/$(VERSION)/g" \
|
||||||
|
metadata_modern.json.in > build/$(UUID)/metadata.json
|
||||||
|
|
||||||
|
# Zip‑Paket
|
||||||
|
@cd build && zip -qr ../$(UUID)-modern-v$(VERSION).zip .
|
||||||
|
@rm -rf build
|
||||||
|
@echo "✓ created $(UUID)-modern-v$(VERSION).zip"
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
clean:
|
||||||
|
@rm -rf build $(UUID)-legacy-v$(VERSION).zip $(UUID)-modern-v$(VERSION).zip
|
||||||
|
@echo "Build‑Ordner und ZIPs entfernt."
|
||||||
@@ -4,12 +4,11 @@ Simple Tiling
|
|||||||
</span>
|
</span>
|
||||||
<h4 align="center">
|
<h4 align="center">
|
||||||
<span style="display:inline-flex; align-items:center; gap:12px;">
|
<span style="display:inline-flex; align-items:center; gap:12px;">
|
||||||
A lightweight, opinionated, and automatic tiling window manager for GNOME Shell 3.38.
|
A lightweight, opinionated, and automatic tiling window manager for GNOME Shell
|
||||||
</span>
|
</span>
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||

|
|
||||||
|
|
||||||
<img width="2560" height="1440" alt="Simple-Tiling-v6" src="https://github.com/user-attachments/assets/eb0f7cc3-6a5a-4036-8a1e-8f945c52e55c" />
|
<img width="2560" height="1440" alt="Simple-Tiling-v6" src="https://github.com/user-attachments/assets/eb0f7cc3-6a5a-4036-8a1e-8f945c52e55c" />
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ A lightweight, opinionated, and automatic tiling window manager for GNOME Shell
|
|||||||
|
|
||||||
Simple Tiling is a GNOME Shell extension created for users who want a clean, predictable, and automatic tiling layout without the complexity of larger, more feature-heavy tiling extensions. It is designed to be simple to configure and intuitive to use, focusing on a core set of essential tiling features.
|
Simple Tiling is a GNOME Shell extension created for users who want a clean, predictable, and automatic tiling layout without the complexity of larger, more feature-heavy tiling extensions. It is designed to be simple to configure and intuitive to use, focusing on a core set of essential tiling features.
|
||||||
|
|
||||||
This extension was built from the ground up to be stable and performant on **GNOME Shell 3.38**.
|
This extension was built from the ground up to be stable and performant on **GNOME Shell 3.38**. However it is now also supporting modern gnome shells up to **version 48**.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
@@ -36,10 +35,10 @@ This extension was built from the ground up to be stable and performant on **GNO
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Please note that this extension has been developed for a very specific environment:
|
Please note that this extension has been developed for a very specific environment. However, with the latest updates, I have ensured that modern Gnome Shells and Wayland are also supported.
|
||||||
|
|
||||||
* **GNOME Shell Version:** **3.38**
|
* **GNOME Shell Version:** **3.38 - 48**
|
||||||
* **Session Type:** **X11** (Wayland is not supported).
|
* **Session Type:** **X11** (Wayland is still in beta but should be fine!).
|
||||||
* **Monitor Setup:** **Single monitor only.** Multi-monitor support is not yet implemented.
|
* **Monitor Setup:** **Single monitor only.** Multi-monitor support is not yet implemented.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -50,26 +49,40 @@ Use the [GNOME Shell Extensions website](https://extensions.gnome.org/extension/
|
|||||||
|
|
||||||
#### Manual Installation
|
#### Manual Installation
|
||||||
|
|
||||||
1. **Navigate to your extensions folder:**
|
The repository includes a Makefile that produces ready‑to‑install ZIP packages for the two supported GNOME‑Shell lines (a legacy build (Gnome-Shell 3.38 - 44) and a modern build for Gnome-Shell 45+).
|
||||||
|
|
||||||
|
1. **Clone the Source**
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/YourUser/Simple-Tiling.git
|
||||||
|
cd Simple-Tiling
|
||||||
|
```
|
||||||
|
|
||||||
|
2 · **Create the package that matches your GNOME-Shell version**
|
||||||
|
Open the Terminal within the Simple-Tiling directory and run
|
||||||
```bash
|
```bash
|
||||||
cd ~/.local/share/gnome-shell/extensions/
|
make build
|
||||||
```
|
```
|
||||||
3. **Clone the repository directly into a folder named after the extension's UUID:**
|
**Note:** This will create a ready to go .zip archive of both, the modern and the legacy version of the extension ready to be used. Alternativley you can also run "make build-legacy" or "make build-modern" to only compile one of both versions.
|
||||||
|
|
||||||
```bash
|
3 · **Locate the output**
|
||||||
git clone https://github.com/Domoel/Simple-Tiling.git simple-tiling@domoel
|
```bash
|
||||||
```
|
ls -1 ../simple-tiling@domoel-*-v*.zip
|
||||||
5. **Compile the GSettings schema.** This is a mandatory step for the keyboard shortcuts to work.
|
```
|
||||||
|
4 · **Install & enable**
|
||||||
|
```bash
|
||||||
|
gnome-extensions install ../simple-tiling@domoel-legacy-v6.zip
|
||||||
|
gnome-extensions enable simple-tiling@domoel
|
||||||
|
```
|
||||||
|
**Note:** You can also unzip the file and put the folder right into your extensions directory (~/.local/share/gnome-shell/extensions/)
|
||||||
|
|
||||||
```bash
|
5 · **Reload the shell**
|
||||||
cd ~/.local/share/gnome-shell/extensions/simple-tiling@domoel
|
```bash
|
||||||
glib-compile-schemas schemas/
|
Press Alt + F2, type r , hit ↩ (works for X11 and Wayland)
|
||||||
```
|
```
|
||||||
|
6 · **Clean up (optional)**
|
||||||
3. **Restart GNOME Shell.** Press `Alt` + `F2`, type `r`, and press `Enter`.
|
```bash
|
||||||
|
make clean # removes build/ folder and generated ZIPs
|
||||||
5. **Enable the extension** using the GNOME Extensions app or GNOME Tweaks.
|
```
|
||||||
|
|
||||||
**Note:** You have to use "simple-tiling@domoel" as your extension folder / directory. Put all necessary files into this directory. Otherwise the extension will not show up in extension manager.
|
**Note:** You have to use "simple-tiling@domoel" as your extension folder / directory. Put all necessary files into this directory. Otherwise the extension will not show up in extension manager.
|
||||||
|
|
||||||
@@ -113,7 +126,6 @@ If you have race condition issues between mutter (Gnome WM) and the Simple Tilin
|
|||||||
|
|
||||||
This extension was built to solve a specific need. However, future enhancements could include:
|
This extension was built to solve a specific need. However, future enhancements could include:
|
||||||
* Multi-monitor support.
|
* Multi-monitor support.
|
||||||
* Support for newer Gnome shells
|
|
||||||
* Additional layout algorithms.
|
* Additional layout algorithms.
|
||||||
* A more detailed settings panel to configure other options via a GUI.
|
* A more detailed settings panel to configure other options via a GUI.
|
||||||
|
|
||||||
|
|||||||
@@ -24,3 +24,12 @@
|
|||||||
# --- Start of the Exception List ---
|
# --- Start of the Exception List ---
|
||||||
|
|
||||||
ulauncher
|
ulauncher
|
||||||
|
steam
|
||||||
|
element
|
||||||
|
totem
|
||||||
|
extension-manager
|
||||||
|
timeshift-gtk
|
||||||
|
gnome-screenshot
|
||||||
|
org.gnome.NautilusPreviewer
|
||||||
|
org.gnome.Shell.Extensions
|
||||||
|
evolution-alarm-notify
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////
|
|
||||||
// Simple-Tiling – GLOBAL CONFIG //
|
|
||||||
// © 2025 domoel – MIT //
|
|
||||||
//////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
// --- GLOBAL IMPORTS ---
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
|
||||||
const Config = imports.misc.config;
|
|
||||||
const Me = ExtensionUtils.getCurrentExtension();
|
|
||||||
const [SHELL_MAJOR] = Config.PACKAGE_VERSION.split('.').map(n => parseInt(n));
|
|
||||||
|
|
||||||
let extension = null;
|
|
||||||
|
|
||||||
function init() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- SHELL SWITCH ---
|
|
||||||
async function enable() {
|
|
||||||
try {
|
|
||||||
if (SHELL_MAJOR >= 40) {
|
|
||||||
const module = await import('./modern.js');
|
|
||||||
extension = new module.default(Me.metadata);
|
|
||||||
} else {
|
|
||||||
const { LegacyExtension } = Me.imports.legacy;
|
|
||||||
extension = new LegacyExtension(Me.metadata);
|
|
||||||
}
|
|
||||||
extension.enable();
|
|
||||||
} catch (e) {
|
|
||||||
logError(e, `[Simple Tiling] Failed to enable extension`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function disable() {
|
|
||||||
if (extension) {
|
|
||||||
extension.disable();
|
|
||||||
extension = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"uuid": "__UUID__",
|
||||||
|
"name": "Simple Tiling",
|
||||||
|
"description": "A Simple Tiling Extension for Gnome Shell.",
|
||||||
|
"version": __VERSION__,
|
||||||
|
"shell-version": [
|
||||||
|
"3.38",
|
||||||
|
"40",
|
||||||
|
"41",
|
||||||
|
"42",
|
||||||
|
"43",
|
||||||
|
"44"
|
||||||
|
],
|
||||||
|
"settings-schema": "org.gnome.shell.extensions.simple-tiling.domoel",
|
||||||
|
"preferences_ui": "prefs.js",
|
||||||
|
"url": "https://github.com/Domoel/Simple-Tiling",
|
||||||
|
"gettext-domain": "__UUID__"
|
||||||
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
"uuid": "simple-tiling@domoel",
|
"uuid": "__UUID__",
|
||||||
"name": "Simple Tiling",
|
"name": "Simple Tiling",
|
||||||
"description": "A Simple Tiling Extension for Gnome Shell.",
|
"description": "A Simple Tiling Extension for Gnome Shell.",
|
||||||
"version": 6,
|
"version": __VERSION__,
|
||||||
"shell-version": [
|
"shell-version": [
|
||||||
"3.38",
|
|
||||||
"45",
|
"45",
|
||||||
"46",
|
"46",
|
||||||
"47",
|
"47",
|
||||||
@@ -13,5 +12,5 @@
|
|||||||
"settings-schema": "org.gnome.shell.extensions.simple-tiling.domoel",
|
"settings-schema": "org.gnome.shell.extensions.simple-tiling.domoel",
|
||||||
"preferences_ui": "prefs.js",
|
"preferences_ui": "prefs.js",
|
||||||
"url": "https://github.com/Domoel/Simple-Tiling",
|
"url": "https://github.com/Domoel/Simple-Tiling",
|
||||||
"gettext-domain": "simple-tiling-domoel"
|
"gettext-domain": "__UUID__"
|
||||||
}
|
}
|
||||||
@@ -1,109 +1,117 @@
|
|||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
// Simple-Tiling – MODERN (for GNOME Shell 40+) //
|
// Simple‑Tiling – MODERN (GNOME Shell 45+) //
|
||||||
// © 2025 domoel – MIT //
|
// © 2025 domoel – MIT //
|
||||||
//////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
// --- GLOBAL IMPORTS ---
|
// ── GLOBAL IMPORTS ────────────────────────────────────────
|
||||||
import { Extension } from "resource:///org/gnome/shell/extensions/extension.js";
|
import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||||
import * as Main from "resource:///org/gnome/shell/ui/main.js";
|
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||||
import Meta from "gi://Meta";
|
import Meta from 'gi://Meta';
|
||||||
import Shell from "gi://Shell";
|
import Shell from 'gi://Shell';
|
||||||
import Gio from "gi://Gio";
|
import Gio from 'gi://Gio';
|
||||||
import GLib from "gi://GLib";
|
import GLib from 'gi://GLib';
|
||||||
|
import Clutter from 'gi://Clutter';
|
||||||
|
|
||||||
const SCHEMA_NAME = "org.gnome.shell.extensions.simple-tiling.domoel";
|
// ── CONST ────────────────────────────────────────────
|
||||||
const WM_SCHEMA = "org.gnome.desktop.wm.keybindings";
|
const WM_SCHEMA = 'org.gnome.desktop.wm.keybindings';
|
||||||
|
|
||||||
const TILING_DELAY_MS = 20; // Change Tiling Window Delay
|
const TILING_DELAY_MS = 20; // Change Tiling Window Delay
|
||||||
const CENTERING_DELAY_MS = 5; // Change Centered Window Delay
|
const CENTERING_DELAY_MS = 5; // Change Centered Window Delay
|
||||||
|
|
||||||
const KEYBINDINGS = {
|
const KEYBINDINGS = {
|
||||||
"swap-master-window": (self) => self._swapWithMaster(),
|
'swap-master-window': (self) => self._swapWithMaster(),
|
||||||
"swap-left-window": (self) => self._swapInDirection("left"),
|
'swap-left-window': (self) => self._swapInDirection('left'),
|
||||||
"swap-right-window": (self) => self._swapInDirection("right"),
|
'swap-right-window': (self) => self._swapInDirection('right'),
|
||||||
"swap-up-window": (self) => self._swapInDirection("up"),
|
'swap-up-window': (self) => self._swapInDirection('up'),
|
||||||
"swap-down-window": (self) => self._swapInDirection("down"),
|
'swap-down-window': (self) => self._swapInDirection('down'),
|
||||||
"focus-left": (self) => self._focusInDirection("left"),
|
'focus-left': (self) => self._focusInDirection('left'),
|
||||||
"focus-right": (self) => self._focusInDirection("right"),
|
'focus-right': (self) => self._focusInDirection('right'),
|
||||||
"focus-up": (self) => self._focusInDirection("up"),
|
'focus-up': (self) => self._focusInDirection('up'),
|
||||||
"focus-down": (self) => self._focusInDirection("down"),
|
'focus-down': (self) => self._focusInDirection('down'),
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- INTERACTIONHANDLER ---
|
// ── HELPER‑FUNCTION ────────────────────────────────────────
|
||||||
|
function getPointerXY() {
|
||||||
|
if (global.get_pointer) {
|
||||||
|
const [x, y] = global.get_pointer();
|
||||||
|
return [x, y];
|
||||||
|
}
|
||||||
|
|
||||||
|
const ev = Clutter.get_current_event();
|
||||||
|
if (ev) {
|
||||||
|
const coords = ev.get_coords();
|
||||||
|
if (Array.isArray(coords))
|
||||||
|
return coords;
|
||||||
|
}
|
||||||
|
|
||||||
|
const device = Clutter.get_default_backend()
|
||||||
|
.get_default_seat()
|
||||||
|
.get_pointer();
|
||||||
|
return device ? device.get_position() : [0, 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── INTERACTIONHANDLER ───────────────────────────────────
|
||||||
class InteractionHandler {
|
class InteractionHandler {
|
||||||
constructor(tiler) {
|
constructor(tiler) {
|
||||||
this.tiler = tiler;
|
this.tiler = tiler;
|
||||||
this._settings = this.tiler.settings;
|
this._settings = this.tiler.settings;
|
||||||
this._wmSettings = new Gio.Settings({ schema: WM_SCHEMA });
|
this._wmSettings = new Gio.Settings({ schema: WM_SCHEMA });
|
||||||
this._wmKeysToDisable = [];
|
|
||||||
this._savedWmShortcuts = {};
|
this._wmKeysToDisable = [];
|
||||||
this._grabOpIds = [];
|
this._savedWmShortcuts = {};
|
||||||
|
this._grabOpIds = [];
|
||||||
this._settingsChangedId = null;
|
this._settingsChangedId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
this._prepareWmShortcuts();
|
this._prepareWmShortcuts();
|
||||||
if (this._wmKeysToDisable.length) {
|
|
||||||
this._wmKeysToDisable.forEach((key) =>
|
if (this._wmKeysToDisable.length)
|
||||||
this._wmSettings.set_value(key, new GLib.Variant("as", []))
|
this._wmKeysToDisable.forEach(k =>
|
||||||
);
|
this._wmSettings.set_value(k, new GLib.Variant('as', [])));
|
||||||
}
|
|
||||||
this._bindAllShortcuts();
|
this._bindAllShortcuts();
|
||||||
this._settingsChangedId = this._settings.connect("changed", () =>
|
this._settingsChangedId =
|
||||||
this._onSettingsChanged()
|
this._settings.connect('changed', () => this._onSettingsChanged());
|
||||||
|
|
||||||
|
this._grabOpIds.push(
|
||||||
|
global.display.connect('grab-op-begin',
|
||||||
|
(_, __, win) => { if (this.tiler.windows.includes(win))
|
||||||
|
this.tiler.grabbedWindow = win; })
|
||||||
);
|
);
|
||||||
this._grabOpIds.push(
|
this._grabOpIds.push(
|
||||||
global.display.connect(
|
global.display.connect('grab-op-end', () => this._onGrabEnd())
|
||||||
"grab-op-begin",
|
|
||||||
(display, screen, window) => {
|
|
||||||
if (this.tiler.windows.includes(window)) {
|
|
||||||
this.tiler.grabbedWindow = window;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
this._grabOpIds.push(
|
|
||||||
global.display.connect("grab-op-end", () => this._onGrabEnd())
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
if (this._wmKeysToDisable.length) {
|
if (this._wmKeysToDisable.length)
|
||||||
this._wmKeysToDisable.forEach((key) =>
|
this._wmKeysToDisable.forEach(k =>
|
||||||
this._wmSettings.set_value(key, this._savedWmShortcuts[key])
|
this._wmSettings.set_value(k, this._savedWmShortcuts[k]));
|
||||||
);
|
|
||||||
}
|
|
||||||
this._unbindAllShortcuts();
|
this._unbindAllShortcuts();
|
||||||
|
|
||||||
if (this._settingsChangedId) {
|
if (this._settingsChangedId) {
|
||||||
this._settings.disconnect(this._settingsChangedId);
|
this._settings.disconnect(this._settingsChangedId);
|
||||||
this._settingsChangedId = null;
|
this._settingsChangedId = null;
|
||||||
}
|
}
|
||||||
this._grabOpIds.forEach((id) => global.display.disconnect(id));
|
this._grabOpIds.forEach(id => global.display.disconnect(id));
|
||||||
this._grabOpIds = [];
|
this._grabOpIds = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
_bind(key, callback) {
|
_bind(key, handler) {
|
||||||
global.display.add_keybinding(
|
global.display.add_keybinding(
|
||||||
key,
|
key,
|
||||||
this._settings,
|
this._settings,
|
||||||
Meta.KeyBindingFlags.NONE,
|
Meta.KeyBindingFlags.NONE,
|
||||||
Shell.ActionMode.NORMAL,
|
Shell.ActionMode.NORMAL,
|
||||||
callback
|
(..._args) => handler(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_bindAllShortcuts() {
|
_bindAllShortcuts() { for (const [k,h] of Object.entries(KEYBINDINGS)) this._bind(k, h); }
|
||||||
for (const [key, handler] of Object.entries(KEYBINDINGS)) {
|
_unbindAllShortcuts(){ for (const k in KEYBINDINGS) global.display.remove_keybinding(k); }
|
||||||
this._bind(key, () => handler(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_unbindAllShortcuts() {
|
|
||||||
for (const key in KEYBINDINGS) {
|
|
||||||
global.display.remove_keybinding(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_onSettingsChanged() {
|
_onSettingsChanged() {
|
||||||
this._unbindAllShortcuts();
|
this._unbindAllShortcuts();
|
||||||
@@ -111,253 +119,168 @@ class InteractionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_prepareWmShortcuts() {
|
_prepareWmShortcuts() {
|
||||||
const schema = this._wmSettings
|
const schema = this._wmSettings.settings_schema;
|
||||||
.get_schema_source()
|
|
||||||
.lookup(WM_SCHEMA, true);
|
|
||||||
if (!schema) return;
|
if (!schema) return;
|
||||||
|
|
||||||
const addKeyIfExists = (keys, key) => {
|
|
||||||
if (schema.has_key(key)) keys.push(key);
|
|
||||||
};
|
|
||||||
|
|
||||||
const keys = [];
|
const keys = [];
|
||||||
if (schema.has_key("toggle-tiled-left")) {
|
|
||||||
keys.push("toggle-tiled-left", "toggle-tiled-right");
|
const add = key => { if (schema.has_key(key)) keys.push(key); };
|
||||||
} else {
|
|
||||||
addKeyIfExists(keys, "tile-left");
|
if (schema.has_key('toggle-tiled-left'))
|
||||||
addKeyIfExists(keys, "tile-right");
|
keys.push('toggle-tiled-left', 'toggle-tiled-right');
|
||||||
|
else {
|
||||||
|
add('tile-left'); add('tile-right');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schema.has_key("toggle-maximized")) {
|
if (schema.has_key('toggle-maximized'))
|
||||||
keys.push("toggle-maximized");
|
keys.push('toggle-maximized');
|
||||||
} else {
|
else {
|
||||||
addKeyIfExists(keys, "maximize");
|
add('maximize'); add('unmaximize');
|
||||||
addKeyIfExists(keys, "unmaximize");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keys.length) {
|
if (keys.length) {
|
||||||
this._wmKeysToDisable = keys;
|
this._wmKeysToDisable = keys;
|
||||||
keys.forEach(
|
keys.forEach(k => this._savedWmShortcuts[k] =
|
||||||
(key) =>
|
this._wmSettings.get_value(k));
|
||||||
(this._savedWmShortcuts[key] = this._wmSettings.get_value(
|
|
||||||
key
|
|
||||||
))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_focusInDirection(direction) {
|
_focusInDirection(direction) {
|
||||||
const sourceWindow = global.display.get_focus_window();
|
const src = global.display.get_focus_window();
|
||||||
if (!sourceWindow || !this.tiler.windows.includes(sourceWindow)) return;
|
if (!src || !this.tiler.windows.includes(src)) return;
|
||||||
|
const tgt = this._findTargetInDirection(src, direction);
|
||||||
const targetWindow = this._findTargetInDirection(
|
if (tgt) tgt.activate(global.get_current_time());
|
||||||
sourceWindow,
|
|
||||||
direction
|
|
||||||
);
|
|
||||||
if (targetWindow) {
|
|
||||||
targetWindow.activate(global.get_current_time());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_swapWithMaster() {
|
_swapWithMaster() {
|
||||||
const windows = this.tiler.windows;
|
const w = this.tiler.windows;
|
||||||
if (windows.length < 2) return;
|
if (w.length < 2) return;
|
||||||
const focusedWindow = global.display.get_focus_window();
|
const foc = global.display.get_focus_window();
|
||||||
if (!focusedWindow || !windows.includes(focusedWindow)) return;
|
if (!foc || !w.includes(foc)) return;
|
||||||
const focusedIndex = windows.indexOf(focusedWindow);
|
const idx = w.indexOf(foc);
|
||||||
if (focusedIndex > 0) {
|
if (idx > 0) [w[0], w[idx]] = [w[idx], w[0]];
|
||||||
[windows[0], windows[focusedIndex]] = [
|
else [w[0], w[1]] = [w[1], w[0]];
|
||||||
windows[focusedIndex],
|
|
||||||
windows[0],
|
|
||||||
];
|
|
||||||
} else if (focusedIndex === 0) {
|
|
||||||
[windows[0], windows[1]] = [windows[1], windows[0]];
|
|
||||||
}
|
|
||||||
this.tiler.tileNow();
|
this.tiler.tileNow();
|
||||||
if (windows.length > 0) windows[0].activate(global.get_current_time());
|
w[0]?.activate(global.get_current_time());
|
||||||
}
|
}
|
||||||
|
|
||||||
_swapInDirection(direction) {
|
_swapInDirection(direction) {
|
||||||
const sourceWindow = global.display.get_focus_window();
|
const src = global.display.get_focus_window();
|
||||||
if (!sourceWindow || !this.tiler.windows.includes(sourceWindow)) return;
|
if (!src || !this.tiler.windows.includes(src)) return;
|
||||||
let targetWindow = null;
|
let tgt = null;
|
||||||
const sourceIndex = this.tiler.windows.indexOf(sourceWindow);
|
const idx = this.tiler.windows.indexOf(src);
|
||||||
if (
|
if (idx === 0 && direction==='right' && this.tiler.windows.length>1)
|
||||||
sourceIndex === 0 &&
|
tgt = this.tiler.windows[1];
|
||||||
direction === "right" &&
|
else
|
||||||
this.tiler.windows.length > 1
|
tgt = this._findTargetInDirection(src, direction);
|
||||||
) {
|
if (!tgt) return;
|
||||||
targetWindow = this.tiler.windows[1];
|
const tidx = this.tiler.windows.indexOf(tgt);
|
||||||
} else {
|
[this.tiler.windows[idx], this.tiler.windows[tidx]] =
|
||||||
targetWindow = this._findTargetInDirection(sourceWindow, direction);
|
[this.tiler.windows[tidx], this.tiler.windows[idx]];
|
||||||
}
|
|
||||||
if (!targetWindow) return;
|
|
||||||
const targetIndex = this.tiler.windows.indexOf(targetWindow);
|
|
||||||
[this.tiler.windows[sourceIndex], this.tiler.windows[targetIndex]] = [
|
|
||||||
this.tiler.windows[targetIndex],
|
|
||||||
this.tiler.windows[sourceIndex],
|
|
||||||
];
|
|
||||||
this.tiler.tileNow();
|
this.tiler.tileNow();
|
||||||
sourceWindow.activate(global.get_current_time());
|
src.activate(global.get_current_time());
|
||||||
}
|
}
|
||||||
|
|
||||||
_findTargetInDirection(source, direction) {
|
_findTargetInDirection(src, dir) {
|
||||||
const sourceRect = source.get_frame_rect();
|
const sRect = src.get_frame_rect(), cand=[];
|
||||||
let candidates = [];
|
|
||||||
for (const win of this.tiler.windows) {
|
for (const win of this.tiler.windows) {
|
||||||
if (win === source) continue;
|
if (win===src) continue;
|
||||||
const targetRect = win.get_frame_rect();
|
const r=win.get_frame_rect();
|
||||||
switch (direction) {
|
if (dir==='left' && r.x<sRect.x) cand.push(win);
|
||||||
case "left":
|
if (dir==='right'&& r.x>sRect.x) cand.push(win);
|
||||||
if (targetRect.x < sourceRect.x) candidates.push(win);
|
if (dir==='up' && r.y<sRect.y) cand.push(win);
|
||||||
break;
|
if (dir==='down' && r.y>sRect.y) cand.push(win);
|
||||||
case "right":
|
|
||||||
if (targetRect.x > sourceRect.x) candidates.push(win);
|
|
||||||
break;
|
|
||||||
case "up":
|
|
||||||
if (targetRect.y < sourceRect.y) candidates.push(win);
|
|
||||||
break;
|
|
||||||
case "down":
|
|
||||||
if (targetRect.y > sourceRect.y) candidates.push(win);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (candidates.length === 0) return null;
|
if (!cand.length) return null;
|
||||||
let bestTarget = null;
|
let best=null, min=Infinity;
|
||||||
let minDeviation = Infinity;
|
for (const w of cand) {
|
||||||
for (const win of candidates) {
|
const r=w.get_frame_rect();
|
||||||
const targetRect = win.get_frame_rect();
|
const dev = (dir==='left'||dir==='right')
|
||||||
let deviation;
|
? Math.abs(sRect.y - r.y)
|
||||||
if (direction === "left" || direction === "right") {
|
: Math.abs(sRect.x - r.x);
|
||||||
deviation = Math.abs(sourceRect.y - targetRect.y);
|
if (dev<min){min=dev; best=w;}
|
||||||
} else {
|
|
||||||
deviation = Math.abs(sourceRect.x - targetRect.x);
|
|
||||||
}
|
|
||||||
if (deviation < minDeviation) {
|
|
||||||
minDeviation = deviation;
|
|
||||||
bestTarget = win;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return bestTarget;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onGrabEnd() {
|
_onGrabEnd() {
|
||||||
const grabbedWindow = this.tiler.grabbedWindow;
|
const grabbed = this.tiler.grabbedWindow;
|
||||||
if (!grabbedWindow) return;
|
if (!grabbed) return;
|
||||||
const targetWindow = this._findTargetUnderPointer(grabbedWindow);
|
const tgt = this._findTargetUnderPointer(grabbed);
|
||||||
if (targetWindow) {
|
if (tgt) {
|
||||||
const sourceIndex = this.tiler.windows.indexOf(grabbedWindow);
|
const a = this.tiler.windows.indexOf(grabbed);
|
||||||
const targetIndex = this.tiler.windows.indexOf(targetWindow);
|
const b = this.tiler.windows.indexOf(tgt);
|
||||||
[
|
[this.tiler.windows[a], this.tiler.windows[b]] =
|
||||||
this.tiler.windows[sourceIndex],
|
[this.tiler.windows[b], this.tiler.windows[a]];
|
||||||
this.tiler.windows[targetIndex],
|
|
||||||
] = [
|
|
||||||
this.tiler.windows[targetIndex],
|
|
||||||
this.tiler.windows[sourceIndex],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
this.tiler.queueTile();
|
this.tiler.queueTile();
|
||||||
this.tiler.grabbedWindow = null;
|
this.tiler.grabbedWindow = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_findTargetUnderPointer(excludeWindow) {
|
_findTargetUnderPointer(exclude) {
|
||||||
let [pointerX, pointerY] = global.get_pointer();
|
const [x,y] = getPointerXY();
|
||||||
let windows = global
|
const wins = global.get_window_actors()
|
||||||
.get_window_actors()
|
.map(a=>a.meta_window)
|
||||||
.map((actor) => actor.meta_window)
|
.filter(w=>w && w!==exclude &&
|
||||||
.filter((win) => {
|
this.tiler.windows.includes(w) && (()=>{const f=w.get_frame_rect();
|
||||||
if (
|
return x>=f.x && x<f.x+f.width &&
|
||||||
!win ||
|
y>=f.y && y<f.y+f.height;})());
|
||||||
win === excludeWindow ||
|
if (wins.length) return wins[wins.length-1];
|
||||||
!this.tiler.windows.includes(win)
|
|
||||||
)
|
|
||||||
return false;
|
|
||||||
let frame = win.get_frame_rect();
|
|
||||||
return (
|
|
||||||
pointerX >= frame.x &&
|
|
||||||
pointerX < frame.x + frame.width &&
|
|
||||||
pointerY >= frame.y &&
|
|
||||||
pointerY < frame.y + frame.height
|
|
||||||
);
|
|
||||||
});
|
|
||||||
if (windows.length > 0) {
|
|
||||||
return windows[windows.length - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
let bestTarget = null;
|
let best=null, max=0, sRect=exclude.get_frame_rect();
|
||||||
let maxOverlap = 0;
|
for (const w of this.tiler.windows) {
|
||||||
const sourceFrame = excludeWindow.get_frame_rect();
|
if (w===exclude) continue;
|
||||||
for (const win of this.tiler.windows) {
|
const r=w.get_frame_rect();
|
||||||
if (win === excludeWindow) continue;
|
const ovX=Math.max(0, Math.min(sRect.x+sRect.width, r.x+r.width)-Math.max(sRect.x,r.x));
|
||||||
const targetFrame = win.get_frame_rect();
|
const ovY=Math.max(0, Math.min(sRect.y+sRect.height,r.y+r.height)-Math.max(sRect.y,r.y));
|
||||||
const overlapX = Math.max(
|
const area=ovX*ovY;
|
||||||
0,
|
if (area>max){max=area; best=w;}
|
||||||
Math.min(
|
|
||||||
sourceFrame.x + sourceFrame.width,
|
|
||||||
targetFrame.x + targetFrame.width
|
|
||||||
) - Math.max(sourceFrame.x, targetFrame.x)
|
|
||||||
);
|
|
||||||
const overlapY = Math.max(
|
|
||||||
0,
|
|
||||||
Math.min(
|
|
||||||
sourceFrame.y + sourceFrame.height,
|
|
||||||
targetFrame.y + targetFrame.height
|
|
||||||
) - Math.max(sourceFrame.y, targetFrame.y)
|
|
||||||
);
|
|
||||||
const overlapArea = overlapX * overlapY;
|
|
||||||
if (overlapArea > maxOverlap) {
|
|
||||||
maxOverlap = overlapArea;
|
|
||||||
bestTarget = win;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return bestTarget;
|
return best;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- TILER ---
|
// ── TILER ────────────────────────────────────────────────
|
||||||
class Tiler {
|
class Tiler {
|
||||||
constructor(extension) {
|
constructor(extension) {
|
||||||
this._extension = extension;
|
this._extension = extension;
|
||||||
this.settings = this._extension.getSettings();
|
this.settings = this._extension.getSettings();
|
||||||
|
|
||||||
this.windows = [];
|
this.windows = [];
|
||||||
this.grabbedWindow = null;
|
this.grabbedWindow = null;
|
||||||
this._signalIds = new Map();
|
this._signalIds = new Map();
|
||||||
this._tileInProgress = false;
|
this._tileInProgress = false;
|
||||||
|
|
||||||
this._innerGap = this.settings.get_int("inner-gap");
|
this._innerGap = this.settings.get_int('inner-gap');
|
||||||
this._outerGapVertical = this.settings.get_int("outer-gap-vertical");
|
this._outerGapVertical= this.settings.get_int('outer-gap-vertical');
|
||||||
this._outerGapHorizontal = this.settings.get_int(
|
this._outerGapHorizontal = this.settings.get_int('outer-gap-horizontal');
|
||||||
"outer-gap-horizontal"
|
|
||||||
);
|
|
||||||
|
|
||||||
this._tilingDelay = TILING_DELAY_MS;
|
this._tilingDelay = TILING_DELAY_MS;
|
||||||
this._centeringDelay = CENTERING_DELAY_MS;
|
this._centeringDelay = CENTERING_DELAY_MS;
|
||||||
|
|
||||||
this._exceptions = [];
|
this._exceptions = [];
|
||||||
this._interactionHandler = new InteractionHandler(this);
|
this._interactionHandler = new InteractionHandler(this);
|
||||||
|
|
||||||
this._tileTimeoutId = null;
|
this._tileTimeoutId = null;
|
||||||
this._centerTimeoutIds = [];
|
this._centerTimeoutIds= [];
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
this._loadExceptions();
|
this._loadExceptions();
|
||||||
this._workspaceManager = global.workspace_manager;
|
this._workspaceManager = global.workspace_manager;
|
||||||
|
|
||||||
this._signalIds.set("workspace-changed", {
|
this._signalIds.set('workspace-changed', {
|
||||||
object: this._workspaceManager,
|
object: this._workspaceManager,
|
||||||
id: this._workspaceManager.connect("active-workspace-changed", () =>
|
id: this._workspaceManager.connect('active-workspace-changed',
|
||||||
this._onActiveWorkspaceChanged()
|
()=>this._onActiveWorkspaceChanged())
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this._connectToWorkspace();
|
this._connectToWorkspace();
|
||||||
this._interactionHandler.enable();
|
this._interactionHandler.enable();
|
||||||
this._signalIds.set("settings-changed", {
|
|
||||||
|
this._signalIds.set('settings-changed', {
|
||||||
object: this.settings,
|
object: this.settings,
|
||||||
id: this.settings.connect("changed", () =>
|
id: this.settings.connect('changed', ()=>this._onSettingsChanged())
|
||||||
this._onSettingsChanged()
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,47 +289,38 @@ class Tiler {
|
|||||||
GLib.source_remove(this._tileTimeoutId);
|
GLib.source_remove(this._tileTimeoutId);
|
||||||
this._tileTimeoutId = null;
|
this._tileTimeoutId = null;
|
||||||
}
|
}
|
||||||
this._centerTimeoutIds.forEach((id) => GLib.source_remove(id));
|
this._centerTimeoutIds.forEach(id=>GLib.source_remove(id));
|
||||||
this._centerTimeoutIds = [];
|
this._centerTimeoutIds = [];
|
||||||
|
|
||||||
this._interactionHandler.disable();
|
this._interactionHandler.disable();
|
||||||
this._disconnectFromWorkspace();
|
this._disconnectFromWorkspace();
|
||||||
for (const [, signal] of this._signalIds) {
|
|
||||||
try {
|
for (const [,sig] of this._signalIds) {
|
||||||
signal.object.disconnect(signal.id);
|
try { sig.object.disconnect(sig.id); } catch {}
|
||||||
} catch (e) {}
|
|
||||||
}
|
}
|
||||||
this._signalIds.clear();
|
this._signalIds.clear();
|
||||||
this.windows = [];
|
this.windows = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
_onSettingsChanged() {
|
_onSettingsChanged() {
|
||||||
this._innerGap = this.settings.get_int("inner-gap");
|
this._innerGap = this.settings.get_int('inner-gap');
|
||||||
this._outerGapVertical = this.settings.get_int("outer-gap-vertical");
|
this._outerGapVertical = this.settings.get_int('outer-gap-vertical');
|
||||||
this._outerGapHorizontal = this.settings.get_int(
|
this._outerGapHorizontal= this.settings.get_int('outer-gap-horizontal');
|
||||||
"outer-gap-horizontal"
|
|
||||||
);
|
|
||||||
this.queueTile();
|
this.queueTile();
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadExceptions() {
|
_loadExceptions() {
|
||||||
const file = Gio.File.new_for_path(
|
const file = Gio.File.new_for_path(this._extension.path + '/exceptions.txt');
|
||||||
this._extension.path + "/exceptions.txt"
|
if (!file.query_exists(null)) { this._exceptions=[]; return; }
|
||||||
);
|
|
||||||
if (!file.query_exists(null)) {
|
const [ok,data] = file.load_contents(null);
|
||||||
this._exceptions = [];
|
if (!ok) { this._exceptions=[]; return; }
|
||||||
return;
|
|
||||||
}
|
const txt = new TextDecoder('utf-8').decode(data);
|
||||||
const [ok, data] = file.load_contents(null);
|
this._exceptions = txt.split('\n')
|
||||||
if (ok) {
|
.map(l=>l.trim())
|
||||||
this._exceptions = GLib.locale_from_utf8(data)
|
.filter(l=>l && !l.startsWith('#'))
|
||||||
.split("\n")
|
.map(l=>l.toLowerCase());
|
||||||
.map((l) => l.trim())
|
|
||||||
.filter((l) => l && !l.startsWith("#"))
|
|
||||||
.map((l) => l.toLowerCase());
|
|
||||||
} else {
|
|
||||||
this._exceptions = [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_isException(win) {
|
_isException(win) {
|
||||||
@@ -677,17 +591,8 @@ class Tiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- MODERN EXTENSION WRAPPER ---
|
// ── EXTENSION‑WRAPPER ───────────────────────────────────
|
||||||
export default class ModernExtension extends Extension {
|
export default class ModernExtension extends Extension {
|
||||||
enable() {
|
enable() { this.tiler = new Tiler(this); this.tiler.enable(); }
|
||||||
this.tiler = new Tiler(this);
|
disable() { this.tiler?.disable(); this.tiler = null; }
|
||||||
this.tiler.enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
disable() {
|
|
||||||
if (this.tiler) {
|
|
||||||
this.tiler.disable();
|
|
||||||
this.tiler = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,221 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////
|
|
||||||
// --- Extension Settings Menu for Simple Tiling --- //
|
|
||||||
// --- © 2025 domoel – MIT --- //
|
|
||||||
///////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
// --- GLOBAL IMPORTS ---
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { Gtk, GObject, Gio, GLib } = imports.gi;
|
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
|
||||||
|
|
||||||
// --- Global Version Checkup ---
|
|
||||||
let Adw;
|
|
||||||
try {
|
|
||||||
Adw = imports.gi.Adw;
|
|
||||||
} catch (e) {
|
|
||||||
Adw = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --- DEFINITIONS ---
|
|
||||||
|
|
||||||
// --- Definitions for GNOME Shell 40+ ---
|
|
||||||
const ModernPrefs = Adw ? class extends ExtensionPreferences {
|
|
||||||
fillPreferencesWindow(window) {
|
|
||||||
const settings = this.getSettings();
|
|
||||||
const page = new Adw.PreferencesPage();
|
|
||||||
window.add(page);
|
|
||||||
|
|
||||||
// --- Window Gaps ---
|
|
||||||
const groupGaps = new Adw.PreferencesGroup({ title: 'Window Gaps' });
|
|
||||||
page.add(groupGaps);
|
|
||||||
|
|
||||||
const rowInnerGap = new Adw.SpinRow({
|
|
||||||
title: 'Inner Gap',
|
|
||||||
subtitle: 'The gap between windows in pixels.',
|
|
||||||
adjustment: new Gtk.Adjustment({ lower: 0, upper: 100, step_increment: 1 }),
|
|
||||||
});
|
|
||||||
groupGaps.add(rowInnerGap);
|
|
||||||
settings.bind('inner-gap', rowInnerGap, 'value', Gio.SettingsBindFlags.DEFAULT);
|
|
||||||
|
|
||||||
const rowOuterHGap = new Adw.SpinRow({
|
|
||||||
title: 'Outer Gap (horizontal)',
|
|
||||||
subtitle: 'The gap to the left and right screen edges.',
|
|
||||||
adjustment: new Gtk.Adjustment({ lower: 0, upper: 100, step_increment: 1 }),
|
|
||||||
});
|
|
||||||
groupGaps.add(rowOuterHGap);
|
|
||||||
settings.bind('outer-gap-horizontal', rowOuterHGap, 'value', Gio.SettingsBindFlags.DEFAULT);
|
|
||||||
|
|
||||||
const rowOuterVGap = new Adw.SpinRow({
|
|
||||||
title: 'Outer Gap (vertical)',
|
|
||||||
subtitle: 'The gap to the top and bottom screen edges.',
|
|
||||||
adjustment: new Gtk.Adjustment({ lower: 0, upper: 100, step_increment: 1 }),
|
|
||||||
});
|
|
||||||
groupGaps.add(rowOuterVGap);
|
|
||||||
settings.bind('outer-gap-vertical', rowOuterVGap, 'value', Gio.SettingsBindFlags.DEFAULT);
|
|
||||||
|
|
||||||
// --- Window Behavior ---
|
|
||||||
const groupBehavior = new Adw.PreferencesGroup({ title: 'Window Behavior' });
|
|
||||||
page.add(groupBehavior);
|
|
||||||
|
|
||||||
const rowNewWindow = new Adw.ComboRow({
|
|
||||||
title: 'Open new windows as',
|
|
||||||
subtitle: 'Determines if a new window is added as master or stack window.',
|
|
||||||
model: new Gtk.StringList({ strings: ['Stack Window (Default)', 'Master Window'] }),
|
|
||||||
});
|
|
||||||
groupBehavior.add(rowNewWindow);
|
|
||||||
|
|
||||||
const mapping = new Gio.SettingsBindMapping({
|
|
||||||
settings: settings, key: 'new-window-behavior', property: 'selected',
|
|
||||||
get_mapping: (value, variant_type) => value === 'master' ? 1 : 0,
|
|
||||||
set_mapping: (value, param_type) => new GLib.Variant('s', value === 1 ? 'master' : 'stack'),
|
|
||||||
});
|
|
||||||
settings.bind_with_mapping('new-window-behavior', rowNewWindow, 'selected', Gio.SettingsBindFlags.DEFAULT, mapping);
|
|
||||||
|
|
||||||
// --- Keybindings ---
|
|
||||||
const groupKeys = new Adw.PreferencesGroup({ title: 'Keybindings' });
|
|
||||||
page.add(groupKeys);
|
|
||||||
|
|
||||||
const rowKeys = new Adw.ActionRow({
|
|
||||||
title: 'Configure Shortcuts',
|
|
||||||
subtitle: 'All shortcuts can be configured in GNOME\'s main Keyboard settings.',
|
|
||||||
});
|
|
||||||
groupKeys.add(rowKeys);
|
|
||||||
|
|
||||||
const button = new Gtk.Button({ label: 'Open Keyboard Settings', valign: Gtk.Align.CENTER });
|
|
||||||
button.connect('clicked', () => {
|
|
||||||
const appInfo = Gio.AppInfo.create_from_commandline(
|
|
||||||
'gnome-control-center keyboard', null, Gio.AppInfoCreateFlags.NONE
|
|
||||||
);
|
|
||||||
appInfo.launch([], null);
|
|
||||||
});
|
|
||||||
rowKeys.add_suffix(button);
|
|
||||||
rowKeys.set_activatable_widget(button);
|
|
||||||
}
|
|
||||||
} : null;
|
|
||||||
|
|
||||||
|
|
||||||
// --- Definitions for GNOME Shell 3.38 ---
|
|
||||||
const buildLegacyPrefsWidget = () => {
|
|
||||||
const settings = ExtensionUtils.getSettings("org.gnome.shell.extensions.simple-tiling.domoel");
|
|
||||||
const prefsWidget = new Gtk.Box({
|
|
||||||
orientation: Gtk.Orientation.VERTICAL,
|
|
||||||
margin_top: 20, margin_bottom: 20, margin_start: 20, margin_end: 20,
|
|
||||||
spacing: 18,
|
|
||||||
visible: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
// --- Keybindings ---
|
|
||||||
const keysTitle = new Gtk.Label({ label: "<b>Keybindings</b>", use_markup: true, halign: Gtk.Align.START, visible: true });
|
|
||||||
const keysFrame = new Gtk.Frame({ label_widget: keysTitle, shadow_type: Gtk.ShadowType.NONE, visible: true });
|
|
||||||
let keysBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, margin: 12, spacing: 6, visible: true });
|
|
||||||
keysFrame.add(keysBox);
|
|
||||||
|
|
||||||
let store = new Gtk.ListStore();
|
|
||||||
store.set_column_types([ GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_INT, GObject.TYPE_INT ]);
|
|
||||||
|
|
||||||
const COLUMN_ID = 0, COLUMN_DESC = 1, COLUMN_KEY = 2, COLUMN_MODS = 3;
|
|
||||||
const addKeybinding = (id, desc) => {
|
|
||||||
let [key, mods] = [0, 0];
|
|
||||||
const strv = settings.get_strv(id);
|
|
||||||
if (strv && strv[0]) [key, mods] = Gtk.accelerator_parse(strv[0]);
|
|
||||||
let iter = store.append();
|
|
||||||
store.set(iter, [COLUMN_ID, COLUMN_DESC, COLUMN_KEY, COLUMN_MODS], [id, desc, key, mods]);
|
|
||||||
};
|
|
||||||
|
|
||||||
addKeybinding("swap-master-window", "Swap current window with master");
|
|
||||||
addKeybinding("swap-up-window", "Swap current window with window above");
|
|
||||||
addKeybinding("swap-down-window", "Swap current window with window below");
|
|
||||||
addKeybinding("swap-left-window", "Swap current window with window to the left");
|
|
||||||
addKeybinding("swap-right-window", "Swap current window with window to the right");
|
|
||||||
addKeybinding("focus-up", "Focus window above");
|
|
||||||
addKeybinding("focus-down", "Focus window below");
|
|
||||||
addKeybinding("focus-left", "Focus window to the left");
|
|
||||||
addKeybinding("focus-right", "Focus window to the right");
|
|
||||||
|
|
||||||
let treeView = new Gtk.TreeView({ model: store, headers_visible: false, hexpand: true, visible: true });
|
|
||||||
keysBox.add(treeView);
|
|
||||||
|
|
||||||
let descRenderer = new Gtk.CellRendererText();
|
|
||||||
let descColumn = new Gtk.TreeViewColumn({ expand: true });
|
|
||||||
descColumn.pack_start(descRenderer, true);
|
|
||||||
descColumn.add_attribute(descRenderer, "text", COLUMN_DESC);
|
|
||||||
treeView.append_column(descColumn);
|
|
||||||
|
|
||||||
let accelRenderer = new Gtk.CellRendererAccel({ "accel-mode": Gtk.CellRendererAccelMode.GTK, editable: true });
|
|
||||||
accelRenderer.connect("accel-edited", (r, path, key, mods) => {
|
|
||||||
let [ok, iter] = store.get_iter_from_string(path);
|
|
||||||
if (ok) {
|
|
||||||
store.set(iter, [COLUMN_KEY, COLUMN_MODS], [key, mods]);
|
|
||||||
settings.set_strv(store.get_value(iter, COLUMN_ID), [ Gtk.accelerator_name(key, mods) ]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
accelRenderer.connect("accel-cleared", (r, path) => {
|
|
||||||
let [ok, iter] = store.get_iter_from_string(path);
|
|
||||||
if (ok) {
|
|
||||||
store.set(iter, [COLUMN_KEY, COLUMN_MODS], [0, 0]);
|
|
||||||
settings.set_strv(store.get_value(iter, COLUMN_ID), []);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let accelColumn = new Gtk.TreeViewColumn();
|
|
||||||
accelColumn.pack_end(accelRenderer, false);
|
|
||||||
accelColumn.add_attribute(accelRenderer, "accel-key", COLUMN_KEY);
|
|
||||||
accelColumn.add_attribute(accelRenderer, "accel-mods", COLUMN_MODS);
|
|
||||||
treeView.append_column(accelColumn);
|
|
||||||
prefsWidget.add(keysFrame);
|
|
||||||
|
|
||||||
// --- Window Gaps ---
|
|
||||||
const gapsTitle = new Gtk.Label({ label: "<b>Window Gaps</b>", use_markup: true, halign: Gtk.Align.START, visible: true });
|
|
||||||
const gapsFrame = new Gtk.Frame({ label_widget: gapsTitle, shadow_type: Gtk.ShadowType.NONE, visible: true });
|
|
||||||
const gapsGrid = new Gtk.Grid({ margin: 12, column_spacing: 12, row_spacing: 12, visible: true });
|
|
||||||
gapsFrame.add(gapsGrid);
|
|
||||||
|
|
||||||
const addSpinButtonRow = (desc, key, pos) => {
|
|
||||||
const label = new Gtk.Label({ label: desc, halign: Gtk.Align.START, visible: true });
|
|
||||||
gapsGrid.attach(label, 0, pos, 1, 1);
|
|
||||||
const adj = new Gtk.Adjustment({ lower: 0, upper: 50, step_increment: 1 });
|
|
||||||
const spin = new Gtk.SpinButton({ adjustment: adj, climb_rate: 1, digits: 0, halign: Gtk.Align.END, visible: true });
|
|
||||||
settings.bind(key, spin, "value", Gio.SettingsBindFlags.DEFAULT);
|
|
||||||
gapsGrid.attach(spin, 1, pos, 1, 1);
|
|
||||||
};
|
|
||||||
addSpinButtonRow("Inner Gap", "inner-gap", 0);
|
|
||||||
addSpinButtonRow("Outer Gap (horizontal)", "outer-gap-horizontal", 1);
|
|
||||||
addSpinButtonRow("Outer Gap (vertical)", "outer-gap-vertical", 2);
|
|
||||||
prefsWidget.add(gapsFrame);
|
|
||||||
|
|
||||||
// --- Window Behavior ---
|
|
||||||
const behaviorTitle = new Gtk.Label({ label: "<b>Window Behavior</b>", use_markup: true, halign: Gtk.Align.START, visible: true });
|
|
||||||
const behaviorFrame = new Gtk.Frame({ label_widget: behaviorTitle, shadow_type: Gtk.ShadowType.NONE, visible: true });
|
|
||||||
const behaviorGrid = new Gtk.Grid({ margin: 12, column_spacing: 12, row_spacing: 12, visible: true });
|
|
||||||
behaviorFrame.add(behaviorGrid);
|
|
||||||
|
|
||||||
const label = new Gtk.Label({ label: "Open new windows as", halign: Gtk.Align.START, visible: true });
|
|
||||||
behaviorGrid.attach(label, 0, 0, 1, 1);
|
|
||||||
const combo = new Gtk.ComboBoxText({ visible: true, halign: Gtk.Align.END });
|
|
||||||
combo.append("stack", "Stack Window (Default)");
|
|
||||||
combo.append("master", "Master Window");
|
|
||||||
combo.set_active_id(settings.get_string("new-window-behavior"));
|
|
||||||
combo.connect("changed", () => {
|
|
||||||
settings.set_string("new-window-behavior", combo.get_active_id());
|
|
||||||
});
|
|
||||||
behaviorGrid.attach(combo, 1, 0, 1, 1);
|
|
||||||
prefsWidget.add(behaviorFrame);
|
|
||||||
|
|
||||||
return prefsWidget;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// --- MAIN ENTRY POINTS (called by GNOME Shell) ---
|
|
||||||
|
|
||||||
function init() {}
|
|
||||||
|
|
||||||
function buildPrefsWidget() {
|
|
||||||
return buildLegacyPrefsWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Adw) {
|
|
||||||
var defaultExport = ModernPrefs;
|
|
||||||
}
|
|
||||||
+227
@@ -0,0 +1,227 @@
|
|||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Simple‑Tiling – LEGACY MENU (GNOME Shell 3.38 ‑ 44) //
|
||||||
|
// © 2025 domoel – MIT //
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// ── GLOBAL IMPORTS ────────────────────────────────────────
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const { Gtk, GObject, Gio } = imports.gi;
|
||||||
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
|
|
||||||
|
const SCHEMA_NAME = "org.gnome.shell.extensions.simple-tiling.domoel";
|
||||||
|
|
||||||
|
// ── DEFINITIONS ────────────────────────────────────────────
|
||||||
|
const COLUMN_ID = 0;
|
||||||
|
const COLUMN_DESC = 1;
|
||||||
|
const COLUMN_KEY = 2;
|
||||||
|
const COLUMN_MODS = 3;
|
||||||
|
|
||||||
|
function init() {}
|
||||||
|
|
||||||
|
function buildPrefsWidget() {
|
||||||
|
const settings = ExtensionUtils.getSettings(SCHEMA_NAME);
|
||||||
|
|
||||||
|
const prefsWidget = new Gtk.Box({
|
||||||
|
orientation: Gtk.Orientation.VERTICAL,
|
||||||
|
margin_top: 20,
|
||||||
|
margin_bottom: 20,
|
||||||
|
margin_start: 20,
|
||||||
|
margin_end: 20,
|
||||||
|
spacing: 18,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// ── KEYBINDINGS ────────────────────────────────────────────
|
||||||
|
const keysTitle = new Gtk.Label({
|
||||||
|
label: "<b>Keybindings</b>",
|
||||||
|
use_markup: true,
|
||||||
|
halign: Gtk.Align.START,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
const keysFrame = new Gtk.Frame({
|
||||||
|
label_widget: keysTitle,
|
||||||
|
shadow_type: Gtk.ShadowType.NONE,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
let keysBox = new Gtk.Box({
|
||||||
|
orientation: Gtk.Orientation.VERTICAL,
|
||||||
|
margin: 12,
|
||||||
|
spacing: 6,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
keysFrame.add(keysBox);
|
||||||
|
|
||||||
|
let store = new Gtk.ListStore();
|
||||||
|
store.set_column_types([
|
||||||
|
GObject.TYPE_STRING,
|
||||||
|
GObject.TYPE_STRING,
|
||||||
|
GObject.TYPE_INT,
|
||||||
|
GObject.TYPE_INT,
|
||||||
|
]);
|
||||||
|
|
||||||
|
addKeybinding(store, settings, "swap-master-window", "Swap current window with master");
|
||||||
|
|
||||||
|
addKeybinding(store, settings, "swap-up-window", "Swap current window with window above");
|
||||||
|
addKeybinding(store, settings, "swap-down-window", "Swap current window with window below");
|
||||||
|
addKeybinding(store, settings, "swap-left-window", "Swap current window with window to the left");
|
||||||
|
addKeybinding(store, settings, "swap-right-window", "Swap current window with window to the right");
|
||||||
|
|
||||||
|
addKeybinding(store, settings, "focus-up", "Focus window above");
|
||||||
|
addKeybinding(store, settings, "focus-down", "Focus window below");
|
||||||
|
addKeybinding(store, settings, "focus-left", "Focus window to the left");
|
||||||
|
addKeybinding(store, settings, "focus-right", "Focus window to the right");
|
||||||
|
|
||||||
|
let treeView = new Gtk.TreeView({
|
||||||
|
model: store,
|
||||||
|
headers_visible: false,
|
||||||
|
hexpand: true,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
keysBox.add(treeView);
|
||||||
|
|
||||||
|
let descRenderer = new Gtk.CellRendererText();
|
||||||
|
let descColumn = new Gtk.TreeViewColumn({ expand: true });
|
||||||
|
descColumn.pack_start(descRenderer, true);
|
||||||
|
descColumn.add_attribute(descRenderer, "text", COLUMN_DESC);
|
||||||
|
treeView.append_column(descColumn);
|
||||||
|
|
||||||
|
let accelRenderer = new Gtk.CellRendererAccel({
|
||||||
|
"accel-mode": Gtk.CellRendererAccelMode.GTK,
|
||||||
|
editable: true,
|
||||||
|
});
|
||||||
|
let accelColumn = new Gtk.TreeViewColumn();
|
||||||
|
accelColumn.pack_end(accelRenderer, false);
|
||||||
|
accelColumn.add_attribute(accelRenderer, "accel-key", COLUMN_KEY);
|
||||||
|
accelColumn.add_attribute(accelRenderer, "accel-mods", COLUMN_MODS);
|
||||||
|
treeView.append_column(accelColumn);
|
||||||
|
|
||||||
|
accelRenderer.connect("accel-edited", (r, path, key, mods) => {
|
||||||
|
let [ok, iter] = store.get_iter_from_string(path);
|
||||||
|
if (ok) {
|
||||||
|
store.set(iter, [COLUMN_KEY, COLUMN_MODS], [key, mods]);
|
||||||
|
settings.set_strv(store.get_value(iter, COLUMN_ID), [
|
||||||
|
Gtk.accelerator_name(key, mods),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
accelRenderer.connect("accel-cleared", (r, path) => {
|
||||||
|
let [ok, iter] = store.get_iter_from_string(path);
|
||||||
|
if (ok) {
|
||||||
|
store.set(iter, [COLUMN_KEY, COLUMN_MODS], [0, 0]);
|
||||||
|
settings.set_strv(store.get_value(iter, COLUMN_ID), []);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
prefsWidget.add(keysFrame);
|
||||||
|
|
||||||
|
// ── WINDOW GAPS ────────────────────────────────────────────
|
||||||
|
const gapsTitle = new Gtk.Label({
|
||||||
|
label: "<b>Window Gaps</b>",
|
||||||
|
use_markup: true,
|
||||||
|
halign: Gtk.Align.START,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
const gapsFrame = new Gtk.Frame({
|
||||||
|
label_widget: gapsTitle,
|
||||||
|
shadow_type: Gtk.ShadowType.NONE,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
const gapsGrid = new Gtk.Grid({
|
||||||
|
margin: 12,
|
||||||
|
column_spacing: 12,
|
||||||
|
row_spacing: 12,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
gapsFrame.add(gapsGrid);
|
||||||
|
|
||||||
|
addSpinButtonRow(gapsGrid, settings, "Inner Gap", "inner-gap", 0);
|
||||||
|
addSpinButtonRow(gapsGrid, settings, "Outer Gap (horizontal)", "outer-gap-horizontal", 1);
|
||||||
|
addSpinButtonRow(gapsGrid, settings, "Outer Gap (vertical)", "outer-gap-vertical", 2);
|
||||||
|
|
||||||
|
prefsWidget.add(gapsFrame);
|
||||||
|
|
||||||
|
// ── WINDOW BEHAVIOR ────────────────────────────────────────────
|
||||||
|
const behaviorTitle = new Gtk.Label({
|
||||||
|
label: "<b>Window Behavior</b>",
|
||||||
|
use_markup: true,
|
||||||
|
halign: Gtk.Align.START,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
const behaviorFrame = new Gtk.Frame({
|
||||||
|
label_widget: behaviorTitle,
|
||||||
|
shadow_type: Gtk.ShadowType.NONE,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
const behaviorGrid = new Gtk.Grid({
|
||||||
|
margin: 12,
|
||||||
|
column_spacing: 12,
|
||||||
|
row_spacing: 12,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
behaviorFrame.add(behaviorGrid);
|
||||||
|
addComboBoxRow(
|
||||||
|
behaviorGrid,
|
||||||
|
settings,
|
||||||
|
"Open new windows as",
|
||||||
|
"new-window-behavior",
|
||||||
|
0
|
||||||
|
);
|
||||||
|
prefsWidget.add(behaviorFrame);
|
||||||
|
|
||||||
|
prefsWidget.show_all();
|
||||||
|
return prefsWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addKeybinding(model, settings, id, desc) {
|
||||||
|
let [key, mods] = [0, 0];
|
||||||
|
const strv = settings.get_strv(id);
|
||||||
|
if (strv && strv[0]) {
|
||||||
|
[key, mods] = Gtk.accelerator_parse(strv[0]);
|
||||||
|
}
|
||||||
|
let iter = model.append();
|
||||||
|
model.set(
|
||||||
|
iter,
|
||||||
|
[COLUMN_ID, COLUMN_DESC, COLUMN_KEY, COLUMN_MODS],
|
||||||
|
[id, desc, key, mods]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function addSpinButtonRow(grid, settings, desc, key, pos) {
|
||||||
|
const label = new Gtk.Label({
|
||||||
|
label: desc,
|
||||||
|
halign: Gtk.Align.START,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
grid.attach(label, 0, pos, 1, 1);
|
||||||
|
const adj = new Gtk.Adjustment({ lower: 0, upper: 100, step_increment: 1 });
|
||||||
|
const spin = new Gtk.SpinButton({
|
||||||
|
adjustment: adj,
|
||||||
|
climb_rate: 1,
|
||||||
|
digits: 0,
|
||||||
|
halign: Gtk.Align.END,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
settings.bind(key, spin, "value", Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
grid.attach(spin, 1, pos, 1, 1);
|
||||||
|
}
|
||||||
|
function addComboBoxRow(grid, settings, desc, key, pos) {
|
||||||
|
const label = new Gtk.Label({
|
||||||
|
label: desc,
|
||||||
|
halign: Gtk.Align.START,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
grid.attach(label, 0, pos, 1, 1);
|
||||||
|
const combo = new Gtk.ComboBoxText({
|
||||||
|
visible: true,
|
||||||
|
halign: Gtk.Align.END,
|
||||||
|
});
|
||||||
|
combo.append("stack", "Stack Window (Default)");
|
||||||
|
combo.append("master", "Master Window");
|
||||||
|
combo.set_active_id(settings.get_string(key));
|
||||||
|
combo.connect("changed", () => {
|
||||||
|
settings.set_string(key, combo.get_active_id());
|
||||||
|
});
|
||||||
|
grid.attach(combo, 1, pos, 1, 1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Simple‑Tiling – MODERN MENU (GNOME Shell 45+) //
|
||||||
|
// © 2025 domoel – MIT //
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ── GLOBAL IMPORTS ────────────────────────────────────────
|
||||||
|
import { ExtensionPreferences } from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||||
|
import Adw from 'gi://Adw';
|
||||||
|
import Gio from 'gi://Gio';
|
||||||
|
import Gtk from 'gi://Gtk';
|
||||||
|
|
||||||
|
export default class SimpleTilingPrefs extends ExtensionPreferences {
|
||||||
|
fillPreferencesWindow(window) {
|
||||||
|
const settings = this.getSettings();
|
||||||
|
const page = new Adw.PreferencesPage();
|
||||||
|
window.add(page);
|
||||||
|
|
||||||
|
// ── WINDOW GAPS ────────────────────────────────────────────
|
||||||
|
const groupGaps = new Adw.PreferencesGroup({
|
||||||
|
title: 'Window Gaps',
|
||||||
|
description: 'Adjust spacing between windows and screen edges.'
|
||||||
|
});
|
||||||
|
page.add(groupGaps);
|
||||||
|
|
||||||
|
const rowInnerGap = new Adw.SpinRow({
|
||||||
|
title: 'Inner Gap',
|
||||||
|
subtitle: 'Space between tiled windows (pixels)',
|
||||||
|
adjustment: new Gtk.Adjustment({ lower: 0, upper: 100, step_increment: 1 }),
|
||||||
|
});
|
||||||
|
groupGaps.add(rowInnerGap);
|
||||||
|
settings.bind('inner-gap', rowInnerGap, 'value', Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
|
const rowOuterH = new Adw.SpinRow({
|
||||||
|
title: 'Outer Gap (horizontal)',
|
||||||
|
subtitle: 'Left / right screen edges (pixels)',
|
||||||
|
adjustment: new Gtk.Adjustment({ lower: 0, upper: 100, step_increment: 1 }),
|
||||||
|
});
|
||||||
|
groupGaps.add(rowOuterH);
|
||||||
|
settings.bind('outer-gap-horizontal', rowOuterH, 'value', Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
|
const rowOuterV = new Adw.SpinRow({
|
||||||
|
title: 'Outer Gap (vertical)',
|
||||||
|
subtitle: 'Top / bottom screen edges (pixels)',
|
||||||
|
adjustment: new Gtk.Adjustment({ lower: 0, upper: 100, step_increment: 1 }),
|
||||||
|
});
|
||||||
|
groupGaps.add(rowOuterV);
|
||||||
|
settings.bind('outer-gap-vertical', rowOuterV, 'value', Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
|
// ── WINDOW BEHAVIOR ────────────────────────────────────────────
|
||||||
|
const groupBehavior = new Adw.PreferencesGroup({ title: 'Window Behavior' });
|
||||||
|
page.add(groupBehavior);
|
||||||
|
|
||||||
|
const rowNewWindow = new Adw.ComboRow({
|
||||||
|
title: 'Open new windows as',
|
||||||
|
subtitle: 'Whether a new window starts as Master or Stack',
|
||||||
|
model: new Gtk.StringList({
|
||||||
|
strings: ['Stack Window (Default)', 'Master Window'],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
groupBehavior.add(rowNewWindow);
|
||||||
|
|
||||||
|
rowNewWindow.selected = settings.get_string('new-window-behavior') === 'master' ? 1 : 0;
|
||||||
|
|
||||||
|
rowNewWindow.connect('notify::selected', () => {
|
||||||
|
const newVal = rowNewWindow.selected === 1 ? 'master' : 'stack';
|
||||||
|
settings.set_string('new-window-behavior', newVal);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ── KEYBINDINGS ────────────────────────────────────────────
|
||||||
|
const groupKeys = new Adw.PreferencesGroup({ title: 'Keybindings' });
|
||||||
|
page.add(groupKeys);
|
||||||
|
|
||||||
|
const rowKeys = new Adw.ActionRow({
|
||||||
|
title: 'Configure Shortcuts',
|
||||||
|
subtitle: 'Adjust all shortcuts in GNOME Keyboard settings.',
|
||||||
|
});
|
||||||
|
groupKeys.add(rowKeys);
|
||||||
|
|
||||||
|
const btnOpenKeyboard = new Gtk.Button({ label: 'Open Keyboard Settings' });
|
||||||
|
btnOpenKeyboard.connect('clicked', () => {
|
||||||
|
const appInfo = Gio.AppInfo.create_from_commandline(
|
||||||
|
'gnome-control-center keyboard', null, Gio.AppInfoCreateFlags.NONE
|
||||||
|
);
|
||||||
|
appInfo.launch([], null);
|
||||||
|
});
|
||||||
|
rowKeys.add_suffix(btnOpenKeyboard);
|
||||||
|
rowKeys.set_activatable_widget(btnOpenKeyboard);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user