Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit d9581f2

Browse files
committed
💄 Make vertical tabs visible in sway fullscreen
1 parent d89f640 commit d9581f2

File tree

3 files changed

+74
-17
lines changed

3 files changed

+74
-17
lines changed

src/browser/app/profile/pulse-browser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,7 @@ pref('layout.css.has-selector.enabled', true);
109109
// digression
110110
pref('pulse.tabs.show.close', true);
111111
pref('pulse.tabs.show.new', true);
112+
113+
// Disable bookmark toolbar by default
114+
pref('browser.toolbars.bookmarks.visibility', 'never');
115+

src/browser/base/content/browser-verticaltabs.js

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function insertAfter(toInsertAfter, toInsert) {
2222

2323
if (!parent) {
2424
throw new Error(
25-
'The element you want me to base insertions on has no parent'
25+
'The element you want me to base insertions on has no parent',
2626
)
2727
}
2828

@@ -111,6 +111,9 @@ var VerticalTabs = {
111111
/** @type {MutationObserver?} */
112112
_widthObserver: null,
113113

114+
/** @type {boolean} */
115+
isFullScreen: false,
116+
114117
init() {
115118
if (this._initialized) {
116119
return
@@ -125,11 +128,11 @@ var VerticalTabs = {
125128

126129
document.documentElement.setAttribute(
127130
'show-tab-close',
128-
this.showCloseButton ? 'true' : 'false'
131+
this.showCloseButton ? 'true' : 'false',
129132
)
130133
document.documentElement.setAttribute(
131134
'show-tab-new',
132-
this.showNewTab ? 'true' : 'false'
135+
this.showNewTab ? 'true' : 'false',
133136
)
134137

135138
if (this.verticalTabsEnabled) {
@@ -142,6 +145,19 @@ var VerticalTabs = {
142145
gBrowser.handleNewTabMiddleClick(this.arrowScrollbox, event)
143146
})
144147

148+
addEventListener('fullscreen', this, true)
149+
window.addEventListener('mousemove', (e) => {
150+
if (!window.fullScreen || !this.verticalTabsEnabled) return
151+
const tabsToolbar = this.tabsToolbar
152+
if (!tabsToolbar) return
153+
154+
const tabsWidth = tabsToolbar.clientWidth
155+
// If not hovering over the expanded tabs, we should collpase them
156+
if (e.clientX > tabsWidth) return this.fsMethods.collapse()
157+
// If towards the edge of the screen, the tabs should be reexpanded
158+
if (e.clientX == 0) return this.fsMethods.expand()
159+
})
160+
145161
this._initialized = true
146162
},
147163

@@ -160,7 +176,7 @@ var VerticalTabs = {
160176

161177
this.tabsToolbar?.setAttribute(
162178
'collapse',
163-
this.browserCollapseTabs ? 'true' : 'false'
179+
this.browserCollapseTabs ? 'true' : 'false',
164180
)
165181
this.tabsToolbar?.removeAttribute('flex')
166182
changeXULTagName('vbox', this.tabsToolbar)
@@ -171,20 +187,20 @@ var VerticalTabs = {
171187

172188
this.tabsToolbar?.setAttribute(
173189
'width',
174-
Services.prefs.getIntPref(VERTICAL_TABS_WIDTH, 200)
190+
Services.prefs.getIntPref(VERTICAL_TABS_WIDTH, 200),
175191
)
176192
if (this.tabsToolbar)
177193
this.tabsToolbar.style.width = `${Services.prefs.getIntPref(
178194
VERTICAL_TABS_WIDTH,
179-
200
195+
200,
180196
)}px`
181197

182198
if (!this.splitter) {
183199
const separator = document.createXULElement('splitter')
184200
separator.setAttribute('id', 'verticaltabs-splitter')
185201
separator.setAttribute(
186202
'class',
187-
'chromeclass-extrachrome verticaltabs-splitter'
203+
'chromeclass-extrachrome verticaltabs-splitter',
188204
)
189205
separator.setAttribute('resizebefore', 'sibling')
190206
separator.setAttribute('resizeafter', 'none')
@@ -224,6 +240,43 @@ var VerticalTabs = {
224240
}
225241
},
226242

243+
handleEvent(event) {
244+
switch (event.type) {
245+
case 'fullscreen':
246+
if (!window.fullScreen) this.fsMethods.collapse()
247+
else this.fsMethods.expand()
248+
break
249+
}
250+
},
251+
252+
fsMethods: {
253+
isCollapsed: false,
254+
get parent() {
255+
return VerticalTabs
256+
},
257+
258+
collapse() {
259+
if (this.isCollapsed) return
260+
this.isCollapsed = true
261+
262+
// Set the margin to hide the tabs of the side of the screen
263+
if (!this.parent.tabsToolbar || !this.parent.splitter) return
264+
this.parent.tabsToolbar.style.marginLeft =
265+
-(
266+
this.parent.tabsToolbar.clientWidth + this.parent.splitter.clientWidth
267+
) + 'px'
268+
},
269+
270+
expand() {
271+
if (!this.isCollapsed) return
272+
this.isCollapsed = false
273+
274+
// Reset left margin
275+
if (!this.parent.tabsToolbar) return
276+
this.parent.tabsToolbar.style.marginLeft = ''
277+
},
278+
},
279+
227280
/**
228281
* @param {MutationRecord[]} mutationsList
229282
* @param {MutationObserver} _observer
@@ -235,7 +288,7 @@ var VerticalTabs = {
235288

236289
Services.prefs.setIntPref(
237290
VERTICAL_TABS_WIDTH,
238-
parseInt(tabsToolbar?.getAttribute('width') || '100')
291+
parseInt(tabsToolbar?.getAttribute('width') || '100'),
239292
)
240293
}
241294
}
@@ -259,18 +312,18 @@ var VerticalTabs = {
259312
.getElementById('TabsToolbar')
260313
?.setAttribute(
261314
'collapse',
262-
this.browserCollapseTabs ? 'true' : 'false'
315+
this.browserCollapseTabs ? 'true' : 'false',
263316
)
264317
}
265318

266319
if (data === SHOW_CLOSE_BUTTON || data === SHOW_NEW_TAB) {
267320
document.documentElement.setAttribute(
268321
'show-tab-close',
269-
this.showCloseButton ? 'true' : 'false'
322+
this.showCloseButton ? 'true' : 'false',
270323
)
271324
document.documentElement.setAttribute(
272325
'show-tab-new',
273-
this.showNewTab ? 'true' : 'false'
326+
this.showNewTab ? 'true' : 'false',
274327
)
275328
}
276329

src/browser/themes/pulse/vertical_tabs.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
-moz-box-ordinal-group: 0;
3535
overflow-x: hidden;
3636

37-
transition: min-width 150ms ease-in-out, max-width 150ms ease-in-out;
37+
transition:
38+
min-width 150ms ease-in-out,
39+
max-width 150ms ease-in-out;
3840
}
3941

4042
#browser #TabsToolbar:-moz-lwtheme {
@@ -73,7 +75,9 @@
7375
height: var(--tab-min-height);
7476
max-height: var(--tab-min-height);
7577

76-
transition: min-height 150ms ease-in-out, max-height 150ms ease-in-out;
78+
transition:
79+
min-height 150ms ease-in-out,
80+
max-height 150ms ease-in-out;
7781
}
7882

7983
#browser #TabsToolbar .tab-background {
@@ -169,7 +173,3 @@
169173
-moz-box-ordinal-group: 1;
170174
border: solid 1px var(--tab-selected-bgcolor, var(--toolbar-bgcolor));
171175
}
172-
173-
:root[sizemode='fullscreen'] #browser #TabsToolbar {
174-
display: none;
175-
}

0 commit comments

Comments
 (0)