aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-01-13 12:45:09 -0800
committerKen Moore <ken@ixsystems.com>2018-01-13 12:45:09 -0800
commit91e8877b9fe79f01518f89653a9dc157a79a2e83 (patch)
tree9fe6f1fc242086224f79354833607da930f06796 /src-qt5/core/lumina-desktop-unified
parentAdd an additional OS-specific network device type parser. (diff)
downloadlumina-91e8877b9fe79f01518f89653a9dc157a79a2e83.tar.gz
lumina-91e8877b9fe79f01518f89653a9dc157a79a2e83.tar.bz2
lumina-91e8877b9fe79f01518f89653a9dc157a79a2e83.zip
Another large checkpoint commit for Lumina 2:
* Integrate the new window geometry manager class * Get the new OSInterface framework tied in * Start getting the various system monitoring solutions tied into the OSInterface
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified')
-rw-r--r--src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf21
-rw-r--r--src-qt5/core/lumina-desktop-unified/lumina-desktop.pro1
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp19
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h3
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp6
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h6
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-events/Window-mgmt.cpp105
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-events/events.pri3
8 files changed, 156 insertions, 8 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf b/src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf
new file mode 100644
index 00000000..07cf4635
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf
@@ -0,0 +1,21 @@
+[General]
+
+[templates]
+windows/anchor="bottom"
+windows/align="center"
+windows/length_percent=100
+windows/plugins=""
+windows/background="rgba(0,0,0,120)"
+
+[default]
+active_ids="initial"
+
+[session]
+
+[initial]
+anchor="bottom"
+align="center"
+length_percent=100
+width_percent=2.1
+plugins=""
+background="rgba(0,0,0,120)"
diff --git a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
index f28b96c2..96d84a71 100644
--- a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
+++ b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
@@ -24,6 +24,7 @@ include(../libLumina/ExternalProcess.pri)
include(../libLumina/XDGMime.pri)
include(../../src-cpp/plugins-base.pri)
+include(../../src-cpp/framework-OSInterface.pri)
#include all the main individual source groups
include(src-events/events.pri)
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 dae4676c..9bb78dd0 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
@@ -130,6 +130,10 @@ QRect NativeWindowObject::geometry(){
return geom;
}
+void NativeWindowObject::setGeometryNow(QRect geom){
+ updateGeometry(geom.x(), geom.y(), geom.width(), geom.height(), true);
+}
+
// QML ACCESS FUNCTIONS (shortcuts for particular properties in a format QML can use)
QString NativeWindowObject::winImage(){
//Need to alternate something on the end to ensure that QML knows to fetch the new image (non-cached only)
@@ -252,16 +256,21 @@ QRect NativeWindowObject::imageGeometry(){
return geom;
}
-void NativeWindowObject::updateGeometry(int x, int y, int width, int height){
+void NativeWindowObject::updateGeometry(int x, int y, int width, int height, bool now){
// Full frame+window geometry - go ahead and pull it apart and only update the interior window geom
QList<int> fgeom = this->property(NativeWindowObject::FrameExtents).value<QList<int> >();
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);
- //qDebug() << "Update Geometry:" << fgeom << QRect(x,y,width,height) << pos << sz;
- //requestProperties(QList<NativeWindowObject::Property>() << NativeWindowObject::GlobalPos << NativeWindowObject::Size, QList<QVariant>() << pos << sz);
- if(!geomTimer->isActive()){ geomTimer->start(); }
+ if(!now){
+ newgeom = QRect(pos, sz);
+ //qDebug() << "Update Geometry:" << fgeom << QRect(x,y,width,height) << pos << sz;
+ //requestProperties(QList<NativeWindowObject::Property>() << NativeWindowObject::GlobalPos << NativeWindowObject::Size, QList<QVariant>() << pos << sz);
+ if(!geomTimer->isActive()){ geomTimer->start(); }
+ }else{
+ requestProperties(QList<NativeWindowObject::Property>() << NativeWindowObject::GlobalPos << NativeWindowObject::Size , QList<QVariant>() << pos << sz );
+ setProperties(QList<NativeWindowObject::Property>() << NativeWindowObject::GlobalPos << NativeWindowObject::Size , QList<QVariant>() << pos << sz );
+ }
}
// ==== PUBLIC SLOTS ===
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 332fe896..6a63813e 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
@@ -92,6 +92,7 @@ public:
void requestProperties(QList<NativeWindowObject::Property>, QList<QVariant>, bool force = false);
Q_INVOKABLE QRect geometry(); //this returns the "full" geometry of the window (window + frame)
+ void setGeometryNow(QRect geom);
// QML ACCESS FUNCTIONS (shortcuts for particular properties in a format QML can use)
Q_INVOKABLE QString winImage();
@@ -113,7 +114,7 @@ public:
//QML Geometry reporting
Q_INVOKABLE QRect frameGeometry();
Q_INVOKABLE QRect imageGeometry();
- Q_INVOKABLE void updateGeometry(int x, int y, int width, int height); //For QML to change the current window position
+ Q_INVOKABLE void updateGeometry(int x, int y, int width, int height, bool now = false); //For QML to change the current window position
public slots:
Q_INVOKABLE void toggleVisibility();
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 bd6d0179..063c1337 100644
--- a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp
@@ -784,15 +784,19 @@ void NativeWindowSystem::NewWindowDetected(WId id){
registerClientEvents(win->id());
NWindows << win;
UpdateWindowProperties(win, NativeWindowObject::allProperties());
- win->setProperty(NativeWindowObject::FrameExtents, QVariant::fromValue<QList<int> >( QList<int>() << 5 << 5 << 30 << 5 ));
+ if(win->showWindowFrame()){
+ win->setProperty(NativeWindowObject::FrameExtents, QVariant::fromValue<QList<int> >( QList<int>() << 5 << 5 << 30 << 5 ));
+ }
qDebug() << "New Window [& associated ID's]:" << win->id() << win->property(NativeWindowObject::Name).toString();
SetupNewWindow(win);
+ CheckWindowPosition(id, true); //first time placement
//Now setup the connections with this window
connect(win, SIGNAL(RequestClose(WId)), this, SLOT(RequestClose(WId)) );
connect(win, SIGNAL(RequestKill(WId)), this, SLOT(RequestKill(WId)) );
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<NativeWindowObject::Property>, QList<QVariant>)), this, SLOT(RequestPropertiesChange(WId, QList<NativeWindowObject::Property>, QList<QVariant>)) );
+ connect(win, SIGNAL(VerifyNewGeometry(WId)), this, SLOT(CheckWindowPosition(WId)) );
xcb_map_window(QX11Info::connection(), win->id());
emit NewWindowAvailable(win);
}
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 24128f32..5810fc36 100644
--- a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h
+++ b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h
@@ -129,6 +129,12 @@ private slots:
void RequestPing(WId);
void RequestReparent(WId, WId, QPoint); //client, parent, relative origin point in parent
+ //Window-mgmt functions (see Window-mgmt.cpp for details)
+ void ArrangeWindows(WId primary, QString type);
+ void TileWindows(WId primary, QString type);
+ void CheckWindowPosition(WId id, bool newwindow = false);
+ void arrangeWindows(NativeWindowObject *primary, QString type, bool primaryonly = false);
+
signals:
void NewWindowAvailable(NativeWindowObject*);
void WindowClosed();
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
new file mode 100644
index 00000000..0b45c208
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-events/Window-mgmt.cpp
@@ -0,0 +1,105 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "NativeWindowSystem.h"
+inline QScreen* screenUnderMouse(){
+ QPoint pos = QCursor::pos();
+ QList<QScreen*> scrns = QGuiApplication::screens();
+ for(int i=0; i<scrns.length(); i++){
+ if(scrns[i]->geometry().contains(pos)){ return scrns[i]; }
+ }
+ return 0;
+}
+
+
+//Primary/private function
+void NativeWindowSystem::arrangeWindows(NativeWindowObject *primary, QString type, bool primaryonly){
+ if(type.isEmpty()){ type = "center"; }
+ if(primary==0){
+ //Get the currently active window and treat that as the primary
+ for(int i=0; i<NWindows.length(); i++){
+ if(NWindows[i]->property(NativeWindowObject::Active).toBool()){ primary = NWindows[i]; }
+ }
+ if(primary==0 && !NWindows.isEmpty()){ primary = NWindows[0]; } //just use the first one in the list
+ }
+ //Now get the current screen that the mouse cursor is over (and valid area)
+ QScreen *screen = screenUnderMouse();
+ if(screen==0){ return; } //should never happen (theoretically)
+ QRect desktopArea = screen->availableGeometry();
+ //qDebug() << "Arrange Windows:" << primary->geometry() << type << primaryonly << desktopArea;
+ //Now start filtering out all the windows that need to be ignored
+ int wkspace = primary->property(NativeWindowObject::Workspace).toInt();
+ QList<NativeWindowObject*> winlist = NWindows;
+ for(int i=0; i<winlist.length(); i++){
+ if(winlist[i]->property(NativeWindowObject::Workspace).toInt()!=wkspace
+ || !winlist[i]->property(NativeWindowObject::Visible).toBool()
+ || desktopArea.intersected(winlist[i]->geometry()).isNull() ){
+ //window is outside of the desired area or invisible - ignore it
+ winlist.removeAt(i);
+ i--;
+ }
+ }
+ if(!winlist.contains(primary)){ winlist << primary; } //could be doing this on a window right before it is shown
+ else if(primaryonly){ winlist.removeAll(primary); winlist << primary; } //move primary window to last
+ //QRegion used;
+ for(int i=0; i<winlist.length(); i++){
+ if(primaryonly && winlist[i]!=primary){ continue; } //skip this window
+ //Now loop over the windows and arrange them as needed
+ QRect geom = winlist[i]->geometry();
+ //verify that the window is contained by the desktop area
+ if(geom.width()>desktopArea.width()){ geom.setWidth(desktopArea.width()); }
+ if(geom.height()>desktopArea.height()){ geom.setHeight(desktopArea.height()); }
+ //Now apply the proper placement routine
+ if(type=="center"){
+ QPoint ct = desktopArea.center();
+ winlist[i]->setGeometryNow( QRect( ct.x()-(geom.width()/2), ct.y()-(geom.height()/2), geom.width(), geom.height()) );
+ }else if(type=="snap"){
+
+ }else if(type=="single_max"){
+ winlist[i]->setGeometryNow( QRect( desktopArea.x(), desktopArea.y(), desktopArea.width(), desktopArea.height()) );
+ }else if(type=="under-mouse"){
+ QPoint ct = QCursor::pos();
+ geom = QRect(ct.x()-(geom.width()/2), ct.y()-(geom.height()/2), geom.width(), geom.height() );
+ //Now verify that the top of the window is still contained within the desktop area
+ if(geom.y() < desktopArea.y() ){ geom.moveTop(desktopArea.y()); }
+ winlist[i]->setGeometryNow(geom);
+
+ }
+ //qDebug() << " - New Geometry:" << winlist[i]->geometry();
+ } //end loop over winlist
+}
+
+// ================
+// Public slots for starting the arrangement routine(s) above
+// ================
+void NativeWindowSystem::ArrangeWindows(WId primary, QString type){
+ NativeWindowObject* win = findWindow(primary);
+ if(type.isEmpty()){ type = "center"; } //grab the default arrangement format
+ arrangeWindows(win, type);
+}
+
+void NativeWindowSystem::TileWindows(WId primary, QString type){
+ NativeWindowObject* win = findWindow(primary);
+ if(type.isEmpty()){ type = "single_max"; } //grab the default arrangement format for tiling
+ arrangeWindows(win, type);
+}
+
+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);
+ if(win==0){ return; } //invalid window
+ QRect geom = win->geometry();
+ bool changed = false;
+ //Make sure it is on the screen (quick check)
+ if(geom.x() < 0){ changed = true; geom.moveLeft(0); }
+ if(geom.y() < 0){ changed = true; geom.moveTop(0); }
+ if(geom.width() < 20){ changed = true; geom.setWidth(100); }
+ if(geom.height() < 20){ changed = true; geom.setHeight(100); }
+ if(changed){ win->setGeometryNow(geom); }
+ //Now run it through the window arrangement routine
+ arrangeWindows(win, newwindow ?"center" : "snap", true);
+}
diff --git a/src-qt5/core/lumina-desktop-unified/src-events/events.pri b/src-qt5/core/lumina-desktop-unified/src-events/events.pri
index 3f89fdf2..3f586e8b 100644
--- a/src-qt5/core/lumina-desktop-unified/src-events/events.pri
+++ b/src-qt5/core/lumina-desktop-unified/src-events/events.pri
@@ -5,7 +5,8 @@ LIBS *= -lc -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-image -lxcb-composite -lxcb-damag
SOURCES *= $${PWD}/LShortcutEvents.cpp \
$${PWD}/NativeEventFilter.cpp \
$${PWD}/NativeKeyToQt.cpp \
- $${PWD}/NativeWindowSystem.cpp
+ $${PWD}/NativeWindowSystem.cpp \
+ $${PWD}/Window-mgmt.cpp
HEADERS *= $${PWD}/LShortcutEvents.h \
bgstack15