This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch feature/rootless-mode in repository x2gokdriveclient. from 468c632 Support for MS Windows in rootless mode. new 27ab44d Improved display image updates. The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: client.cpp | 87 +++++++++++++++++++++----------------- client.h | 9 ++-- displayarea.cpp | 126 +++++++++++++++++++++++--------------------------------- displayarea.h | 1 - menuframe.cpp | 2 + 5 files changed, 107 insertions(+), 118 deletions(-) -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gokdriveclient.git
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 27ab44de9d988003748f34619d41acd7c4d147b7 Author: Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> Date: Mon Feb 14 13:30:47 2022 -0600 Improved display image updates. --- client.cpp | 87 +++++++++++++++++++++----------------- client.h | 9 ++-- displayarea.cpp | 126 +++++++++++++++++++++++--------------------------------- displayarea.h | 1 - menuframe.cpp | 2 + 5 files changed, 107 insertions(+), 118 deletions(-) diff --git a/client.cpp b/client.cpp index dd43279..34041bc 100644 --- a/client.cpp +++ b/client.cpp @@ -254,19 +254,7 @@ void Client::initDesktopMode() connect(menu,SIGNAL(aboutToShow()), this, SLOT(slotSetupMenu())); setWindowTitle(mainWndTitle); } -void Client::slotGrabDisplay() -{ - if(hasUpdates) - { - // Client::KDRStdErr()<<"save display"; - if(!rootless) - { - QScreen *screen = QGuiApplication::primaryScreen(); - displayPix = screen->grabWindow(winId()); - } - hasUpdates=false; - } -} + void Client::slotIdentifyScreen() { @@ -323,9 +311,6 @@ void Client::slotIdentifyScreen() menu->show(); //hide the identifier, when no screen actions are hovered QTimer::singleShot(100,this, SLOT(slotIdentifyScreen())); - QTimer *tm=new QTimer(this); - connect(tm, &QTimer::timeout, this, &Client::slotGrabDisplay); - tm->start(1000); } void Client::editWindowTitle() @@ -526,7 +511,6 @@ void Client::slotSetupMenu() actDisp[i]->setVisible(false); } } - slotGrabDisplay(); } bool Client::isDisplayPointer(QMouseEvent* event) @@ -730,28 +714,19 @@ QPixmap Client::getPixmapFromCache(uint32_t crc) return frameCache[crc]; } -void Client::setDisplayPix(QPixmap pix, int32_t x, int32_t y) +void Client::saveDispImage(QString path) { - if(x==-1 || y==-1) - { - displayPix=pix; - } - else - { - QPainter pt; - pt.begin(&displayPix); - pt.drawPixmap(x,y,pix); - pt.end(); - } + displayImage.save(path); } - void Client::renderFrame() { + QPainter dispImagePainter; + if(!currentFrame->crc) { //we got a whole display copy - if(currentFrame->x==-1) + if(currentFrame->x==-1||currentFrame->y==-1) { KDRStdErr()<<"got initial Image: "<<currentFrame->width<<"x"<<currentFrame->height<<" "<<QSizeToStr(currentFrame->regions[0]->pix.size())<<KDR_ENDL; if(!rootless) @@ -759,13 +734,19 @@ void Client::renderFrame() displayArea->resize(currentFrame->width, currentFrame->height); this->resize(currentFrame->width, currentFrame->height); } - setDisplayPix(currentFrame->regions[0]->pix); - } - else - { -// KDRStdErr()<<"got Screen update: "<<currentFrame->x<<":"<< currentFrame->y<<" "<<KDR_ENDL; - setDisplayPix(currentFrame->regions[0]->pix, currentFrame->x, currentFrame->y); + displayImage=QImage(currentFrame->width, currentFrame->height, QImage::Format_RGB32); +/* dispImagePainter.begin(&displayImage); + dispImagePainter.drawPixmap(0,0,currentFrame->regions[0]->pix); + dispImagePainter.end();*/ +// saveDispImage("/tmp/dispInit.png"); } +// else +// { +// dispImagePainter.begin(&displayImage); +// dispImagePainter.drawPixmap(currentFrame->x,currentFrame->y,currentFrame->regions[0]->pix); +// dispImagePainter.end(); +// // saveDispImage("/tmp/dispUpdate.png"); +// } } else { @@ -805,9 +786,14 @@ void Client::renderFrame() cacheSize+=frameSize; frameCount++; - +// saveDispImage("/tmp/dispDraw.png"); /*KDRStdErr()<<"Insert in cache Frame:"<<frameCount<<dec<<frameSize<<pix.size()<< frameCache.count()<<"Total(MB)"<<cacheSize/(1024*1024);*/ +// QPainter dispImagePainter; +// dispImagePainter.begin(this->getDisplayImage()); +// dispImagePainter.drawPixmap(currentFrame->x,currentFrame->y,pix); +// dispImagePainter.end(); + } } wantRepaint=true; @@ -837,6 +823,31 @@ void Client::renderFrame() } } setUptodate(); + + +//////put another func if works + + Frame* currentFrame=this->getCurrentFrame(); + QPixmap pix; + if(!currentFrame->crc) + { + // Client::KDRStdErr()<<"Draw DISPLAY PIX "<<KDR_ENDL; + pix=currentFrame->regions[0]->pix; + // disp=true; + } + else + { + // Client::KDRStdErr()<<"Draw PIX from cache"<<KDR_ENDL; + pix=this->getPixmapFromCache(currentFrame->crc); + } + if(currentFrame->x==-1 || currentFrame->y==-1) + { + currentFrame->x=currentFrame->y=0; + } + QPainter painter; + painter.begin(this->getDisplayImage()); + painter.drawPixmap(currentFrame->x,currentFrame->y,pix); + painter.end(); } void Client::setUptodate() diff --git a/client.h b/client.h index ad87a8e..b9c544a 100644 --- a/client.h +++ b/client.h @@ -183,7 +183,6 @@ public: void setUptodate(); QPixmap getPixmapFromCache(uint32_t crc); QPixmap addPixmapToCache(); - QPixmap getDisplayPix(){return displayPix;} bool isDisplayPointer(QMouseEvent* event); void addToSelectionOutput(OutputChunk* chunk); bool serverSupportsExtSelection(){return serverExtSelection;} @@ -200,11 +199,11 @@ public: const QList<ExtWin*> getExtWindows(){return extWindows;} const QList<ExtWin*> getSiblings(ExtWin* win); ExtWin* findExtWinById(uint32_t extWinId); + QImage* getDisplayImage(){return &displayImage;} public slots: void sendOutputSelChunk(); - void slotGrabDisplay(); - + void saveDispImage(QString path="/tmp/dispPin.png"); private slots: @@ -267,7 +266,6 @@ private: void setFS(int screenNumber); void reinitCaches(); void initGeometry(); - void setDisplayPix(QPixmap pix, int32_t x=-1, int32_t y=-1); bool wantRepaint=false; bool hasUpdates=false; #ifndef Q_OS_LINUX @@ -276,6 +274,8 @@ private: #endif void parseOptions(); void initDesktopMode(); + QImage displayImage; + static bool debug; //initial values @@ -365,7 +365,6 @@ private: int cacheSize=0; ScreenIdentifier *screenIdentifier=0l; QLabel* fr; - QPixmap displayPix; //selection #ifdef Q_OS_LINUX diff --git a/displayarea.cpp b/displayarea.cpp index 444a758..9b913ea 100644 --- a/displayarea.cpp +++ b/displayarea.cpp @@ -120,92 +120,70 @@ DisplayArea::~DisplayArea() void DisplayArea::paintEvent(QPaintEvent* ev) { QPainter painter; - bool disp=false; - if(! client->getDisplayPix().isNull()) +// bool disp=false; + painter.begin(this); + if(client->needUpdate()) { - painter.begin(this); - if(client->needUpdate()) + Frame* currentFrame=client->getCurrentFrame(); + QPixmap pix; + if(!currentFrame->crc) { - Frame* currentFrame=client->getCurrentFrame(); - QPixmap pix; - if(!currentFrame->crc) - { -// Client::KDRStdErr()<<"Draw DISPLAY PIX "<<KDR_ENDL; - pix=client->getDisplayPix(); - disp=true; - } - else - { -// Client::KDRStdErr()<<"Draw PIX from cache"<<KDR_ENDL; - pix=client->getPixmapFromCache(currentFrame->crc); - } - if(currentFrame->x==-1 || currentFrame->y==-1) - { - currentFrame->x=currentFrame->y=0; - } - if(!client->isRootless()) - { - if(!disp) - painter.drawPixmap(currentFrame->x,currentFrame->y,pix); - else - painter.drawPixmap(currentFrame->x,currentFrame->y,pix,currentFrame->x,currentFrame->y,currentFrame->width,currentFrame->height); - } - else - { - if(!disp) - { - painter.drawPixmap(currentFrame->x-((ExtWin*)parentWidget)->adjustGeometry().x(),currentFrame->y-((ExtWin*)parentWidget)->adjustGeometry().y(),pix); - } - else - painter.drawPixmap(currentFrame->x-((ExtWin*)parentWidget)->adjustGeometry().x(),currentFrame->y-((ExtWin*)parentWidget)->adjustGeometry().y(),pix, - currentFrame->x,currentFrame->y,ev->rect().width(),ev->rect().height()); - } + // Client::KDRStdErr()<<"Draw DISPLAY PIX "<<KDR_ENDL; + pix=currentFrame->regions[0]->pix; +// disp=true; } else { -// Client::KDRStdErr()<<"Win update event: "<<KDR_HEX<<((ExtWin*)parentWidget)->getPtr()<< " "<<Client::QRectToStr(ev->rect()) <<KDR_ENDL; - char evmsg[EVLENGTH]={}; - int32_t etype, x, y, width, height; - etype=UPDATE; - width=ev->rect().width(); - height=ev->rect().height(); - - if(!client->isRootless()) - { - x=ev->rect().x(); - y=ev->rect().y(); - painter.drawPixmap(ev->rect(),client->getDisplayPix(),ev->rect()); - } - else + // Client::KDRStdErr()<<"Draw PIX from cache"<<KDR_ENDL; + pix=client->getPixmapFromCache(currentFrame->crc); + } + if(currentFrame->x==-1 || currentFrame->y==-1) + { + currentFrame->x=currentFrame->y=0; + } + if(!client->isRootless()) + { +// if(!disp) { - x=((ExtWin*)parentWidget)->adjustGeometry().x()+ev->rect().x(); - y=((ExtWin*)parentWidget)->adjustGeometry().y()+ev->rect().y(); -// painter.drawPixmap(0,0,client->getDisplayPix(),((ExtWin*)parentWidget)->adjustGeometry().x(),((ExtWin*)parentWidget)->adjustGeometry().y(),ev->rect().width(),ev->rect().height()); - - #warning check this later - //this is making the window to flicker a bit, but it's the best I can do at the moment. We should try to get the displaypix not from the main image in - //x2gokdrive, but maybe directly from the window drawable to get the image not covered by windows on top and save it for every window separately - painter.drawPixmap(ev->rect().x(),ev->rect().y(), ev->rect().width(), ev->rect().height(), - client->getDisplayPix(), ev->rect().x()+((ExtWin*)parentWidget)->adjustGeometry().x(), - ev->rect().y()+((ExtWin*)parentWidget)->adjustGeometry().y(), ev->rect().width(), ev->rect().height()); + painter.drawPixmap(currentFrame->x,currentFrame->y,pix); + } -// Client::KDRStdErr()<<"Request update:"<<KDR_HEX<<((ExtWin*)parentWidget)->getExtWinId() <<KDR_DEC<<" "<<x<<":"<<y<<" - "<<width<<"x"<<height<<KDR_ENDL<<"====================="<<KDR_ENDL; - memcpy(evmsg,(char*)&etype,4); - memcpy(evmsg+4,(char*)&width,4); - memcpy(evmsg+8,(char*)&height,4); - memcpy(evmsg+12,(char*)&x,4); - memcpy(evmsg+16,(char*)&y,4); - if(client->isRootless()) +// else +// { +// painter.drawPixmap(currentFrame->x,currentFrame->y,pix,currentFrame->x,currentFrame->y,currentFrame->width,currentFrame->height); +// dispImagePainter.drawPixmap(currentFrame->x,currentFrame->y,pix,currentFrame->x,currentFrame->y,currentFrame->width,currentFrame->height); +// } + } + else + { +// if(!disp) { - uint32_t win_id=(((ExtWin*)parentWidget)->getExtWinId()); - memcpy(evmsg+20,(char*)&win_id,4); + painter.drawPixmap(currentFrame->x-((ExtWin*)parentWidget)->adjustGeometry().x(),currentFrame->y-((ExtWin*)parentWidget)->adjustGeometry().y(),pix); } - client->sendEvent(evmsg); +// else +// { +// painter.drawPixmap(currentFrame->x-((ExtWin*)parentWidget)->adjustGeometry().x(),currentFrame->y-((ExtWin*)parentWidget)->adjustGeometry().y(),pix, +// currentFrame->x,currentFrame->y,ev->rect().width(),ev->rect().height()); +// dispImagePainter.drawPixmap(currentFrame->x-((ExtWin*)parentWidget)->adjustGeometry().x(),currentFrame->y-((ExtWin*)parentWidget)->adjustGeometry().y(),pix, +// currentFrame->x,currentFrame->y,ev->rect().width(),ev->rect().height()); +// } } - painter.end(); } else - Client::KDRStdErr()<<"DISPLAY PIX IS NULL"<<KDR_ENDL; + { + if(!client->isRootless()) + { +// Client::KDRStdErr()<<"WM update: "<<Client::QRectToStr(ev->rect())<<KDR_ENDL; + painter.drawImage(ev->rect(),*(client->getDisplayImage()),ev->rect()); + } + else + { + 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()); + } + } + painter.end(); } uint32_t DisplayArea::X11MouseButtonsState(Qt::MouseButtons qtMouseButtons) diff --git a/displayarea.h b/displayarea.h index e32bc9b..b573b03 100644 --- a/displayarea.h +++ b/displayarea.h @@ -39,7 +39,6 @@ public: DisplayArea(Client* client, QWidget* parentWidget); ~DisplayArea(); private: - QPainter* painter=0l; Client* client; QWidget* parentWidget; diff --git a/menuframe.cpp b/menuframe.cpp index 576185d..774b593 100644 --- a/menuframe.cpp +++ b/menuframe.cpp @@ -127,6 +127,8 @@ MenuFrame::MenuFrame(QWidget* parent, QMenu* menu):QFrame(parent) bDisc->setIcon(QIcon(":res/network-disconnect.svg")); Client* client=(Client*)parent; connect(bDisc, SIGNAL(clicked(bool)),client, SLOT(slotDisconnect())); + connect(bPin, SIGNAL(toggled(bool)), client, SLOT(saveDispImage())); + bMin=new QToolButton(this); bMin->setToolTip(tr("Minimize")); -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gokdriveclient.git