aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/LDesktop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-desktop/LDesktop.cpp')
-rw-r--r--lumina-desktop/LDesktop.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp
index 80e28e59..c9168651 100644
--- a/lumina-desktop/LDesktop.cpp
+++ b/lumina-desktop/LDesktop.cpp
@@ -11,7 +11,7 @@
#include <LuminaX11.h>
#include "LWinInfo.h"
-#define DEBUG 0
+#define DEBUG 1
LDesktop::LDesktop(int deskNum, bool setdefault) : QObject(){
@@ -188,7 +188,7 @@ LDPluginContainer* LDesktop::CreateDesktopPluginContainer(LDPlugin *plug){
LDPluginContainer *win = new LDPluginContainer(plug, desktoplocked);
if(desktoplocked){
bgDesktop->addSubWindow(win, Qt::Tool | Qt::FramelessWindowHint);
- }else{ bgDesktop->addSubWindow(win, Qt::Tool | Qt::FramelessWindowHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); }
+ }else{ bgDesktop->addSubWindow(win, Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); }
win->loadInitialPosition();
if(DEBUG){
qDebug() << "Initial DP Geom:" << plug->geometry();
@@ -197,9 +197,9 @@ LDPluginContainer* LDesktop::CreateDesktopPluginContainer(LDPlugin *plug){
win->show();
plug->update();
win->update();
- QApplication::processEvents();
bgDesktop->update();
QApplication::processEvents();
+ QApplication::processEvents();
connect(win, SIGNAL(PluginRemoved(QString)), this, SLOT(DesktopPluginRemoved(QString)) );
return win;
@@ -208,20 +208,20 @@ LDPluginContainer* LDesktop::CreateDesktopPluginContainer(LDPlugin *plug){
QPoint LDesktop::findNewPluginLocation(QRegion avail, QSize winsize){
//This just searches through the region of available space until it find the first location where it
// will fit without overlapping anything else (scanning left->right, top->bottom)
+ //return QPoint(-1,-1); //just for testing
QRect bounds = avail.boundingRect();
+ qDebug() << "Bounds:" << bounds;
if(bounds.width()<winsize.width() || bounds.height()<winsize.height()){ return QPoint(-1,-1); }
- //qDebug() << "Bounds:" << bounds;
QPoint pt = bounds.topLeft(); //start in upper-left corner
bool found = false;
- //qDebug() << "Check Availability:" << bounds << winsize;
+ if(DEBUG){ qDebug() << "Check Availability:" << bounds << winsize; }
while(pt.y()+winsize.height() < bounds.bottom() && !found){
int dy = winsize.height()/2;
while(pt.x()+winsize.width() < bounds.right() && !found){
- //qDebug() << "Check X:" << pt << winsize;
//Check the horizontal position (incrementing as necessary)
QRect inter = avail.intersected(QRect(pt, winsize)).boundingRect();
- //qDebug() << " - Inter:" << inter;
+ if(DEBUG){ qDebug() << "Check X:" << pt << " - Inter:" << inter; }
if(inter.size() == winsize && avail.contains(inter) ){ found = true; } //use this point
else{
int dx = winsize.width() - inter.width();
@@ -238,7 +238,7 @@ QPoint LDesktop::findNewPluginLocation(QRegion avail, QSize winsize){
//Nothing in the horizontal direction - increment the vertical dimension
pt.setX( bounds.left() ); //reset back to the left-most edge
pt.setY( pt.y()+dy );
- //qDebug() << "Check Y:" << pt << dy;
+ if(DEBUG){ qDebug() << "Check Y:" << pt << dy; }
}
}
//qDebug() << "Found Point:" << found << pt;
@@ -413,13 +413,16 @@ void LDesktop::UpdateDesktop(){
}
}
//Now get an accounting of all the available/used space
- QRegion avail(this->availableScreenGeom());
- if(avail.isEmpty()){ avail = QRegion( QRect(QPoint(0,0),desktop->screenGeometry(desktopnumber).size()) ); }
+ QRegion avail;//Note that this is child-geometry space
+ if(!bgDesktop->isVisible()){ avail = QRegion( QRect(QPoint(0,0),desktop->screenGeometry(desktopnumber).size()) ); }
+ else{ avail = QRegion(QRect(QPoint(0,0),bgDesktop->size()) ); qDebug() << "Desktop size:" << bgDesktop->size(); }
//qDebug() << "Available Screen Geom:" << avail.boundingRect();
- QList<QMdiSubWindow*> wins = bgDesktop->subWindowList();
+ //avail = avail.subtracted( bgDesktop->childrenRegion() ); //
+ /*QList<QMdiSubWindow*> wins = bgDesktop->subWindowList();
for(int i=0; i<wins.length(); i++){
- if(avail.contains(wins[i]->geometry())){ avail = avail.subtracted( QRegion(wins[i]->geometry()) ); }
- }
+ QRect geom = wins[i]->geometry()
+ if(avail.contains(wins[i]->geometry())){ avail = avail.subtracted( QRegion(wins[i]->geometry()) ); }
+ }*/
//qDebug() << " - after removals:" << avail.boundingRect();
//Now add/update plugins
for(int i=0; i<plugins.length(); i++){
@@ -442,22 +445,23 @@ void LDesktop::UpdateDesktop(){
if(DEBUG){ qDebug() << " --- Show Plugin"; }
PLUGINS << plug;
QApplication::processEvents(); //need a moment between plugin/container creation
+ QRegion tmpavail = avail - bgDesktop->childrenRegion(); //currently available space right now
LDPluginContainer *cont = CreateDesktopPluginContainer(plug);
cont->show();
QApplication::processEvents();
if(!cont->hasFixedPosition()){
//Need to arrange the location of the plugin (leave size alone)
if(DEBUG){ qDebug() << " --- Floating Plugin - find a spot for it"; }
- QPoint pt = findNewPluginLocation(avail, cont->size());
- if(pt.x()>=0 && pt.y()>=0){
+ QPoint pt = findNewPluginLocation(tmpavail, cont->size());
+ if(pt.x()>=0 && pt.y()>=0){
cont->saveNewPosition(pt);
- QTimer::singleShot(1000, cont, SLOT(loadInitialPosition()) ); //re-load geometry in a moment
+ QTimer::singleShot(500, cont, SLOT(loadInitialPosition()) ); //re-load geometry in a moment
if(DEBUG){ qDebug() << " --- Moving to point:" << pt; }
}
}
//Done with this plugin - removed it's area from the available space
if(DEBUG){ qDebug() << " --- Done Creating Plugin Container" << cont->geometry(); }
- avail = avail.subtracted( QRegion(cont->geometry()) );
+ //avail = avail.subtracted( QRegion(cont->geometry()) );
}
}
bgstack15