From 671c2e8a4d65648e0c6747799a5a5ff0c0846cee Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 16 Aug 2017 16:06:01 -0400 Subject: Get rudimentary y-dimension tiling working. --- src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 44 ++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'src-qt5/core-utils/lumina-xconfig/MainUI.cpp') diff --git a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp index 246fba62..b97d1b3b 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -197,26 +197,46 @@ void MainUI::updateNewScreenResolutions(){ } void MainUI::tileScreens(bool activeonly){ + qDebug() << "Tile Windows in Y Dimension"; QList wins = ui->mdiArea->subWindowList(); QRegion total; int xpos, ypos; xpos = ypos = 0; QMdiSubWindow *cur = 0; - float diff; while(!wins.isEmpty()){ cur=0; - diff = -1; - //Scan for the window closest to the current X value - for(x=0; xgeometry().y()geometry().y() && wins[y]->geometry().y()>ypos){ cur = wins[y]; } - } + for(int i=0; ipos().y() < cur->pos().y()){ cur = wins[i]; } } - if(cur!=0){ - + if(cur==0){ + //Note: This should **never** happen + qDebug() << "No windows found below y=:" << ypos; + //need to move the reference point + QRect bounding = total.boundingRect(); + ypos+= (bounding.height()/2); + }else{ + if(total.isNull()){ + //First window handled + cur->move(cur->pos().x(), ypos); + }else{ + int newy = ypos; + bool overlap = true; + while(overlap){ + QRegion tmp(cur->pos().x(), newy, cur->width(), cur->height()); + QRegion diff = tmp.subtracted(total); + overlap = (diff.boundingRect()!=tmp.boundingRect()); + qDebug() << "Check Overlap:" << newy << overlap << tmp.boundingRect() << diff.boundingRect(); + if(overlap){ + QRect bound = diff.boundingRect(); + if(newy!=bound.top()){ newy = bound.top(); } + else{ newy = bound.bottom(); } + } + } + cur->move(cur->pos().x(), newy); + } + total = total.united(cur->geometry()); + wins.removeAll(cur); } } } -- cgit