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

Merge develop to master #181

Merged
merged 10 commits into from
Feb 16, 2024
Merged
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
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,4 @@ globals:
clearInterval: readonly
parserOptions:
ecmaVersion: 2022
sourceType: module
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

rm [email protected]
glib-compile-schemas schemas/
zip -r9 [email protected] extension.js keybindings.js metadata.json prefs.js schemas
zip -r9 [email protected] extension.js keybindings.js metadata.json prefs.js settings.ui schemas
126 changes: 76 additions & 50 deletions extension.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
/* global global */

/* BEGIN NON-G45 */
const Meta = imports.gi.Meta;
const Main = imports.ui.main;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const ExtensionUtils = imports.misc.extensionUtils;
const Clutter = imports.gi.Clutter;
const St = imports.gi.St;
const Config = imports.misc.config;
const SHELL_VERSION = parseFloat(Config.PACKAGE_VERSION);
// const Meta = imports.gi.Meta;
// const Main = imports.ui.main;
// const Gio = imports.gi.Gio;
// const GLib = imports.gi.GLib;
// const ExtensionUtils = imports.misc.extensionUtils;
// const Clutter = imports.gi.Clutter;
// const St = imports.gi.St;
// const Config = imports.misc.config;
// const SHELL_VERSION = parseFloat(Config.PACKAGE_VERSION);
/* END NON-G45 */

/* BEGIN G45 */
// import Meta from 'gi://Meta';
// import * as Main from 'resource:///org/gnome/shell/ui/main.js';
// import Gio from 'gi://Gio';
// import GLib from 'gi://GLib';
// import Extension from 'resource:///org/gnome/shell/extensions/extension.js';
// import Clutter from 'gi://Clutter';
// import St from 'gi://St';
// import Config from imports.misc.config;
// const SHELL_VERSION = parseFloat(Config.PACKAGE_VERSION);
import Meta from 'gi://Meta';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
import Clutter from 'gi://Clutter';
import St from 'gi://St';
import {PACKAGE_VERSION} from 'resource:///org/gnome/shell/misc/config.js';
import KeyBindingsManager from './keybindings.js';
const SHELL_VERSION = parseFloat(PACKAGE_VERSION);
/* END G45 */

let onWindowGrabBegin, onWindowGrabEnd;
Expand Down Expand Up @@ -82,13 +83,16 @@ function updateSettings() {
_log(JSON.stringify(config));
}

const wintile = {
extdatadir: imports.misc.extensionUtils.getCurrentExtension().path,
shell_version: parseInt(Config.PACKAGE_VERSION.split('.')[1], 10),
};
imports.searchPath.unshift(wintile.extdatadir);
/* BEGIN NON-G45 */
// const wintile = {
// extdatadir: imports.misc.extensionUtils.getCurrentExtension().path,
// shell_version: parseInt(Config.PACKAGE_VERSION.split('.')[1], 10),
// };
// imports.searchPath.unshift(wintile.extdatadir);

// const KeyBindings = imports.keybindings;
/* END NON-G45 */

