Skip to content

Commit ea23c3f

Browse files
committed
feat: Added context menus to workspace icons at the button and small fixes, b=no-bug, c=common, workspaces
1 parent 7d51ae1 commit ea23c3f

File tree

11 files changed

+64
-29
lines changed

11 files changed

+64
-29
lines changed

src/browser/base/content/navigator-toolbox-inc-xhtml.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/browser/base/content/navigator-toolbox.inc.xhtml b/browser/base/content/navigator-toolbox.inc.xhtml
2-
index 00c8976d3e258c0875d7da2f3ec823d8907a84c9..cc61d5a845b5ce22a61f5a1aab8b280b2bcdf101 100644
2+
index 30e7b9b2ac63db6ccd2727a9341081cecefc25cb..ceff29d10a32fe9e5296340c8c56a2fdbf321c31 100644
33
--- a/browser/base/content/navigator-toolbox.inc.xhtml
44
+++ b/browser/base/content/navigator-toolbox.inc.xhtml
55
@@ -2,7 +2,7 @@

src/browser/base/content/zen-panels/popups.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<menuitem id="context_zenEditWorkspace" data-l10n-id="zen-workspaces-panel-change-name" command="cmd_zenChangeWorkspaceName"/>
1313
<menuitem id="context_zenEditWorkspaceIcon" data-l10n-id="zen-workspaces-panel-change-icon" command="cmd_zenChangeWorkspaceIcon"/>
1414
<menuitem class="zenToolbarThemePicker"
15+
id="context_zenChangeWorkspaceTheme"
1516
data-l10n-id="zen-workspaces-change-theme"
1617
command="cmd_zenOpenZenThemePicker"/>
1718
<menu id="context_zenWorkspacesOpenInContainerTab"
@@ -25,5 +26,6 @@
2526
<menuseparator/>
2627
<menuitem id="context_zenReorderWorkspaces" data-l10n-id="zen-workspaces-panel-context-reorder" command="cmd_zenReorderWorkspaces"/>
2728
<menuseparator/>
29+
<menuitem data-l10n-id="zen-panel-ui-workspaces-create" command="cmd_zenOpenWorkspaceCreation"/>
2830
<menuitem id="context_zenDeleteWorkspace" data-l10n-id="zen-workspaces-panel-context-delete" command="cmd_zenCtxDeleteWorkspace"/>
2931
</menupopup>

src/zen/common/ZenCustomizableUI.sys.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export var ZenCustomizableUI = new (class {
116116
const handlePopupHidden = () => {
117117
window.setTimeout(() => {
118118
button.removeAttribute('open');
119-
}, 100);
119+
}, 500);
120120
window.gZenUIManager.motion.animate(
121121
image,
122122
{ transform: ['rotate(45deg)', 'rotate(0deg)'] },

src/zen/common/ZenStartup.mjs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
document.getElementById('zen-appcontent-wrapper').prepend(deckTemplate);
4242
}
4343

44-
this._hideUnusedElements();
45-
4644
gZenWorkspaces.init();
4745
gZenUIManager.init();
4846

@@ -148,16 +146,6 @@
148146
}
149147
},
150148

151-
_hideUnusedElements() {
152-
const kElements = ['firefox-view-button'];
153-
for (let id of kElements) {
154-
const elem = document.getElementById(id);
155-
if (elem) {
156-
elem.setAttribute('hidden', 'true');
157-
}
158-
}
159-
},
160-
161149
_initSearchBar() {
162150
// Only focus the url bar
163151
gURLBar.focus();

src/zen/common/ZenUIManager.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ var gZenUIManager = {
8383
'--zen-urlbar-top',
8484
`${window.innerHeight / 2 - Math.max(kUrlbarHeight, gURLBar.textbox.getBoundingClientRect().height) / 2}px`
8585
);
86-
gURLBar.textbox.style.setProperty('--zen-urlbar-width', `${window.innerWidth / 2}px`);
86+
gURLBar.textbox.style.setProperty('--zen-urlbar-width', `${window.innerWidth / 3}px`);
8787
gZenVerticalTabsManager.actualWindowButtons.removeAttribute('zen-has-hover');
8888
gZenVerticalTabsManager.recalculateURLBarHeight();
8989
if (!this._preventToolbarRebuild) {

src/zen/common/styles/zen-single-components.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ body > #confetti {
3636
min-height: 30px;
3737
}
3838

39+
/* Firefox View */
40+
#firefox-view-button {
41+
display: none !important;
42+
}
43+
3944
/* Emojis picker */
4045

4146
#PanelUI-zen-emojis-picker {

