Skip to content

Commit

Permalink
FreeRDP::Rail: modify window status
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Dec 30, 2024
1 parent 2c48e51 commit 6035ace
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 59 deletions.
97 changes: 52 additions & 45 deletions Plugins/FreeRDP/Client/Rail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include "ConnectFreeRDP.h"

static Q_LOGGING_CATEGORY(log, "FreeRDP.Rail")
static Q_LOGGING_CATEGORY(logWinInfo, "FreeRDP.Rail.Window.Info")
static Q_LOGGING_CATEGORY(logInfoWin, "FreeRDP.Rail.Info.Window")
static Q_LOGGING_CATEGORY(logIconInfo, "FreeRDP.Rail.Info.Icon")

int g_CRailInfo = qRegisterMetaType<CRailInfo>("CRailInfo");
int g_QSharedPointer_CRailInfo = qRegisterMetaType<QSharedPointer<CRailInfo> >("QSharedPointer<CRailInfo>");
Expand Down Expand Up @@ -112,7 +113,7 @@ static const WINDOW_STYLE EXTENDED_WINDOW_STYLES[] = {

static void PrintWindowStyles(UINT32 style)
{
qDebug(logWinInfo, "\tWindow Styles: {");
qDebug(logInfoWin, "\tWindow Styles: {");

for (size_t i = 0; i < ARRAYSIZE(WINDOW_STYLES); i++)
{
Expand All @@ -124,16 +125,16 @@ static void PrintWindowStyles(UINT32 style)
continue;
}

qDebug(logWinInfo, "\t\t%s", WINDOW_STYLES[i].name);
qDebug(logInfoWin, "\t\t%s", WINDOW_STYLES[i].name);
}
}

qDebug(logWinInfo, "\t}");
qDebug(logInfoWin, "\t}");
}

static void PrintExtendedWindowStyles(UINT32 style)
{
qDebug(logWinInfo, "\tExtended Window Styles: {");
qDebug(logInfoWin, "\tExtended Window Styles: {");
for (size_t i = 0; i < ARRAYSIZE(EXTENDED_WINDOW_STYLES); i++)
{
if (style & EXTENDED_WINDOW_STYLES[i].style)
Expand All @@ -144,143 +145,143 @@ static void PrintExtendedWindowStyles(UINT32 style)
continue;
}

qDebug(logWinInfo, "\t\t%s", EXTENDED_WINDOW_STYLES[i].name);
qDebug(logInfoWin, "\t\t%s", EXTENDED_WINDOW_STYLES[i].name);
}
}
qDebug(logWinInfo, "\t}");
qDebug(logInfoWin, "\t}");
}

static void PrintRailWindowState(const WINDOW_ORDER_INFO* orderInfo,
const WINDOW_STATE_ORDER* windowState)
{
if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW)
qDebug(logWinInfo, "WindowCreate: WindowId: 0x%08X", orderInfo->windowId);
qDebug(logInfoWin, "WindowCreate: WindowId: 0x%08X", orderInfo->windowId);
else
qDebug(logWinInfo, "WindowUpdate: WindowId: 0x%08X", orderInfo->windowId);
qDebug(logInfoWin, "WindowUpdate: WindowId: 0x%08X", orderInfo->windowId);

