Skip to content

Commit ed88aaf

Browse files
committed
Fix workspace position dragging on Linux (Fixes #7542)
This commit fixes an issue where dragging workspaces to change their position doesn't work on Linux platforms. The main changes include: 1. Added Linux-specific drag and drop handling with a transparent drag image 2. Enhanced dragover event handling for better visual feedback on Linux 3. Improved CSS styles for drag and drop elements on Linux 4. Added clearer comments to explain the reorder mode behavior The issue was that the drag and drop functionality wasn't working properly on Linux due to platform-specific behavior differences. This fix ensures that workspace reordering works consistently across all platforms.
1 parent d94deed commit ed88aaf

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/zen/workspaces/ZenWorkspaces.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
10181018
element.classList.add('identity-color-' + containerGroup.color);
10191019
element.setAttribute('data-usercontextid', containerGroup.userContextId);
10201020
}
1021+
// Set draggable attribute based on reorder mode
10211022
if (this.isReorderModeOn(browser)) {
10221023
element.setAttribute('draggable', 'true');
10231024
}
@@ -1028,6 +1029,15 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
10281029
this.draggedElement = element;
10291030
event.dataTransfer.effectAllowed = 'move';
10301031
event.dataTransfer.setData('text/plain', element.getAttribute('zen-workspace-id'));
1032+
1033+
// Create a transparent drag image for Linux
1034+
if (AppConstants.platform === 'linux') {
1035+
const dragImage = document.createElement('canvas');
1036+
dragImage.width = 1;
1037+
dragImage.height = 1;
1038+
event.dataTransfer.setDragImage(dragImage, 0, 0);
1039+
}
1040+
10311041
element.classList.add('dragging');
10321042
} else {
10331043
event.preventDefault();
@@ -1041,6 +1051,15 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
10411051
if (this.isReorderModeOn(browser) && this.draggedElement) {
10421052
event.preventDefault();
10431053
event.dataTransfer.dropEffect = 'move';
1054+
1055+
// Ensure the dragover effect is visible on Linux
1056+
if (AppConstants.platform === 'linux') {
1057+
const targetId = element.getAttribute('zen-workspace-id');
1058+
const draggedId = this.draggedElement.getAttribute('zen-workspace-id');
1059+
if (targetId !== draggedId) {
1060+
element.classList.add('dragover');
1061+
}
1062+
}
10441063
}
10451064
}.bind(browser.ZenWorkspaces)
10461065
);
@@ -1150,6 +1169,11 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
11501169
if (this.isReorderModeOn(browser) && this.draggedElement) {
11511170
event.preventDefault();
11521171
event.dataTransfer.dropEffect = 'move';
1172+
1173+
// Ensure the dragover effect is visible on Linux
1174+
if (AppConstants.platform === 'linux') {
1175+
element.classList.add('dragover');
1176+
}
11531177
}
11541178
}.bind(browser.ZenWorkspaces)
11551179
);
@@ -1259,6 +1283,8 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
12591283
// Update draggable attribute
12601284
const workspaceElements = document.querySelectorAll('.zen-workspace-button');
12611285
workspaceElements.forEach((elem) => {
1286+
// When reorder mode is toggled off, remove draggable attribute
1287+
// When reorder mode is toggled on, set draggable attribute
12621288
if (isActive) {
12631289
elem.removeAttribute('draggable');
12641290
} else {

src/zen/workspaces/zen-workspaces.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,34 @@
365365
background-color: var(--toolbarbutton-icon-fill-attention);
366366
}
367367

368+
/* Enhanced visual feedback for Linux platform */
369+
@supports (-moz-gtk-csd-available) {
370+
.zen-workspace-button.dragover {
371+
background-color: color-mix(in srgb, var(--toolbarbutton-icon-fill-attention) 15%, transparent);
372+
}
373+
374+
.zen-workspace-button.dragover::after {
375+
height: 3px;
376+
}
377+
}
378+
368379
.zen-workspace-last-place-drop-target.dragover {
369380
background-color: var(--toolbarbutton-icon-fill-attention);
370381
}
371382

383+
/* Enhanced visual feedback for Linux platform */
384+
@supports (-moz-gtk-csd-available) {
385+
.zen-workspace-last-place-drop-target {
386+
height: 6px;
387+
margin: 4px 0;
388+
}
389+
390+
.zen-workspace-last-place-drop-target.dragover {
391+
background-color: var(--toolbarbutton-icon-fill-attention);
392+
box-shadow: 0 0 4px var(--toolbarbutton-icon-fill-attention);
393+
}
394+
}
395+
372396
#PanelUI-zen-workspaces-reorder-mode[active='true'] {
373397
color: var(--toolbarbutton-icon-fill-attention) !important;
374398
}

0 commit comments

Comments
 (0)