Skip to content

Commit

Permalink
Merge pull request #321 from Leleat/misc-bugfixes
Browse files Browse the repository at this point in the history
Misc fixes
  • Loading branch information
Leleat authored Mar 3, 2024
2 parents f7a928c + e575676 commit 58a80dc
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,14 @@ export default class TilingLayoutsManager {
const window = this._remainingWindows[idx];
idx !== -1 && this._remainingWindows.splice(idx, 1);

if (window)
Twm.tile(window, this._currRect, { openTilingPopup: false });
else if (app.can_open_new_window())
if (window) {
Twm.tile(window, this._currRect, {
openTilingPopup: false,
skipAnim: true
});
} else if (app.can_open_new_window()) {
Twm.openAppTiled(app, this._currRect);
}

this._step();
}
Expand Down Expand Up @@ -238,7 +242,8 @@ export default class TilingLayoutsManager {
// If this._currItem is the last item and we don't loop over it,
// allow the Tiling Popup itself to spawn another instance of
// a Tiling Popup, if there is free screen space.
this._currItem === this._items.at(-1) && !this._currItem.loopType
this._currItem === this._items.at(-1) && !this._currItem.loopType,
true
);
const stacked = global.display.sort_windows_by_stacking(this._tiledWithLayout);
const tileGroup = stacked.reverse();
Expand Down
42 changes: 33 additions & 9 deletions tiling-assistant@leleat-on-github/src/extension/moveHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,44 @@ export default class TilingMoveHandler {
// The mouse button mod to move/resize a window may be changed to Alt.
// So switch Alt and Super in our own prefs, if the user switched from
// Super to Alt.
const wmPrefs = new Gio.Settings({
const modKeys = [
Settings.ADAPTIVE_TILING_MOD,
Settings.FAVORITE_LAYOUT_MOD,
Settings.IGNORE_TA_MOD
];
const handleWindowActionKeyConflict = () => {
const currMod = this._wmPrefs.get_string('mouse-button-modifier');

if (currMod === '<Alt>') {
for (const key of modKeys) {
const mod = Settings.getInt(key);
if (mod === 2) // Alt
Settings.setInt(key, 0);
}
} else if (currMod === '<Super>') {
for (const key of modKeys) {
const mod = Settings.getInt(key);
if (mod === 4) // Super
Settings.setInt(key, 0);
}
}
};

this._wmPrefs = new Gio.Settings({
schema_id: 'org.gnome.desktop.wm.preferences'
});
const altAsMod = wmPrefs.get_string('mouse-button-modifier') === '<Alt>';
if (altAsMod) {
for (const s of [Settings.ADAPTIVE_TILING_MOD, Settings.FAVORITE_LAYOUT_MOD]) {
const mod = Settings.getInt(s);
if (mod === 1) // 1 -> Alt; see settings ui
Settings.setInt(s, 3); // 3 -> Super; see settings ui
}
}
this._wmPrefs.connectObject(
'changed::mouse-button-modifier',
() => handleWindowActionKeyConflict(),
this
);
handleWindowActionKeyConflict();
}

destroy() {
this._wmPrefs.disconnectObject(this);
this._wmPrefs = null;

this._displaySignals.forEach(sId => global.display.disconnect(sId));
this._tilePreview.destroy();

Expand Down
10 changes: 8 additions & 2 deletions tiling-assistant@leleat-on-github/src/extension/tilingPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ export const TilingSwitcherPopup = GObject.registerClass({
* @param {boolean} allowConsecutivePopup allow the popup to create another
* Tiling Popup, if there is still unambiguous free screen space after
* this popup tiled a window.
* @param {boolean} skipAnim
*/
_init(openWindows, freeScreenRect, allowConsecutivePopup = true) {
_init(openWindows, freeScreenRect, allowConsecutivePopup = true, skipAnim = false) {
this._freeScreenRect = freeScreenRect;
this._shadeBG = null;
this._monitor = -1;
Expand All @@ -43,6 +44,7 @@ export const TilingSwitcherPopup = GObject.registerClass({
// or null, if the popup was closed with tiling a window
this.tiledWindow = null;
this._allowConsecutivePopup = allowConsecutivePopup;
this._skipAnim = skipAnim;

this._switcherList = new TSwitcherList(this, openWindows);
this._items = this._switcherList.icons;
Expand Down Expand Up @@ -299,7 +301,11 @@ export const TilingSwitcherPopup = GObject.registerClass({
// tile group won't be accidentally raised.
Twm.clearTilingProps(window.get_id());
window.activate(global.get_current_time());
Twm.tile(window, rect, { monitorNr: this._monitor, openTilingPopup: this._allowConsecutivePopup });
Twm.tile(window, rect, {
monitorNr: this._monitor,
openTilingPopup: this._allowConsecutivePopup,
skipAnim: this._skipAnim
});
}

// Dont _finish(), if no mods are pressed
Expand Down
1 change: 1 addition & 0 deletions tiling-assistant@leleat-on-github/src/ui/prefs.ui
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Default Window Movement Mode</property>
<property name="description" translatable="yes">The movement mode that is activated when no modifier key is pressed</property>
<property name="visible"
bind-source="enable_advanced_experimental_features"
bind-property="active"
Expand Down

0 comments on commit 58a80dc

Please sign in to comment.