qDebug(logWinInfo, "{");
qDebug(logInfoWin, "{");

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OWNER)
{
qDebug(logWinInfo, "\tOwnerWindowId: 0x%08X", windowState->ownerWindowId);
qDebug(logInfoWin, "\tOwnerWindowId: 0x%08X", windowState->ownerWindowId);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE)
{
qDebug(logWinInfo, "\tStyle: 0x%08X ExtendedStyle: 0x%08X",
qDebug(logInfoWin, "\tStyle: 0x%08X ExtendedStyle: 0x%08X",
windowState->style, windowState->extendedStyle);
PrintWindowStyles(windowState->style);
PrintExtendedWindowStyles(windowState->extendedStyle);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_SHOW)
{
qDebug(logWinInfo, "\tShowState: %u", windowState->showState);
qDebug(logInfoWin, "\tShowState: %u", windowState->showState);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TITLE)
{
QString szTitle = GetString(windowState->titleInfo);
qDebug(logWinInfo, "\tTitleInfo: %s (length = %hu)",
qDebug(logInfoWin, "\tTitleInfo: %s (length = %hu)",
szTitle.toStdString().c_str(),
windowState->titleInfo.length);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
{
qDebug(logWinInfo, "\tClientOffsetX: %d ClientOffsetY: %d",
qDebug(logInfoWin, "\tClientOffsetX: %d ClientOffsetY: %d",
windowState->clientOffsetX, windowState->clientOffsetY);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
{
qDebug(logWinInfo, "\tClientAreaWidth: %u ClientAreaHeight: %u",
qDebug(logInfoWin, "\tClientAreaWidth: %u ClientAreaHeight: %u",
windowState->clientAreaWidth, windowState->clientAreaHeight);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT)
{
qDebug(logWinInfo, "\tRPContent: %u", windowState->RPContent);
qDebug(logInfoWin, "\tRPContent: %u", windowState->RPContent);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT)
{
qDebug(logWinInfo, "\tRootParentHandle: 0x%08X",
qDebug(logInfoWin, "\tRootParentHandle: 0x%08X",
windowState->rootParentHandle);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET)
{
qDebug(logWinInfo, "\tWindowOffsetX: %d WindowOffsetY: %d",
qDebug(logInfoWin, "\tWindowOffsetX: %d WindowOffsetY: %d",
windowState->windowOffsetX, windowState->windowOffsetY);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
{
qDebug(logWinInfo, "\tWindowClientDeltaX: %d WindowClientDeltaY: %d",
qDebug(logInfoWin, "\tWindowClientDeltaX: %d WindowClientDeltaY: %d",
windowState->windowClientDeltaX, windowState->windowClientDeltaY);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)
{
qDebug(logWinInfo, "\tWindowWidth: %u WindowHeight: %u",
qDebug(logInfoWin, "\tWindowWidth: %u WindowHeight: %u",
windowState->windowWidth, windowState->windowHeight);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
{
RECTANGLE_16* rect;
qDebug(logWinInfo, "\tnumWindowRects: %u", windowState->numWindowRects);
qDebug(logInfoWin, "\tnumWindowRects: %u", windowState->numWindowRects);

for (UINT32 index = 0; index < windowState->numWindowRects; index++)
{
rect = &windowState->windowRects[index];
qDebug(logWinInfo, "\twindowRect[%u]: left: %hu top: %hu right: %hu bottom: %hu", index,
qDebug(logInfoWin, "\twindowRect[%u]: left: %hu top: %hu right: %hu bottom: %hu", index,
rect->left, rect->top, rect->right, rect->bottom);
}
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET)
{
qDebug(logWinInfo, "\tvisibileOffsetX: %d visibleOffsetY: %d",
qDebug(logInfoWin, "\tvisibileOffsetX: %d visibleOffsetY: %d",
windowState->visibleOffsetX, windowState->visibleOffsetY);
}

if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
{
RECTANGLE_16* rect;
qDebug(logWinInfo, "\tnumVisibilityRects: %u",
qDebug(logInfoWin, "\tnumVisibilityRects: %u",
windowState->numVisibilityRects);

for (UINT32 index = 0; index < windowState->numVisibilityRects; index++)
{
rect = &windowState->visibilityRects[index];
qDebug(logWinInfo, "\tvisibilityRect[%u]: left: %hu top: %hu right: %hu bottom: %hu", index,
qDebug(logInfoWin, "\tvisibilityRect[%u]: left: %hu top: %hu right: %hu bottom: %hu", index,
rect->left, rect->top, rect->right, rect->bottom);
}
}

qDebug(logWinInfo, "}");
qDebug(logInfoWin, "}");
}

static void PrintRailIconInfo(const WINDOW_ORDER_INFO* orderInfo, const ICON_INFO* iconInfo)
{
qDebug(logWinInfo, "ICON_INFO");
qDebug(logWinInfo, "{");
qDebug(logWinInfo, "\tbigIcon: %s",
qDebug(logIconInfo, "ICON_INFO");
qDebug(logIconInfo, "{");
qDebug(logIconInfo, "\tbigIcon: %s",
(orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ICON_BIG) ? "true" : "false");
qDebug(logWinInfo, "\tcacheEntry; 0x%08X", iconInfo->cacheEntry);
qDebug(logWinInfo, "\tcacheId: 0x%08X", iconInfo->cacheId);
qDebug(logWinInfo, "\tbpp: %u", iconInfo->bpp);
qDebug(logWinInfo, "\twidth: %u", iconInfo->width);
qDebug(logWinInfo, "\theight: %u", iconInfo->height);
qDebug(logWinInfo, "\tcbColorTable: %u", iconInfo->cbColorTable);
qDebug(logWinInfo, "\tcbBitsMask: %u", iconInfo->cbBitsMask);
qDebug(logWinInfo, "\tcbBitsColor: %u", iconInfo->cbBitsColor);
qDebug(logWinInfo, "\tcolorTable: %p", (void*)iconInfo->colorTable);
qDebug(logWinInfo, "\tbitsMask: %p", (void*)iconInfo->bitsMask);
qDebug(logWinInfo, "\tbitsColor: %p", (void*)iconInfo->bitsColor);
qDebug(logWinInfo, "}");
qDebug(logIconInfo, "\tcacheEntry; 0x%08X", iconInfo->cacheEntry);
qDebug(logIconInfo, "\tcacheId: 0x%08X", iconInfo->cacheId);
qDebug(logIconInfo, "\tbpp: %u", iconInfo->bpp);
qDebug(logIconInfo, "\twidth: %u", iconInfo->width);
qDebug(logIconInfo, "\theight: %u", iconInfo->height);
qDebug(logIconInfo, "\tcbColorTable: %u", iconInfo->cbColorTable);
qDebug(logIconInfo, "\tcbBitsMask: %u", iconInfo->cbBitsMask);
qDebug(logIconInfo, "\tcbBitsColor: %u", iconInfo->cbBitsColor);
qDebug(logIconInfo, "\tcolorTable: %p", (void*)iconInfo->colorTable);
qDebug(logIconInfo, "\tbitsMask: %p", (void*)iconInfo->bitsMask);
qDebug(logIconInfo, "\tbitsColor: %p", (void*)iconInfo->bitsColor);
qDebug(logIconInfo, "}");
}

CRailInfo::CRailInfo()
Expand Down Expand Up @@ -577,23 +578,29 @@ UINT CRail::cbServerMinMaxInfo(
RailClientContext *context,
const RAIL_MINMAXINFO_ORDER *minMaxInfo)
{
qDebug(log) << Q_FUNC_INFO;
qDebug(log) << Q_FUNC_INFO << WINDOW_ID(minMaxInfo->windowId) << "Max:"
<< minMaxInfo->maxPosX << minMaxInfo->maxPosY
<< minMaxInfo->maxWidth << minMaxInfo->maxHeight
<< minMaxInfo->maxTrackWidth << minMaxInfo->maxTrackHeight
<< "min:" << minMaxInfo->minTrackWidth << minMaxInfo->minTrackHeight;
return CHANNEL_RC_OK;
}

UINT CRail::cbServerLanguageBarInfo(
RailClientContext *context,
const RAIL_LANGBAR_INFO_ORDER *langBarInfo)
{
qDebug(log) << Q_FUNC_INFO;
qDebug(log) << Q_FUNC_INFO << HEX(langBarInfo->languageBarStatus);
return CHANNEL_RC_OK;
}

UINT CRail::cbServerGetAppIdResponse(
RailClientContext *context,
const RAIL_GET_APPID_RESP_ORDER *getAppIdResp)
{
qDebug(log) << Q_FUNC_INFO;
qDebug(log) << Q_FUNC_INFO
<< WINDOW_ID(getAppIdResp->windowId)
<< "AppId:" << QString(getAppIdResp->applicationId);

Check failure on line 603 in Plugins/FreeRDP/Client/Rail.cpp

View workflow job for this annotation

GitHub Actions / macos / build_macos (Release, 5.12.12, clang_64, x64-osx)

no matching conversion for functional-style cast from 'const WCHAR[260]' (aka 'const unsigned short[260]') to 'QString'
return CHANNEL_RC_OK;
}

Expand Down
4 changes: 3 additions & 1 deletion Plugins/FreeRDP/Client/Rail.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
#include <freerdp/gdi/dc.h>
#include <freerdp/gdi/region.h>

class CConnectFreeRDP;
#define HEX(x) QString("0x%1").arg((x), 8, 16, QLatin1Char('0'))
#define WINDOW_ID(x) QString("WindowId: 0x%1").arg((x), 8, 16, QLatin1Char('0'))

class CConnectFreeRDP;
class CRailManageWindows;

/*!
Expand Down
51 changes: 38 additions & 13 deletions Plugins/FreeRDP/Client/RailManageWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#endif
#endif

#define HEX(x) QString("0x%1").arg((x), 8, 16, QLatin1Char('0'))
#define WINDOW_ID(x) QString("WindowId: 0x%1").arg((x), 8, 16, QLatin1Char('0'))

static Q_LOGGING_CATEGORY(log, "FreeRDP.Rail.ManageWindows")
static Q_LOGGING_CATEGORY(logWin, "FreeRDP.Rail.ManageWindows.Window")

Expand Down Expand Up @@ -158,20 +155,48 @@ void CRailManageWindows::slotWindow(QSharedPointer<CRailInfo> info)

if (fieldFlags & WINDOW_ORDER_FIELD_STYLE)
{
/*
auto flags = pWin->windowFlags();
if(info->m_Style & WS_POPUP)
flags |= Qt::Popup;
else
flags &= ~Qt::Popup;
pWin->setWindowFlags(flags);
*/
}

if (fieldFlags & WINDOW_ORDER_FIELD_SHOW)
{
pWin->setVisible(info->m_ShowStatus);
switch(info->m_ShowStatus){
case 0: //SW_HIDE:
pWin->hide();
break;
case 1: //SW_SHOWNORMAL:
pWin->showNormal();
pWin->setFocus();
break;
case 2: //SW_SHOWMINIMIZED:
pWin->showMinimized();
pWin->setFocus();
break;
case 3: //SW_SHOWMAXIMIZED:
pWin->showMaximized();
pWin->setFocus();
break;
case 4: //SW_SHOWNOACTIVATE:
pWin->showNormal();
break;
case 5: //SW_SHOW:
pWin->show();
pWin->setFocus();
break;
case 6: //SW_MINIMIZE:
case 7: //SW_SHOWMINNOACTIVE:
pWin->showMinimized();
break;
case 8: //SW_SHOWNA:
pWin->show();
break;
case 9: //SW_RESTORE:
case 10: //SW_SHOWDEFAULT:
case 11: //SW_FORCEMINIMIZE:
pWin->show();
break;
default:
break;
}
}

if (fieldFlags & WINDOW_ORDER_FIELD_TITLE)
Expand Down

0 comments on commit 6035ace

Please sign in to comment.