Skip to content

Commit 2a01fb8

Browse files
committed
fix: Update the fork.prev_ratio on manual resize
Closes #948
1 parent 563a14d commit 2a01fb8

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

src/extension.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -952,34 +952,36 @@ export class Ext extends Ecs.System<ExtEvent> {
952952
on_grab_end(meta: Meta.Window, op?: any) {
953953
let win = this.get_window(meta);
954954

955+
if (win !== null) {
956+
win.grab = false
957+
}
958+
955959
if (null === win || !win.is_tilable(this)) {
956960
this.unset_grab_op()
957961
return;
958962
}
959963

960-
win.grab = false;
961-
this.moved_by_mouse = true
964+
this.on_grab_end_(win, op);
965+
this.unset_grab_op()
966+
}
962967

968+
on_grab_end_(win: Window.ShellWindow, op?: any) {
969+
this.moved_by_mouse = true
963970
this.size_signals_unblock(win);
964971

965972
if (win.meta && win.meta.minimized) {
966-
this.on_minimize(win);
967-
this.unset_grab_op()
973+
this.on_minimize(win)
968974
return;
969975
}
970976

971977
if (win.is_maximized()) {
972-
this.unset_grab_op()
973978
return;
974979
}
975980

976981
const grab_op = this.grab_op
977982

978-
this.grab_op = null
979-
980983
if (!win) {
981984
log.error('an entity was dropped, but there is no window')
982-
this.unset_grab_op()
983985
return
984986
}
985987

@@ -994,13 +996,11 @@ export class Ext extends Ecs.System<ExtEvent> {
994996
}
995997
}
996998

997-
this.unset_grab_op()
998999
return
9991000
}
10001001

10011002
if (!(grab_op && Ecs.entity_eq(grab_op.entity, win.entity))) {
10021003
log.error(`grabbed entity is not the same as the one that was dropped`)
1003-
this.unset_grab_op()
10041004
return
10051005
}
10061006

@@ -1060,8 +1060,6 @@ export class Ext extends Ecs.System<ExtEvent> {
10601060
} else if (this.settings.snap_to_grid()) {
10611061
this.tiler.snap(this, win);
10621062
}
1063-
1064-
this.unset_grab_op()
10651063
}
10661064

10671065
movement_is_valid(win: Window.ShellWindow, movement: movement.Movement) {

src/fork.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ export class Fork {
212212
area: Rectangle,
213213
record: (win: Entity, parent: Entity, area: Rectangle) => void
214214
) {
215-
let ratio;
215+
let ratio = null
216+
217+
let manually_moved = ext.grab_op !== null || ext.tiler.resizing_window
216218

217219
if (!this.is_toplevel) {
218220
if (this.orientation_changed) {
@@ -229,7 +231,10 @@ export class Fork {
229231
}
230232

231233
if (ratio) {
232-
this.length_left = Math.round(ratio * this.length());
234+
this.length_left = Math.round(ratio * this.length())
235+
if (manually_moved) this.prev_ratio = ratio
236+
} else if (manually_moved) {
237+
this.prev_ratio = this.length_left / this.length()
233238
}
234239

235240
if (this.right) {

src/tiling.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class Tiler {
3737
window: Entity | null = null;
3838

3939
moving: boolean = false;
40+
resizing_window: boolean = false;
4041

4142
private swap_window: Entity | null = null;
4243

@@ -616,6 +617,7 @@ export class Tiler {
616617

617618
resize(ext: Ext, direction: Direction) {
618619
if (!this.window) return;
620+
this.resizing_window = true
619621

620622
if (ext.auto_tiler && !ext.contains_tag(this.window, Tags.Floating)) {
621623
this.resize_auto(ext, direction);
@@ -643,6 +645,8 @@ export class Tiler {
643645
.change(ext.overlay, rect, 0, 0, 0, 0);
644646
});
645647
}
648+
649+
this.resizing_window = false
646650
}
647651

648652
swap(ext: Ext, selector: window.ShellWindow | null) {

0 commit comments

Comments
 (0)