From 1902050558bfdb3cbb5ff8fb271dc7c0bfe3b97b Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 10 Jul 2015 10:16:40 -0400 Subject: Adjust the window check/resize routine a bit more. Now it seems to workmuch better, still have a couple apps which might go past the bottom of the screen a couple pixels, but that might be the app doing some auto-resizing of itself later. --- lumina-desktop/LSession.cpp | 70 ++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 26 deletions(-) (limited to 'lumina-desktop/LSession.cpp') diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index aa1c1e0c..58062fb4 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -25,7 +25,7 @@ #include #ifndef DEBUG -#define DEBUG 0 +#define DEBUG 1 #endif XCBEventFilter *evFilter = 0; @@ -320,6 +320,15 @@ void LSession::watcherChange(QString changed){ } } +void LSession::checkWindowGeoms(){ + //Only do one window per run (this will be called once per new window - with time delays between) + if(checkWin.isEmpty()){ return; } + if(RunningApps.contains(checkWin[0]) ){ //just to make sure it did not close during the delay + adjustWindowGeom( checkWin[0] ); + } + checkWin.removeAt(0); +} + void LSession::checkUserFiles(){ //internal version conversion examples: // [1.0.0 -> 1000000], [1.2.3 -> 1002003], [0.6.1 -> 6001] @@ -452,9 +461,15 @@ void LSession::registerDesktopWindows(){ void LSession::adjustWindowGeom(WId win, bool maximize){ //Quick hack for making sure that new windows are not located underneath any panels // Get the window location - QRect geom = XCB->WindowGeometry(win, true); //always include the frame if possible - if(DEBUG){ qDebug() << "Check Window Geometry:" << XCB->WindowClass(win) << !geom.isNull(); } - if(geom.isNull()){ return; } //Could not get geometry + QRect geom = XCB->WindowGeometry(win, false); + //Get the frame size + QList frame = XCB->WindowFrameGeometry(win); //[top,bottom,left,right] sizes of the frame + //Calculate the full geometry (window + frame) + QRect fgeom = QRect(geom.x()-frame[2], geom.y()-frame[0], geom.width()+frame[2]+frame[3], geom.height()+frame[0]+frame[1]); + if(DEBUG){ + qDebug() << "Check Window Geometry:" << XCB->WindowClass(win) << !geom.isNull() << geom << fgeom; + } + if(geom.isNull()){ return; } //Could not get geometry for some reason //Get the available geometry for the screen the window is on QRect desk; for(int i=0; iScreen(); } desk = DESKTOPS[i]->availableScreenGeom(); + if(DEBUG){ qDebug() << " - Screen Geom:" << desk; } break; } } @@ -472,28 +488,33 @@ void LSession::adjustWindowGeom(WId win, bool maximize){ XCB->MoveResizeWindow(win, geom); XCB->MaximizeWindow(win, true); //directly set the appropriate "maximized" flags (bypassing WM) - }else if(!desk.contains(geom) ){ - if(DEBUG){ - qDebug() << " - Desk:" << desk.x() << desk.y() << desk.width() << desk.height(); - qDebug() << " - Geom:" << geom.x() << geom.y() << geom.width() << geom.height(); - } - QList frame = XCB->WindowFrameGeometry(win); - if(DEBUG){ qDebug() << " - Frame:" << frame; } + }else if(!desk.contains(fgeom) ){ //Adjust origin point for left/top margins - if(geom.y() < desk.y()){ geom.moveTop(desk.y()); } //move down to the edge (top panel) - if(geom.x() < desk.x()){ geom.moveLeft(desk.x()); } //move right to the edge (left panel) + if(fgeom.y() < desk.y()){ geom.moveTop(desk.y()+frame[0]); fgeom.moveTop(desk.y()); } //move down to the edge (top panel) + if(fgeom.x() < desk.x()){ geom.moveLeft(desk.x()+frame[2]); fgeom.moveLeft(desk.x()); } //move right to the edge (left panel) //Adjust size for bottom margins (within reason, since window titles are on top normally) // if(geom.right() > desk.right() && (geom.width() > 100)){ geom.setRight(desk.right()); } - if(geom.bottom() > desk.bottom() && geom.height() > 10){ - //Also adjust the sizing for the frame (the moveResize fuction is for the base window only) - geom.setBottom(desk.bottom()-frame[0]-frame[1]); + if(fgeom.bottom() > desk.bottom() && geom.height() > 10){ + int diff = fgeom.bottom()-desk.bottom(); //amount of overlap + if( (fgeom.height()+ diff)< desk.height()){ + //just move the window - there is room for it above + geom.setBottom(desk.bottom()-frame[1]); + fgeom.setBottom(desk.bottom()); + }else{ + //Need to resize the window - keeping the origin point the same + geom.setHeight( geom.height()-diff-1 ); //shrink it by the difference (need an extra pixel somewhere) + fgeom.setHeight( fgeom.height()-diff ); + } } //Now move/resize the window - if(DEBUG){ qDebug() << " - New Geom:" << geom.x() << geom.y() << geom.width() << geom.height(); } - XCB->MoveResizeWindow(win, geom); + if(DEBUG){ + qDebug() << " - New Geom:" << geom << fgeom; + } + //Note: Fluxbox treats this weird, the origin point needs to be the total (frame included), + // but the size needs to be the raw (no frame) value + XCB->MoveResizeWindow(win, QRect(fgeom.topLeft(), geom.size()) ); } - } void LSession::SessionEnding(){ @@ -541,13 +562,7 @@ void LSession::systemWindow(){ void LSession::playAudioFile(QString filepath){ //Setup the audio output systems for the desktop if(DEBUG){ qDebug() << "Play Audio File"; } - //if(audioThread==0){ qDebug() << " - Initialize audio systems"; audioThread = new QThread(); init = true; } if(mediaObj==0){ qDebug() << " - Initialize media player"; mediaObj = new QMediaPlayer(); } - /*if(mediaObj && init){ //in case it errors for some reason - qDebug() << " -- Move audio objects to separate thread"; - mediaObj->moveToThread(audioThread); - audioThread->start(); - }*/ if(mediaObj !=0 ){ if(DEBUG){ qDebug() << " - starting playback:" << filepath; } mediaObj->setVolume(100); @@ -569,7 +584,10 @@ void LSession::WindowPropertyEvent(){ LSession::restoreOverrideCursor(); //restore the mouse cursor back to normal (new window opened?) //Perform sanity checks on any new window geometries for(int i=0; i Date: Fri, 10 Jul 2015 11:32:46 -0400 Subject: Final cleanup of debugging messages and temporary changes prior to release. Aslo update the default key bindings a bit: 1) Add a shortcut to lock the screen (Pause key) 2) Adjust the tiling shortcuts to Alt+[left/right] instead of Ctrl-[left/right]. The Ctrl shortcuts were already in use by Fluxbox. --- lumina-desktop/LSession.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lumina-desktop/LSession.cpp') diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 58062fb4..815920e5 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -25,7 +25,7 @@ #include #ifndef DEBUG -#define DEBUG 1 +#define DEBUG 0 #endif XCBEventFilter *evFilter = 0; -- cgit From 257e7c26a9751242ed01ef5cad2d090f04b052b7 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 17 Jul 2015 14:59:28 -0400 Subject: Fix up a calculation of the new window geometry - add in checks for those strange windows (like gimp) which move the main window off-screen before showing it (causing errors/crashes in the program when moving it back). --- lumina-desktop/LSession.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lumina-desktop/LSession.cpp') diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 815920e5..a0424667 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -459,6 +459,7 @@ void LSession::registerDesktopWindows(){ } void LSession::adjustWindowGeom(WId win, bool maximize){ + if(DEBUG){ qDebug() << "AdjustWindowGeometry():" << win << maximize; } //Quick hack for making sure that new windows are not located underneath any panels // Get the window location QRect geom = XCB->WindowGeometry(win, false); @@ -481,6 +482,7 @@ void LSession::adjustWindowGeom(WId win, bool maximize){ break; } } + if(desk.isNull()){ return; } //Unable to deteremine screen //Adjust the window location if necessary if(maximize){ if(DEBUG){ qDebug() << " - Maximizing New Window:" << desk.width() << desk.height(); } @@ -495,12 +497,15 @@ void LSession::adjustWindowGeom(WId win, bool maximize){ //Adjust size for bottom margins (within reason, since window titles are on top normally) // if(geom.right() > desk.right() && (geom.width() > 100)){ geom.setRight(desk.right()); } if(fgeom.bottom() > desk.bottom() && geom.height() > 10){ + if(DEBUG){ qDebug() << "Adjust Y:" << fgeom << geom << desk; } int diff = fgeom.bottom()-desk.bottom(); //amount of overlap + if(DEBUG){ qDebug() << "Y-Diff:" << diff; } + if(diff < 0){ diff = -diff; } //need a positive value if( (fgeom.height()+ diff)< desk.height()){ //just move the window - there is room for it above geom.setBottom(desk.bottom()-frame[1]); fgeom.setBottom(desk.bottom()); - }else{ + }else if(geom.height() < diff){ //window bigger than the difference //Need to resize the window - keeping the origin point the same geom.setHeight( geom.height()-diff-1 ); //shrink it by the difference (need an extra pixel somewhere) fgeom.setHeight( fgeom.height()-diff ); -- cgit