chore: update .gitignore and CHANGELOG, refactor watch_point.py

- Add *.backup pattern to .gitignore for temporary backup files
- Update CHANGELOG.md with version 2.0.1 changes
- Remove dead MonitorTracker class and its usage to improve maintainability
- Restore missing zoom_level initialization to fix AttributeError on first run
This commit is contained in:
Gmorks
2026-01-27 18:15:16 -06:00
parent ce511456d1
commit 8e0afadcdb
3 changed files with 12 additions and 67 deletions
+2
View File
@@ -34,3 +34,5 @@ watchpoint_debug_config.json
# Files not yet ready to be uploaded
beta/
# Temporal Backup files
*.backup
+9
View File
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2.0.1] - 2026-01-27
### Changed
- Refactored `watch_point.py` to remove dead code (`MonitorTracker` class) and redundant monitor detection logic.
- Improved code maintainability by cleaning up unused imports and definitions.
### Fixed
- Fixed `AttributeError: 'WatchPointWindow' object has no attribute 'zoom_level'` occurring on first run by restoring missing state initialization.
## [2.0.0] - 2026-01-26
### Removed
+1 -67
View File
@@ -181,73 +181,7 @@ if sys.platform.startswith("win") and CTYPES_AVAILABLE:
("dwFlags", wintypes.DWORD),
]
class MonitorTracker:
"""Handles cross-platform monitor detection."""
def __init__(self):
self.user32 = None
if sys.platform.startswith("win") and CTYPES_AVAILABLE:
try:
self.user32 = ctypes.windll.user32
except Exception as e:
print(f"WatchPoint: Failed to load user32: {e}")
def get_monitor_geometry(self, widget):
"""
Returns (x, y, width, height) of the monitor containing the widget's center.
"""
# 1. Try Windows ctypes (Most accurate for Windows)
if self.user32:
try:
# Need absolute coordinates
x = widget.winfo_rootx()
y = widget.winfo_rooty()
# If window coordinates are weird (e.g. -32000 when minimized), fallback
if x < -10000 or y < -10000:
# Use mouse pointer as fallback for detection if window is off-screen/minimized
x, y = widget.winfo_pointerxy()
width = widget.winfo_width()
height = widget.winfo_height()
cx = x + width // 2
cy = y + height // 2
point = wintypes.POINT(cx, cy)
MONITOR_DEFAULTTONEAREST = 2
hMonitor = self.user32.MonitorFromPoint(point, MONITOR_DEFAULTTONEAREST)
mi = MONITORINFO()
mi.cbSize = ctypes.sizeof(MONITORINFO)
if self.user32.GetMonitorInfoW(hMonitor, ctypes.byref(mi)):
r = mi.rcMonitor
return (r.left, r.top, r.right - r.left, r.bottom - r.top)
except Exception as e:
# Silently fail and try next method
pass
# 2. Try screeninfo (Cross-platform if installed)
if SCREENINFO_AVAILABLE:
try:
# Need absolute coordinates
x = widget.winfo_rootx()
y = widget.winfo_rooty()
cx = x + widget.winfo_width() // 2
cy = y + widget.winfo_height() // 2
for m in get_monitors():
if (m.x <= cx < m.x + m.width) and (m.y <= cy < m.y + m.height):
return (m.x, m.y, m.width, m.height)
except Exception:
pass
# 3. Fallback to Tkinter screen info (Primary monitor or screen containing widget)
# Note: winfo_screenwidth/height typically return primary monitor size
try:
return (0, 0, widget.winfo_screenwidth(), widget.winfo_screenheight())
except:
return (0, 0, 800, 600)
# Settings Management
class SettingsManager:
@@ -798,8 +732,8 @@ class WatchPointWindow:
self.root = root
self.display_idx = display_idx
self.manager = manager
self.settings = manager.settings_manager
self.monitor_tracker = MonitorTracker()
# UI State
self.zoom_level, self.pan_x, self.pan_y = 1.0, 0, 0