window geometry: check x, y values (#700)

* window geometry: check x, y values

* window geometry: negative w, h are not allowed
This commit is contained in:
Ayase 2024-04-28 14:46:30 +08:00 committed by GitHub
parent 194cea5acb
commit c29c6f5927
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -94,6 +94,8 @@ class saveposwindow(QMainWindow):
d = QApplication.primaryScreen() d = QApplication.primaryScreen()
self.dic, self.key = dic, key self.dic, self.key = dic, key
if self.dic: if self.dic:
dic[key][2] = max(0, min(dic[key][2], d.size().width()))
dic[key][3] = max(0, min(dic[key][3], d.size().height()))
dic[key][0] = min(max(dic[key][0], 0), d.size().width() - dic[key][2]) dic[key][0] = min(max(dic[key][0], 0), d.size().width() - dic[key][2])
dic[key][1] = min(max(dic[key][1], 0), d.size().height() - dic[key][3]) dic[key][1] = min(max(dic[key][1], 0), d.size().height() - dic[key][3])
self.setGeometry(*dic[key]) self.setGeometry(*dic[key])