diff options
author | Ken Moore <ken@ixsystems.com> | 2016-11-11 17:31:40 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2016-11-11 17:31:40 -0500 |
commit | 522e8444ec27ff825a33d7447a0011cc8b5749c1 (patch) | |
tree | 0c64d8d26e4fafccacb7834206723a058b54b866 | |
parent | Oops - forgot to add some files to the previous commits. (diff) | |
download | lumina-522e8444ec27ff825a33d7447a0011cc8b5749c1.tar.gz lumina-522e8444ec27ff825a33d7447a0011cc8b5749c1.tar.bz2 lumina-522e8444ec27ff825a33d7447a0011cc8b5749c1.zip |
Fix up the panel autohide routine so it actually resizes the panels instead of just moving them around.
-rw-r--r-- | src-qt5/core/lumina-desktop/LPanel.cpp | 44 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop/LPanel.h | 4 |
2 files changed, 37 insertions, 11 deletions
diff --git a/src-qt5/core/lumina-desktop/LPanel.cpp b/src-qt5/core/lumina-desktop/LPanel.cpp index 933dc778..62534acb 100644 --- a/src-qt5/core/lumina-desktop/LPanel.cpp +++ b/src-qt5/core/lumina-desktop/LPanel.cpp @@ -121,6 +121,7 @@ void LPanel::UpdatePanel(bool geomonly){ layout->setDirection(QBoxLayout::TopToBottom); } int ht = qRound(settings->value(PPREFIX+"height", 30).toDouble()); //this is technically the distance into the screen from the edge + fullwidth = ht; //save this for later if(ht<=1){ ht = 30; } //some kind of error in the saved height - use the default value int hidesize = qRound(ht*0.01); //use 1% of the panel size if(hidesize<2){ hidesize=2; } //minimum of 2 pixels (need space for the mouse to go over it) @@ -151,9 +152,10 @@ void LPanel::UpdatePanel(bool geomonly){ if(!hidden){ LSession::handle()->XCB->ReserveLocation(this->winId(), this->geometry(), "top"); } else{ LSession::handle()->XCB->ReserveLocation(this->winId(), QRect(xloc, yloc, this->width(), hidesize), "top"); - hidepoint = QPoint(xloc, yloc+hidesize-ht); + hidepoint = QPoint(xloc, yloc); showpoint = QPoint(xloc, yloc); - this->move(hidepoint); //Could bleed over onto the screen above + this->move(hidepoint); + this->resize( this->width(), viswidth); } }else if(loc=="bottom"){ //bottom of screen QSize sz = QSize(xwid*panelPercent, ht); @@ -169,6 +171,7 @@ void LPanel::UpdatePanel(bool geomonly){ hidepoint = QPoint(xloc, yloc+xhi-hidesize); showpoint = QPoint(xloc, yloc+xhi-ht); this->move(hidepoint); //Could bleed over onto the screen below + this->resize( this->width(), viswidth); } }else if(loc=="left"){ //left side of screen QSize sz = QSize(ht, xhi*panelPercent); @@ -181,9 +184,10 @@ void LPanel::UpdatePanel(bool geomonly){ if(!hidden){ LSession::handle()->XCB->ReserveLocation(this->winId(), this->geometry(), "left"); } else{ LSession::handle()->XCB->ReserveLocation(this->winId(), QRect(xloc, yloc, hidesize, sz.height()), "left"); - hidepoint = QPoint(xloc-ht+hidesize, yloc); + hidepoint = QPoint(xloc, yloc); showpoint = QPoint(xloc, yloc); this->move(hidepoint); //Could bleed over onto the screen left + this->resize( viswidth, this->height()); } }else{ //right side of screen QSize sz = QSize(ht, xhi*panelPercent); @@ -199,6 +203,7 @@ void LPanel::UpdatePanel(bool geomonly){ hidepoint = QPoint(xloc+xwid-hidesize, yloc); showpoint = QPoint(xloc+xwid-ht, yloc); this->move(hidepoint); //Could bleed over onto the screen right + this->resize( viswidth, this->height()); } } if(DEBUG){ qDebug() << " - Done with panel geometry"; } @@ -265,7 +270,7 @@ void LPanel::UpdatePanel(bool geomonly){ i--; //make sure we don't miss the next item with the re-order } } - LSession::processEvents(); + //LSession::processEvents(); } //Now remove any extra plugins from the end //qDebug() << "plugins:" << plugins; @@ -279,7 +284,7 @@ void LPanel::UpdatePanel(bool geomonly){ } layout->takeAt(i); //remove from the layout PLUGINS.takeAt(i)->deleteLater(); //delete the actual widget - LSession::processEvents(); + //LSession::processEvents(); i--; //need to back up one space to not miss another plugin } this->update(); @@ -289,7 +294,8 @@ void LPanel::UpdatePanel(bool geomonly){ for(int i=0; i<PLUGINS.length(); i++){ QTimer::singleShot(0,PLUGINS[i], SLOT(OrientationChange())); } - LSession::processEvents(); + checkPanelFocus(); + //LSession::processEvents(); } void LPanel::UpdateLocale(){ @@ -310,13 +316,24 @@ void LPanel::UpdateTheme(){ // PRIVATE SLOTS // =================== void LPanel::checkPanelFocus(){ + qDebug() << "Check Panel Focus:" << panelnum << viswidth << fullwidth << this->size(); if( !this->geometry().contains(QCursor::pos()) ){ //Move the panel back to it's "hiding" spot - if(hidden){ this->move(hidepoint); this->update(); } + if(hidden){ + QSize sz(horizontal ? this->width() : viswidth, horizontal ? viswidth : this->height() ); + this->setMinimumSize(sz); + this->setMaximumSize(sz); + this->setGeometry( QRect(hidepoint, sz) ); + } //Re-active the old window if(LSession::handle()->activeWindow()!=0){ LSession::handle()->XCB->ActivateWindow(LSession::handle()->activeWindow()); } + }else if(hidden){ + QSize sz(horizontal ? this->width() : fullwidth, horizontal ? fullwidth : this->height() ); + this->setMinimumSize(sz); + this->setMaximumSize(sz); + this->setGeometry( QRect(showpoint, sz) ); } } @@ -324,10 +341,15 @@ void LPanel::checkPanelFocus(){ //=========== // PROTECTED //=========== +void LPanel::resizeEvent(QResizeEvent *event){ + QWidget::resizeEvent(event); + for(int i=0; i<PLUGINS.length(); i++){ PLUGINS[i]->OrientationChange(); } +} + void LPanel::paintEvent(QPaintEvent *event){ if(!hascompositer){ QPainter *painter = new QPainter(this); - //qDebug() << "Paint Panel:" << PPREFIX; + qDebug() << "Paint Panel:" << PPREFIX; //Make sure the base background of the event rectangle is the associated rectangle from the BGWindow QRect rec = event->rect();//this->geometry(); //start with the global geometry of the panel rec.adjust(-1,-1,2,2); //add 1 more pixel on each side @@ -343,11 +365,13 @@ void LPanel::paintEvent(QPaintEvent *event){ void LPanel::enterEvent(QEvent *event){ //qDebug() << "Panel Enter Event:"; - if(hidden){ + checkPanelFocus(); + /*if(hidden){ //Move the panel out so it is fully available this->move(showpoint); + this->resize( horizontal ? this->width() : fullwidth, horizontal ? fullwidth : this->height() ); this->update(); - } + }*/ //this->activateWindow(); event->accept(); //just to quiet the compile warning } diff --git a/src-qt5/core/lumina-desktop/LPanel.h b/src-qt5/core/lumina-desktop/LPanel.h index b3c9ba60..2828161c 100644 --- a/src-qt5/core/lumina-desktop/LPanel.h +++ b/src-qt5/core/lumina-desktop/LPanel.h @@ -35,11 +35,12 @@ private: QString PPREFIX; //internal prefix for all settings QDesktopWidget *screen; QWidget *bgWindow, *panelArea; + //QRect hidegeom, showgeom; //for hidden panels QPoint hidepoint, showpoint; //for hidden panels: locations when hidden/visible bool defaultpanel, horizontal, hidden, hascompositer; int screennum; int panelnum; - int viswidth; + int viswidth, fullwidth; QList<LPPlugin*> PLUGINS; public: @@ -69,6 +70,7 @@ private slots: void checkPanelFocus(); protected: + void resizeEvent(QResizeEvent *event); void paintEvent(QPaintEvent *event); void enterEvent(QEvent *event); void leaveEvent(QEvent *event); |