mirror of
https://github.com/ralsina/xrandroll.git
synced 2024-11-24 12:02:23 +00:00
made other bits work
This commit is contained in:
parent
d5164d016b
commit
60038ae394
@ -187,36 +187,39 @@ class Window(QObject):
|
|||||||
self.ui.verticalScale.setValue(self.ui.horizontalScale.value())
|
self.ui.verticalScale.setValue(self.ui.horizontalScale.value())
|
||||||
|
|
||||||
def replica_changed(self):
|
def replica_changed(self):
|
||||||
mon = self.ui.screenCombo.currentText()
|
mon_name = self.ui.screenCombo.currentText()
|
||||||
replicate = self.ui.replicaOf.currentText()
|
replicate = self.ui.replicaOf.currentText()
|
||||||
print(f"Making {mon} a replica of {replicate}")
|
print(f"Making {mon_name} a replica of {replicate}")
|
||||||
if replicate in ("None", "", None):
|
if replicate in ("None", "", None):
|
||||||
print("TODO: make things non-replicas")
|
print("TODO: make things non-replicas")
|
||||||
return
|
return
|
||||||
mon = self.xrandr_info[mon]
|
mon = self.screen.monitors[mon_name]
|
||||||
replicate = self.xrandr_info[replicate]
|
replicate = self.screen.monitors[replicate]
|
||||||
|
|
||||||
# Making a replica implies:
|
# Making a replica implies:
|
||||||
# Set the same position
|
# Set the same position
|
||||||
mon["pos_x"] = replicate["pos_x"]
|
mon.pos_x = replicate.pos_x
|
||||||
mon["pos_y"] = replicate["pos_y"]
|
mon.pos_y = replicate.pos_y
|
||||||
|
|
||||||
# Set the same mode if possible
|
# Set the same mode if possible
|
||||||
if replicate["current_mode"] in mon["modes"]:
|
matching_mode = mon.get_matching_mode(replicate.get_current_mode())
|
||||||
mon["current_mode"] = replicate["current_mode"]
|
if matching_mode:
|
||||||
|
mon.set_current_mode(matching_mode.name)
|
||||||
else:
|
else:
|
||||||
# Keep the current mode, and change scaling so it
|
# Keep the current mode, and change scaling so it
|
||||||
# has the same effective size as the desired mode
|
# has the same effective size as the desired mode
|
||||||
mod_x, mod_y = parse_mode(mon["current_mode"])
|
c_mode = mon.get_current_mode()
|
||||||
target_x, target_y = [replicate[x] for x in ["res_x", "res_y"]]
|
mod_x, mod_y = c_mode.res_x, c_mode.res_y
|
||||||
|
r_mode = replicate.get_current_mode
|
||||||
|
target_x, target_y = r_mode.res_x, r_mode.res_y
|
||||||
scale_x = 1000 * target_x / mod_x
|
scale_x = 1000 * target_x / mod_x
|
||||||
scale_y = 1000 * target_y / mod_y
|
scale_y = 1000 * target_y / mod_y
|
||||||
self.ui.horizontalScale.setValue(scale_x)
|
self.ui.horizontalScale.setValue(scale_x)
|
||||||
self.ui.verticalScale.setValue(scale_y)
|
self.ui.verticalScale.setValue(scale_y)
|
||||||
|
|
||||||
self.update_replica_of_data()
|
self.screen.update_replica_of()
|
||||||
for _, mon in self.xrandr_info.items():
|
for mon in self.screen.monitors.values():
|
||||||
mon["item"].update_visuals(mon)
|
mon.item.update_visuals(mon)
|
||||||
|
|
||||||
def do_reset(self):
|
def do_reset(self):
|
||||||
for n in self.xrandr_info:
|
for n in self.xrandr_info:
|
||||||
|
@ -104,6 +104,12 @@ class Monitor:
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"Monitor: {self.output}"
|
return f"Monitor: {self.output}"
|
||||||
|
|
||||||
|
def get_matching_mode(self, mode):
|
||||||
|
"""Try to find a mode that matches resolution with given one."""
|
||||||
|
for m in self.modes.values():
|
||||||
|
if m.res_x == mode.res_x and m.res_y == mode.res_y:
|
||||||
|
return m
|
||||||
|
|
||||||
def get_current_mode_name(self):
|
def get_current_mode_name(self):
|
||||||
for k, v in self.modes.items():
|
for k, v in self.modes.items():
|
||||||
if v.current:
|
if v.current:
|
||||||
|
Loading…
Reference in New Issue
Block a user