JBrowser Source Docs
You are reading the documentation for JBrowser 2.0.0. The newest release is 2.0.3. Go to the latest documentation

jbrowser.ui.backdrop

Generated from the source code of JBrowser 2.0.0.

jbrowser/ui/backdrop.py · 211 lines

One owner for a top-level window's Windows 11 look: the system material behind it and its light/dark mode.

Windows keeps that state per native window, and more than one party touches it: JBrowser, and Qt, which re-applies its own idea of light/dark to every window frame when the application palette or colour scheme changes. Earlier versions applied the state from several places, read it back, rebuilt the material when it looked wrong and changed JBrowser's whole look when Windows reported a failure. On some PCs those reactions fed each other: pale windows behind dark text, a stale rectangle after maximising, a caption that stopped dragging, a window that flashed black or white and stopped responding.

So, per window, one Backdrop:

  • applies the material and the mode when they change (once for each new native window, and with the same values again when the window comes back from the taskbar), and never reads anything back from Windows;
  • after anything that can reset the mode (palette or theme changes, activation, window state changes, Windows settings broadcasts), sets the mode again. Setting the same value is free and changes nothing on screen, so nothing can loop;
  • never rebuilds the material, never forces a frame refresh and never restyles the application.

JBrowser also paints its own base colour under its content (Theme.backdrop_layers), so the window stays readable whatever Windows draws behind it.

Backdrop#

class Backdrop(QObject)source
Backdrop(window: QWidget, kind: str='window')

Keeps window's system backdrop and light/dark mode in step with the theme.

kind is "window" (a frameless JBrowser window with a material), "popup" (a borderless popup: Acrylic over the whole window) or "frame" (a dialog with a native title bar: only the mode and the caption colours).

Backdrop.schedule#

schedule() -> Nonesource

Apply soon, once, after the current event (Qt's own handling of it comes first).

Backdrop.apply#

apply(showing: bool=False) -> Nonesource

Qt overrides: eventFilter

WindowTransitions#

class WindowTransitions(QObject)source
WindowTransitions(window: QWidget, native: 'win.NativeFrame', repaint=None)

Minimise, maximise and restore without the colour warp.

Windows animates these with a snapshot of the window. On some PCs the see-through parts of that snapshot come out in the wrong colours (pale, dark or tinted) until something repaints. So the window paints itself opaque just before the change (Theme.hold_opaque), stays opaque while Windows animates, then repaints normally. Commands from Windows itself (taskbar, Win+arrow keys, double-clicking the caption) arrive as WM_SYSCOMMAND: the window takes them over, paints, and sends them again (NativeFrame.on_transition).

Attributes

Name Value
PAINT_MS 40
HOLD_MS 420

WindowTransitions.run#

run(action) -> Nonesource

Qt overrides: eventFilter

Functions#

caption_hit#

caption_hit(window: QWidget, local: QPoint, max_button: QWidget | None) -> intsource

The hit-test code for a point in a frameless JBrowser window: the caption (drag), the maximise button (Snap Layouts) or ordinary client area. Never raises: an error here used to make the window procedure fall back to "client area", and the window stopped dragging.