Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gnome_randr_cycle not working under Wayland (LP:#2036172)(BugFix) #855

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions providers/base/bin/gnome_randr_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,35 @@
modeline = line.split()
try:
mode, resolution, rate = modeline[:3]
#ignore preferred for rate
hugh712 marked this conversation as resolved.
Show resolved Hide resolved
rate = rate.replace('+', '')
hugh712 marked this conversation as resolved.
Show resolved Hide resolved
width, height = [int(x) for x in resolution.split('x')]
aspect = Fraction(width, height)
if width < 675 or width / aspect < 530:
continue
if "*" in rate:
current_modes.append((monitor, resolution, mode, rate))
if resolution in monitors[monitor]:
existing_rate = monitors[monitor][resolution][4]
if rate < existing_rate:
rate=rate.replace('*', '')
existing_rate = monitors[monitor][resolution][3]
if float(rate) < float(existing_rate):
continue
monitors[monitor][resolution] = (width, aspect, mode, rate)
except IndexError:
continue
except ValueError as e:
print(f"Invalid refresh rate format: {e}")
hugh712 marked this conversation as resolved.
Show resolved Hide resolved
continue

for monitor in monitors.keys():
# let's create a dict of aspect_ratio:largest_width for each display
# (width, because it's easier to compare simple ints when looking for the
# highest value).
top_res_per_aspect = OrderedDict()
connected = False
for resolution in monitors[monitor]:
width, aspect, mode, rate = monitors[monitor][resolution]
cur_max = top_res_per_aspect.get(aspect, 0)
top_res_per_aspect[aspect] = max(cur_max, width)
if '*' in rate:
connected = True
current_modes.append((monitor, resolution, mode, rate))
if not connected:
continue
for aspect_ratio, max_width in reversed(top_res_per_aspect.items()):
for resolution in monitors[monitor]:
width, aspect, mode, rate = monitors[monitor][resolution]
Expand Down
Loading