mirror of
https://github.com/FranP-code/wintile.git
synced 2025-10-13 00:33:46 +00:00
27
extension.js
27
extension.js
@@ -13,6 +13,9 @@ const PopupMenu = imports.ui.popupMenu;
|
||||
const St = imports.gi.St;
|
||||
const Tweener = imports.tweener && imports.tweener.tweener || imports.ui.tweener;
|
||||
|
||||
const Config = imports.misc.config;
|
||||
const SHELL_VERSION_MAJOR = parseInt(Config.PACKAGE_VERSION.split('.')[0]);
|
||||
|
||||
let onWindowGrabBegin, onWindowGrabEnd;
|
||||
let windowMoving = false;
|
||||
|
||||
@@ -63,7 +66,6 @@ updateSettings();
|
||||
// Watch the settings for changes
|
||||
let settingsChangedId = settings.connect('changed', updateSettings.bind());
|
||||
|
||||
const Config = imports.misc.config;
|
||||
window.wintile = {
|
||||
extdatadir: imports.misc.extensionUtils.getCurrentExtension().path,
|
||||
shell_version: parseInt(Config.PACKAGE_VERSION.split('.')[1], 10)
|
||||
@@ -623,7 +625,7 @@ function checkForMove(x, y, app) {
|
||||
}
|
||||
}
|
||||
|
||||
function windowGrabBegin(meta_display, meta_screen, meta_window, meta_grab_op, gpointer) {
|
||||
function windowGrabBegin(meta_window, meta_grab_op) {
|
||||
_log('windowGrabBegin')
|
||||
if (meta_window) {
|
||||
windowMoving = true;
|
||||
@@ -641,7 +643,7 @@ function windowGrabBegin(meta_display, meta_screen, meta_window, meta_grab_op, g
|
||||
}
|
||||
}
|
||||
|
||||
function windowGrabEnd(meta_display, meta_screen, meta_window, meta_grab_op, gpointer) {
|
||||
function windowGrabEnd(meta_window, meta_grab_op) {
|
||||
_log('windowGrabEnd')
|
||||
if (meta_window) {
|
||||
windowMoving = false;
|
||||
@@ -855,8 +857,23 @@ var enable = function() {
|
||||
keyManager.add("<Super>up", function() { requestMove("up") })
|
||||
keyManager.add("<Super>down", function() { requestMove("down") })
|
||||
});
|
||||
onWindowGrabBegin = global.display.connect('grab-op-begin', windowGrabBegin);
|
||||
onWindowGrabEnd = global.display.connect('grab-op-end', windowGrabEnd);
|
||||
|
||||
// Since GNOME 40 the meta_display argument isn't passed anymore to these callbacks.
|
||||
// We "translate" the parameters here so that things work on both GNOME 3 and 40.
|
||||
onWindowGrabBegin = global.display.connect('grab-op-begin', (meta_display, meta_screen, meta_window, meta_grab_op, gpointer) => {
|
||||
if (SHELL_VERSION_MAJOR >= 40) {
|
||||
windowGrabBegin(meta_screen, meta_window);
|
||||
} else {
|
||||
windowGrabBegin(meta_window, meta_grab_op);
|
||||
}
|
||||
});
|
||||
onWindowGrabEnd = global.display.connect('grab-op-end', (meta_display, meta_screen, meta_window, meta_grab_op, gpointer) => {
|
||||
if (SHELL_VERSION_MAJOR >= 40) {
|
||||
windowGrabEnd(meta_screen, meta_window);
|
||||
} else {
|
||||
windowGrabEnd(meta_window, meta_grab_op);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ const Main = imports.ui.main;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Shell = imports.gi.Shell;
|
||||
|
||||
const SHELL_VERSION_MAJOR = parseInt(Config.PACKAGE_VERSION.split('.')[0]);
|
||||
const SHELL_VERSION_MINOR = parseInt(Config.PACKAGE_VERSION.split('.')[1]);
|
||||
|
||||
|
||||
@@ -57,10 +58,10 @@ var Manager = class Manager {
|
||||
let action = Meta.KeyBindingAction.NONE;
|
||||
|
||||
// A flags argument was added somewhere between 3.30-3.32
|
||||
if (SHELL_VERSION_MINOR > 30) {
|
||||
action = global.display.grab_accelerator(accelerator, 0);
|
||||
} else {
|
||||
if (SHELL_VERSION_MAJOR == 3 && SHELL_VERSION_MINOR < 30) {
|
||||
action = global.display.grab_accelerator(accelerator);
|
||||
} else {
|
||||
action = global.display.grab_accelerator(accelerator, 0);
|
||||
}
|
||||
|
||||
if (action !== Meta.KeyBindingAction.NONE) {
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
"3.32",
|
||||
"3.34",
|
||||
"3.36",
|
||||
"3.38"
|
||||
"3.38",
|
||||
"40.0"
|
||||
],
|
||||
"version": 6
|
||||
}
|
||||
|
||||
20
prefs.js
20
prefs.js
@@ -10,6 +10,9 @@ const Me = ExtensionUtils.getCurrentExtension();
|
||||
const Gettext = imports.gettext;
|
||||
const _ = Gettext.domain('wintile').gettext;
|
||||
|
||||
const Config = imports.misc.config;
|
||||
const SHELL_VERSION_MAJOR = parseInt(Config.PACKAGE_VERSION.split('.')[0]);
|
||||
|
||||
let gschema = Gio.SettingsSchemaSource.new_from_directory(
|
||||
Me.dir.get_child('schemas').get_path(),
|
||||
Gio.SettingsSchemaSource.get_default(),
|
||||
@@ -45,7 +48,10 @@ function buildPrefsWidget() {
|
||||
|
||||
// Create a parent widget that we'll return from this function
|
||||
let layout = new Gtk.Grid({
|
||||
margin: 18,
|
||||
margin_bottom: 18,
|
||||
margin_end: 18,
|
||||
margin_start: 18,
|
||||
margin_top: 18,
|
||||
column_spacing: 12,
|
||||
row_spacing: 12,
|
||||
visible: true
|
||||
@@ -146,7 +152,11 @@ function buildPrefsWidget() {
|
||||
visible: true
|
||||
});
|
||||
previewDistanceSettingInt.set_value(gsettings.get_int('distance'));
|
||||
previewDistanceInput.add(previewDistanceSettingInt);
|
||||
if (SHELL_VERSION_MAJOR >= 40) {
|
||||
previewDistanceInput.append(previewDistanceSettingInt);
|
||||
} else {
|
||||
previewDistanceInput.add(previewDistanceSettingInt);
|
||||
}
|
||||
layout.attach(previewDistanceLabel, 0, row, 1, 1);
|
||||
layout.attach(previewDistanceInput, 1, row++, 1, 1);
|
||||
|
||||
@@ -172,7 +182,11 @@ function buildPrefsWidget() {
|
||||
visible: true
|
||||
});
|
||||
previewDelaySettingInt.set_value(gsettings.get_int('delay'));
|
||||
previewDelayInput.add(previewDelaySettingInt);
|
||||
if (SHELL_VERSION_MAJOR >= 40) {
|
||||
previewDelayInput.append(previewDelaySettingInt);
|
||||
} else {
|
||||
previewDelayInput.add(previewDelaySettingInt);
|
||||
}
|
||||
layout.attach(previewDelayLabel, 0, row, 1, 1);
|
||||
layout.attach(previewDelayInput, 1, row++, 1, 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user