Skip to content

Commit

Permalink
fix: "Tile Windows" toggle causing recursion when using shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
epetousis authored and jacobgkau committed Dec 31, 2024
1 parent e25621e commit 104269e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/panel_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,21 +308,27 @@ function show_title(ext: Ext): any {
return t;
}

function toggle(desc: string, active: boolean, connect: (toggle: any) => void): any {
function toggle(desc: string, active: boolean, connect: (toggle: any, state: boolean) => void): any {
let toggle = new PopupSwitchMenuItem(desc, active);

toggle.label.set_y_align(Clutter.ActorAlign.CENTER);

toggle.connect('toggled', () => {
connect(toggle);
toggle.connect('toggled', (_: any, state: boolean) => {
connect(toggle, state);
return true;
});

return toggle;
}

function tiled(ext: Ext): any {
let t = toggle(_('Tile Windows'), null != ext.auto_tiler, () => ext.toggle_tiling());
let t = toggle(_('Tile Windows'), null != ext.auto_tiler, (_, shouldTile) => {
if (shouldTile) {
ext.auto_tile_on();
} else {
ext.auto_tile_off();
}
});
return t;
}

Expand Down

0 comments on commit 104269e

Please sign in to comment.