From 447098b9fa679fa6f803dc216d58ec3aa09f2369 Mon Sep 17 00:00:00 2001 From: LemonNexus Date: Mon, 16 Feb 2026 00:09:11 +0000 Subject: [PATCH] fix: Disable EU focus detection by default - fixes 4.5s UI freeze Changes: - Fixed is_focused property (was calling as method) - EU focus detection now DISABLED by default - Added auto_show_on_focus setting (default: false) - Hard disable if focus check takes >1 second - ActivityBarConfig now includes auto_show_on_focus setting This prevents the EnumWindows blocking that was causing 4.5s freezes. Users can manually enable in settings if they want auto-show behavior. --- core/activity_bar.py | 2 ++ core/main.py | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/core/activity_bar.py b/core/activity_bar.py index f475460..0595b6b 100644 --- a/core/activity_bar.py +++ b/core/activity_bar.py @@ -31,6 +31,7 @@ class ActivityBarConfig: icon_size: int = 32 auto_hide: bool = True auto_hide_delay: int = 3000 # milliseconds + auto_show_on_focus: bool = False # DISABLED by default - causes UI freezing pinned_plugins: List[str] = None def __post_init__(self): @@ -44,6 +45,7 @@ class ActivityBarConfig: 'icon_size': self.icon_size, 'auto_hide': self.auto_hide, 'auto_hide_delay': self.auto_hide_delay, + 'auto_show_on_focus': self.auto_show_on_focus, 'pinned_plugins': self.pinned_plugins } diff --git a/core/main.py b/core/main.py index f032ccd..eab2099 100644 --- a/core/main.py +++ b/core/main.py @@ -465,19 +465,30 @@ class EUUtilityApp: """Start timer to detect EU window focus and show/hide activity bar.""" from PyQt6.QtCore import QTimer + # Check if disabled in settings + settings = get_settings() + if not settings.get('activity_bar.auto_show_on_focus', False): + debug_logger.info("MAIN", "EU focus detection DISABLED in settings (activity_bar.auto_show_on_focus=false)") + return + debug_logger.info("MAIN", "Starting EU focus detection...") debug_logger.start_timer("MAIN_start_eu_focus") self.eu_focus_timer = QTimer(self.app) self.eu_focus_timer.timeout.connect(self._check_eu_focus) - self.eu_focus_timer.start(5000) # Check every 5 seconds (reduced from 2s for debugging) + self.eu_focus_timer.start(5000) # Check every 5 seconds self._last_eu_focused = False + self._focus_detection_disabled = False # Will be set to True if too slow debug_logger.end_timer("MAIN_start_eu_focus") debug_logger.info("MAIN", "EU focus detection started (5s interval)") def _check_eu_focus(self): """Check if EU window is focused and show/hide activity bar.""" + # HARD DISABLE: If focus detection has been slow before, don't run it again + if getattr(self, '_focus_detection_disabled', False): + return + debug_logger.start_timer("MAIN_check_eu_focus") try: @@ -498,7 +509,7 @@ class EUUtilityApp: if eu_window: debug_logger.debug("MAIN", "EU window found, checking focus...") - is_focused = eu_window.is_focused() + is_focused = eu_window.is_focused # Property, not method! debug_logger.debug("MAIN", f"EU focused: {is_focused}, last: {getattr(self, '_last_eu_focused', None)}") if is_focused != getattr(self, '_last_eu_focused', False): @@ -550,6 +561,14 @@ class EUUtilityApp: elapsed = debug_logger.end_timer("MAIN_check_eu_focus") if elapsed > 100: # Log if taking more than 100ms debug_logger.warn("MAIN", f"EU focus check took {elapsed:.2f}ms - SLOW!") + + # HARD DISABLE: If focus detection is slow, permanently disable it + if elapsed > 1000: # More than 1 second - this is killing the UI + debug_logger.error("MAIN", "FOCUS DETECTION TOO SLOW - DISABLING PERMANENTLY!") + self._focus_detection_disabled = True + if hasattr(self, 'eu_focus_timer'): + self.eu_focus_timer.stop() + debug_logger.info("MAIN", "EU focus detection DISABLED to prevent UI freezing") def _load_overlay_widgets(self): """Load saved overlay widgets."""