const KeyBindings = imports.keybindings;
let keyManager = null;
var oldbindings = {
unmaximize: [],
Expand Down Expand Up @@ -171,8 +175,8 @@ function moveApp(app, loc) {
var colWidth = Math.floor(monitor.width / colCount);
var rowHeight = Math.floor(monitor.height / rowCount);

let x = loc.col * colWidth + monitor.x;
let y = loc.row * rowHeight + monitor.y;
let x = loc.col * colWidth + monitor.leftEdge;
let y = loc.row * rowHeight + monitor.topEdge;
let w = loc.width * colWidth;
let h = loc.height * rowHeight;

Expand Down Expand Up @@ -799,26 +803,26 @@ function checkIfNearGrid(app) {
_log(`checkIfNearGrid) keys - ctrl:${ctrlPressed} superPressed:${superPressed}`);
_log(`checkIfNearGrid) monitor - x:${monitor.x} y:${monitor.y} w:${monitor.width} h:${monitor.height}`);
_log(`checkIfNearGrid) window - x:${window.x} y:${window.y} w:${window.width} h:${window.height}`);
var c = Math.floor((mouseX - monitor.x) / colWidth);
var r = Math.floor((mouseY - monitor.y) / rowHeight);
var c = Math.floor((mouseX - monitor.leftEdge) / colWidth);
var r = Math.floor((mouseY - monitor.topEdge) / rowHeight);
c = Math.max(0, Math.min(c, colCount - 1));
r = Math.max(0, Math.min(r, rowCount - 1));

var gridX = c * colWidth + monitor.x;
var inGrid = mouseX > gridX && mouseX < gridX + colWidth;
var centerOfGrid = mouseX > Math.floor(gridX + colWidth / 3) && mouseX < Math.floor(gridX + (2 * colWidth / 3));
var topRow = mouseY < monitor.y + rowHeight;
var bottomRow = mouseY > monitor.y + monitor.height - rowHeight;
var nearTop = isClose(mouseY, monitor.y) || mouseY < monitor.y;
var nearBottom = isClose(mouseY, monitor.y + monitor.height) || mouseY > monitor.y + monitor.height;
var nearLeft = isClose(mouseX, monitor.x) || mouseX < monitor.x;
var nearRight = isClose(mouseX, monitor.rightEdge) || mouseX > monitor.rightEdge;

var centerOfScreenH = monitor.x + Math.floor(monitor.width / 2);
var gridX = c * colWidth + monitor.leftEdge;
var inGrid = mouseX >= gridX && mouseX <= gridX + colWidth;
var centerOfGrid = mouseX >= Math.floor(gridX + colWidth / 3) && mouseX <= Math.floor(gridX + (2 * colWidth / 3));
var topRow = mouseY <= monitor.topEdge + rowHeight;
var bottomRow = mouseY >= monitor.bottomEdge - rowHeight;
var nearTop = isClose(mouseY, monitor.topEdge) || mouseY <= monitor.topEdge;
var nearBottom = isClose(mouseY, monitor.bottomEdge) || mouseY >= monitor.bottomEdge;
var nearLeft = isClose(mouseX, monitor.leftEdge) || mouseX <= monitor.leftEdge;
var nearRight = isClose(mouseX, monitor.rightEdge) || mouseX >= monitor.rightEdge;

var centerOfScreenH = monitor.leftEdge + Math.floor(monitor.width / 2);
var columnWidthFraction = Math.floor(colWidth / 3);
var nearCenterH = mouseX > centerOfScreenH - (columnWidthFraction / 2) && mouseX < centerOfScreenH + (columnWidthFraction / 2);

var centerOfScreenV = monitor.y + Math.floor(monitor.height / 2);
var centerOfScreenV = monitor.topEdge + Math.floor(monitor.height / 2);
var rowHeightFraction = Math.floor(rowHeight / 3);
var nearCenterV = mouseY > centerOfScreenV - (rowHeightFraction / 2) && mouseY < centerOfScreenV + (rowHeightFraction / 2);

Expand Down Expand Up @@ -1068,10 +1072,24 @@ function getMonitorInfo(monitorIndex) {
/**
*
*/
class WintileExtension {

/* BEGIN NON-G45 */
// class WintileExtension {
/* END NON-G45 */

/* BEGIN G45 */
export default class WintileExtension extends Extension {
/* END G45 */
enable() {
_log('enable) Keymanager is being defined');
keyManager = new KeyBindings.Manager();

/* BEGIN G45 */
keyManager = new KeyBindingsManager();
/* END G45 */

/* BEGIN NON-G45 */
// keyManager = new KeyBindings.Manager();
/* END NON-G45 */
let desktopSettings = new Gio.Settings({schema_id: 'org.gnome.desktop.wm.keybindings'});
let mutterKeybindingSettings = new Gio.Settings({schema_id: 'org.gnome.mutter.keybindings'});
let mutterSettings = new Gio.Settings({schema_id: 'org.gnome.mutter'});
Expand Down Expand Up @@ -1139,7 +1157,13 @@ class WintileExtension {
});
Main.uiGroup.add_actor(preview);

gsettings = ExtensionUtils.getSettings();
/* BEGIN G45 */
gsettings = this.getSettings();
/* END G45 */

/* BEGIN NON-G45 */
// gsettings = ExtensionUtils.getSettings();
/* END NON-G45 */
updateSettings();

// Watch the gsettings for changes
Expand Down Expand Up @@ -1187,10 +1211,12 @@ class WintileExtension {
}
}

/**
*
* @param {object} _meta = standard meta object
*/
function init(_meta) {
return new WintileExtension();
}
/* BEGIN NON-G45 */
// /**
// *
// * @param {object} _meta = standard meta object
// */
// function init(_meta) {
// return new WintileExtension();
// }
/* END NON-G45 */
23 changes: 18 additions & 5 deletions keybindings.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
'use strict';
/* global global */

const Main = imports.ui.main;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
/* BEGIN NON-G45 */
// const Main = imports.ui.main;
// const Meta = imports.gi.Meta;
// const Shell = imports.gi.Shell;
/* END NON-G45 */

/* BEGIN G45 */
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import Meta from 'gi://Meta';
import Shell from 'gi://Shell';
/* END G45 */

/**
* Keybindings.Manager is a simple convenience class for managing keyboard
Expand All @@ -20,7 +28,12 @@ const Shell = imports.gi.Shell;
* https://developer.gnome.org/meta/stable/meta-MetaKeybinding.html
* https://gitlab.gnome.org/GNOME/gnome-shell/blob/master/js/ui/windowManager.js#L1093-1112
*/
var Manager = class Manager {
/* BEGIN NON-G45 */
// var Manager = class Manager {
/* END NON-G45 */
/* BEGIN G45 */
export default class KeyBindingsManager {
/* END G45 */
constructor() {
this._keybindings = new Map();

Expand Down Expand Up @@ -94,5 +107,5 @@ var Manager = class Manager {
global.display.disconnect(this._acceleratorActivatedId);
this.removeAll();
}
};
}

8 changes: 3 additions & 5 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"name": "WinTile",
"description": "WinTile is a hotkey driven window tiling system for GNOME that imitates the standard Win-Arrow keys of Windows 10, allowing you to maximize, maximize to sides, or 1/4 sized to corner across a single or multiple monitors using just Super+Arrow.\n\nAs of v16, WinTile also supports:\n- 1-5 columns and 1-5 rows for standard or ultrawide monitors\n- Top/bottom half support\n- Mouse preview and snapping for placing windows\n- 'Maximize' mode, which adds/removes GNOME animations\n- 'Ultrawide-only' mode, to allow standard screens to have different cols/row than ultrawides\n- Portrait screens will automatically swap columns and rows\n- Add gaps around tiles to avoid the 'crowded elevator' feeling'\n- Ctrl+Super+Arrow to grow a tile in that direction if space is available\n- Ctrl+drag to drop a tile in a specific spot\n- Ctrl+Super+drag to draw a grid for the new tile",
"description": "WinTile is a hotkey driven window tiling system for GNOME that imitates the standard Win-Arrow keys of Windows 10, allowing you to maximize, maximize to sides, or 1/4 sized to corner across a single or multiple monitors using just Super+Arrow.\n\nAs of v17, WinTile also supports:\n- 1-5 columns and 1-5 rows for standard or ultrawide monitors\n- Top/bottom half support\n- Mouse preview and snapping for placing windows\n- 'Maximize' mode, which adds/removes GNOME animations\n- 'Ultrawide-only' mode, to allow standard screens to have different cols/row than ultrawides\n- Portrait screens will automatically swap columns and rows\n- Add gaps around tiles to avoid the 'crowded elevator' feeling'\n- Ctrl+Super+Arrow to grow a tile in that direction if space is available\n- Ctrl+drag to drop a tile in a specific spot\n- Ctrl+Super+drag to draw a grid for the new tile",
"uuid": "[email protected]",
"url": "https://github.com/fmstrat/wintile",
"settings-schema":"org.gnome.shell.extensions.wintile",
"shell-version": [
"42",
"43",
"44"
"45"
],
"version": 16
"version": 17
}
Loading
Loading