aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina/RootSubWindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core/libLumina/RootSubWindow.cpp')
-rw-r--r--src-qt5/core/libLumina/RootSubWindow.cpp87
1 files changed, 37 insertions, 50 deletions
diff --git a/src-qt5/core/libLumina/RootSubWindow.cpp b/src-qt5/core/libLumina/RootSubWindow.cpp
index 9ef6464e..322e524f 100644
--- a/src-qt5/core/libLumina/RootSubWindow.cpp
+++ b/src-qt5/core/libLumina/RootSubWindow.cpp
@@ -14,6 +14,7 @@
#define WIN_BORDER 5
#include <LIconCache.h>
+#include <DesktopSettings.h>
// === PUBLIC ===
RootSubWindow::RootSubWindow(QWidget *root, NativeWindow *win) : QFrame(root){
@@ -246,6 +247,14 @@ void RootSubWindow::LoadProperties( QList< NativeWindow::Property> list){
propertiesChanged(list, vals);
}
+QRect RootSubWindow::clientGlobalGeom(){
+ QRect tot = this->geometry();
+ QList<int> frame = WIN->property(NativeWindow::FrameExtents).value< QList<int> >();
+ //Now adjust this to take out the frame
+ tot.adjust(frame[0], frame[2], -frame[1], -frame[3]);
+ return tot;
+}
+
// === PUBLIC SLOTS ===
void RootSubWindow::clientClosed(){
//qDebug() << "Client Closed";
@@ -257,9 +266,9 @@ void RootSubWindow::LoadAllProperties(){
QList< NativeWindow::Property> list;
list << NativeWindow::WinTypes << NativeWindow::WinActions << NativeWindow::States
<< NativeWindow::MinSize << NativeWindow::MaxSize << NativeWindow::Title << NativeWindow::ShortTitle
- << NativeWindow::Icon << NativeWindow::Size << NativeWindow::GlobalPos << NativeWindow::Visible << NativeWindow::Active;
+ << NativeWindow::Icon << NativeWindow::Size << NativeWindow::GlobalPos;// << NativeWindow::Visible << NativeWindow::Active;
LoadProperties(list);
- WIN->requestProperty(NativeWindow::Visible, true);
+ //WIN->requestProperty(NativeWindow::Visible, true);
}
//Button Actions - public so they can be tied to key shortcuts and stuff as well
@@ -296,6 +305,7 @@ void RootSubWindow::startMoving(){
activeState = Move;
offset = this->mapFromGlobal(curpt);
setMouseCursor(activeState, true); //this one is an override cursor
+ //WinWidget->pause();
//Also need to capture the mouse
this->grabMouse();
}
@@ -312,24 +322,8 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
switch(props[i]){
case NativeWindow::Visible:
//qDebug() << "Got Visibility Change:" << vals[i] << this->geometry() << WIN->geometry();
- if(vals[i].toBool()){
- if(lastGeom.isNull()){ animResetProp = this->geometry(); }
- else{ animResetProp = lastGeom; }
- anim->setPropertyName("geometry");
- anim->setStartValue( QRect(animResetProp.toRect().center(), QSize(0,0)) );
- anim->setEndValue(animResetProp);
- this->setGeometry( anim->startValue().toRect() ); //ensure the window is the initial geom before it becomes visible
- anim->start();
- this->show();
- }else{
- animResetProp = this->geometry(); //hide event - should already be the right geom
- lastGeom = this->geometry();
- anim->setPropertyName("geometry");
- anim->setStartValue(this->geometry());
- anim->setEndValue( QRect(this->geometry().center(), QSize(0,0) ) );
- anim->start();
- QTimer::singleShot(anim->duration(), this, SLOT(hide()) );
- }
+ if(vals[i].toBool()){ loadAnimation( DesktopSettings::instance()->value(DesktopSettings::Animation, "window/appear", "random").toString(), NativeWindow::Visible, vals[i]); }
+ else{ loadAnimation( DesktopSettings::instance()->value(DesktopSettings::Animation, "window/disappear", "random").toString(), NativeWindow::Visible, vals[i]); }
break;
case NativeWindow::Title:
titleLabel->setText(vals[i].toString());
@@ -340,11 +334,6 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
else{ otherB->setIcon(vals[i].value<QIcon>()); }
break;
case NativeWindow::GlobalPos:
- //qDebug() << "Got Global Pos:" << this->pos() << WinWidget->mapToGlobal(QPoint(0,0)) << WIN->geometry().topLeft() << vals[i].toPoint();
- if(activeState == RootSubWindow::Normal){
- this->move( WIN->geometry().topLeft() );
- }
- break;
case NativeWindow::Size:
//qDebug() << " - SIZE CHANGE";
if(WIN->property(NativeWindow::FrameExtents).isNull() && (i<props.indexOf(NativeWindow::FrameExtents)) ){
@@ -353,16 +342,25 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
vals << vals.takeAt(i);
i--;
}else if(anim->state() != QPropertyAnimation::Running ){
- if(vals[i].toSize() != WinWidget->size() && activeState==Normal){
- //qDebug() << "Got Widget Size Change:" << vals[i].toSize() << WinWidget->size();
- WinWidget->resize(vals[i].toSize());
- this->resize( WIN->geometry().size() );
- //qDebug() << " - Size after change:" << WinWidget->size() << this->size() << WIN->geometry();
+ if(WIN->property(NativeWindow::Size).toSize() != WinWidget->size() && activeState==Normal ){
+ this->setGeometry(WIN->geometry());
}
}
break;
case NativeWindow::MinSize:
- WinWidget->setMinimumSize(vals[i].toSize());
+ if(vals[i].toSize().isValid()){
+ //Just larger than titlebar, with enough space for 8 characters in the titlebar (+4 buttons)
+ //qDebug() << "Got invalid Min Size: Set a reasonable default minimum";
+ WinWidget->setMinimumSize( QSize( this->fontMetrics().height()*4 + this->fontMetrics().width("O")*10, this->fontMetrics().height()*10) );
+ WIN->setProperty(NativeWindow::MinSize, WinWidget->minimumSize());
+ }else{
+ WinWidget->setMinimumSize(vals[i].toSize());
+ }
+ if(WIN->property(NativeWindow::Size).toSize().width() < WinWidget->minimumSize().width() \
+ || WIN->property(NativeWindow::Size).toSize().height() < WinWidget->minimumSize().height() ){
+ WIN->setProperty(NativeWindow::Size, WinWidget->minimumSize(), true); //force this
+ //WinWidget->resize(WinWidget->minimumSize());
+ }
break;
case NativeWindow::MaxSize:
WinWidget->setMaximumSize(vals[i].toSize());
@@ -388,20 +386,6 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
}
}
-void RootSubWindow::animFinished(){
- if(closing){ this->close(); return;}
- else if(anim->propertyName()=="geometry"){
- if(!animResetProp.isNull()){
- /*qDebug() << "Animation Finished, Reset Geometry:" << animResetProp;
- qDebug() << " - Starting Value:" << anim->startValue();
- qDebug() << " - Ending Value:" << anim->endValue();
- qDebug() << " - Current Value:" << this->geometry();*/
- this->setGeometry( animResetProp.toRect() );
- }
- }
- animResetProp = QVariant(); //clear the variable
-}
-
// === PROTECTED ===
void RootSubWindow::mousePressEvent(QMouseEvent *ev){
activate();
@@ -409,7 +393,7 @@ void RootSubWindow::mousePressEvent(QMouseEvent *ev){
//qDebug() << "Frame Mouse Press Event";
offset.setX(0); offset.setY(0);
if(activeState != Normal){ return; } // do nothing - already in a state of grabbed mouse
- this->activate();
+ //this->activate();
if(this->childAt(ev->pos())!=0){
//Check for any non-left-click event and skip it
if(ev->button()!=Qt::LeftButton){ return; }
@@ -420,6 +404,8 @@ void RootSubWindow::mousePressEvent(QMouseEvent *ev){
activeState = getStateAtPoint(ev->pos(), true); //also have it set the offset variable
}
setMouseCursor(activeState, true); //this one is an override cursor
+ //if(activeState!=Normal){WinWidget->pause(); }
+ if(activeState!=Normal && activeState!=Move){WinWidget->pause(); }
QFrame::mousePressEvent(ev);
}
@@ -498,7 +484,9 @@ void RootSubWindow::mouseMoveEvent(QMouseEvent *ev){
default:
break;
}
- this->setGeometry(geom);
+ //if( (geom.width()%2==0 && geom.height()%2==0) || activeState==Move){
+ this->setGeometry(geom);
+ //}
}
QFrame::mouseMoveEvent(ev);
}
@@ -511,6 +499,8 @@ void RootSubWindow::mouseReleaseEvent(QMouseEvent *ev){
otherM->popup(ev->globalPos());
return;
}
+ if(activeState!=Normal){ WinWidget->resume(); }
+ if(activeState!=Normal && activeState!=Move){WinWidget->resume(); }
activeState = Normal;
QApplication::restoreOverrideCursor();
setMouseCursor( getStateAtPoint(ev->pos()) );
@@ -529,8 +519,5 @@ void RootSubWindow::moveEvent(QMoveEvent *ev){
QFrame::moveEvent(ev);
if(!closing && anim->state()!=QAbstractAnimation::Running){
moveTimer->start();
- //WinWidget->resyncWindow();
- //WIN->requestProperty(NativeWindow::GlobalPos, ev->pos() );
}
-
}
bgstack15