steamcompmgr: Parse Windows styles/stylesex

This commit is contained in:
Joshua Ashton 2022-08-17 00:08:10 +00:00
parent f32e8637b7
commit 910ae1b3c7
2 changed files with 92 additions and 0 deletions

View file

@ -86,6 +86,62 @@
#define GPUVIS_TRACE_IMPLEMENTATION
#include "gpuvis_trace_utils.h"
const uint32_t WS_OVERLAPPED = 0x00000000u;
const uint32_t WS_POPUP = 0x80000000u;
const uint32_t WS_CHILD = 0x40000000u;
const uint32_t WS_MINIMIZE = 0x20000000u;
const uint32_t WS_VISIBLE = 0x10000000u;
const uint32_t WS_DISABLED = 0x08000000u;
const uint32_t WS_CLIPSIBLINGS = 0x04000000u;
const uint32_t WS_CLIPCHILDREN = 0x02000000u;
const uint32_t WS_MAXIMIZE = 0x01000000u;
const uint32_t WS_BORDER = 0x00800000u;
const uint32_t WS_DLGFRAME = 0x00400000u;
const uint32_t WS_VSCROLL = 0x00200000u;
const uint32_t WS_HSCROLL = 0x00100000u;
const uint32_t WS_SYSMENU = 0x00080000u;
const uint32_t WS_THICKFRAME = 0x00040000u;
const uint32_t WS_GROUP = 0x00020000u;
const uint32_t WS_TABSTOP = 0x00010000u;
const uint32_t WS_MINIMIZEBOX = 0x00020000u;
const uint32_t WS_MAXIMIZEBOX = 0x00010000u;
const uint32_t WS_CAPTION = WS_BORDER | WS_DLGFRAME;
const uint32_t WS_TILED = WS_OVERLAPPED;
const uint32_t WS_ICONIC = WS_MINIMIZE;
const uint32_t WS_SIZEBOX = WS_THICKFRAME;
const uint32_t WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME| WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
const uint32_t WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU;
const uint32_t WS_CHILDWINDOW = WS_CHILD;
const uint32_t WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW;
const uint32_t WS_EX_DLGMODALFRAME = 0x00000001u;
const uint32_t WS_EX_DRAGDETECT = 0x00000002u; // Undocumented
const uint32_t WS_EX_NOPARENTNOTIFY = 0x00000004u;
const uint32_t WS_EX_TOPMOST = 0x00000008u;
const uint32_t WS_EX_ACCEPTFILES = 0x00000010u;
const uint32_t WS_EX_TRANSPARENT = 0x00000020u;
const uint32_t WS_EX_MDICHILD = 0x00000040u;
const uint32_t WS_EX_TOOLWINDOW = 0x00000080u;
const uint32_t WS_EX_WINDOWEDGE = 0x00000100u;
const uint32_t WS_EX_CLIENTEDGE = 0x00000200u;
const uint32_t WS_EX_CONTEXTHELP = 0x00000400u;
const uint32_t WS_EX_RIGHT = 0x00001000u;
const uint32_t WS_EX_LEFT = 0x00000000u;
const uint32_t WS_EX_RTLREADING = 0x00002000u;
const uint32_t WS_EX_LTRREADING = 0x00000000u;
const uint32_t WS_EX_LEFTSCROLLBAR = 0x00004000u;
const uint32_t WS_EX_RIGHTSCROLLBAR = 0x00000000u;
const uint32_t WS_EX_CONTROLPARENT = 0x00010000u;
const uint32_t WS_EX_STATICEDGE = 0x00020000u;
const uint32_t WS_EX_APPWINDOW = 0x00040000u;
const uint32_t WS_EX_LAYERED = 0x00080000u;
const uint32_t WS_EX_NOINHERITLAYOUT = 0x00100000u;
const uint32_t WS_EX_NOREDIRECTIONBITMAP = 0x00200000u;
const uint32_t WS_EX_LAYOUTRTL = 0x00400000u;
const uint32_t WS_EX_COMPOSITED = 0x02000000u;
const uint32_t WS_EX_NOACTIVATE = 0x08000000u;
template< typename T >
constexpr const T& clamp( const T& x, const T& min, const T& max )
{
@ -192,6 +248,11 @@ struct win {
bool is_dialog;
bool maybe_a_dropdown;
bool hasHwndStyle;
uint32_t hwndStyle;
bool hasHwndStyleEx;
uint32_t hwndStyleEx;
motif_hints_t *motif_hints;
Window transientFor;
@ -3193,6 +3254,11 @@ add_win(xwayland_ctx_t *ctx, Window id, Window prev, unsigned long sequence)
new_win->maybe_a_dropdown = false;
new_win->motif_hints = nullptr;
new_win->hasHwndStyle = false;
new_win->hwndStyle = 0;
new_win->hasHwndStyleEx = false;
new_win->hwndStyleEx = 0;
if ( steamMode == true )
{
if ( new_win->pid != -1 )
@ -4088,6 +4154,26 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev)
g_bIsCompositeDebug = !!get_prop( ctx, ctx->root, ctx->atoms.gamescopeCompositeDebug, 0 );
hasRepaint = true;
}
if (ev->atom == ctx->atoms.wineHwndStyle)
{
win * w = find_win(ctx, ev->window);
if (w)
{
w->hasHwndStyle = true;
w->hwndStyle = get_prop(ctx, w->id, ctx->atoms.wineHwndStyle, 0);
focusDirty = true;
}
}
if (ev->atom == ctx->atoms.wineHwndStyleEx)
{
win * w = find_win(ctx, ev->window);
if (w)
{
w->hasHwndStyleEx = true;
w->hwndStyleEx = get_prop(ctx, w->id, ctx->atoms.wineHwndStyleEx, 0);
focusDirty = true;
}
}
}
static int
@ -4979,6 +5065,9 @@ void init_xwayland_ctx(gamescope_xwayland_server_t *xwayland_server)
ctx->atoms.gamescopeCompositeForce = XInternAtom( ctx->dpy, "GAMESCOPE_COMPOSITE_FORCE", false );
ctx->atoms.gamescopeCompositeDebug = XInternAtom( ctx->dpy, "GAMESCOPE_COMPOSITE_DEBUG", false );
ctx->atoms.wineHwndStyle = XInternAtom( ctx->dpy, "_WINE_HWND_STYLE", false );
ctx->atoms.wineHwndStyleEx = XInternAtom( ctx->dpy, "_WINE_HWND_EXSTYLE", false );
ctx->root_width = DisplayWidth(ctx->dpy, ctx->scr);
ctx->root_height = DisplayHeight(ctx->dpy, ctx->scr);

View file

@ -142,5 +142,8 @@ struct xwayland_ctx_t
Atom gamescopeCompositeForce;
Atom gamescopeCompositeDebug;
Atom wineHwndStyle;
Atom wineHwndStyleEx;
} atoms;
};