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 31, 2024
1 parent 8e6fd8f commit d1a082b
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 60 deletions.
96 changes: 51 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,28 @@ 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);
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
14 changes: 1 addition & 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,11 @@ 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);
pWin->Show(info->m_ShowStatus);
}

if (fieldFlags & WINDOW_ORDER_FIELD_TITLE)
Expand Down
66 changes: 65 additions & 1 deletion Plugins/FreeRDP/Client/RailWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,27 @@

#include "RailWindow.h"

static Q_LOGGING_CATEGORY(log, "FreeRDP.Rail.Window")
#if defined(_MSC_VER)
#include <WinUser.h>
#else
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
#define SW_SHOWNOACTIVATE 4
#define SW_SHOW 5
#define SW_MINIMIZE 6
#define SW_SHOWMINNOACTIVE 7
#define SW_SHOWNA 8
#define SW_RESTORE 9
#define SW_SHOWDEFAULT 10
#define SW_FORCEMINIMIZE 11
#define SW_MAX 11
#endif

static Q_LOGGING_CATEGORY(log, "FreeRDP.Rail.Window")
CRailWindow::CRailWindow(QWidget *parent)
: CFrmViewer{parent}
{
Expand All @@ -19,6 +38,51 @@ CRailWindow::CRailWindow(QWidget *parent)
<< "maximumSize:" << maximumSize();
}

int CRailWindow::Show(UINT32 state)
{
switch(state){
case SW_HIDE:
hide();
break;
case SW_SHOWNORMAL:
showNormal();
setFocus();
break;
case SW_SHOWMINIMIZED:
showMinimized();
setFocus();
break;
case SW_SHOWMAXIMIZED:
showMaximized();
setFocus();
break;
case SW_SHOWNOACTIVATE:
showNormal();
break;
case SW_SHOW:
show();
setFocus();
break;
case SW_MINIMIZE:
case SW_SHOWMINNOACTIVE:
showMinimized();
break;
case SW_SHOWNA:
show();
break;
case SW_RESTORE:
case SW_SHOWDEFAULT:
show();
break;
case SW_FORCEMINIMIZE:
showMinimized();
break;
default:
break;
}
return 0;
}

void CRailWindow::mousePressEvent(QMouseEvent *event)
{
QPointF pos =
Expand Down
1 change: 1 addition & 0 deletions Plugins/FreeRDP/Client/RailWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CRailWindow : public CFrmViewer
explicit CRailWindow(QWidget *parent = nullptr);

CRailInfo m_Info;
int Show(UINT32 state);

protected:
virtual void mousePressEvent(QMouseEvent *event) override;
Expand Down

0 comments on commit d1a082b

Please sign in to comment.