protect user from changing to occupied edges

--Views should not move to already occupied screen
edges except in the case these are found in Shared
Layouts
pull/6/head
Michail Vourlakos 6 years ago
parent bb8a946140
commit ae2bc089ff

@ -148,38 +148,29 @@ PlasmaComponents.Page {
Component.onCompleted: screenRow.updateScreens(); Component.onCompleted: screenRow.updateScreens();
//they are used to restore the index when the screen edge
//is occupied
property bool acceptedIndex: true
property int previousIndex: -1
onCurrentIndexChanged: {
//it is used to restore the index when the screen edge
//is occupied
if (!acceptedIndex) {
acceptedIndex = true;
currentIndex = previousIndex;
}
}
onActivated: { onActivated: {
previousIndex = currentIndex; var succeed = false;
if (index === 0) { if (index === 0) {
var succeed = latteView.positioner.setCurrentScreen("primary"); succeed = latteView.positioner.setCurrentScreen("primary");
latteView.onPrimary = true; if (succeed) {
acceptedIndex = true; latteView.onPrimary = true;
} else if (!latteView.onPrimary){
console.log("the edge is already occupied!!!");
currentIndex = findScreen(latteView.positioner.currentScreenName);
}
} else if (index>0 && (index !== findScreen(latteView.positioner.currentScreenName) || latteView.onPrimary)) { } else if (index>0 && (index !== findScreen(latteView.positioner.currentScreenName) || latteView.onPrimary)) {
console.log("current index changed!!! :"+ index); console.log("current index changed!!! :"+ index);
console.log("screen must be changed..."); console.log("screen must be changed...");
var succeed = latteView.positioner.setCurrentScreen(textAt(index)); succeed = latteView.positioner.setCurrentScreen(textAt(index));
if(succeed) { if(succeed) {
latteView.onPrimary = false; latteView.onPrimary = false;
} else { } else {
console.log("the edge is already occupied!!!"); console.log("the edge is already occupied!!!");
acceptedIndex = false; currentIndex = findScreen(latteView.positioner.currentScreenName);
} }
} }
} }

Loading…
Cancel
Save