aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina/RootWindow-mgmt.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-08-27 08:14:44 -0400
committerKen Moore <ken@ixsystems.com>2017-08-27 08:14:44 -0400
commit6824bc2c5069b8ea6799bf6e84d66de205bc8e0c (patch)
tree43fc0b68b74d3e5d303affd1eb9772cd94e8f1df /src-qt5/core/libLumina/RootWindow-mgmt.cpp
parentMerge branch 'master' of github.com:trueos/lumina (diff)
downloadlumina-6824bc2c5069b8ea6799bf6e84d66de205bc8e0c.tar.gz
lumina-6824bc2c5069b8ea6799bf6e84d66de205bc8e0c.tar.bz2
lumina-6824bc2c5069b8ea6799bf6e84d66de205bc8e0c.zip
Add 3 simple window arrangements to Lumina 2.
Also clean up a bit of the invisible layering for embedded windows.
Diffstat (limited to 'src-qt5/core/libLumina/RootWindow-mgmt.cpp')
-rw-r--r--src-qt5/core/libLumina/RootWindow-mgmt.cpp56
1 files changed, 50 insertions, 6 deletions
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);
}
bgstack15