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 e8fbd77 Handling minimizing windows. new 468c632 Support for MS Windows in rootless mode. 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 | 14 ++------ client.h | 1 - extwin.cpp | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------- extwin.h | 7 ++++ 4 files changed, 103 insertions(+), 26 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 468c632a0ba1131625561f86cacbc1a4e3369147 Author: Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> Date: Fri Feb 11 11:12:53 2022 -0600 Support for MS Windows in rootless mode. --- client.cpp | 14 ++------ client.h | 1 - extwin.cpp | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------- extwin.h | 7 ++++ 4 files changed, 103 insertions(+), 26 deletions(-) diff --git a/client.cpp b/client.cpp index fcbaee5..dd43279 100644 --- a/client.cpp +++ b/client.cpp @@ -1097,15 +1097,6 @@ void Client::getDeletedCursorsList() freeMessageBuffer(); } -ExtWin* Client::getExtWin(uint32_t id) -{ - foreach( ExtWin* win, extWindows) - { - if(win->getExtWinId()==id) - return win; - } - return NULL; -} ExtWin* Client::findExtWinById(uint32_t extWinId) { for(QList<ExtWin*>::iterator j=extWindows.begin(); j!=extWindows.end(); ++j) @@ -1133,7 +1124,7 @@ void Client::getWinUpdateBuffer() ExtWin* win; if(state!=2) { - win=getExtWin(extWinId); + win=findExtWinById(extWinId); if(!win) { KDRStdErr()<<"Error: update Wind "<<KDR_HEX<<extWinId<<" not found in the list"<<KDR_DEC<<KDR_ENDL; @@ -1215,7 +1206,9 @@ void Client::getWinUpdateBuffer() Qt::WindowFlags flags; switch(winType) { + case WINDOW_TYPE_UTILITY: case WINDOW_TYPE_DIALOG: + winType=WINDOW_TYPE_DIALOG; flags=Qt::Dialog; KDRStdErr()<<"new win: "<<KDR_HEX<<extWinId<<" Setting dialog flags"; break; @@ -1225,7 +1218,6 @@ void Client::getWinUpdateBuffer() case WINDOW_TYPE_COMBO: case WINDOW_TYPE_POPUP_MENU: case WINDOW_TYPE_DROPDOWN_MENU: - case WINDOW_TYPE_UTILITY: flags=Qt::Window|Qt::FramelessWindowHint|Qt::BypassWindowManagerHint|Qt::X11BypassWindowManagerHint|Qt::WindowStaysOnTopHint; break; case WINDOW_TYPE_TOOLTIP: diff --git a/client.h b/client.h index 079cd4c..ad87a8e 100644 --- a/client.h +++ b/client.h @@ -276,7 +276,6 @@ private: #endif void parseOptions(); void initDesktopMode(); - ExtWin* getExtWin(uint32_t id); static bool debug; //initial values diff --git a/extwin.cpp b/extwin.cpp index ea9c3a7..4fe46d9 100644 --- a/extwin.cpp +++ b/extwin.cpp @@ -36,6 +36,7 @@ ExtWin::ExtWin(uint32_t extWinId, Client *client, QWidget* parent, Qt::WindowFla this->extWinId=extWinId; this->client=client; // QTimer::singleShot(10,this,SLOT(update())); +#ifdef Q_OS_LINUX switch(windowType) { case WINDOW_TYPE_DROPDOWN_MENU: @@ -54,6 +55,7 @@ ExtWin::ExtWin(uint32_t extWinId, Client *client, QWidget* parent, Qt::WindowFla setAttribute(Qt::WA_X11NetWmWindowTypeUtility); break; } +#endif setFocusPolicy(Qt::NoFocus); } @@ -66,7 +68,7 @@ void ExtWin::moveEvent(QMoveEvent* ev) { if((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG)) { - Client::KDRStdErr()<<"Move "<<Client::QRectToStr(geometry())<<KDR_ENDL; +// Client::KDRStdErr()<<"Move "<<Client::QRectToStr(geometry())<<KDR_ENDL; client->changeWindow(this); } QMainWindow::moveEvent(ev); @@ -86,7 +88,7 @@ void ExtWin::resizeEvent(QResizeEvent* ev) { if((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG)) { - Client::KDRStdErr()<<"Resize "<<Client::QRectToStr(geometry())<<KDR_ENDL; +// Client::KDRStdErr()<<"Resize "<<Client::QRectToStr(geometry())<<KDR_ENDL; client->changeWindow(this); } QMainWindow::resizeEvent(ev); @@ -97,7 +99,7 @@ void ExtWin::showEvent(QShowEvent *ev) QMainWindow::showEvent(ev); if((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG)) { - Client::KDRStdErr()<<"Show "<<Client::QRectToStr(geometry())<<KDR_ENDL; +// Client::KDRStdErr()<<"Show "<<Client::QRectToStr(geometry())<<KDR_ENDL; foreach(ExtWin* w, client->getExtWindows()) { if(w->transWinId==extWinId) @@ -112,7 +114,7 @@ void ExtWin::hideEvent(QHideEvent *ev) QMainWindow::hideEvent(ev); if(((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG))&&isMinimized()) { - Client::KDRStdErr()<<"Request window minimize"; +// Client::KDRStdErr()<<"Request window minimize"; client->changeWindow(this,ICONIFIED); foreach(ExtWin* w, client->getExtWindows()) { @@ -136,6 +138,7 @@ void ExtWin::focusOutEvent(QFocusEvent *ev) QMainWindow::focusOutEvent(ev); } +#ifdef Q_OS_LINUX xcb_window_t getRootNativeId(xcb_window_t winId) { xcb_query_tree_cookie_t cookie; @@ -214,6 +217,21 @@ ExtWin* ExtWin::findWinByTopWinId(xcb_window_t topWinId, QList<ExtWin*> &sibling return 0; } +#endif //Q_OS_LINUX +#ifdef Q_OS_WIN +ExtWin* ExtWin::findWinByHWND(HWND hwnd, QList<ExtWin*> &siblings) +{ + for(int i=0; i< siblings.count(); ++i) + { + if((HWND)(siblings[i]->winId())==hwnd) + { + return siblings[i]; + } + } + return 0; +} +#endif + ExtWin* ExtWin::findWinByZInd(int zInd, QList<ExtWin*> &siblings) { for(int i=0; i< siblings.count(); ++i) @@ -247,13 +265,18 @@ QRect ExtWin::adjustGeometry() void ExtWin::slotCheckStackOrder() { + #ifdef Q_OS_WIN + if(!isVisible()) + return; + #endif //Q_OS_WIN QList<ExtWin*> siblings=client->getSiblings(this); - // Client::KDRStdErr()<<"Have Siblings: "<<siblings.count()<<KDR_ENDL; +// Client::KDRStdErr()<<"Have Siblings: "<<siblings.count()<<KDR_ENDL; if(siblings.count()) { + siblings<<this; + #ifdef Q_OS_LINUX xcb_window_t commonParent=getCommonParent(this->winId(), siblings[0]->winId()); // Client::KDRStdErr()<<"common parent: "<<KDR_HEX<<commonParent<<KDR_ENDL; - siblings<<this; xcb_connection_t *connection = QX11Info::connection(); xcb_query_tree_cookie_t cookie; xcb_query_tree_reply_t *reply; @@ -263,22 +286,46 @@ void ExtWin::slotCheckStackOrder() if ((reply = xcb_query_tree_reply(connection, cookie, NULL))) { xcb_window_t *children = xcb_query_tree_children(reply); + #endif //Q_OS_LINUX int z=0; int negative_z=0; // Client::KDRStdErr()<<"Current stack for parent: "<<KDR_ENDL; + #ifdef Q_OS_LINUX for (int i = 0; i < xcb_query_tree_children_length(reply); i++) { ExtWin* win=findWinByTopWinId(children[i], siblings); + #endif //Q_OS_LINUX + #ifdef Q_OS_WIN + HWND w=GetTopWindow(NULL); + while (w) + { + ExtWin* win=findWinByHWND(w, siblings); + w=GetNextWindow(w,GW_HWNDNEXT); + #endif //Q_OS_WIN if(win) { if(!win->isMinimized()) win->zOrderInd=z++; else win->zOrderInd=--negative_z; - // Client::KDRStdErr()<<win->zOrderInd<<" - "<<KDR_HEX<< win->extWinId<<" "<<win->windowTitle()<<"->"; +// Client::KDRStdErr()<<win->zOrderInd<<" - "<<KDR_HEX<< win->extWinId<<" "<<win->windowTitle()<<KDR_ENDL; } } +#ifdef Q_OS_WIN + //need to invert z-order for visible windows (to make it like in Linux) + for(int i=0;i<siblings.count();++i) + { + if(siblings[i]->zOrderInd>=0) + { + siblings[i]->zOrderInd=(z-1)-siblings[i]->zOrderInd; + } +// Client::KDRStdErr()<<siblings[i]->zOrderInd<<" - "<<KDR_HEX<< siblings[i]->extWinId<<" "<<siblings[i]->windowTitle()<<KDR_ENDL; + } + +#endif //Q_OS_WIN + #ifdef Q_OS_LINUX free(reply); + #endif //Q_OS_LINUX // Client::KDRStdErr()<<"End of stack "<<KDR_ENDL; uint32_t newNextSib; ExtWin* win=findWinByZInd(zOrderInd-1, siblings); @@ -302,12 +349,10 @@ void ExtWin::slotCheckStackOrder() nextSibId=newNextSib; client->changeWindow(this); } - /*else - * { - * Client::KDRStdErr()<<"Stack order is ok"<<KDR_ENDL; - }*/ } +#ifdef Q_OS_LINUX } +#endif } bool ExtWin::checkModality(QList<ExtWin*> &siblings) @@ -337,6 +382,7 @@ bool ExtWin::checkModality(QList<ExtWin*> &siblings) // QTimer::singleShot(2,w,SLOT(update())); // trwin->update(); w->raise(); + w->activateWindow(); mod_res=false; } } @@ -349,16 +395,17 @@ bool ExtWin::checkModality(QList<ExtWin*> &siblings) bool ExtWin::nativeEvent(const QByteArray &eventType, void *message, long *result) { +#ifdef Q_OS_LINUX if((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG)) { if(!eventType.compare("xcb_generic_event_t") && parentId==0) { - slotCheckStackOrder(); xcb_generic_event_t* ev = static_cast<xcb_generic_event_t *>(message); switch((ev->response_type & ~0x80)) { case XCB_FOCUS_IN: - Client::KDRStdErr()<<"FOCUS IN "<<KDR_HEX<<extWinId<<KDR_ENDL; + slotCheckStackOrder(); +// Client::KDRStdErr()<<"FOCUS IN "<<KDR_HEX<<extWinId<<KDR_ENDL; if(!hasFocus()) { setHasFocus(true); @@ -366,7 +413,38 @@ bool ExtWin::nativeEvent(const QByteArray &eventType, void *message, long *resul } break; case XCB_FOCUS_OUT: - Client::KDRStdErr()<<"FOCUS OUT "<<KDR_HEX<<extWinId<<KDR_ENDL; + slotCheckStackOrder(); +// Client::KDRStdErr()<<"FOCUS OUT "<<KDR_HEX<<extWinId<<KDR_ENDL; + if(hasFocus()) + { + setHasFocus(false); + client->changeWindow(this); + } + break; + } + } + } +#endif //Q_OS_LINUX +#ifdef Q_OS_WIN + if((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG)) + { + if(!eventType.compare("windows_generic_MSG") && parentId==0) + { + MSG* ev = static_cast<MSG *>(message); + switch((ev->message)) + { + case WM_SETFOCUS: + slotCheckStackOrder(); +// Client::KDRStdErr()<<"FOCUS IN "<<KDR_HEX<<extWinId<<KDR_ENDL; + if(!hasFocus()) + { + setHasFocus(true); + client->changeWindow(this); + } + break; + case WM_KILLFOCUS: + slotCheckStackOrder(); +// Client::KDRStdErr()<<"FOCUS OUT "<<KDR_HEX<<extWinId<<KDR_ENDL; if(hasFocus()) { setHasFocus(false); @@ -376,5 +454,6 @@ bool ExtWin::nativeEvent(const QByteArray &eventType, void *message, long *resul } } } +#endif return QMainWindow::nativeEvent(eventType, message, result); } diff --git a/extwin.h b/extwin.h index f13279a..175edd2 100644 --- a/extwin.h +++ b/extwin.h @@ -53,7 +53,12 @@ public: uint8_t getHasFocus(){return focus;} private: +#ifdef Q_OS_LINUX ExtWin* findWinByTopWinId(xcb_window_t topWinId, QList<ExtWin*> &siblings); +#endif +#ifdef Q_OS_WIN + ExtWin* findWinByHWND(HWND hwnd, QList<ExtWin*> &siblings); +#endif ExtWin* findWinByZInd(int zInd, QList<ExtWin*> &siblings); bool checkModality(QList<ExtWin*> &siblings); DisplayArea* displayArea; @@ -63,7 +68,9 @@ private: uint32_t nextSibId=0; uint32_t transWinId=0; uint8_t windowType=WINDOW_TYPE_NORMAL; +#ifdef Q_OS_LINUX xcb_window_t topWinId=0; +#endif int zOrderInd; int modality=MOD_NONE; bool focus=0; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gokdriveclient.git