src/zen/workspaces/ZenWorkspaceIcons.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
this.addEventListener('mousedown', (e) => {
2626
const target = e.target.closest('toolbarbutton[zen-workspace-id]');
27-
if (!target) {
27+
if (!target || e.button != 0 || e.ctrlKey || e.shiftKey || e.altKey) {
2828
return;
2929
}
3030

@@ -89,6 +89,7 @@
8989
button.setAttribute('class', 'subviewbutton');
9090
button.setAttribute('tooltiptext', workspace.name);
9191
button.setAttribute('zen-workspace-id', workspace.uuid);
92+
button.setAttribute('context', 'zenWorkspaceMoreActions');
9293
const icon = document.createXULElement('label');
9394
icon.setAttribute('class', 'zen-workspace-icon');
9495
if (gZenWorkspaces.workspaceHasIcon(workspace)) {

src/zen/workspaces/ZenWorkspaces.mjs

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,9 +1028,13 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
10281028
}
10291029

10301030
changeWorkspaceIcon() {
1031-
const anchor = this.activeWorkspaceIndicator?.querySelector(
1031+
let anchor = this.activeWorkspaceIndicator?.querySelector(
10321032
'.zen-current-workspace-indicator-icon'
10331033
);
1034+
if (this.#contextMenuData?.workspaceId) {
1035+
anchor = this.#contextMenuData.originalTarget;
1036+
}
1037+
const workspaceId = this.#contextMenuData?.workspaceId || this.activeWorkspace;
10341038
if (!anchor) {
10351039
return;
10361040
}
@@ -1042,7 +1046,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
10421046
gZenEmojiPicker
10431047
.open(anchor)
10441048
.then(async (emoji) => {
1045-
const workspace = this.getActiveWorkspaceFromCache();
1049+
const workspace = this.getWorkspaceFromId(workspaceId);
10461050
if (!workspace) {
10471051
console.warn('No active workspace found to change icon');
10481052
return;
@@ -1129,6 +1133,11 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
11291133
addPopupListeners() {
11301134
const workspaceActions = document.getElementById('zenWorkspaceMoreActions');
11311135
workspaceActions.addEventListener('popupshowing', this.updateWorkspaceActionsMenu.bind(this));
1136+
workspaceActions.addEventListener('popuphidden', () => {
1137+
setTimeout(() => {
1138+
this.#contextMenuData = null;
1139+
}, 0); // Delay to ensure the context menu data is cleared after the popup is hidden
1140+
});
11321141

11331142
const contextChangeContainerTabMenu = document.getElementById(
11341143
'context_zenWorkspacesOpenInContainerTab'
@@ -1143,6 +1152,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
11431152
);
11441153
}
11451154

1155+
#contextMenuData = null;
11461156
updateWorkspaceActionsMenu(event) {
11471157
if (event.target.id !== 'zenWorkspaceMoreActions') {
11481158
return;
@@ -1155,10 +1165,35 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
11551165
} else {
11561166
openInContainerMenuItem.setAttribute('hidden', 'true');
11571167
}
1168+
const target = event.explicitOriginalTarget?.closest('toolbarbutton');
1169+
this.#contextMenuData = {
1170+
workspaceId: target?.getAttribute('zen-workspace-id'),
1171+
originalTarget: target,
1172+
};
1173+
const workspaceName = document.getElementById('context_zenEditWorkspace');
1174+
const themePicker = document.getElementById('context_zenChangeWorkspaceTheme');
1175+
workspaceName.hidden =
1176+
this.#contextMenuData.workspaceId &&
1177+
this.#contextMenuData.workspaceId !== this.activeWorkspace;
1178+
themePicker.hidden =
1179+
this.#contextMenuData.workspaceId &&
1180+
this.#contextMenuData.workspaceId !== this.activeWorkspace;
1181+
event.target.addEventListener(
1182+
'popuphidden',
1183+
() => {
1184+
this.#contextMenuData = null;
1185+
},
1186+
{ once: true }
1187+
);
11581188
}
11591189

11601190
updateWorkspaceActionsMenuContainer(event) {
1161-
const workspace = this.getActiveWorkspaceFromCache();
1191+
let workspace;
1192+
if (this.#contextMenuData?.workspaceId) {
1193+
workspace = this.getWorkspaceFromId(this.#contextMenuData.workspaceId);
1194+
} else {
1195+
workspace = this.getActiveWorkspaceFromCache();
1196+
}
11621197
let containerTabId = workspace.containerTabId;
11631198
return window.createUserContextMenu(event, {
11641199
isContextMenu: true,
@@ -2349,12 +2384,12 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
23492384
this._organizingWorkspaceStrip = true;
23502385
let workspaces = await this._workspaces();
23512386
let workspace = workspaces.workspaces.find(
2352-
(workspace) => workspace.uuid === this.activeWorkspace
2387+
(workspace) => workspace.uuid === (this.#contextMenuData?.workspaceId || this.activeWorkspace)
23532388
);
23542389
let userContextId = parseInt(event.target.getAttribute('data-usercontextid'));
23552390
workspace.containerTabId = userContextId + 0; // +0 to convert to number
23562391
await this.saveWorkspace(workspace);
2357-
await this._organizeWorkspaceStripLocations(workspace, true);
2392+
await this._organizeWorkspaceStripLocations(this.getActiveWorkspaceFromCache(), true);
23582393
await gZenWorkspaces.updateTabsContainers();
23592394
this.tabContainer._invalidateCachedTabs();
23602395
}
@@ -2365,7 +2400,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
23652400
{ id: 'zen-workspaces-delete-workspace-body' },
23662401
]);
23672402
if (Services.prompt.confirm(null, title, body)) {
2368-
await this.removeWorkspace(this.activeWorkspace);
2403+
await this.removeWorkspace(this.#contextMenuData?.workspaceId || this.activeWorkspace);
23692404
}
23702405
}
23712406

src/zen/workspaces/zen-workspaces.css

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@
4141
align-items: center;
4242
position: relative;
4343

44-
& .zen-workspace-icon[no-icon='true'] {
45-
width: 6px;
46-
height: 6px;
47-
background: light-dark(rgba(0, 0, 0, 0.4), rgba(255, 255, 255, 0.4));
48-
border-radius: 50%;
44+
& .zen-workspace-icon {
45+
pointer-events: none;
46+
47+
&[no-icon='true'] {
48+
width: 6px;
49+
height: 6px;
50+
background: light-dark(rgba(0, 0, 0, 0.4), rgba(255, 255, 255, 0.4));
51+
border-radius: 50%;
52+
}
4953
}
5054

5155
filter: grayscale(1);

0 commit comments

Comments
 (0)