feat: keep OSD always visible with pre-map fullscreen states (#3)
This commit is contained in:
@@ -27,6 +27,10 @@ const (
|
||||
maxImageText16Units = 127
|
||||
// windowTypePropertyName is the EWMH property naming a window's role.
|
||||
windowTypePropertyName = "_NET_WM_WINDOW_TYPE"
|
||||
// windowStatePropertyName is the EWMH property carrying a window's
|
||||
// initial states; a compliant window manager must honor it when the
|
||||
// window is mapped.
|
||||
windowStatePropertyName = "_NET_WM_STATE"
|
||||
// layerMarkerPropertyName tags Ground Station layer windows so sibling
|
||||
// layers — and their window-manager frames — never count as video
|
||||
// output for each other.
|
||||
@@ -90,6 +94,20 @@ func fullscreenState(role LayerRole) string {
|
||||
return "below"
|
||||
}
|
||||
|
||||
// fullscreenStateAtoms are the initial EWMH states announced as a property
|
||||
// before mapping: every layer is genuinely fullscreen and undecorated from
|
||||
// its first frame, with the canvas additionally parking below and the OSD
|
||||
// overlay above. A compliant window manager must honor pre-map states; the
|
||||
// post-map wmctrl request remains as reinforcement, never as the only
|
||||
// fullscreen mechanism.
|
||||
func fullscreenStateAtoms(role LayerRole) []string {
|
||||
atoms := []string{"_NET_WM_STATE_FULLSCREEN"}
|
||||
if role == RoleAbove {
|
||||
return append(atoms, "_NET_WM_STATE_ABOVE")
|
||||
}
|
||||
return append(atoms, "_NET_WM_STATE_BELOW")
|
||||
}
|
||||
|
||||
// stackModeForVideoAppear is where a layer goes relative to the first
|
||||
// presented video window: the canvas parks below it, the OSD rises above it.
|
||||
func stackModeForVideoAppear(role LayerRole) uint32 {
|
||||
@@ -308,6 +326,26 @@ func (o X11Opener) Open(ctx context.Context) (Session, error) {
|
||||
xproto.AtomAtom, 32, 1, value)
|
||||
}
|
||||
}
|
||||
// Announce the initial fullscreen state before mapping: a compliant
|
||||
// window manager then maps the layer fullscreen and undecorated from
|
||||
// its first frame, instead of a decorated, repositioned window that
|
||||
// only becomes fullscreen after a later wmctrl round trip (or never,
|
||||
// when wmctrl is missing).
|
||||
stateProp := internAtom(conn, windowStatePropertyName)
|
||||
if stateProp != 0 {
|
||||
var stateData []byte
|
||||
for _, name := range fullscreenStateAtoms(o.Role) {
|
||||
if atom := internAtom(conn, name); atom != 0 {
|
||||
value := make([]byte, 4)
|
||||
binary.LittleEndian.PutUint32(value, uint32(atom))
|
||||
stateData = append(stateData, value...)
|
||||
}
|
||||
}
|
||||
if len(stateData) > 0 {
|
||||
xproto.ChangeProperty(conn, xproto.PropModeReplace, window, stateProp,
|
||||
xproto.AtomAtom, 32, uint32(len(stateData)/4), stateData)
|
||||
}
|
||||
}
|
||||
// The OSD overlay must be transparent and input-transparent from its
|
||||
// first mapped frame: the shapes are emptied before mapping, and a
|
||||
// server without the shape extension never gets the overlay at all, so
|
||||
|
||||
Reference in New Issue
Block a user