Add auto-initialization to MSS and DXcam engines to fix WGC multi-monitor issue
- MSS and DXcam now auto-initialize on first capture_display() call, matching WGC behavior - Remove engine.initialize() call from test endpoint to prevent WGC from initializing monitor 0 unnecessarily - This fixes the issue where testing WGC with secondary monitor would show borders on both displays Previously, calling engine.initialize() would initialize WGC's monitor 0 by default, then capture_display() would initialize the requested monitor, causing both to be active. Now all engines consistently auto-initialize only when needed. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -930,9 +930,8 @@ async def test_template(
|
||||
)
|
||||
)
|
||||
|
||||
# Create and initialize engine
|
||||
# Create engine (auto-initializes on first capture)
|
||||
engine = EngineRegistry.create_engine(test_request.engine_type, test_request.engine_config)
|
||||
engine.initialize()
|
||||
|
||||
# Run sustained capture test
|
||||
logger.info(f"Starting {test_request.capture_duration}s capture test with {test_request.engine_type}")
|
||||
|
||||
@@ -168,12 +168,12 @@ class DXcamEngine(CaptureEngine):
|
||||
ScreenCapture object with image data
|
||||
|
||||
Raises:
|
||||
RuntimeError: If not initialized
|
||||
ValueError: If display_index doesn't match configured output
|
||||
RuntimeError: If capture fails
|
||||
"""
|
||||
# Auto-initialize if not already initialized
|
||||
if not self._initialized:
|
||||
raise RuntimeError("Engine not initialized")
|
||||
self.initialize()
|
||||
|
||||
# DXcam is configured for a specific output
|
||||
configured_output = self.config.get("output_idx", 0)
|
||||
|
||||
@@ -115,12 +115,12 @@ class MSSEngine(CaptureEngine):
|
||||
ScreenCapture object with image data
|
||||
|
||||
Raises:
|
||||
RuntimeError: If not initialized
|
||||
ValueError: If display_index is invalid
|
||||
RuntimeError: If capture fails
|
||||
"""
|
||||
# Auto-initialize if not already initialized
|
||||
if not self._initialized:
|
||||
raise RuntimeError("Engine not initialized")
|
||||
self.initialize()
|
||||
|
||||
try:
|
||||
# mss monitors[0] is the combined screen, monitors[1+] are individual displays
|
||||
|
||||
Reference in New Issue
Block a user