get-state: Do not require too-modern python version for match stanza

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2448>
This commit is contained in:
Marco Trevisan (Treviño) 2022-06-03 18:58:38 +02:00 committed by Marge Bot
parent 40509154fb
commit b02d746512

View File

@ -12,17 +12,16 @@ class Source(enum.Enum):
DBUS = 1 DBUS = 1
FILE = 2 FILE = 2
TRANSFORM_STRINGS = {
def transform_to_string(transform): 0: 'normal',
match transform: 1: '90',
case 0: return 'normal' 2: '180',
case 1: return '90' 3: '270',
case 2: return '180' 4: 'flipped',
case 3: return '270' 5: 'flipped-90',
case 4: return 'flipped' 6: 'flipped-180',
case 5: return 'flipped-90' 7: 'flipped-270',
case 6: return 'flipped-180' }
case 7: return 'flipped-270'
def print_data(level, is_last, lines, data): def print_data(level, is_last, lines, data):
if is_last: if is_last:
@ -140,7 +139,7 @@ def print_current_state(args):
print_data(1, False, lines, print_data(1, False, lines,
f'Scale: {logical_monitor[2]}') f'Scale: {logical_monitor[2]}')
print_data(1, False, lines, print_data(1, False, lines,
f'Transform: {transform_to_string(logical_monitor[3])}') f'Transform: {TRANSFORM_STRINGS.get(logical_monitor[3])}')
print_data(1, False, lines, print_data(1, False, lines,
f'Primary: {logical_monitor[4]}') f'Primary: {logical_monitor[4]}')
monitors = logical_monitor[5] monitors = logical_monitor[5]