Enhance monitor selection with advanced debugging and logging
- Improved monitor detection with primary/secondary identification - Enhanced logging to track monitor layout and selection process - Added comprehensive debug scripts for troubleshooting monitor issues - Better error handling in monitor selection logic - Created test utilities for validating monitor selection behavior Debug tools added: - debug_monitor_issue.sh: Comprehensive monitor debugging script - test_enhanced_monitor.py: Tests monitor selection logic with logging - debug_rdp_command.py: Tests RDP command generation Fixes: - Monitor detection now identifies primary monitor correctly - Detailed logging shows exactly which monitors are selected - Better fallback handling for monitor detection errors - Enhanced command logging for easier troubleshooting
This commit is contained in:
@@ -253,9 +253,14 @@ class RDPClient:
|
||||
if result.returncode == 0:
|
||||
lines = result.stdout.strip().split('\n')
|
||||
monitors = []
|
||||
primary_monitor = None
|
||||
|
||||
for line in lines:
|
||||
# Clean up the line and split by whitespace/tabs
|
||||
cleaned_line = line.strip().replace('*', '').strip()
|
||||
cleaned_line = line.strip()
|
||||
is_primary = cleaned_line.startswith('*')
|
||||
cleaned_line = cleaned_line.replace('*', '').strip()
|
||||
|
||||
if '[' in cleaned_line and ']' in cleaned_line and 'x' in cleaned_line and '+' in cleaned_line:
|
||||
# Split by whitespace/tabs
|
||||
parts = cleaned_line.split()
|
||||
@@ -265,19 +270,31 @@ class RDPClient:
|
||||
if '[' in id_part and ']' in id_part:
|
||||
monitor_id = int(id_part.strip('[]'))
|
||||
x_pos = int(pos_part.split('+')[1])
|
||||
monitors.append((monitor_id, x_pos))
|
||||
monitor_info = (monitor_id, x_pos, is_primary)
|
||||
monitors.append(monitor_info)
|
||||
|
||||
if is_primary:
|
||||
primary_monitor = monitor_id
|
||||
|
||||
# Sort monitors by X position (left to right)
|
||||
monitors.sort(key=lambda x: x[1])
|
||||
|
||||
# Return the leftmost monitors
|
||||
# For debugging, log the monitor layout
|
||||
self.logger.info(f"Monitor layout detected: {[(m[0], m[1], 'primary' if m[2] else 'secondary') for m in monitors]}")
|
||||
|
||||
# Return the leftmost monitors (excluding position and primary flag)
|
||||
selected = [str(m[0]) for m in monitors[:count]]
|
||||
return ','.join(selected)
|
||||
except:
|
||||
pass
|
||||
selected_str = ','.join(selected)
|
||||
|
||||
self.logger.info(f"Selected {count} monitors: {selected_str}")
|
||||
return selected_str
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error detecting monitors: {e}")
|
||||
|
||||
# Fallback: simple sequential selection
|
||||
return ','.join([str(i) for i in range(count)])
|
||||
fallback = ','.join([str(i) for i in range(count)])
|
||||
self.logger.warning(f"Using fallback monitor selection: {fallback}")
|
||||
return fallback
|
||||
|
||||
def _setup_gui(self):
|
||||
"""Setup the main GUI"""
|
||||
@@ -840,17 +857,23 @@ Multi-Monitor Support:
|
||||
multimon = conn.get("multimon", "No")
|
||||
if multimon == "2 Monitors":
|
||||
monitor_list = self._get_best_monitor_selection(2)
|
||||
# Try using /monitors without /multimon for specific monitor selection
|
||||
cmd.append(f"/monitors:{monitor_list}")
|
||||
self.logger.info(f"Using specific monitors for 2 monitors: {monitor_list}")
|
||||
elif multimon == "3 Monitors":
|
||||
monitor_list = self._get_best_monitor_selection(3)
|
||||
cmd.append(f"/monitors:{monitor_list}")
|
||||
self.logger.info(f"Using specific monitors for 3 monitors: {monitor_list}")
|
||||
elif multimon == "4 Monitors":
|
||||
monitor_list = self._get_best_monitor_selection(4)
|
||||
cmd.append(f"/monitors:{monitor_list}")
|
||||
self.logger.info(f"Using specific monitors for 4 monitors: {monitor_list}")
|
||||
elif multimon == "All Monitors":
|
||||
cmd.append("/multimon")
|
||||
self.logger.info("Using all available monitors")
|
||||
elif multimon == "Span":
|
||||
cmd.append("/span")
|
||||
self.logger.info("Using span mode across monitors")
|
||||
|
||||
# Sound
|
||||
sound = conn.get("sound", "Yes")
|
||||
|
||||
Reference in New Issue
Block a user