This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch feature/rootless-mode in repository x2gokdriveclient. commit 972ee17166f206c4fbb2a0af18a3e1159455ecb7 Author: Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> Date: Wed Feb 16 13:41:59 2022 -0600 transition between kdrive and virtual desktop coordinates. --- client.cpp | 43 ++++++++++++++++++++++++++----------------- displayarea.cpp | 20 ++++++++++++++------ extwin.cpp | 30 ++++++++++++------------------ extwin.h | 3 ++- 4 files changed, 54 insertions(+), 42 deletions(-) diff --git a/client.cpp b/client.cpp index 874eb4b..b19b3fd 100644 --- a/client.cpp +++ b/client.cpp @@ -164,11 +164,6 @@ Client::Client() parseOptions(); if(!rootless) initDesktopMode(); - else - { - hide(); - ((QGuiApplication*)QGuiApplication::instance())->setQuitOnLastWindowClosed(false); - } clientSocket=new QTcpSocket(this); @@ -202,6 +197,11 @@ Client::Client() slotScreenAdded(screen); } QTimer::singleShot(10,this,SLOT(connectToServer())); + if(rootless) + { + hide(); + ((QGuiApplication*)QGuiApplication::instance())->setQuitOnLastWindowClosed(false); + } } Client::~Client() @@ -695,6 +695,10 @@ void Client::connectToServer() { // setWindowTitle("X2GO SESSION"); + if(rootless) + { + hide(); + } KDRStdErr(false)<<"Connecting to remote host "<<host<<":"<<port<<KDR_ENDL; clientSocket->connectToHost(host, port); } @@ -802,7 +806,8 @@ void Client::renderFrame() ExtWin* win=findExtWinById(currentFrame->winId); if(win) { - win->getDisplayArea()->repaint(currentFrame->x-win->geometry().x(), currentFrame->y-win->geometry().y(), currentFrame->width, currentFrame->height); + QPoint kdrPos=win->virtualToKdrivePosition(win->geometry().topLeft()); + win->getDisplayArea()->repaint(currentFrame->x-kdrPos.x(), currentFrame->y-kdrPos.y(), currentFrame->width, currentFrame->height); } else { @@ -813,7 +818,8 @@ void Client::renderFrame() { foreach(ExtWin* win, extWindows) { - win->getDisplayArea()->repaint(currentFrame->x-win->geometry().x(), currentFrame->y-win->geometry().y(), currentFrame->width, currentFrame->height); + QPoint kdrPos=win->virtualToKdrivePosition(win->geometry().topLeft()); + win->getDisplayArea()->repaint(currentFrame->x-kdrPos.x(), currentFrame->y-kdrPos.y(), currentFrame->width, currentFrame->height); } } } @@ -1209,7 +1215,7 @@ void Client::getWinUpdateBuffer() } else { - KDRStdErr()<<"load icon: "<<icon.width()<<"x"<<icon.height(); +// KDRStdErr()<<"load icon: "<<icon.width()<<"x"<<icon.height(); } readFromBuf+=icon_size; } @@ -1294,7 +1300,8 @@ void Client::getWinUpdateBuffer() win->setMinimumHeight(minh); } win->resize(w,h); - win->move(x,y); + win->move(win->kdriveToVirtualPosition(QPoint(x,y))); +// Client::KDRStdErr()<<"new win pos: "<<x<<":"<<y<<" translated to "<< win->kdriveToVirtualPosition(QPoint(x,y)).x()<<":"<<win->kdriveToVirtualPosition(QPoint(x,y)).y()<<KDR_ENDL; win->showNormal(); win->raise(); win->activateWindow(); @@ -1305,11 +1312,12 @@ void Client::getWinUpdateBuffer() } // win->update(); } + QPoint adjustedWinPos=win->kdriveToVirtualPosition(QPoint(x,y)); // KDRStdErr()<<KDR_DEC<<name<<" "<<x<<":"<<y<<" "<<w<<"x"<<h<<" min size: "<<minw<<"x"<<minh<<" bw - "<<bw<<" "<<visibility<<KDR_ENDL; if(win->geometry().width() != w || win->geometry().height() != h) win->resize(w,h); - if(win->geometry().x()!=x || win->geometry().y()!=y) - win->move(x,y); + if(win->geometry().x()!=adjustedWinPos.x() || win->geometry().y()!=adjustedWinPos.y()) + win->move(adjustedWinPos); if(win->windowTitle()!=name) win->setWindowTitle(name); // win->raise(); @@ -1854,7 +1862,7 @@ void Client::sendGeometryEvent() { bool isPrimary=(i==primaryScreenIndex); QRect* scr=&ephyrScreens[i]; -// KDRStdErr()<<"X2GoKDrive-"<<i<<scr->size().width()<<scr->size().height()<<scr->topLeft().x()<<scr->topLeft().y()<<isPrimary; + KDRStdErr()<<"X2GoKDrive-"<<i<<" "<<scr->size().width()<<"x"<<scr->size().height()<<" "<<scr->topLeft().x()<<":"<<scr->topLeft().y()<<" isPrimary: "<<isPrimary<<KDR_ENDL; if(isPrimary) { memcpy(evmsg+8,(char*)&i,1); @@ -1912,12 +1920,13 @@ void Client::changeWindow(ExtWin* win, uint8_t newState) uint32_t sibId=win->getNextSibId(); uint16_t x,y,w,h; uint8_t focus=win->getHasFocus(); - x=win->adjustGeometry().x(); - y=win->adjustGeometry().y(); - w=win->adjustGeometry().width(); - h=win->adjustGeometry().height(); + QPoint kdrPoint=win->virtualToKdrivePosition(QPoint(win->geometry().topLeft())); + x=kdrPoint.x(); + y=kdrPoint.y(); + w=win->geometry().width(); + h=win->geometry().height(); etype=WINCHANGE; - // KDRStdErr()<<"Request change for "<<KDR_HEX<<extWinId<<KDR_ENDL; +// KDRStdErr()<<"win pos "<<x<<":"<<y<<KDR_ENDL; memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&extWinId,4); memcpy(evmsg+8,(char*)&sibId,4); diff --git a/displayarea.cpp b/displayarea.cpp index 598996e..c90242f 100644 --- a/displayarea.cpp +++ b/displayarea.cpp @@ -158,7 +158,10 @@ void DisplayArea::paintEvent(QPaintEvent* ev) { // if(!disp) { - painter.drawPixmap(currentFrame->x-((ExtWin*)parentWidget)->adjustGeometry().x(),currentFrame->y-((ExtWin*)parentWidget)->adjustGeometry().y(),pix); + ExtWin* parWin=(ExtWin*)parentWidget; + QPoint kdrPos=parWin->virtualToKdrivePosition(parWin->geometry().topLeft()); + painter.drawPixmap(currentFrame->x-kdrPos.x(),currentFrame->y-kdrPos.y(),pix); +// Client::KDRStdErr()<<"DRAW pix on: "<<currentFrame->x-kdrPos.x()<<":"<<currentFrame->y-kdrPos.y()<<KDR_ENDL; } // else // { @@ -173,16 +176,19 @@ void DisplayArea::paintEvent(QPaintEvent* ev) { if(!client->isRootless()) { - Client::KDRStdErr()<<"WM update: "<<Client::QRectToStr(ev->rect())<<KDR_ENDL; +// Client::KDRStdErr()<<"WM update: "<<Client::QRectToStr(ev->rect())<<KDR_ENDL; painter.drawImage(ev->rect(),*(client->getDisplayImage()),ev->rect()); } else { // if(((ExtWin*)parentWidget)->getWindowType()==WINDOW_TYPE_NORMAL) // Client::KDRStdErr()<<"WM update: "<<Client::QRectToStr(ev->rect())<<KDR_ENDL; + ExtWin* parWin=(ExtWin*)parentWidget; + QPoint kdrPos=parWin->virtualToKdrivePosition(parWin->geometry().topLeft()); + painter.drawImage(ev->rect().x(),ev->rect().y(), - *(client->getDisplayImage()), ev->rect().x()+((ExtWin*)parentWidget)->adjustGeometry().x(), - ev->rect().y()+((ExtWin*)parentWidget)->adjustGeometry().y(), ev->rect().width(), ev->rect().height()); + *(client->getDisplayImage()), ev->rect().x()+kdrPos.x(), + ev->rect().y()+kdrPos.y(), ev->rect().width(), ev->rect().height()); } } painter.end(); @@ -237,8 +243,10 @@ void DisplayArea::mouseMoveEvent(QMouseEvent* event) } else { - x=event->x()+parentWidget->geometry().x(); - y=event->y()+parentWidget->geometry().y(); + ExtWin* w=(ExtWin*) parentWidget; + QPoint parTopLeft=w->virtualToKdrivePosition(w->geometry().topLeft()); + x=event->x()+parTopLeft.x(); + y=event->y()+parTopLeft.y(); } memcpy(evmsg,(char*)&etype,4); diff --git a/extwin.cpp b/extwin.cpp index 98204de..dab59d6 100644 --- a/extwin.cpp +++ b/extwin.cpp @@ -23,6 +23,7 @@ #include <QApplication> #include <QTimer> #include <QCloseEvent> +#include <QScreen> ExtWin::ExtWin(uint32_t extWinId, Client *client, QWidget* parent, Qt::WindowFlags flags): QMainWindow(parent, flags) @@ -78,7 +79,7 @@ void ExtWin::closeEvent(QCloseEvent* ev) { if((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG)) { - Client::KDRStdErr()<<"Request window close "; +// Client::KDRStdErr()<<"Request window close "; client->changeWindow(this,DELETED); ev->ignore(); } @@ -244,23 +245,16 @@ ExtWin* ExtWin::findWinByZInd(int zInd, QList<ExtWin*> &siblings) return 0; } -QRect ExtWin::adjustGeometry() +QPoint ExtWin::virtualToKdrivePosition(QPoint virtPos) { - return geometry(); - /* - if(transWinId) - { - ExtWin* trwin=client->findExtWinById(transWinId); - if(!trwin) - { - Client::KDRStdErr()<<"Error finding trans window "<<transWinId<<KDR_ENDL; - return geometry(); - } - QRect trGeom=trwin->adjustGeometry(); - QRect geom=geometry(); - return QRect(trGeom.x()+geom.x(), trGeom.y()+geom.y(),geom.width(),geom.height()); - } - return geometry();*/ + QRect avGeom=((QGuiApplication*)QGuiApplication::instance())->screens()[0]->availableVirtualGeometry(); + return QPoint(virtPos.x()-avGeom.x(),virtPos.y()-avGeom.y()); +} + +QPoint ExtWin::kdriveToVirtualPosition(QPoint kdrPos) +{ + QRect avGeom=((QGuiApplication*)QGuiApplication::instance())->screens()[0]->availableVirtualGeometry(); + return QPoint(kdrPos.x()+avGeom.x(),kdrPos.y()+avGeom.y()); } void ExtWin::slotCheckStackOrder() @@ -345,7 +339,7 @@ void ExtWin::slotCheckStackOrder() QTimer::singleShot(5,this,SLOT(slotCheckStackOrder())); return ; } - Client::KDRStdErr()<<"Need to restack "<<KDR_HEX<<extWinId<<" Above "<<newNextSib<<KDR_ENDL; +// Client::KDRStdErr()<<"Need to restack "<<KDR_HEX<<extWinId<<" Above "<<newNextSib<<KDR_ENDL; client->repaintAllWindows(); nextSibId=newNextSib; client->changeWindow(this); diff --git a/extwin.h b/extwin.h index a82498e..7bf6c4f 100644 --- a/extwin.h +++ b/extwin.h @@ -48,7 +48,8 @@ public: uint32_t getTransWinId(){return transWinId;} DisplayArea* getDisplayArea(){return displayArea;} void setModality(int mod){modality=mod;} - QRect adjustGeometry(); + QPoint virtualToKdrivePosition(QPoint virtPos); + QPoint kdriveToVirtualPosition(QPoint kdrPos); void setHasFocus( bool f){focus=f;} uint8_t getHasFocus(){return focus;} -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gokdriveclient.git