aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-qt5/core/libLumina/RootSubWindow.cpp4
-rw-r--r--src-qt5/core/libLumina/RootWindow-mgmt.cpp56
-rw-r--r--src-qt5/core/libLumina/RootWindow.cpp10
-rw-r--r--src-qt5/core/libLumina/RootWindow.h7
4 files changed, 69 insertions, 8 deletions
diff --git a/src-qt5/core/libLumina/RootSubWindow.cpp b/src-qt5/core/libLumina/RootSubWindow.cpp
index 68fdde5c..a42f866a 100644
--- a/src-qt5/core/libLumina/RootSubWindow.cpp
+++ b/src-qt5/core/libLumina/RootSubWindow.cpp
@@ -347,6 +347,7 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
i--;
}else if(anim->state() != QPropertyAnimation::Running ){
if(WIN->property(NativeWindow::Size).toSize() != WinWidget->size() && activeState==Normal ){
+ qDebug() << "Got Direct Geometry Change:" << WIN->geometry();
this->setGeometry(WIN->geometry());
}
}
@@ -370,7 +371,7 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
WinWidget->setMaximumSize(vals[i].toSize());
break;
case NativeWindow::Active:
- //if(vals[i].toBool()){ WinWidget->setFocus(); }
+ if(vals[i].toBool()){ WinWidget->raiseWindow(); }
break;
/*case NativeWindow::FrameExtents:
qDebug() << " - FRAME CHANGE";
@@ -500,6 +501,7 @@ void RootSubWindow::mouseReleaseEvent(QMouseEvent *ev){
//Check for a right-click event
//qDebug() << "Frame Mouse Release Event";
QFrame::mouseReleaseEvent(ev);
+ WinWidget->raiseWindow(); //need to ensure the native window is always on top of this frame
if( (activeState==Normal) && (titleBar->geometry().contains(ev->pos())) && (ev->button()==Qt::RightButton) ){
otherM->popup(ev->globalPos());
return;
diff --git a/src-qt5/core/libLumina/RootWindow-mgmt.cpp b/src-qt5/core/libLumina/RootWindow-mgmt.cpp
index 00b3e336..525e43be 100644
--- a/src-qt5/core/libLumina/RootWindow-mgmt.cpp
+++ b/src-qt5/core/libLumina/RootWindow-mgmt.cpp
@@ -7,13 +7,57 @@
#include "RootWindow.h"
//Primary/private function
-void RootWindow::arrangeWindows(RootSubWindow *primary, QString type){
+void RootWindow::arrangeWindows(RootSubWindow *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<WINDOWS.length(); i++){
+ if(WINDOWS[i]->nativeWindow()->property(NativeWindow::Active).toBool()){ primary = WINDOWS[i]; }
+ }
+ if(primary==0 && !WINDOWS.isEmpty()){ primary = WINDOWS[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();
+ 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->nativeWindow()->property(NativeWindow::Workspace).toInt();
+ QList<RootSubWindow*> winlist = WINDOWS;
+ for(int i=0; i<winlist.length(); i++){
+ if(winlist[i]->nativeWindow()->property(NativeWindow::Workspace).toInt()!=wkspace
+ || !winlist[i]->nativeWindow()->property(NativeWindow::Visible).toBool()
+ || desktopArea.intersected(winlist[i]->geometry()).isNull() ){
+ //window is outside of the desired area or invisible - ignore it
+ winlist.removeAt(i);
+ i--;
+ }
}
- //Now loop over the windows and arrange them as needed
+ 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]->setGeometry( ct.x()-(geom.width()/2), ct.y()-(geom.height()/2), geom.width(), geom.height());
+ }else if(type=="single_max"){
+ winlist[i]->setGeometry( 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]->setGeometry(geom);
+ }
+ //qDebug() << " - New Geometry:" << winlist[i]->geometry();
+ } //end loop over winlist
}
// ================
@@ -21,13 +65,13 @@ void RootWindow::arrangeWindows(RootSubWindow *primary, QString type){
// ================
void RootWindow::ArrangeWindows(WId primary, QString type){
RootSubWindow* win = windowForId(primary);
- if(type.isEmpty()){ type = ""; } //grab the default arrangement format
+ if(type.isEmpty()){ type = "center"; } //grab the default arrangement format
arrangeWindows(win, type);
}
void RootWindow::TileWindows(WId primary, QString type){
RootSubWindow* win = windowForId(primary);
- if(type.isEmpty()){ type = ""; } //grab the default arrangement format for tiling
+ if(type.isEmpty()){ type = "single_max"; } //grab the default arrangement format for tiling
arrangeWindows(win, type);
}
@@ -45,5 +89,5 @@ void RootWindow::CheckWindowPosition(WId id, bool newwindow){
if(geom.height() < 20){ changed = true; geom.setHeight(100); }
if(changed){ win->setGeometry(geom); }
//Now run it through the window arrangement routine
- ArrangeWindows(id);
+ arrangeWindows(win, newwindow ?"center" : "snap", true);
}
diff --git a/src-qt5/core/libLumina/RootWindow.cpp b/src-qt5/core/libLumina/RootWindow.cpp
index 48c37c86..b0d07600 100644
--- a/src-qt5/core/libLumina/RootWindow.cpp
+++ b/src-qt5/core/libLumina/RootWindow.cpp
@@ -108,6 +108,16 @@ RootSubWindow* RootWindow::windowForId(WId id){
return tmp;
}
+QScreen* RootWindow::screenUnderMouse(){
+ QPoint mpos = QCursor::pos();
+ QList<QScreen*> scrns = QApplication::screens();
+ for(int i=0; i<scrns.length(); i++){
+ if(scrns[i]->geometry().contains(mpos)){ return scrns[i]; }
+ }
+ //Could not find an exact match - just return the first one
+ return scrns.first();
+}
+
// === PUBLIC SLOTS ===
void RootWindow::ResizeRoot(){
if(DEBUG){ qDebug() << "Resize Root..."; }
diff --git a/src-qt5/core/libLumina/RootWindow.h b/src-qt5/core/libLumina/RootWindow.h
index 9b1334dc..5f11fd6d 100644
--- a/src-qt5/core/libLumina/RootWindow.h
+++ b/src-qt5/core/libLumina/RootWindow.h
@@ -18,6 +18,8 @@
#include <QTimer>
#include <QApplication>
#include <QPaintEvent>
+#include <QScreen>
+#include <QDebug>
#include "RootSubWindow.h"
@@ -51,7 +53,10 @@ private:
//Window Management
QList<RootSubWindow*> WINDOWS;
RootSubWindow* windowForId(WId id);
- void arrangeWindows(RootSubWindow *primary = 0, QString type = "");
+ void arrangeWindows(RootSubWindow *primary = 0, QString type = "", bool primaryonly = false);
+
+ QScreen* screenUnderMouse();
+
public slots:
void ResizeRoot();
bgstack15