Skip to content

Commit

Permalink
Wlroots: Rename *_VERSION, mark as Final and change err
Browse files Browse the repository at this point in the history
  • Loading branch information
jwijenbergh committed May 12, 2024
1 parent 00198c3 commit 5cc1a94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions wlroots/wlr_types/compositor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Final
from weakref import WeakKeyDictionary

from pywayland.protocol.wayland import WlOutput
Expand All @@ -19,7 +19,7 @@
from wlroots.renderer import Renderer


COMPOSITOR_VERSION = 5
_MAX_COMPOSITOR_VERSION: Final = 5


class Compositor(Ptr):
Expand All @@ -35,9 +35,9 @@ def __init__(
:param renderer:
The wlroots renderer to attach the compositor to.
"""
if not version <= COMPOSITOR_VERSION:
if not 0 < version <= _MAX_COMPOSITOR_VERSION:
raise ValueError(
f"Compositor version must be less than or equal to {COMPOSITOR_VERSION}"
f"Invalid compositor version, should be a value between 1 (inclusive) and {_MAX_COMPOSITOR_VERSION} (inclusive), got: {version}"
)
if renderer is None:
self._ptr = lib.wlr_compositor_create(display._ptr, version, ffi.NULL)
Expand Down
10 changes: 6 additions & 4 deletions wlroots/wlr_types/layer_shell_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import enum
from dataclasses import dataclass
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Final
from weakref import WeakKeyDictionary

from pywayland.server import Signal
Expand Down Expand Up @@ -197,14 +197,16 @@ def surface_at(self, sx: float, sy: float) -> tuple[Surface | None, float, float
return Surface(surface_ptr), sub_x_data[0], sub_y_data[0]


LAYER_SHELL_VERSION = 4
_MAX_LAYER_SHELL_VERSION: Final = 4


class LayerShellV1(PtrHasData):
def __init__(self, display: Display, version: int) -> None:
"""Create an wlr_xdg_output_manager_v1"""
if not 0 < version <= LAYER_SHELL_VERSION:
raise ValueError("Invalid layer shell version.")
if not 0 < version <= _MAX_LAYER_SHELL_VERSION:
raise ValueError(
f"Invalid layer shell version, should be a value between 1 (inclusive) and {_MAX_LAYER_SHELL_VERSION} (inclusive), got: {version}"
)

self._ptr = lib.wlr_layer_shell_v1_create(display._ptr, version)

Expand Down

0 comments on commit 5cc1a94

Please sign in to comment.