tools/per-slot-delta: use dataclasses and enums

Slight modernization of the code

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1101>
This commit is contained in:
Peter Hutterer 2024-12-19 08:39:22 +10:00 committed by Marge Bot
parent 530ca423a7
commit 01f133fbc4

View file

@ -29,6 +29,9 @@
#
# Input is a libinput record yaml file
from dataclasses import dataclass
from enum import Enum
import argparse
import math
import sys
@ -122,24 +125,23 @@ class SlotFormatter:
self.slots.append(string.ljust(self.width + len(color) + len(reset)))
class SlotState:
class SlotState(Enum):
NONE = 0
BEGIN = 1
UPDATE = 2
END = 3
@dataclass
class Slot:
state = SlotState.NONE
x = 0
y = 0
dx = 0
dy = 0
used = False
dirty = False
def __init__(self, index):
self.index = index
index: int
state: SlotState = SlotState.NONE
x: float = 0
y: float = 0
dx: float = 0
dy: float = 0
used: bool = False
dirty: bool = False
def main(argv):