diff options
-rw-r--r-- | libLumina/LuminaX11.cpp | 1 | ||||
-rw-r--r-- | lumina-desktop/LSession.cpp | 7 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/LWindow.cpp | 77 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/LWindow.h | 16 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/LWindowManager.cpp | 5 |
5 files changed, 68 insertions, 38 deletions
diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp index 6cbc670d..fea15a8f 100644 --- a/libLumina/LuminaX11.cpp +++ b/libLumina/LuminaX11.cpp @@ -1170,6 +1170,7 @@ bool LXCB::WM_ManageWindow(WId win, bool needsmap){ XCB_EVENT_MASK_STRUCTURE_NOTIFY | \ XCB_EVENT_MASK_FOCUS_CHANGE) //return whether the window is/should be managed + if(WM_ICCCM_GetClass(win).isEmpty() ){ return false; } xcb_get_window_attributes_cookie_t cookie = xcb_get_window_attributes(QX11Info::connection(), win); xcb_get_window_attributes_reply_t *attr = xcb_get_window_attributes_reply(QX11Info::connection(), cookie, NULL); if(attr == 0){ return false; } //could not get attributes of window diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 7f182583..9fd30b7d 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -162,7 +162,8 @@ void LSession::setupSession(){ connect(this, SIGNAL(aboutToQuit()), this, SLOT(SessionEnding()) ); if(DEBUG){ qDebug() << " - Init Finished:" << timer->elapsed(); delete timer;} QApplication::processEvents(); - QTimer::singleShot(500, this, SLOT(launchStartupApps()) ); + launchStartupApps(); + //QTimer::singleShot(500, this, SLOT(launchStartupApps()) ); QApplication::processEvents(); splash.close(); } @@ -576,7 +577,7 @@ void LSession::adjustWindowGeom(WId win, bool maximize){ break; } } - if(desk.isNull()){ return; } //Unable to deteremine screen + if(desk.isNull()){ return; } //Unable to determine screen //Adjust the window location if necessary if(maximize){ if(DEBUG){ qDebug() << " - Maximizing New Window:" << desk.width() << desk.height(); } @@ -599,7 +600,7 @@ void LSession::adjustWindowGeom(WId win, bool maximize){ //just move the window - there is room for it above geom.setBottom(desk.bottom()-frame[1]); fgeom.setBottom(desk.bottom()); - }else if(geom.height() < diff){ //window bigger than the difference + }else if(geom.height() > diff){ //window bigger than the difference //Need to resize the window - keeping the origin point the same geom.setHeight( geom.height()-diff-1 ); //shrink it by the difference (need an extra pixel somewhere) fgeom.setHeight( fgeom.height()-diff ); diff --git a/lumina-wm-INCOMPLETE/LWindow.cpp b/lumina-wm-INCOMPLETE/LWindow.cpp index ad34c4dd..85fec396 100644 --- a/lumina-wm-INCOMPLETE/LWindow.cpp +++ b/lumina-wm-INCOMPLETE/LWindow.cpp @@ -39,30 +39,38 @@ void LWindowFrame::InitWindow(){ titleBar = new QLabel(this); //This is the "container" for all the title buttons/widgets titleBar->setObjectName("TitleBar"); titleBar->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); + titleBar->setFocusPolicy(Qt::NoFocus); + titleBar->setCursor(Qt::ArrowCursor); title = new QLabel(this); //Shows the window title/text title->setObjectName("Title"); title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); title->setCursor(Qt::ArrowCursor); + title->setFocusPolicy(Qt::NoFocus); icon = new QLabel(this); //Contains the window icon icon->setObjectName("Icon"); icon->setCursor(Qt::ArrowCursor); + icon->setFocusPolicy(Qt::NoFocus); minB = new QToolButton(this); //Minimize Button minB->setObjectName("Minimize"); minB->setCursor(Qt::ArrowCursor); + minB->setFocusPolicy(Qt::NoFocus); connect(minB, SIGNAL(clicked()), this, SLOT(minClicked()) ); maxB = new QToolButton(this); //Maximize Button maxB->setObjectName("Maximize"); maxB->setCursor(Qt::ArrowCursor); + maxB->setFocusPolicy(Qt::NoFocus); connect(maxB, SIGNAL(clicked()), this, SLOT(maxClicked()) ); closeB = new QToolButton(this); closeB->setObjectName("Close"); closeB->setCursor(Qt::ArrowCursor); + closeB->setFocusPolicy(Qt::NoFocus); connect(closeB, SIGNAL(clicked()), this, SLOT(closeClicked()) ); otherB = new QToolButton(this); //Button to place any other actions otherB->setObjectName("Options"); otherB->setCursor(Qt::ArrowCursor); otherB->setPopupMode(QToolButton::InstantPopup); otherB->setStyleSheet("QToolButton::menu-indicator{ image: none; }"); + otherB->setFocusPolicy(Qt::NoFocus); otherM = new QMenu(this); //menu of "other" actions for the window otherB->setMenu(otherM); connect(otherM, SIGNAL(triggered(QAction*)), this, SLOT(otherClicked(QAction*)) ); @@ -78,45 +86,48 @@ void LWindowFrame::InitWindow(){ titleBar->setLayout(HL); QVBoxLayout *VL = new QVBoxLayout(this); this->setLayout(VL); - VL->addWidget(titleBar); - VL->setAlignment(titleBar, Qt::AlignTop); VL->setContentsMargins(0,0,0,0); VL->setSpacing(0); //Have the window take the same initial size of the client window - this->setGeometry( LWM::SYSTEM->WM_Window_Geom(CID) ); - qDebug() << "First Geom:" << this->geometry(); - if(this->width() < 100 && this->height() < 100){ this->resize(100,100); } + QRect geom = LWM::SYSTEM->WM_Window_Geom(CID); + this->setGeometry( geom ); + qDebug() << "First Geom:" << geom; + if(geom.width() < 100 && geom.height() < 100){ this->resize(100,100); } //Now embed the native window into the frame WIN = QWindow::fromWinId(CID); WinWidget = QWidget::createWindowContainer( WIN, this); + WinWidget->setCursor(Qt::ArrowCursor); //this is just a fallback - the window itself will adjust it //WINBACK = new QBackingStore(WIN); //create a data backup for the widget - //this->layout()->addWidget( WinWidget ); - //VL->setStretch(1,1); + + //Now assemble te initial layout for the window (all while still invisible) + VL->addWidget(titleBar); + VL->addWidget(WinWidget); + VL->setStretch(1,1); } LWindowFrame::ModState LWindowFrame::getStateAtPoint(QPoint pt, bool setoffset){ //Note: pt should be in widget-relative coordinates, not global if(!this->layout()->geometry().contains(pt)){ //above the frame itself - need to figure out which quadrant it is in (8-directions) - if(pt.y() < this->height()/3){ + if(pt.y() < 3){ //One of the top options - if(pt.x() < this->width()/3){ + if(pt.x() < 3){ if(setoffset){ offset.setX(pt.x()); offset.setY(pt.y()); } //difference from top-left corner return ResizeTopLeft; - }else if(pt.x() > (2*this->width()/3)){ + }else if(pt.x() > (this->width()-3)){ if(setoffset){ offset.setX(this->width()-pt.x()); 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) return ResizeTop; } - }else if(pt.y() > (2*this->height())/3){ + }else if(pt.y() > (this->height()-3) ){ //One of the bottom options - if(pt.x() < this->width()/3){ + if(pt.x() < 3){ if(setoffset){ offset.setX(pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-left corner return ResizeBottomLeft; - }else if(pt.x() > (2*this->width()/3)){ + }else if(pt.x() > (this->width()-3)){ if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-right corner return ResizeBottomRight; }else{ @@ -125,12 +136,14 @@ LWindowFrame::ModState LWindowFrame::getStateAtPoint(QPoint pt, bool setoffset){ } }else{ //One of the side options - if(pt.x() < this->width()/2){ + if(pt.x() < 3){ if(setoffset){ offset.setX(pt.x()); offset.setY(0); } //difference from left edge (Y does not matter) return ResizeLeft; - }else{ + }else if(pt.x() > (this->width()-3) ){ if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(0); } //difference from right edge (Y does not matter) return ResizeRight; + }else{ + return Normal; } } } @@ -236,13 +249,12 @@ void LWindowFrame::showAnimation(LWM::WindowAction act){ //anim->setStartValue( 0.0 ); //anim->setEndValue( 1.0 ); }else{ - if(this->layout()->count() <2){ this->layout()->addWidget(WinWidget); } + ShowClient(true); this->raise(); this->show(); //just show it right away } }else if(act==LWM::Hide){ - if(this->layout()->count() >1){ this->layout()->removeWidget(WinWidget); } if(useanimation){ //Collapse in on center point lastGeom = this->geometry(); @@ -255,7 +267,6 @@ void LWindowFrame::showAnimation(LWM::WindowAction act){ }else if(act==LWM::Closed){ //Need to clean up the container widget first to prevent XCB errors //qDebug() << "Window Closed:" << WIN->winId() << CID; - if(this->layout()->count() >1){ this->layout()->removeWidget(WinWidget); } if(useanimation){ //Collapse in on center line lastGeom = this->geometry(); @@ -267,30 +278,44 @@ void LWindowFrame::showAnimation(LWM::WindowAction act){ } } if(useanimation){ - if(this->layout()->count() >1){ this->layout()->removeWidget(WinWidget); } + ShowClient(false); this->show(); - //if(WIN!=0){ LWM::SYSTEM->WM_HideWindow(CID); } qDebug() << " - Starting Animation:" << act; lastAction = act; anim->start(); }; } +void LWindowFrame::ShowClient(bool show){ + if(show && this->layout()->indexOf(WinWidget)<0 && !Closing){ + while(this->layout()->count()>0){ this->layout()->removeItem(0); } + this->layout()->addWidget(titleBar); + this->layout()->setAlignment(titleBar, Qt::AlignTop); + this->layout()->addWidget(WinWidget); + static_cast<QVBoxLayout*>(this->layout())->setStretch(1,1); + LWM::SYSTEM->WM_ShowWindow(CID); + }else if( !show && this->layout()->indexOf(WinWidget)>=0){ + LWM::SYSTEM->WM_HideWindow(CID); + this->layout()->removeWidget(WinWidget); + } +} + void LWindowFrame::finishedAnimation(){ //Also set any final values qDebug() << " - Finished Animation:" << lastAction; switch(lastAction){ case LWM::Show: - if(WIN!=0 && !Closing){ LWM::SYSTEM->WM_ShowWindow(CID); } - if(this->layout()->count()<2){ this->layout()->addWidget(WinWidget); } + ShowClient(true); break; case LWM::Closed: case LWM::Hide: this->hide(); + LWM::SYSTEM->WM_HideWindow(this->winId()); default: break; } if(Closing){ + qDebug() << "Emitting finished signal"; emit Finished(); } } @@ -310,12 +335,6 @@ void LWindowFrame::windowChanged(LWM::WindowAction act){ //A window property was changed - update accordingly switch(act){ case LWM::Closed: - /*if(anim->state()==QAbstractAnimation::Running){ - anim->pause(); - //delete WinWidget; - WIN = 0; - anim->resume(); - }*/ Closing = true; case LWM::Hide: case LWM::Show: @@ -340,7 +359,7 @@ void LWindowFrame::closeClicked(){ void LWindowFrame::minClicked(){ qDebug() << "Minimize Window"; - this->showMinimized(); + //this->showMinimized(); //need direct modification with XCB } void LWindowFrame::maxClicked(){ diff --git a/lumina-wm-INCOMPLETE/LWindow.h b/lumina-wm-INCOMPLETE/LWindow.h index 10b0dd84..d2495467 100644 --- a/lumina-wm-INCOMPLETE/LWindow.h +++ b/lumina-wm-INCOMPLETE/LWindow.h @@ -46,7 +46,7 @@ private: QPropertyAnimation *anim; //used for appear/disappear animations QRect lastGeom; //used for appear/disappear animations void showAnimation(LWM::WindowAction); //sets lastAction - + void ShowClient(bool show); public slots: //These slots are generally used for the outside event watcher to prod for changes @@ -79,19 +79,25 @@ signals: private: WId CID; LWindowFrame *FID; + bool needsFrame(QList<LXCB::WINDOWTYPE> list){ + if(list.isEmpty()){ return true; } //assume a normal window (fallback) + return !(list.contains(LXCB::T_DESKTOP) || list.contains(LXCB::T_DOCK) || list.contains(LXCB::T_TOOLBAR) \ + || list.contains(LXCB::T_UTILITY) || list.contains(LXCB::T_SPLASH) || list.contains(LXCB::T_DROPDOWN_MENU) \ + || list.contains(LXCB::T_TOOLTIP) || list.contains(LXCB::T_POPUP_MENU) || list.contains(LXCB::T_TOOLTIP) \ + || list.contains(LXCB::T_COMBO) || list.contains(LXCB::T_DND) ); + } private slots: void frameclosed(){ qDebug() << " - Window got frame closed signal"; - FID->close(); - delete FID; + //FID->close(); + //delete FID; emit Finished(CID); } public: LWindow(WId client){ FID= 0; CID = client; - QList<LXCB::WINDOWTYPE> list = LWM::SYSTEM->WM_Get_Window_Type(CID); - if(list.isEmpty() || (list.first()==LXCB::T_DIALOG || list.first()==LXCB::T_NORMAL) ){ + if( needsFrame(LWM::SYSTEM->WM_Get_Window_Type(CID)) ){ FID = new LWindowFrame(CID); connect(FID, SIGNAL(Finished()), this, SLOT(frameclosed()) ); } diff --git a/lumina-wm-INCOMPLETE/LWindowManager.cpp b/lumina-wm-INCOMPLETE/LWindowManager.cpp index 87519ff6..725bc18e 100644 --- a/lumina-wm-INCOMPLETE/LWindowManager.cpp +++ b/lumina-wm-INCOMPLETE/LWindowManager.cpp @@ -148,7 +148,10 @@ void LWindowManager::RepaintWindows(){ //================= void LWindowManager::FinishedWindow(WId win){ for(int i=0; i<WINS.length(); i++){ - if(WINS[i]->clientID() == win){ qDebug() << " - Finished Window"; delete WINS.takeAt(i); break; } + if(WINS[i]->clientID() == win){ + qDebug() << " - Finished Window"; + delete WINS.takeAt(i); break; + } } //Now update the list of clients RestackWindows(); |