From f228077850b16fdd92310782aafe3f7f2b437adb Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 26 Apr 2018 17:48:37 -0400 Subject: Commit a bunch more work on the Lumina 2 screen reservations. --- src-qt5/core/lumina-desktop-unified/LSession.cpp | 2 +- .../src-desktop/DesktopManager.cpp | 19 ++++++++++ .../src-desktop/DesktopManager.h | 1 + .../src-desktop/src-cpp/NativeWindowObject.cpp | 18 ++++++--- .../src-desktop/src-cpp/NativeWindowObject.h | 2 +- .../src-desktop/src-cpp/PanelObject.cpp | 20 ++++++++-- .../src-desktop/src-cpp/PanelObject.h | 3 +- .../src-desktop/src-cpp/RootDesktopObject.cpp | 33 +++++++++++++++- .../src-desktop/src-cpp/RootDesktopObject.h | 7 +++- .../src-desktop/src-cpp/ScreenObject.cpp | 26 ++++++++++++- .../src-desktop/src-cpp/ScreenObject.h | 5 +++ .../src-desktop/src-widgets/NativeWindow.cpp | 44 +++++++++++----------- .../src-desktop/src-widgets/NativeWindow.h | 4 +- .../src-desktop/src-widgets/src-widgets.pri | 1 + .../src-events/NativeWindowSystem.cpp | 22 +++++++---- .../src-events/NativeWindowSystem.h | 1 + .../src-events/Window-mgmt.cpp | 6 +++ 17 files changed, 167 insertions(+), 47 deletions(-) (limited to 'src-qt5') diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp index 1c103fab..5e931e5f 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.cpp +++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp @@ -169,7 +169,7 @@ void LSession::CleanupSession(){ //Now perform any other cleanup //Lumina::NEF->stop(); //Now wait a moment for things to close down before quitting - if(playaudio){ + if(playaudio && mediaObj!=0){ //wait a max of 5 seconds for audio to finish bool waitmore = true; for(int i=0; i<100 && waitmore; i++){ diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp index 32f84f93..7e763b02 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp @@ -129,6 +129,7 @@ void DesktopManager::NewWindowAvailable(NativeWindowObject* win){ #ifdef USE_WIDGETS qDebug() << "Got New Widget Window:" << win->name(); NativeWindow *tmp = new NativeWindow(win); + //qDebug() << " - Embed Into frame:" << tmp->relativeOrigin(); //Lumina::NWS->RequestReparent(win->id(), win->frameId(), tmp->relativeOrigin()); QTimer::singleShot(10, tmp, SLOT(initProperties()) ); #endif @@ -205,6 +206,24 @@ void DesktopManager::updatePanelSettings(){ } //qDebug() << "Panel Settings Changed:" << total_ids; RootDesktopObject::instance()->setPanels(total_ids); //put the new ones in place + QTimer::singleShot(500, this, SLOT(updatePanelReservations()) ); +} + +void DesktopManager::updatePanelReservations(){ + /*QRect raw_session, reserved_session; + QList screens = RootDesktopObject::instance()->screenObjects(); + //Calculate the total session rectangle and session panel reservations + QList tmp = RootDesktopObject::instance()->panelObjectList(); + for(int i=0; igeometry()); + } + for(int i=0; i() << NativeWindowObject::GlobalPos << NativeWindowObject::Size, QList() << pos << sz); - if(!geomTimer->isActive()){ geomTimer->start(); } + if(!geomTimer->isActive()){ QTimer::singleShot(0,geomTimer, SLOT(start())); } }else{ sendNewGeom(); } @@ -295,18 +296,23 @@ void NativeWindowObject::toggleMaximize(){ } } //Now compare the current geometry to the screen geometry + qDebug() << "Maximize Toggle:" << curgeom << max; if(curgeom!=max){ + qDebug() << " - maximize"; setGeometryNow(max); //will set newgeom to max - newgeom = curgeom; //now reset newgeom + lastgeom = curgeom; //save this for later }else{ + qDebug() << " - restore" << lastgeom; //Already maximized, look at the old geometry and figure out how to restore it - if(newgeom.isNull()){ + if(lastgeom.isNull() || lastgeom == max){ + qDebug() << " -- Reset lastgeom to half-screen size"; //no old info available - center the window at half maximum size - newgeom = QRect(max.x()-max.width()/2, max.y()-max.height()/2, max.width()/2, max.height()/2); + lastgeom = QRect(max.x()-max.width()/2, max.y()-max.height()/2, max.width()/2, max.height()/2); } - setGeometryNow(newgeom); + setGeometryNow(lastgeom); } - emit geomChanged(); + qDebug() << "After toggle:" << lastgeom; + //emit geomChanged(); } void NativeWindowObject::requestClose(){ diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h index ed52c956..c1851d0e 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h @@ -133,7 +133,7 @@ private: unsigned int dmgID, dmg, icodmg; //Collation/Delay for window resize events QTimer *geomTimer; - QRect newgeom; + QRect newgeom, lastgeom; void emitSinglePropChanged(NativeWindowObject::Property); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp index e8830bde..94079bf7 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp @@ -48,6 +48,7 @@ void PanelObject::setBackground(QString fileOrColor){ void PanelObject::setGeometry( QRect newgeom ){ if(geom!=newgeom){ geom = newgeom; + fullside_geom = geom; //unknown full-side geom - no parent info given emit geomChanged(); } } @@ -88,10 +89,19 @@ void PanelObject::syncWithSettings(QRect parent_geom){ this->setBackground( DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/background", "rgba(0,0,0,120)").toString() ); // qDebug() << "Update Panel:" << panel_id << id << anchor+"/"+align << length << width; //Now calculate the geometry of the panel - QRect newgeom; + QRect newgeom, newfullsidegeom; //Figure out the size of the panel - if(anchor=="top" || anchor=="bottom"){ newgeom.setWidth( parent_geom.width()*length ); newgeom.setHeight(width); } - else{ newgeom.setWidth(width); newgeom.setHeight(parent_geom.height()*length); } + if(anchor=="top" || anchor=="bottom"){ + newgeom.setWidth( parent_geom.width()*length ); newgeom.setHeight(width); + newfullsidegeom.setWidth(parent_geom.width()); newfullsidegeom.setHeight(width); + if(anchor=="top"){ newfullsidegeom.moveTopLeft(QPoint(0,0)); } + else{ newfullsidegeom.moveBottomLeft( QPoint(0, parent_geom.height()) ); } + }else{ + newgeom.setWidth(width); newgeom.setHeight(parent_geom.height()*length); + newfullsidegeom.setWidth(width); newfullsidegeom.setHeight(parent_geom.height()); + if(anchor=="left"){ newfullsidegeom.moveTopLeft(QPoint(0,0)); } + else{ newfullsidegeom.moveTopRight( QPoint(parent_geom.width(), 0) ); } + } //qDebug() << " - Size:" << newgeom; //Now figure out the location of the panel if(align=="left" || align=="top"){ @@ -114,7 +124,9 @@ void PanelObject::syncWithSettings(QRect parent_geom){ //qDebug() << " - Calculated Geometry (relative to parent):" << newgeom; //Note: newgeom is currently in parent-relative coordinates (not global) newgeom.translate(parent_geom.x(), parent_geom.y()); + newfullsidegeom.translate(parent_geom.x(), parent_geom.y()); + fullside_geom = newfullsidegeom; //qDebug() << " - Calculated Geometry (global):" << newgeom; - this->setGeometry(newgeom); //shift to global coordinates + this->setGeometry(newgeom); //in global coordinates this->setPlugins( DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/plugins", QStringList()).toStringList() ); } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h index 5ae75ea4..645e20c0 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h @@ -25,7 +25,7 @@ class PanelObject : public QObject { private: QString panel_id, bg; - QRect geom; + QRect geom, fullside_geom; QStringList panel_plugins; public: @@ -42,6 +42,7 @@ public: Q_INVOKABLE bool isVertical(); Q_INVOKABLE QStringList plugins(); Q_INVOKABLE QRect geometry(){ return geom; } + Q_INVOKABLE QRect fullSideGeometry(){ return fullside_geom; } public slots: void setBackground(QString fileOrColor); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp index d9a81f54..79737ddc 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp @@ -18,6 +18,10 @@ RootDesktopObject::RootDesktopObject(QObject *parent) : QObject(parent){ connect(this, SIGNAL(changePanels(QStringList)), this, SLOT(setPanels(QStringList)) ); currentTimeTimer = new QTimer(this); connect(currentTimeTimer, SIGNAL(timeout()), this, SLOT(updateCurrentTime()) ); + availgeomTimer = new QTimer(this); + availgeomTimer->setInterval(100); + availgeomTimer->setSingleShot(true); + connect(availgeomTimer, SIGNAL(timeout()), this, SLOT(submitSessionGeom()) ); } RootDesktopObject::~RootDesktopObject(){ @@ -170,6 +174,16 @@ void RootDesktopObject::setPanels(QStringList ids){ change = true; //list changed } } //end loop over screens+session + //Now calculate the available session geometry + QRegion sess(geom); + for(int i=0; i RootDesktopObject::windowObjects(){ return window_objects; } +QList RootDesktopObject::screenObjects(){ + return s_objects; +} + // === PUBLIC SLOTS === void RootDesktopObject::updateScreens(){ QList scrns = QApplication::screens(); @@ -251,7 +269,11 @@ void RootDesktopObject::updateScreens(){ for(int j=0; jname()==scrns[i]->name()){ found = true; tmp << s_objects.takeAt(j); } } - if(!found){ tmp << new ScreenObject(scrns[i], this); } + if(!found){ + //Create new screen object + tmp << new ScreenObject(scrns[i], this); + connect(tmp.last(), SIGNAL(availableGeomChanged()), this, SLOT(availableScreenGeomChanged()) ); + } } //Delete any leftover objects for(int i=0; ideleteLater(); } @@ -291,3 +313,12 @@ void RootDesktopObject::updateCurrentTime(){ emit currentTimeChanged(); } } + +void RootDesktopObject::availableScreenGeomChanged(){ + if(availgeomTimer->isActive()){ availgeomTimer->stop(); } + availgeomTimer->start(); +} + +void RootDesktopObject::submitSessionGeom(){ + //TODO - read off the available geom from each ScreenObject and register that with NativeWindowSystem +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h index 3c525848..4a722ec0 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h @@ -57,6 +57,7 @@ public: //C++ Access Functions (simplifications for the QML ones) QList windowObjects(); + QList screenObjects(); private: QList s_objects; @@ -64,9 +65,10 @@ private: QList window_objects; QList tray_window_objects; QPointer last_window_up; - QTimer *currentTimeTimer; + QTimer *currentTimeTimer, *availgeomTimer; QString currentTimeFormat, currentTimeString; QDateTime currentDateTimeStruct; + QRegion session_avail_geom; public slots: void updateScreens(); //rescan/update screen objects @@ -84,6 +86,8 @@ public slots: private slots: void updateCurrentTime(); + void availableScreenGeomChanged(); + void submitSessionGeom(); signals: void screensChanged(); @@ -91,6 +95,7 @@ signals: void windowsChanged(); void trayWindowsChanged(); void currentTimeChanged(); + void sessionGeomAvailableChanged(); void startLogout(); void mouseMoved(); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp index c754906d..d6e0abb6 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp @@ -11,6 +11,7 @@ ScreenObject::ScreenObject(QScreen *scrn, QObject *parent) : QObject(parent){ bg_screen = scrn; connect(this, SIGNAL(changePanels(QStringList)), this, SLOT(setPanels(QStringList)) ); + connect(RootWindowObject::instance(), SIGNAL(sessionGeomAvailableChanged()), this, SLOT(updateAvailableGeometry()) ); } void ScreenObject::RegisterType(){ @@ -49,12 +50,15 @@ void ScreenObject::setPanels(QStringList ids){ return; } + QRegion *sess = RootDesktopObject::instance()->availableGeometry(); + QRect avail = sess->intersected(bg_screen->geometry()).boundingRect(); + if(session_available_geometry.isNull()){ avail = bg_screen->geometry(); } //First update/remove any current panel objects bool change = false; for(int i=0; iname()) ){ ids.removeAll(panel_objects[i]->name()); //already handled - panel_objects[i]->syncWithSettings(bg_screen->geometry()); + panel_objects[i]->syncWithSettings(avail); }else{ panel_objects.takeAt(i)->deleteLater(); i--; @@ -87,3 +91,23 @@ PanelObject* ScreenObject::panel(QString id){ } return 0; } + +QRect ScreenObject::availableGeometry(){ + return avail_geom; +} + +void ScreenObject::updateAvailableGeometry(){ + QRegion *sess = RootDesktopObject::instance()->availableGeometry(); + QRegion availRegion = sess->intersected(bg_screen->geometry()); + QRect avail = availRegion.boundingRect(); + for(int i=0; isyncWithSettings(avail); + //Note: Use the "full side" geometry to ensure that we are cleanly cutting off the entire side of the region + availRegion = availRegion.subtracted( panel_objects[i]->fullSideGeometry() ); + } + avail = availRegion.boundingRect(); + if(avail != avail_geom){ + avail_geom = avail; + emit availableGeomChanged(); + } +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h index 250c9403..66c30969 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h @@ -24,11 +24,13 @@ class ScreenObject : public QObject { Q_PROPERTY( int width READ width NOTIFY geomChanged) Q_PROPERTY( int height READ height NOTIFY geomChanged) Q_PROPERTY( QStringList panels READ panels NOTIFY panelsChanged) + Q_PROPERTY( QRect availableGeom READ availableGeometry NOTIFY availableGeomChanged) private: QScreen *bg_screen; QString bg; QList panel_objects; + QRect avail_geom; public: ScreenObject(QScreen *scrn = 0, QObject *parent = 0); @@ -44,6 +46,7 @@ public: Q_INVOKABLE QStringList panels(); Q_INVOKABLE PanelObject* panel(QString id); Q_INVOKABLE QRect geometry(){ return bg_screen->geometry(); } + Q_INVOKABLE QRect availableGeometry(); void setPanels(QList list); @@ -52,10 +55,12 @@ public: public slots: void setPanels(QStringList ids); void setBackground(QString fileOrColor); + void updateAvailableGeometry(); signals: void backgroundChanged(); void geomChanged(); + void availableGeomChanged(); void panelsChanged(); //Internal signals for thread-safety diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeWindow.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeWindow.cpp index 86dd8482..93bff6db 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeWindow.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeWindow.cpp @@ -13,7 +13,7 @@ NativeWindow::NativeWindow( NativeWindowObject *obj ) : QFrame(0, Qt::Window | Qt::FramelessWindowHint){ WIN = obj; createFrame(); - WIN->addFrameWinID(container->winId()); + //WIN->addFrameWinID(this->winId()); } NativeWindow::~NativeWindow(){ @@ -23,14 +23,11 @@ NativeWindow::~NativeWindow(){ QPoint NativeWindow::relativeOrigin(){ //Update all the margins for the frame - /*QList frame = WIN->property(NativeWindowObject::FrameExtents).value >(); + QList frame = WIN->property(NativeWindowObject::FrameExtents).value >(); //QList : [Left, Right, Top, Bottom] in pixels - int topM = frame[2] - titleLabel->fontMetrics().height(); //figure out how much extra we have to work with - if(topM<0){ topM = 0; } - int botM = topM/2.0; - QPoint containerCorner(frame[0], topM-botM); - return containerCorner;*/ - return QPoint(0,0); + QPoint containerCorner(frame[0], frame[2]); + return containerCorner; + //return QPoint(0,0); } void NativeWindow::initProperties(){ @@ -59,7 +56,7 @@ void NativeWindow::initProperties(){ syncWinType(); syncGeom(); syncVisibility(true); //init visibility - force it visible to start with - + container->activateWindow(); } // === PRIVATE === @@ -81,13 +78,12 @@ void NativeWindow::createFrame(){ vlayout->setSpacing(0); toolbarL = new QHBoxLayout(); toolbarL->setSpacing(0); - container = QWidget::createWindowContainer(QWindow::fromWinId(WIN->id()), this); - container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + qDebug() << "Create Native Embed Widget"; + container = new NativeEmbedWidget(this, WIN); + container->widget()->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); //vlayout.align titleLabel = new QLabel(this); titleLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - //contentW = new QWidget(this); - //contentW->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); //Now put the widgets in the right places toolbarL->addWidget(otherB); toolbarL->addWidget(titleLabel); @@ -95,7 +91,8 @@ void NativeWindow::createFrame(){ toolbarL->addWidget(maxB); toolbarL->addWidget(closeB); vlayout->addLayout(toolbarL); - vlayout->addWidget(container); + //vlayout->addStretch(); + vlayout->addWidget(container->widget()); this->setLayout(vlayout); // Load the icons for the buttons loadIcons(); @@ -115,7 +112,7 @@ void NativeWindow::syncWinImage(){ } void NativeWindow::syncName(){ - qDebug() << "Got Name Change:" << WIN->name(); + //qDebug() << "Got Name Change:" << WIN->name(); } void NativeWindow::syncTitle(){ @@ -129,20 +126,20 @@ void NativeWindow::syncIcon(){ } void NativeWindow::syncSticky(){ - qDebug() << "Got Sticky Change:" << WIN->isSticky(); + //qDebug() << "Got Sticky Change:" << WIN->isSticky(); } void NativeWindow::syncVisibility(bool init){ if(init){ WIN->setProperty(NativeWindowObject::Visible, true, true); //force it - }else{ - qDebug() << "Sync Visibility:" << WIN->isVisible(); + }else if(this->isVisible() != WIN->isVisible()){ + //qDebug() << "Sync Visibility:" << WIN->isVisible(); this->setVisible(WIN->isVisible()); } } void NativeWindow::syncWinType(){ - qDebug() << "Sync Win Type"; + //qDebug() << "Sync Win Type"; closeB->setVisible(WIN->showCloseButton()); maxB->setVisible(WIN->showMaxButton()); minB->setVisible(WIN->showMinButton()); @@ -163,7 +160,10 @@ void NativeWindow::syncWinType(){ } void NativeWindow::syncGeom(){ - qDebug() << "Sync Geometry:" << WIN->name(); - qDebug() << " Frame:" << WIN->frameGeometry() << "Win:" << WIN->imageGeometry(); - this->setGeometry( WIN->frameGeometry() ); + //qDebug() << "Sync Geometry:" << WIN->name(); + //qDebug() << " Frame:" << WIN->frameGeometry() << "Win:" << WIN->imageGeometry(); + QRect geom = WIN->frameGeometry(); + if(geom!=this->geometry()){ + this->setGeometry( geom ); + } } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeWindow.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeWindow.h index f2fd822c..47699ae6 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeWindow.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeWindow.h @@ -9,6 +9,7 @@ #include #include +#include "NativeEmbedWidget.h" class NativeWindow : public QFrame{ Q_OBJECT @@ -32,7 +33,8 @@ private: QHBoxLayout *toolbarL; QVBoxLayout *vlayout; QLabel *titleLabel; - QWidget *container; + NativeEmbedWidget *container; + // Info cache variables QRect oldgeom; diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/src-widgets.pri b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/src-widgets.pri index 7ed228f7..5ed94f1b 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/src-widgets.pri +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/src-widgets.pri @@ -9,5 +9,6 @@ SOURCES *= $${PWD}/RootDesktop.cpp \ HEADERS *= $${PWD}/RootDesktop.h \ $${PWD}/ContextMenu.h \ $${PWD}/NativeWindow.h \ + $${PWD}/NativeEmbedWidget.h \ $${PWD}/Panel.h \ $${PWD}/Plugin.h diff --git a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp index 0d1e9c10..2afdd8c2 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp @@ -568,12 +568,12 @@ void NativeWindowSystem::ChangeWindowProperties(NativeWindowObject* win, QList< } if(props.contains(NativeWindowObject::Visible)){ - qDebug() << "Check Window Visibility:" << vals[ props.indexOf(NativeWindowObject::Visible) ]; + //qDebug() << "Check Window Visibility:" << vals[ props.indexOf(NativeWindowObject::Visible) ]; if( vals[ props.indexOf(NativeWindowObject::Visible) ].toBool() ){ - qDebug() << " - Map it!"; + //qDebug() << " - Map it!"; xcb_map_window(QX11Info::connection(), win->id()); }else{ - qDebug() << " - Unmap it!"; + //qDebug() << " - Unmap it!"; xcb_unmap_window(QX11Info::connection(), win->id()); } } @@ -630,6 +630,7 @@ void NativeWindowSystem::SetupNewWindow(NativeWindowObject *win){ Damage dmgID = XDamageCreate(QX11Info::display(), win->id(), XDamageReportRawRectangles); win->addDamageID( (uint) dmgID); //save this for later + registerClientEvents(win->id()); }else{ /* //xcb_reparent_window(QX11Info::connection(), win->id(), this->winId(), 0, 0); @@ -643,7 +644,7 @@ void NativeWindowSystem::SetupNewWindow(NativeWindowObject *win){ */ } //win->addFrameWinID(this->winId()); - registerClientEvents(win->id()); + //registerClientEvents(win->id()); } QImage NativeWindowSystem::GetWindowImage(NativeWindowObject* win){ @@ -802,7 +803,7 @@ void NativeWindowSystem::NewWindowDetected(WId id){ NativeWindowObject *win = new NativeWindowObject(id); //Register for events from this window - registerClientEvents(win->id()); + //registerClientEvents(win->id()); NWindows << win; UpdateWindowProperties(win, NativeWindowObject::allProperties()); if(win->showWindowFrame()){ @@ -815,11 +816,16 @@ void NativeWindowSystem::NewWindowDetected(WId id){ connect(win, SIGNAL(RequestPing(WId)), this, SLOT(RequestPing(WId)) ); connect(win, SIGNAL(RequestReparent(WId, WId, QPoint)), this, SLOT(RequestReparent(WId, WId, QPoint)) ); connect(win, SIGNAL(RequestPropertiesChange(WId, QList, QList)), this, SLOT(RequestPropertiesChange(WId, QList, QList)) ); - connect(win, SIGNAL(VerifyNewGeometry(WId)), this, SLOT(CheckWindowPosition(WId)) ); + connect(win, SIGNAL(WindowClosed(WId)), this, SLOT(WindowCloseDetected(WId)) ); + //connect(win, SIGNAL(VerifyNewGeometry(WId)), this, SLOT(CheckWindowPosition(WId)) ); + qDebug() << " - Setup New Window"; SetupNewWindow(win); - CheckWindowPosition(id, true); //first time placement - xcb_map_window(QX11Info::connection(), win->id()); + qDebug() << " - Setup window position"; + CheckWindowPosition(win, true); //first time placement + //xcb_map_window(QX11Info::connection(), win->id()); + qDebug() << " - Emit new window signal"; emit NewWindowAvailable(win); + connect(win, SIGNAL(VerifyNewGeometry(WId)), this, SLOT(CheckWindowPosition(WId)) ); } void NativeWindowSystem::NewTrayWindowDetected(WId id){ diff --git a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h index f6033674..405d3bc3 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h +++ b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h @@ -140,6 +140,7 @@ private slots: void ArrangeWindows(WId primary, QString type); void TileWindows(WId primary, QString type); void CheckWindowPosition(WId id, bool newwindow = false); + void CheckWindowPosition(NativeWindowObject *win, bool newwindow = false); void arrangeWindows(NativeWindowObject *primary, QString type, bool primaryonly = false); signals: diff --git a/src-qt5/core/lumina-desktop-unified/src-events/Window-mgmt.cpp b/src-qt5/core/lumina-desktop-unified/src-events/Window-mgmt.cpp index 0b45c208..23bd3e40 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/Window-mgmt.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-events/Window-mgmt.cpp @@ -91,8 +91,13 @@ void NativeWindowSystem::CheckWindowPosition(WId id, bool newwindow){ //used after a "drop" to validate/snap/re-arrange window(s) as needed // if "newwindow" is true, then this is the first-placement routine for a window before it initially appears NativeWindowObject* win = findWindow(id); + CheckWindowPosition(win, newwindow); +} + +void NativeWindowSystem::CheckWindowPosition(NativeWindowObject *win, bool newwindow){ if(win==0){ return; } //invalid window QRect geom = win->geometry(); + qDebug() << "Got Window Geometry:" << geom; bool changed = false; //Make sure it is on the screen (quick check) if(geom.x() < 0){ changed = true; geom.moveLeft(0); } @@ -101,5 +106,6 @@ void NativeWindowSystem::CheckWindowPosition(WId id, bool newwindow){ if(geom.height() < 20){ changed = true; geom.setHeight(100); } if(changed){ win->setGeometryNow(geom); } //Now run it through the window arrangement routine + qDebug() << "ArrangeWindows"; arrangeWindows(win, newwindow ?"center" : "snap", true); } -- cgit