FreeRDP
Loading...
Searching...
No Matches
sdl_rail_window_style.hpp
1
19#pragma once
20
21#include <cstdint>
22
23#include <freerdp/window.h>
24
26{
27 bool popup = false;
28 bool layered = false;
29 bool clickThrough = false;
30 bool overlay = false;
31};
32
33/*
34 * RAIL carries the window style, but not SetWindowPos flags such as SWP_NOACTIVATE. An unowned,
35 * caption-less WS_EX_TOOLWINDOW/WS_POPUP is therefore treated as a popup even when applications
36 * add decoration bits such as WS_SYSMENU or WS_MINIMIZEBOX. Keep owned popup/tool windows on their
37 * existing path: some applications implement their own drag loop for those windows.
38 */
39inline SdlRailWindowStyle classifySdlRailWindowStyle(uint32_t style, uint32_t exStyle, bool owned)
40{
41 /* WS_CAPTION is WS_BORDER | WS_DLGFRAME; a partial match is only a border. */
42 const bool captioned = (style & WS_CAPTION) == WS_CAPTION;
43 const bool isDialogOrApp =
44 captioned ||
45 ((style & (WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)) != 0) ||
46 ((exStyle & WS_EX_APPWINDOW) != 0);
47 const bool isToolOrPopup =
48 ((exStyle & (WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW)) != 0) || ((style & WS_POPUP) != 0);
49 const bool noActivate =
50 ((exStyle & WS_EX_NOACTIVATE) != 0) && ((exStyle & WS_EX_APPWINDOW) == 0);
51 const bool unownedPopup =
52 !owned && !captioned && ((style & WS_POPUP) != 0) &&
53 ((exStyle & (WS_EX_TOOLWINDOW | WS_EX_APPWINDOW)) == WS_EX_TOOLWINDOW);
54
55 /* Route drag/feedback overlays through the popup path. */
56 constexpr uint32_t overlayEx = WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
57 const bool overlay = ((exStyle & overlayEx) == overlayEx) &&
58 ((exStyle & (WS_EX_NOACTIVATE | WS_EX_APPWINDOW)) == 0) && !captioned;
59
60 return { noActivate || overlay || unownedPopup || (isToolOrPopup && !isDialogOrApp),
61 ((exStyle & WS_EX_LAYERED) != 0) && !isDialogOrApp, (exStyle & WS_EX_TRANSPARENT) != 0,
62 overlay };
63}