[client,X11] add helper functions for rail window style

* window_styles_to_string
* window_styles_ex_to_string
This commit is contained in:
akallabeth 2024-09-16 09:20:35 +02:00
parent f86f70a022
commit f67e641cce
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
3 changed files with 119 additions and 0 deletions

View File

@ -99,6 +99,10 @@
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
#define ENTRY(x) \
case x: \
return #x
typedef struct
{
unsigned long flags;
@ -108,6 +112,112 @@ typedef struct
unsigned long status;
} PropMotifWmHints;
static const char* window_style_to_string(UINT32 style)
{
switch (style)
{
ENTRY(WS_NONE);
ENTRY(WS_BORDER);
ENTRY(WS_CAPTION);
ENTRY(WS_CHILD);
ENTRY(WS_CLIPCHILDREN);
ENTRY(WS_CLIPSIBLINGS);
ENTRY(WS_DISABLED);
ENTRY(WS_DLGFRAME);
ENTRY(WS_GROUP);
ENTRY(WS_HSCROLL);
ENTRY(WS_MAXIMIZE);
ENTRY(WS_MAXIMIZEBOX);
ENTRY(WS_MINIMIZE);
ENTRY(WS_OVERLAPPEDWINDOW);
ENTRY(WS_POPUP);
ENTRY(WS_POPUPWINDOW);
ENTRY(WS_SIZEBOX);
ENTRY(WS_SYSMENU);
ENTRY(WS_VISIBLE);
ENTRY(WS_VSCROLL);
default:
return NULL;
}
}
const char* window_styles_to_string(UINT32 style, char* buffer, size_t length)
{
(void)_snprintf(buffer, length, "style[0x%08" PRIx32 "] {", style);
const char* sep = "";
for (size_t x = 0; x < 32; x++)
{
const UINT32 val = 1 << x;
if ((style & val) != 0)
{
const char* str = window_style_to_string(val);
if (str)
{
winpr_str_append(str, buffer, length, sep);
sep = "|";
}
}
}
winpr_str_append("}", buffer, length, "");
return buffer;
}
static const char* window_style_ex_to_string(UINT32 styleEx)
{
switch (styleEx)
{
ENTRY(WS_EX_ACCEPTFILES);
ENTRY(WS_EX_APPWINDOW);
ENTRY(WS_EX_CLIENTEDGE);
ENTRY(WS_EX_COMPOSITED);
ENTRY(WS_EX_CONTEXTHELP);
ENTRY(WS_EX_CONTROLPARENT);
ENTRY(WS_EX_DLGMODALFRAME);
ENTRY(WS_EX_LAYERED);
ENTRY(WS_EX_LAYOUTRTL);
ENTRY(WS_EX_LEFTSCROLLBAR);
ENTRY(WS_EX_MDICHILD);
ENTRY(WS_EX_NOACTIVATE);
ENTRY(WS_EX_NOINHERITLAYOUT);
ENTRY(WS_EX_NOPARENTNOTIFY);
ENTRY(WS_EX_OVERLAPPEDWINDOW);
ENTRY(WS_EX_PALETTEWINDOW);
ENTRY(WS_EX_RIGHT);
ENTRY(WS_EX_RIGHTSCROLLBAR);
ENTRY(WS_EX_RTLREADING);
ENTRY(WS_EX_STATICEDGE);
ENTRY(WS_EX_TOOLWINDOW);
ENTRY(WS_EX_TOPMOST);
ENTRY(WS_EX_TRANSPARENT);
ENTRY(WS_EX_WINDOWEDGE);
default:
return NULL;
}
}
const char* window_styles_ex_to_string(UINT32 styleEx, char* buffer, size_t length)
{
(void)_snprintf(buffer, length, "styleEx[0x%08" PRIx32 "] {", styleEx);
const char* sep = "";
for (size_t x = 0; x < 32; x++)
{
const UINT32 val = 1 << x;
if ((styleEx & val) != 0)
{
const char* str = window_style_ex_to_string(val);
if (str)
{
winpr_str_append(str, buffer, length, sep);
sep = "|";
}
}
}
winpr_str_append("}", buffer, length, "");
return buffer;
}
static void xf_SetWindowTitleText(xfContext* xfc, Window window, const char* name)
{
WINPR_ASSERT(xfc);

View File

@ -205,4 +205,7 @@ void xf_StartLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow, int direction
void xf_EndLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow);
xfAppWindow* xf_AppWindowFromX11Window(xfContext* xfc, Window wnd);
const char* window_styles_to_string(UINT32 style, char* buffer, size_t length);
const char* window_styles_ex_to_string(UINT32 styleEx, char* buffer, size_t length);
#endif /* FREERDP_CLIENT_X11_WINDOW_H */

View File

@ -80,9 +80,11 @@
/* Window Styles */
#ifndef _WIN32
#define WS_NONE 0x00000000
#define WS_BORDER 0x00800000
#define WS_CAPTION 0x00C00000
#define WS_CHILD 0x40000000
#define WS_CHILDWINDOW 0x40000000
#define WS_CLIPCHILDREN 0x02000000
#define WS_CLIPSIBLINGS 0x04000000
#define WS_DISABLED 0x08000000
@ -105,10 +107,13 @@
#define WS_THICKFRAME 0x00040000
#define WS_VISIBLE 0x10000000
#define WS_VSCROLL 0x00200000
#define WS_TILEDWINDOW \
(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
#endif
/* Extended Window Styles */
#ifndef _WIN32
#define WS_EX_NONE 0x00000000
#define WS_EX_ACCEPTFILES 0x00000010
#define WS_EX_APPWINDOW 0x00040000
#define WS_EX_CLIENTEDGE 0x00000200
@ -125,6 +130,7 @@
#define WS_EX_NOACTIVATE 0x08000000
#define WS_EX_NOINHERITLAYOUT 0x00100000
#define WS_EX_NOPARENTNOTIFY 0x00000004
#define WS_EX_NOREDIRECTIONBITMAP 0x00200000
#define WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)
#define WS_EX_PALETTEWINDOW (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST)
#define WS_EX_RIGHT 0x00001000