effects/private: Encapsulate DND management, and clean up the store
Use methods with semantic naming instead of raw data manipulation, and make sure to perform clean up of DND data, so it won't haunt us back later e.g. when a window delegate is recreated not because of a drag of itself but due to a desktops rearrangement.
This commit is contained in:
parent
1f0a0c893a
commit
329731be2d
2 changed files with 17 additions and 3 deletions
|
@ -54,6 +54,15 @@ FocusScope {
|
|||
function saveDND(key: int, rect: rect) {
|
||||
dndManagerStore[key] = rect;
|
||||
}
|
||||
function containsDND(key: int): bool {
|
||||
return key in dndManagerStore;
|
||||
}
|
||||
function restoreDND(key: int): rect {
|
||||
return dndManagerStore[key];
|
||||
}
|
||||
function deleteDND(key: int) {
|
||||
delete dndManagerStore[key];
|
||||
}
|
||||
|
||||
KWinComponents.WindowThumbnailItem {
|
||||
id: otherScreenThumbnail
|
||||
|
@ -119,11 +128,11 @@ FocusScope {
|
|||
onItemAdded: (index, item) => {
|
||||
// restore/reparent from drop
|
||||
var key = item.client.internalId;
|
||||
if (key in heap.dndManagerStore) {
|
||||
if (heap.containsDND(key)) {
|
||||
expoLayout.forceLayout();
|
||||
var oldGlobalRect = heap.dndManagerStore[key];
|
||||
var oldGlobalRect = heap.restoreDND(key);
|
||||
item.restoreDND(oldGlobalRect);
|
||||
delete heap.dndManagerStore[key];
|
||||
heap.deleteDND(key);
|
||||
} else if (heap.effectiveOrganized) {
|
||||
// New window has opened in the middle of a running effect.
|
||||
// Make sure it is positioned before enabling its animations.
|
||||
|
|
|
@ -120,6 +120,9 @@ Item {
|
|||
|
||||
thumb.substate = "normal";
|
||||
}
|
||||
function deleteDND() {
|
||||
thumb.windowHeap.deleteDND(thumb.client.internalId);
|
||||
}
|
||||
|
||||
PlasmaCore.FrameSvgItem {
|
||||
anchors {
|
||||
|
@ -392,6 +395,7 @@ Item {
|
|||
// another virtual desktop (not another screen).
|
||||
if (typeof thumbSource !== "undefined") {
|
||||
// Except the case when it was dropped on the same desktop which it's already on, so let's return to normal state anyway.
|
||||
thumbSource.deleteDND();
|
||||
thumb.substate = "normal";
|
||||
}
|
||||
return;
|
||||
|
@ -401,6 +405,7 @@ Item {
|
|||
effect.checkItemDroppedOutOfScreen(globalPos, thumbSource);
|
||||
|
||||
// else, return to normal without reparenting
|
||||
thumbSource.deleteDND();
|
||||
thumb.substate = "normal";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue