jbrowser.platform.win
Generated from the source code of JBrowser 2.0.1.
Windows 11 integration via the Win32 / DWM APIs (ctypes).
- Mica / Mica Alt / Acrylic system backdrops (DWMWA_SYSTEMBACKDROP_TYPE)
- Custom-drawn title bar that keeps native behaviour: the top caption is removed in WM_NCCALCSIZE while the invisible side/bottom resize borders, drop shadow, rounded corners, Aero Snap and the Windows 11 Snap Layouts flyout (HTMAXBUTTON) all remain.
- DPAPI for protecting local secrets, system accent colour, AppUserModelID.
Constants#
| Name | Value |
|---|---|
IS_WINDOWS |
sys.platform == 'win32' |
WIN_BUILD |
sys.getwindowsversion().build if IS_WINDOWS else 0 |
IS_WIN11 |
WIN_BUILD >= 22000 |
WM_NCACTIVATE |
134 |
WM_NCCALCSIZE |
131 |
WM_NCHITTEST |
132 |
WM_NCMOUSEMOVE |
160 |
WM_NCLBUTTONDOWN |
161 |
WM_NCLBUTTONUP |
162 |
WM_NCLBUTTONDBLCLK |
163 |
WM_NCRBUTTONDOWN |
164 |
WM_NCRBUTTONUP |
165 |
WM_NCMOUSELEAVE |
674 |
WM_SYSCOMMAND |
274 |
WM_SETTINGCHANGE |
26 |
WM_DWMCOLORIZATIONCOLORCHANGED |
800 |
WM_THEMECHANGED |
794 |
WM_DWMCOMPOSITIONCHANGED |
798 |
WM_POWERBROADCAST |
536 |
WM_DISPLAYCHANGE |
126 |
HTCLIENT |
1 |
HTCAPTION |
2 |
HTMAXBUTTON |
9 |
DWMWA_CLOAK |
13 |
DWMWA_USE_IMMERSIVE_DARK_MODE |
20 |
DWMWA_USE_IMMERSIVE_DARK_MODE_OLD |
19 |
DWMWA_WINDOW_CORNER_PREFERENCE |
33 |
DWMWA_SYSTEMBACKDROP_TYPE |
38 |
DWMWA_MICA_EFFECT_LEGACY |
1029 |
DWMWCP_ROUND |
2 |
BACKDROPS |
{'solid': 1, 'mica': 2, 'acrylic': 3, 'mica_alt': 4} |
SWP_FRAMECHANGED_FLAGS |
1 | 2 | 4 | 16 | 32 |
DEFAULT_HANDLERS |
{'browser': ('https', 'JBrowserURL'), 'pdf': ('.pdf', 'JBrowserPDF')} |
MARGINS#
class MARGINS(ctypes.Structure)source
NCCALCSIZE_PARAMS#
class NCCALCSIZE_PARAMS(ctypes.Structure)source
APPBARDATA#
class APPBARDATA(ctypes.Structure)source
DATA_BLOB#
class DATA_BLOB(ctypes.Structure)source
HIGHCONTRASTW#
class HIGHCONTRASTW(ctypes.Structure)source
SYSTEM_POWER_STATUS#
class SYSTEM_POWER_STATUS(ctypes.Structure)source
NativeFrame#
class NativeFramesource
NativeFrame(hwnd_getter: Callable[[], int], dpr_getter: Callable[[], float], hit_test: Callable[[QPoint], int], on_max_hover: Callable[[bool], None], on_max_press: Callable[[bool], None], on_max_click: Callable[[], None])
Implements the non-client behaviour for a custom-titlebar top-level window.
hit_test(local_logical_point) -> int is supplied by the window and returns
HTCAPTION for drag regions, HTMAXBUTTON over the maximise button, else HTCLIENT.
Attributes
| Name | Value |
|---|---|
RESIZE_BORDER |
6 |
CORNER |
14 |
NativeFrame.handle#
handle(msg_ptr: int) -> tuple[bool, int]source
Functions#
set_dark_title#
set_dark_title(hwnd: int, dark: bool) -> Nonesource
backdrop_supported#
backdrop_supported() -> boolsource
Whether this Windows can draw a system backdrop (Mica / Acrylic) behind a window: Windows 11, or Windows 10 with pywinstyles' blur. Decided once; JBrowser's look never depends on a single call.
set_caption_colors#
set_caption_colors(hwnd: int, background: QColor, text: QColor) -> Nonesource
Tint a native title bar (Windows 11) so it matches the window content.
set_corner_preference#
set_corner_preference(hwnd: int, preference: int=DWMWCP_ROUND) -> Nonesource
Rounded corners (2 = round, 3 = small) — used for popups, menus and tooltips.
apply_backdrop#
apply_backdrop(hwnd: int, material: str, dark: bool) -> boolsource
Apply a Windows 11 system backdrop. Returns True when a translucent material is active. (ui/backdrop.py decides when; the result is only logged, never used to change the look.)
apply_popup_backdrop#
apply_popup_backdrop(hwnd: int, dark: bool) -> boolsource
Acrylic behind a borderless popup (Windows 11 22H2 and later). Returns True when active.
refresh_frame#
refresh_frame(hwnd: int) -> Nonesource
set_transitions#
set_transitions(hwnd: int, enabled: bool) -> Nonesource
Windows' minimise / maximise / restore animations for this window (DWMWA_TRANSITIONS_FORCEDISABLED).
set_cloak#
set_cloak(hwnd: int, cloaked: bool) -> boolsource
Hide (or show again) a window from the screen without hiding it from Windows: a new window is cloaked until its material and first frame are ready, so it never flashes white or black.
transparency_effects_on#
transparency_effects_on() -> boolsource
Settings → Personalisation → Colours → Transparency effects.
high_contrast_on#
high_contrast_on() -> boolsource
energy_saver_on#
energy_saver_on() -> boolsource
Battery saver / energy saver, which turns Windows' transparency effects off while it's on.
remote_session#
remote_session() -> boolsource
material_blockers#
material_blockers() -> list[str]source
Why Windows won't draw Mica or Acrylic right now (empty when it will).
sample_own_pixel#
sample_own_pixel(hwnd: int, x: int, y: int) -> tuple[int, int, int] | Nonesource
The colour on screen at client pixel (x, y) of hwnd, as Windows composited it, or None when
another window covers that point (then it says nothing about hwnd).
foreground_window#
foreground_window() -> intsource
post_syscommand#
post_syscommand(hwnd: int, command: int) -> Nonesource
is_maximized#
is_maximized(hwnd: int) -> boolsource
set_app_user_model_id#
set_app_user_model_id(app_id: str) -> Nonesource
system_accent_color#
system_accent_color() -> QColor | Nonesource
system_animations_enabled#
system_animations_enabled() -> boolsource
dpapi_protect#
dpapi_protect(data: bytes, entropy: bytes=b'JBrowser') -> bytessource
dpapi_unprotect#
dpapi_unprotect(data: bytes, entropy: bytes=b'JBrowser') -> bytessource
registered_with_windows#
registered_with_windows() -> str | Nonesource
Where the installer registered JBrowser for "Default apps": "user", "machine", or None.
handles_pdf#
handles_pdf() -> boolsource
Whether this installation offers JBrowser for PDF files (installed by 2.0.1 or later).
default_handler#
default_handler(kind: str) -> str | Nonesource
The handler Windows uses for links ("browser") or PDF files ("pdf"), or None if unknown. Newer Windows 11 builds keep the user's choice in UserChoiceLatest, older ones in UserChoice.
is_default#
is_default(kind: str) -> boolsource
open_default_apps#
open_default_apps() -> Nonesource
Windows Settings → Default apps, on JBrowser's own page when Windows knows about it.
running_as_admin#
running_as_admin() -> boolsource
True when this process runs elevated (as administrator).
authenticode#
authenticode(path: str) -> tuple[str, str]source
The Authenticode signature of a file: (status, signer subject), e.g. ("Valid", "CN=…") or ("NotSigned", ""). ("Unknown", "") when it can't be checked. Takes about half a second.
reveal_in_explorer#
reveal_in_explorer(path: str) -> Nonesource