aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-08-31 11:42:33 -0400
committerKen Moore <ken@ixsystems.com>2017-08-31 11:42:33 -0400
commit2ed1ee7459868dca7228d61202a38c7c9c3e23f8 (patch)
tree60d44c92e91f63662ceef064b9f9736f0ffca6ce /src-qt5
parentA but more work on Lumina2: (diff)
downloadlumina-2ed1ee7459868dca7228d61202a38c7c9c3e23f8.tar.gz
lumina-2ed1ee7459868dca7228d61202a38c7c9c3e23f8.tar.bz2
lumina-2ed1ee7459868dca7228d61202a38c7c9c3e23f8.zip
Get all the single-window interactions finished up.
Now the multiple types of animations will not conflict/overwrite each other, and the window itself will be properly "paused" for animations. Also fix up some window resize calculation errors, so the offset to the mouse position is properly handled now
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core/libLumina/NativeEmbedWidget.cpp19
-rw-r--r--src-qt5/core/libLumina/NativeEmbedWidget.h1
-rw-r--r--src-qt5/core/libLumina/RootSubWindow-animations.cpp8
-rw-r--r--src-qt5/core/libLumina/RootSubWindow.cpp93
4 files changed, 68 insertions, 53 deletions
diff --git a/src-qt5/core/libLumina/NativeEmbedWidget.cpp b/src-qt5/core/libLumina/NativeEmbedWidget.cpp
index 21b4494f..96393e98 100644
--- a/src-qt5/core/libLumina/NativeEmbedWidget.cpp
+++ b/src-qt5/core/libLumina/NativeEmbedWidget.cpp
@@ -67,7 +67,7 @@ inline void registerClientEvents(WId id){
// ============
//Simplification functions for the XCB/XLib interactions
void NativeEmbedWidget::syncWinSize(QSize sz){
- if(WIN==0 || paused){ return; }
+ if(WIN==0){ return; }
else if(!sz.isValid()){ sz = this->size(); } //use the current widget size
//qDebug() << "Sync Window Size:" << sz;
//if(sz == winSize){ return; } //no change
@@ -117,8 +117,14 @@ QImage NativeEmbedWidget::windowImage(QRect geom){
return img;
-}
+}
+void NativeEmbedWidget::setWinUnpaused(){
+ paused = false;
+ if(!DISABLE_COMPOSITING){
+ repaintWindow(); //update the cached image right away
+ }
+}
// ============
// PUBLIC
// ============
@@ -215,6 +221,7 @@ void NativeEmbedWidget::resume(){
}else{
repaintWindow(); //update the cached image right away
}
+ QTimer::singleShot(10, this, SLOT(setWinUnpaused()) );
}
void NativeEmbedWidget::resyncWindow(){
@@ -267,7 +274,7 @@ void NativeEmbedWidget::reregisterEvents(){
// ==============
void NativeEmbedWidget::resizeEvent(QResizeEvent *ev){
QWidget::resizeEvent(ev);
- if(WIN!=0){
+ if(WIN!=0 && !paused){
syncWinSize(ev->size());
} //syncronize the window with the new widget size
}
@@ -283,13 +290,13 @@ void NativeEmbedWidget::hideEvent(QHideEvent *ev){
}
void NativeEmbedWidget::paintEvent(QPaintEvent *ev){
- if(WIN==0 || paused){ return; }
+ if(WIN==0){ return; }
//else if( winImage.isNull() ){return; }
else if(DISABLE_COMPOSITING){
// Just make it solid black (underneath the embedded window)
// - only visible when looking through the edge of another window)
- QPainter P(this);
- P.fillRect(ev->rect(), Qt::black);
+ //QPainter P(this);
+ //P.fillRect(ev->rect(), Qt::black);
return;
}
//renderWindowToWidget(WIN->id(), this);
diff --git a/src-qt5/core/libLumina/NativeEmbedWidget.h b/src-qt5/core/libLumina/NativeEmbedWidget.h
index 5025f692..16bb46dc 100644
--- a/src-qt5/core/libLumina/NativeEmbedWidget.h
+++ b/src-qt5/core/libLumina/NativeEmbedWidget.h
@@ -36,6 +36,7 @@ private slots:
void showWindow();
QImage windowImage(QRect geom);
+ void setWinUnpaused();
public:
NativeEmbedWidget(QWidget *parent);
diff --git a/src-qt5/core/libLumina/RootSubWindow-animations.cpp b/src-qt5/core/libLumina/RootSubWindow-animations.cpp
index b1489ad6..54524838 100644
--- a/src-qt5/core/libLumina/RootSubWindow-animations.cpp
+++ b/src-qt5/core/libLumina/RootSubWindow-animations.cpp
@@ -19,6 +19,7 @@ QStringList RootSubWindow::validAnimations(NativeWindow::Property prop){
}
void RootSubWindow::loadAnimation(QString name, NativeWindow::Property prop, QVariant nval){
+ if(anim->state()==QAbstractAnimation::Running){ return; } //already running
animResetProp.clear();
//Special case - random animation each time
if(name=="random"){
@@ -73,7 +74,6 @@ void RootSubWindow::loadAnimation(QString name, NativeWindow::Property prop, QVa
} //end of Visibility animation
else if(prop == NativeWindow::Size){
//This is pretty much all geometry animations where the window is visible->visible
- animResetProp = QVariant(); //reset this - not needed here
anim->setPropertyName("geometry");
anim->setStartValue(this->geometry());
anim->setEndValue(nval.toRect());
@@ -104,11 +104,11 @@ void RootSubWindow::animFinished(){
//qDebug() << "Sub Window geometry:" << clientg;
WIN->setProperties(QList< NativeWindow::Property>() << NativeWindow::Size << NativeWindow::GlobalPos,
QList<QVariant>() << clientg.size() << clientg.topLeft() );
- WinWidget->resyncWindow(); //also let the window know about the current geometry
}
}
+ WinWidget->resyncWindow(); //also let the window know about the current geometry
}
animResetProp = QVariant(); //clear the variable
- QTimer::singleShot(10, WinWidget, SLOT(resume()) );
-
+ //QTimer::singleShot(10, WinWidget, SLOT(resume()) );
+ WinWidget->resume();
}
diff --git a/src-qt5/core/libLumina/RootSubWindow.cpp b/src-qt5/core/libLumina/RootSubWindow.cpp
index 36da43c2..9eb62ff5 100644
--- a/src-qt5/core/libLumina/RootSubWindow.cpp
+++ b/src-qt5/core/libLumina/RootSubWindow.cpp
@@ -57,7 +57,7 @@ RootSubWindow::ModState RootSubWindow::getStateAtPoint(QPoint pt, bool setoffset
if(setoffset){ offset.setX(pt.x()); offset.setY(pt.y()); } //difference from top-left corner
return ResizeTopLeft;
}else if(pt.x() > (this->width()*4.0/5.0)){
- if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(pt.y()); } //difference from top-right corner
+ if(setoffset){ offset.setX(pt.x()-this->width()); offset.setY(pt.y()); } //difference from top-right corner
return ResizeTopRight;
}else{
if(setoffset){ offset.setX(0); offset.setY(pt.y()); } //difference from top edge (X does not matter)
@@ -66,13 +66,13 @@ RootSubWindow::ModState RootSubWindow::getStateAtPoint(QPoint pt, bool setoffset
}else if(pt.y() > (this->height()-WIN_BORDER) ){
//One of the bottom options
if(pt.x() < this->width()/5){
- if(setoffset){ offset.setX(pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-left corner
+ if(setoffset){ offset.setX(pt.x()); offset.setY(pt.y()-this->height()); } //difference from bottom-left corner
return ResizeBottomLeft;
}else if(pt.x() > (this->width()*4.0/5.0)){
- if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-right corner
+ if(setoffset){ offset.setX(pt.x()-this->width()); offset.setY(pt.y()-this->height()); } //difference from bottom-right corner
return ResizeBottomRight;
}else{
- if(setoffset){ offset.setX(0); offset.setY(this->height() - pt.y()); } //difference from bottom edge (X does not matter)
+ if(setoffset){ offset.setX(0); offset.setY(pt.y()-this->height()); } //difference from bottom edge (X does not matter)
return ResizeBottom;
}
}else if(pt.x() < WIN_BORDER){
@@ -81,7 +81,7 @@ RootSubWindow::ModState RootSubWindow::getStateAtPoint(QPoint pt, bool setoffset
if(setoffset){ offset.setX(pt.x()); offset.setY(pt.y()); } //difference from top-left corner
return ResizeTopLeft;
}else if(pt.y() > (this->height()*4.0/5.0)){
- if(setoffset){ offset.setX(pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-left corner
+ if(setoffset){ offset.setX(pt.x()); offset.setY(pt.y()-this->height()); } //difference from bottom-left corner
return ResizeBottomLeft;
}else{
if(setoffset){ offset.setX(pt.x()); offset.setY(0); } //difference from left edge (Y does not matter)
@@ -90,13 +90,13 @@ RootSubWindow::ModState RootSubWindow::getStateAtPoint(QPoint pt, bool setoffset
}else if(pt.x() > (this->width()-WIN_BORDER) ){
//Right side options
if(pt.y() < this->height()/5){
- if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(pt.y()); } //difference from top-right corner
+ if(setoffset){ offset.setX(pt.x()-this->width()); offset.setY(pt.y()); } //difference from top-right corner
return ResizeTopRight;
}else if(pt.y() > (this->height()*4.0/5.0)){
- if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-right corner
+ if(setoffset){ offset.setX(pt.x()-this->width()); offset.setY(pt.y()-this->height()); } //difference from bottom-right corner
return ResizeBottomRight;
}else{
- if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(0); } //difference from right edge (Y does not matter)
+ if(setoffset){ offset.setX(pt.x()-this->width()); offset.setY(0); } //difference from right edge (Y does not matter)
return ResizeRight;
}
}else{
@@ -187,11 +187,12 @@ void RootSubWindow::initWindowFrame(){
titleBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
mainLayout->addWidget(titleBar);
mainLayout->addWidget(WinWidget);
+ mainLayout->setAlignment(titleBar, Qt::AlignTop);
//Setup the cursors for the buttons
closeB->setCursor(Qt::ArrowCursor);
minB->setCursor(Qt::ArrowCursor);
maxB->setCursor(Qt::ArrowCursor);
- otherM->setCursor(Qt::ArrowCursor);
+ otherB->setCursor(Qt::ArrowCursor);
titleLabel->setCursor(Qt::ArrowCursor);
WinWidget->setCursor(Qt::ArrowCursor);
//Now all the stylesheet options
@@ -351,12 +352,14 @@ void RootSubWindow::startMoving(){
offset = this->mapFromGlobal(curpt);
setMouseCursor(activeState, true); //this one is an override cursor
//WinWidget->pause();
- //Also need to capture the mouse
this->grabMouse();
}
void RootSubWindow::startResizing(){
-
+ activeState = getStateAtPoint( this->mapFromGlobal(QCursor::pos()), true); //also have it set the offset variable
+ setMouseCursor(activeState, true); //this one is an override cursor
+ //WinWidget->pause();
+ this->grabMouse();
}
// === PRIVATE SLOTS ===
@@ -366,9 +369,11 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
//qDebug() << "RootSubWindow: Property Changed:" << props[i] << vals[i];
switch(props[i]){
case NativeWindow::Visible:
- //qDebug() << "Got Visibility Change:" << vals[i] << this->geometry() << WIN->geometry();
- 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]); }
+ if(!WinWidget->isPaused() && (this->isVisible()!=vals[i].toBool()) && activeState==Normal ){
+ qDebug() << "Got Visibility Change:" << vals[i] << this->geometry() << WIN->geometry();
+ 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());
@@ -386,9 +391,9 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
props << props.takeAt(i);
vals << vals.takeAt(i);
i--;
- }else if(anim->state() != QPropertyAnimation::Running && !WinWidget->isPaused()){
- if(WIN->property(NativeWindow::Size).toSize() != WinWidget->size() && activeState==Normal ){
- //qDebug() << "Got Direct Geometry Change:" << WIN->geometry();
+ }else if(!WinWidget->isPaused() && !this->isVisible() && activeState==Normal){
+ if(WIN->property(NativeWindow::Size).toSize() != WinWidget->size()){
+ qDebug() << "Got Direct Geometry Change:" << WIN->geometry();
this->setGeometry(WIN->geometry());
}
}
@@ -437,28 +442,24 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
void RootSubWindow::mousePressEvent(QMouseEvent *ev){
activate();
this->raise();
- //WinWidget->raiseWindow();
+ QFrame::mousePressEvent(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();
- if(this->childAt(ev->pos())!=0){
- //Check for any non-left-click event and skip it
- if(ev->button()!=Qt::LeftButton){ return; }
- activeState = Move;
- offset.setX(ev->pos().x()); offset.setY(ev->pos().y());
- }else{
- //Clicked on the frame somewhere
- activeState = getStateAtPoint(ev->pos(), true); //also have it set the offset variable
+ offset.setX(0); offset.setY(0);
+ if(ev->button()==Qt::LeftButton){
+ if(this->childAt(ev->pos())!=0){
+ //Clicked on the titlebar
+ startMoving();
+ }else{
+ //Clicked on the frame somewhere
+ startResizing();
+ }
}
- setMouseCursor(activeState, true); //this one is an override cursor
- //if(activeState!=Normal){WinWidget->pause(); }
- if(activeState!=Normal && activeState!=Move){WinWidget->pause(); }
- QFrame::mousePressEvent(ev);
+
}
void RootSubWindow::mouseMoveEvent(QMouseEvent *ev){
- //activate(); //make sure this window is "Active" on mouse over
+ QFrame::mouseMoveEvent(ev);
if(activeState == Normal){
setMouseCursor( getStateAtPoint(ev->pos()) ); //just update the mouse cursor
}else{
@@ -533,10 +534,15 @@ void RootSubWindow::mouseMoveEvent(QMouseEvent *ev){
break;
}
//if( (geom.width()%2==0 && geom.height()%2==0) || activeState==Move){
- this->setGeometry(geom);
+ //qDebug() << " Change Window:" << this->geometry() << geom;
+ if(activeState==Move){ this->setGeometry(geom); }
+ else{
+ //qDebug() << " Change Window Dimensions:" << this->geometry() << geom;
+ //qDebug() << " - Mouse Pos:" << ev->globalPos() << ev->pos() << "Offset" << offset;
+ this->setGeometry(geom);
+ }
//}
}
- QFrame::mouseMoveEvent(ev);
}
void RootSubWindow::mouseReleaseEvent(QMouseEvent *ev){
@@ -544,18 +550,19 @@ void RootSubWindow::mouseReleaseEvent(QMouseEvent *ev){
//qDebug() << "Frame Mouse Release Event";
QFrame::mouseReleaseEvent(ev);
if( (activeState==Normal) && (titleBar->geometry().contains(ev->pos())) && (ev->button()==Qt::RightButton) ){
- WinWidget->raiseWindow();//need to ensure the native window is always on top of this frame but under the menu
+ //WinWidget->raiseWindow();//need to ensure the native window is always on top of this frame but under the menu
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()) );
+ if(activeState!=Normal){
+ if(WinWidget->isPaused()){ WinWidget->resume(); }
+ activeState = Normal;
+ QApplication::restoreOverrideCursor();
+ setMouseCursor( getStateAtPoint(ev->pos()) );
+ }
if(QFrame::mouseGrabber() == this){ this->releaseMouse(); }
activate();
- QTimer::singleShot(0, WinWidget, SLOT(raiseWindow()) );
+ //QTimer::singleShot(0, WinWidget, SLOT(raiseWindow()) );
}
/*void RootSubWindow::enterEvent(QEvent *ev){
@@ -573,7 +580,7 @@ void RootSubWindow::mouseReleaseEvent(QMouseEvent *ev){
void RootSubWindow::moveEvent(QMoveEvent *ev){
//qDebug() << "Got Move Event:" << ev->pos() << WinWidget->geometry();
QFrame::moveEvent(ev);
- if(!closing && anim->state()!=QAbstractAnimation::Running){
+ if(!closing && !WinWidget->isPaused()){
moveTimer->start();
}
}
bgstack15