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.
This commit is contained in:
parent
5feecaca14
commit
447098b9fa
|
|
@ -31,6 +31,7 @@ class ActivityBarConfig:
|
||||||
icon_size: int = 32
|
icon_size: int = 32
|
||||||
auto_hide: bool = True
|
auto_hide: bool = True
|
||||||
auto_hide_delay: int = 3000 # milliseconds
|
auto_hide_delay: int = 3000 # milliseconds
|
||||||
|
auto_show_on_focus: bool = False # DISABLED by default - causes UI freezing
|
||||||
pinned_plugins: List[str] = None
|
pinned_plugins: List[str] = None
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
|
|
@ -44,6 +45,7 @@ class ActivityBarConfig:
|
||||||
'icon_size': self.icon_size,
|
'icon_size': self.icon_size,
|
||||||
'auto_hide': self.auto_hide,
|
'auto_hide': self.auto_hide,
|
||||||
'auto_hide_delay': self.auto_hide_delay,
|
'auto_hide_delay': self.auto_hide_delay,
|
||||||
|
'auto_show_on_focus': self.auto_show_on_focus,
|
||||||
'pinned_plugins': self.pinned_plugins
|
'pinned_plugins': self.pinned_plugins
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
23
core/main.py
23
core/main.py
|
|
@ -465,19 +465,30 @@ class EUUtilityApp:
|
||||||
"""Start timer to detect EU window focus and show/hide activity bar."""
|
"""Start timer to detect EU window focus and show/hide activity bar."""
|
||||||
from PyQt6.QtCore import QTimer
|
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.info("MAIN", "Starting EU focus detection...")
|
||||||
debug_logger.start_timer("MAIN_start_eu_focus")
|
debug_logger.start_timer("MAIN_start_eu_focus")
|
||||||
|
|
||||||
self.eu_focus_timer = QTimer(self.app)
|
self.eu_focus_timer = QTimer(self.app)
|
||||||
self.eu_focus_timer.timeout.connect(self._check_eu_focus)
|
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._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.end_timer("MAIN_start_eu_focus")
|
||||||
debug_logger.info("MAIN", "EU focus detection started (5s interval)")
|
debug_logger.info("MAIN", "EU focus detection started (5s interval)")
|
||||||
|
|
||||||
def _check_eu_focus(self):
|
def _check_eu_focus(self):
|
||||||
"""Check if EU window is focused and show/hide activity bar."""
|
"""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")
|
debug_logger.start_timer("MAIN_check_eu_focus")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -498,7 +509,7 @@ class EUUtilityApp:
|
||||||
|
|
||||||
if eu_window:
|
if eu_window:
|
||||||
debug_logger.debug("MAIN", "EU window found, checking focus...")
|
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)}")
|
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):
|
if is_focused != getattr(self, '_last_eu_focused', False):
|
||||||
|
|
@ -550,6 +561,14 @@ class EUUtilityApp:
|
||||||
elapsed = debug_logger.end_timer("MAIN_check_eu_focus")
|
elapsed = debug_logger.end_timer("MAIN_check_eu_focus")
|
||||||
if elapsed > 100: # Log if taking more than 100ms
|
if elapsed > 100: # Log if taking more than 100ms
|
||||||
debug_logger.warn("MAIN", f"EU focus check took {elapsed:.2f}ms - SLOW!")
|
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):
|
def _load_overlay_widgets(self):
|
||||||
"""Load saved overlay widgets."""
|
"""Load saved overlay widgets."""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue