diff --git a/Client/FrmViewer.cpp b/Client/FrmViewer.cpp index 17cc912fa..fbdeba7eb 100644 --- a/Client/FrmViewer.cpp +++ b/Client/FrmViewer.cpp @@ -41,8 +41,10 @@ CFrmViewer::CFrmViewer(QWidget *parent) setFocus(); // When the connecter is not connected, don't accept keyboard and mouse event - // When the CConnecter::sigConnected() set true. accept keyboard and mouse event - // \see CConnecter::sigConnected() + // When the CConnect::sigConnected() set true. accept keyboard and mouse event + // \see CConnect::sigConnected() + // CConnectDesktop::SetViewer + // CFrmViewer::slotConnected() setEnabled(false); } diff --git a/Plugins/FreeRDP/Client/ConnectFreeRDP.cpp b/Plugins/FreeRDP/Client/ConnectFreeRDP.cpp index c6001f3ca..9072d093a 100644 --- a/Plugins/FreeRDP/Client/ConnectFreeRDP.cpp +++ b/Plugins/FreeRDP/Client/ConnectFreeRDP.cpp @@ -868,7 +868,7 @@ void CConnectFreeRDP::OnChannelConnectedEventHandler(void *context, if(!pThis->m_pRail) { pThis->m_pRail = new CRail(pThis); - pThis->m_pRailManageWindows->ConnectRail(pThis->m_pRail); + pThis->m_pRailManageWindows->Connect(pThis->m_pRail); } if(pThis->m_pRail) pThis->m_pRail->Init((RailClientContext*)e->pInterface); @@ -1513,9 +1513,8 @@ BOOL CConnectFreeRDP::cb_begin_paint(rdpContext *context) return TRUE; } -BOOL CConnectFreeRDP::UpdateBuffer(INT32 x, INT32 y, INT32 w, INT32 h) +BOOL CConnectFreeRDP::UpdateBuffer(QRect rect) { - QRect rect(x, y, w, h); QImage img = GetImage(rect); emit sigUpdateRect(rect, img); return TRUE; @@ -1593,10 +1592,15 @@ BOOL CConnectFreeRDP::cb_end_paint(rdpContext *context) { extents = region16_extents(&invalidRegion); //qDebug(log) << extents->left << extents->top << extents->right << extents->bottom; - pThis->UpdateBuffer(extents->left, - extents->top, - extents->right - extents->left, - extents->bottom - extents->top); + QRect rect(extents->left, + extents->top, + extents->right - extents->left, + extents->bottom - extents->top); + pThis->UpdateBuffer(rect); + + if(pThis->m_pRailManageWindows) { + emit pThis->sigRailInvalidateRect(rect); + } } region16_uninit(&invalidRegion); @@ -1622,7 +1626,7 @@ BOOL CConnectFreeRDP::cb_desktop_resize(rdpContext* context) return FALSE; emit pThis->sigSetDesktopSize(desktopWidth, desktopHeight); - pThis->UpdateBuffer(0, 0, desktopWidth, desktopHeight); + pThis->UpdateBuffer(QRect(0, 0, desktopWidth, desktopHeight)); return TRUE; } diff --git a/Plugins/FreeRDP/Client/ConnectFreeRDP.h b/Plugins/FreeRDP/Client/ConnectFreeRDP.h index b3dc85919..f93012208 100644 --- a/Plugins/FreeRDP/Client/ConnectFreeRDP.h +++ b/Plugins/FreeRDP/Client/ConnectFreeRDP.h @@ -120,7 +120,7 @@ class CConnectFreeRDP : public CConnectDesktop private: UINT32 GetImageFormat(); BOOL CreateImage(rdpContext* context); - BOOL UpdateBuffer(INT32 x, INT32 y, INT32 w, INT32 h); + BOOL UpdateBuffer(QRect rect); QImage GetImage(INT32 x, INT32 y, INT32 w, INT32 h); QImage GetImage(QRect r); @@ -182,6 +182,8 @@ private Q_SLOTS: friend class CRailManageWindows; int InitRemoteApp(); int SetRailViewer(CFrmViewer* pView); +Q_SIGNALS: + void sigRailInvalidateRect(QRect rect); }; #endif // CCONNECTFREERDP_H diff --git a/Plugins/FreeRDP/Client/Rail.cpp b/Plugins/FreeRDP/Client/Rail.cpp index f635aeb19..f84a53792 100644 --- a/Plugins/FreeRDP/Client/Rail.cpp +++ b/Plugins/FreeRDP/Client/Rail.cpp @@ -1,5 +1,12 @@ // Author: Kang Lin +// See: +// - Overview of RemoteApp: https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc755055(v=ws.11)?redirectedfrom=MSDN +// - RAIL exec error: execResult=RAIL_EXEC_E_NOT_IN_ALLOWLIST NtError=0x15. +// See: https://github.com/FreeRDP/FreeRDP/issues/998 +// this is a configuration problem on your server see #595 on how to add a command to the allow list or +// set "fAllowUnlistedRemotePrograms" to 1 in "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" to allow all commands. + #include #include "winpr/string.h" #include "Rail.h" diff --git a/Plugins/FreeRDP/Client/RailManageWindows.cpp b/Plugins/FreeRDP/Client/RailManageWindows.cpp index 35471f5f0..9b37fc6a9 100644 --- a/Plugins/FreeRDP/Client/RailManageWindows.cpp +++ b/Plugins/FreeRDP/Client/RailManageWindows.cpp @@ -10,10 +10,10 @@ CRailManageWindows::CRailManageWindows(QObject *parent) : QObject{parent} {} -int CRailManageWindows::ConnectRail(CRail *pRail) +int CRailManageWindows::Connect(CRail *pRail) { bool check = false; - Q_ASSERT(pRail); + Q_ASSERT(pRail && m_pConnect); check = connect( pRail, &CRail::sigWindow, this, &CRailManageWindows::slotWindow); @@ -22,6 +22,9 @@ int CRailManageWindows::ConnectRail(CRail *pRail) pRail, &CRail::sigWindowDelete, this, &CRailManageWindows::slotWindowDelete); Q_ASSERT(check); + check = connect(m_pConnect, &CConnectFreeRDP::sigRailInvalidateRect, + this, &CRailManageWindows::slotInvalidateRect); + Q_ASSERT(check); return 0; } @@ -47,6 +50,7 @@ void CRailManageWindows::slotWindow(QSharedPointer info) pWin->m_Info = *info; int nRet = 0; if(m_pConnect) { + //qDebug(log) << "m_pConnect->SetRailViewer:" << pWin; nRet = m_pConnect->SetRailViewer(pWin); if(nRet) { qCritical(log) << "Connect SetViewer fail" << nRet; @@ -257,3 +261,17 @@ int CRailManageWindows::UpdateWindow(CRailWindow *pWin, CRailInfo *info) return 0; } + +void CRailManageWindows::slotInvalidateRect(QRect rect) +{ + foreach(auto pWin, m_Windows) { + if(!pWin) + continue; + QRect r; + r = pWin->m_Info.m_rectWindow.intersected(rect); + if(r.isValid()) { + QImage img = m_pConnect->GetImage(r); + pWin->slotUpdateRect(r, img); + } + } +} diff --git a/Plugins/FreeRDP/Client/RailManageWindows.h b/Plugins/FreeRDP/Client/RailManageWindows.h index 814697eaf..f82b23ec3 100644 --- a/Plugins/FreeRDP/Client/RailManageWindows.h +++ b/Plugins/FreeRDP/Client/RailManageWindows.h @@ -10,13 +10,15 @@ class CRailManageWindows : public QObject public: explicit CRailManageWindows(QObject *parent = nullptr); - int ConnectRail(CRail* pRail); + int Connect(CRail* pRail); CConnectFreeRDP* m_pConnect; + int InvalidateRegion(REGION16* invalidRegion); public Q_SLOTS: void slotWindow(QSharedPointer info); void slotWindowDelete(QSharedPointer info); + void slotInvalidateRect(QRect rect); private: void WindowDelete(UINT32 windowId); diff --git a/Plugins/FreeRDP/Client/RailWindow.cpp b/Plugins/FreeRDP/Client/RailWindow.cpp index 814e2892d..e9a454123 100644 --- a/Plugins/FreeRDP/Client/RailWindow.cpp +++ b/Plugins/FreeRDP/Client/RailWindow.cpp @@ -7,9 +7,8 @@ static Q_LOGGING_CATEGORY(log, "FreeRDP.Rail.Window") CRailWindow::CRailWindow(QWidget *parent) : CFrmViewer{parent} { -#ifndef DEBUG setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint); -#endif slotSetAdaptWindows(ADAPT_WINDOWS::Original); + setEnabled(true); }