From 8ab77628db56aba8e9295ede63c56d9312e4262a Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 19 Jan 2018 14:53:04 -0500 Subject: Get some more of Lumina 2 cleaned up: 1. Ensure window visibility is managed on the QML side 2. Have all panels (even ones pinned to a screen) get created by the root window QML (for layering purposes) 3. Change the default panel setting to include partial-transparency --- .../src-desktop/src-cpp/NativeWindowObject.cpp | 12 +++-- .../src-desktop/src-cpp/NativeWindowObject.h | 4 ++ .../src-desktop/src-cpp/PanelObject.cpp | 22 +++++---- .../src-desktop/src-cpp/RootDesktopObject.cpp | 52 ++++++++++++++-------- 4 files changed, 59 insertions(+), 31 deletions(-) (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp') diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp index 9bb78dd0..e2cac852 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp @@ -242,6 +242,10 @@ bool NativeWindowObject::isSticky(){ return (this->property(NativeWindowObject::Workspace).toInt()<0 || this->property(NativeWindowObject::States).value >().contains(NativeWindowObject::S_STICKY) ); } +bool NativeWindowObject::isVisible(){ + return (this->property(NativeWindowObject::Visible).toBool() ); +} + int NativeWindowObject::workspace(){ return this->property(NativeWindowObject::Workspace).toInt(); } @@ -262,14 +266,13 @@ void NativeWindowObject::updateGeometry(int x, int y, int width, int height, boo if(fgeom.isEmpty()){ fgeom << 0<<0<<0<<0; } //just in case (left/right/top/bottom) QPoint pos(x+fgeom[0], y+fgeom[2]); QSize sz(width-fgeom[0]-fgeom[1], height-fgeom[2]-fgeom[3]); + newgeom = QRect(pos, sz); if(!now){ - newgeom = QRect(pos, sz); //qDebug() << "Update Geometry:" << fgeom << QRect(x,y,width,height) << pos << sz; //requestProperties(QList() << NativeWindowObject::GlobalPos << NativeWindowObject::Size, QList() << pos << sz); if(!geomTimer->isActive()){ geomTimer->start(); } }else{ - requestProperties(QList() << NativeWindowObject::GlobalPos << NativeWindowObject::Size , QList() << pos << sz ); - setProperties(QList() << NativeWindowObject::GlobalPos << NativeWindowObject::Size , QList() << pos << sz ); + sendNewGeom(); } } @@ -311,6 +314,8 @@ void NativeWindowObject::emitSinglePropChanged(NativeWindowObject::Property prop emit winImageChanged(); break; case NativeWindowObject::WinTypes: emit winTypeChanged(); break; + case NativeWindowObject::Visible: + emit visibilityChanged(); break; default: break; //do nothing otherwise } @@ -321,4 +326,5 @@ void NativeWindowObject::sendNewGeom(){ QList vals; vals << newgeom.topLeft() << newgeom.size(); requestProperties(props, vals); setProperties(props,vals); + emit VerifyNewGeometry(winid); } 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 6a63813e..87df1f10 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 @@ -23,6 +23,7 @@ class NativeWindowObject : public QObject{ Q_PROPERTY( QString shortTitle READ shortTitle NOTIFY shortTitleChanged) Q_PROPERTY( QString icon READ icon NOTIFY iconChanged) Q_PROPERTY( bool sticky READ isSticky NOTIFY stickyChanged) + Q_PROPERTY(bool isVisible READ isVisible NOTIFY visibilityChanged) //Button/Titlebar visibility Q_PROPERTY( bool showCloseButton READ showCloseButton NOTIFY winTypeChanged) Q_PROPERTY( bool showMinButton READ showMinButton NOTIFY winTypeChanged) @@ -109,6 +110,7 @@ public: Q_INVOKABLE bool showWindowFrame(); //QML Window States Q_INVOKABLE bool isSticky(); + Q_INVOKABLE bool isVisible(); Q_INVOKABLE int workspace(); //QML Geometry reporting @@ -150,6 +152,7 @@ signals: void RequestKill(WId); //Kill the window/app (usually from being unresponsive) void RequestPing(WId); //Verify that the window is still active (such as not closing after a request void RequestReparent(WId, WId, QPoint); //client window, frame window, relative origin point in frame + void VerifyNewGeometry(WId); // System Tray Icon Embed/Unembed Requests //void RequestEmbed(WId, QWidget*); //void RequestUnEmbed(WId, QWidget*); @@ -163,6 +166,7 @@ signals: void stickyChanged(); void winTypeChanged(); void geomChanged(); + void visibilityChanged(); }; // Declare the enumerations as Qt MetaTypes 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 9054f528..a0f58e71 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 @@ -47,14 +47,15 @@ void PanelObject::setGeometry( QRect newgeom ){ void PanelObject::syncWithSettings(QRect parent_geom){ //Read off all the settings - //qDebug() << "Sync Panel Settings:" << panel_id << parent_geom; - QString anchor = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/anchor", "bottom").toString().toLower(); - QString align = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/align", "center").toString().toLower(); - double length = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/length_percent", 100).toDouble()/100.0; - double width = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/width_font_percent", 2.1).toDouble(); + QString id = panel_id.section("/",-1); //last section (allow for prefixes to distinguish multiple monitors with the same profile but different screens) + //qDebug() << "Sync Panel Settings:" << panel_id << id << parent_geom; + QString anchor = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/anchor", "bottom").toString().toLower(); + QString align = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/align", "center").toString().toLower(); + double length = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/length_percent", 100).toDouble()/100.0; + double width = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/width_font_percent", 2.1).toDouble(); width = qRound(width * QApplication::fontMetrics().height() ); - this->setBackground( DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/background", "rgba(0,0,0,120)").toString() ); - // qDebug() << "Update Panel:" << panel_id << anchor+"/"+align << length << width; + 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; //Figure out the size of the panel @@ -79,6 +80,9 @@ void PanelObject::syncWithSettings(QRect parent_geom){ else if(anchor=="right"){ newgeom.moveTopRight(QPoint(parent_geom.width(), (parent_geom.height()-newgeom.height())/2 )); } else{ newgeom.moveBottomLeft(QPoint( (parent_geom.width()-newgeom.width())/2, parent_geom.height()) ); } } - //qDebug() << " - Calculated Geometry:" << newgeom; - this->setGeometry(newgeom); //Note: This is in parent-relative coordinates (not global) + //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()); + //qDebug() << " - Calculated Geometry (global):" << newgeom; + this->setGeometry(newgeom); //shift to global coordinates } 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 07d4e463..a565ef25 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 @@ -95,31 +95,45 @@ void RootDesktopObject::setPanels(QStringList ids){ this->emit changePanels(ids); return; } - + //qDebug() << "GOT PANEL CHANGE:" << ids; //Get the current bounding rectangle for the session QRect total; - for(int i=0; igeometry()); - } - //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(total); + for(int i=0; i<=s_objects.length(); i++){ + QRect geom; + QString prefix; + if(i==s_objects.length()){ + geom = total; //session geometry + prefix="session/"; }else{ - panel_objects.takeAt(i)->deleteLater(); - i--; + geom = s_objects[i]->geometry(); + total = total.united(geom); + prefix=s_objects[i]->name()+"/"; + } + QStringList newids = ids.filter(prefix); + //qDebug() << " Check Panel IDs:" << prefix << newids << ids; + //First update/remove any current panel objects + for(int i=0; iname()) ){ + //qDebug() << " - Update Existing Panel:" << panel_objects[i]->name(); + newids.removeAll(panel_objects[i]->name()); //already handled + panel_objects[i]->syncWithSettings(geom); + }else if(panel_objects[i]->name().startsWith(prefix) ){ + //qDebug() << " - Remove Existing Panel:" << panel_objects[i]->name(); + panel_objects.takeAt(i)->deleteLater(); + i--; + change = true; //list changed + } + } + //Now create any new panel objects as needed + for(int i=0; isyncWithSettings(geom); + panel_objects << tmp; change = true; //list changed } - } - //Now create any new panel objects as needed - for(int i=0; isyncWithSettings(total); - panel_objects << tmp; - change = true; //list changed - } + } //end loop over screens+session if(change){ emit panelsChanged(); } } -- cgit