Commit a6a54d49 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Simplify code

parent efb14b29
......@@ -390,14 +390,10 @@ def _on_motion_notify(self, _widget, event):
top += delta_y
bottom += delta_y
if left < 0:
left = 0
if top < 0:
top = 0
if right > pb_width:
right = pb_width
if bottom > pb_height:
bottom = pb_height
left = max(left, 0)
top = max(top, 0)
right = min(right, pb_width)
bottom = min(bottom, pb_height)
adj_width = int(right - left + 1)
adj_height = int(bottom - top + 1)
......@@ -501,14 +497,10 @@ def _on_motion_notify(self, _widget, event):
width = right - left + 1
height = bottom - top + 1
if self._aspect < 0:
if left < 0:
left = 0
if top < 0:
top = 0
if right > pb_width:
right = pb_width
if bottom > pb_height:
bottom = pb_height
left = max(left, 0)
top = max(top, 0)
right = min(right, pb_width)
bottom = min(bottom, pb_height)
width = right - left + 1
height = bottom - top + 1
......
......@@ -313,10 +313,8 @@ def resize_window(window: Gtk.Window, width: int, height: int) -> None:
screen_w, screen_h = get_total_screen_geometry()
if not width or not height:
return
if width > screen_w:
width = screen_w
if height > screen_h:
height = screen_h
width = min(width, screen_w)
height = min(height, screen_h)
window.resize(abs(width), abs(height))
......@@ -325,10 +323,9 @@ def move_window(window: Gtk.Window, pos_x: int, pos_y: int) -> None:
Move the window, but also check if out of screen
"""
screen_w, screen_h = get_total_screen_geometry()
if pos_x < 0:
pos_x = 0
if pos_y < 0:
pos_y = 0
pos_x = max(pos_x, 0)
pos_y = max(pos_y, 0)
width, height = window.get_size()
if pos_x + width > screen_w:
pos_x = screen_w - width
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment