Skip to content

Commit 877be5c

Browse files
committed
fix: 🐛 better detection for auto hiding
1 parent 50e43d5 commit 877be5c

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/app-window.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Gtk from "./types/Gtk-3.0"
66
export class AppWindow {
77
window: Gtk.ApplicationWindow
88
dock: Dock
9+
hidden = true
910

1011
constructor(application: Gtk.Application) {
1112
const win = new Gtk.ApplicationWindow({
@@ -66,8 +67,10 @@ export class AppWindow {
6667
}
6768

6869
updateSize() {
70+
if (this.hidden) this.autoHide()
71+
6972
// Hide window when dock is hidden
70-
if (this.dock.toolbar.get_visible()) this.window.show()
73+
if (!this.hidden && this.dock.show) this.window.show()
7174
else {
7275
this.window.hide()
7376
return
@@ -135,7 +138,7 @@ export class AppWindow {
135138
}
136139

137140
autoHide() {
138-
const active = this.window.get_screen().get_active_window()
141+
const active = this.dock.screen.get_active_window()
139142
if (active && this.window) {
140143
const [ax1, ay1, aw, ah] = active.get_geometry()
141144
const [bx1, by1] = this.window.get_position()
@@ -152,14 +155,16 @@ export class AppWindow {
152155
// no vertical overlap
153156
else if (ay1 >= by1 + bh || by1 >= ay1 + ah) show = true
154157

155-
if (show && !this.window.is_visible()) {
158+
if (show && this.hidden) {
156159
log("[no-overlap] showing dock")
157160
this.window.show()
161+
this.hidden = false
158162
}
159163

160-
if (!show && this.window.is_visible()) {
161-
log(`[overlap] overlapping. Hiding dock`)
164+
if (!show && !this.hidden) {
165+
log(`[overlap] overlapping with ${active.get_name()}. Hiding dock`)
162166
this.window.hide()
167+
this.hidden = true
163168
}
164169
}
165170
return true

src/dock.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export class Dock {
77
items = new Map<number, DockItem>()
88
toolbar = new Gtk.Toolbar()
99
screen: Wnck.Screen
10+
show = false
1011

1112
constructor(public horizontal = true) {
1213
const screen = Wnck.Screen.get_default()
@@ -105,10 +106,10 @@ export class Dock {
105106
log(`[update] - ${event} [${buttonCount}]`)
106107
if (buttonCount) {
107108
log("[toobar] show")
108-
this.toolbar.show()
109+
this.show = true
109110
} else {
110111
log("[toobar] hide")
111-
this.toolbar.hide()
112+
this.show = false
112113
}
113114
this.toolbar.check_resize()
114115
}

0 commit comments

Comments
 (0)