monitor-config-manager: Handle laptop lid being closed
Handle configuring when the laptop lid is closed. This is so far handled by creating a linear configuration while ignoring the laptop panel. Changing the current configuration will come later. https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
parent
cde1a730e8
commit
f19cb6a610
@ -291,8 +291,15 @@ meta_monitor_config_manager_assign (MetaMonitorManager *manager,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
typedef enum _MonitorMatchRule
|
||||
{
|
||||
MONITOR_MATCH_ALL = 0,
|
||||
MONITOR_MATCH_EXTERNAL = (1 << 0)
|
||||
} MonitorMatchRule;
|
||||
|
||||
static MetaMonitor *
|
||||
find_monitor_with_highest_preferred_resolution (MetaMonitorManager *monitor_manager)
|
||||
find_monitor_with_highest_preferred_resolution (MetaMonitorManager *monitor_manager,
|
||||
MonitorMatchRule match_rule)
|
||||
{
|
||||
GList *monitors;
|
||||
GList *l;
|
||||
@ -307,6 +314,12 @@ find_monitor_with_highest_preferred_resolution (MetaMonitorManager *monitor_mana
|
||||
int width, height;
|
||||
int area;
|
||||
|
||||
if (match_rule & MONITOR_MATCH_EXTERNAL)
|
||||
{
|
||||
if (meta_monitor_is_laptop_panel (monitor))
|
||||
continue;
|
||||
}
|
||||
|
||||
mode = meta_monitor_get_preferred_mode (monitor);
|
||||
meta_monitor_mode_get_resolution (mode, &width, &height);
|
||||
area = width * height;
|
||||
@ -322,24 +335,48 @@ find_monitor_with_highest_preferred_resolution (MetaMonitorManager *monitor_mana
|
||||
}
|
||||
|
||||
/*
|
||||
* Tries to find the primary monitor as reported by the underlying system;
|
||||
* or failing that, a monitor looks to be the laptop panel; or failing that, the
|
||||
* monitor with the highest preferred resolution.
|
||||
* Try to find the primary monitor. The priority of classification is:
|
||||
*
|
||||
* 1. Find the primary monitor as reported by the underlying system,
|
||||
* 2. Find the laptop panel
|
||||
* 3. Find the external monitor with highest resolution
|
||||
*
|
||||
* If the laptop lid is closed, exclude the laptop panel from possible
|
||||
* alternatives, except if no other alternatives exist.
|
||||
*/
|
||||
static MetaMonitor *
|
||||
find_primary_monitor (MetaMonitorManager *monitor_manager)
|
||||
{
|
||||
MetaMonitor *monitor;
|
||||
|
||||
monitor = meta_monitor_manager_get_primary_monitor (monitor_manager);
|
||||
if (monitor)
|
||||
return monitor;
|
||||
if (meta_monitor_manager_is_lid_closed (monitor_manager))
|
||||
{
|
||||
monitor = meta_monitor_manager_get_primary_monitor (monitor_manager);
|
||||
if (monitor && !meta_monitor_is_laptop_panel (monitor))
|
||||
return monitor;
|
||||
|
||||
monitor = meta_monitor_manager_get_laptop_panel (monitor_manager);
|
||||
if (monitor)
|
||||
return monitor;
|
||||
monitor =
|
||||
find_monitor_with_highest_preferred_resolution (monitor_manager,
|
||||
MONITOR_MATCH_EXTERNAL);
|
||||
if (monitor)
|
||||
return monitor;
|
||||
|
||||
return find_monitor_with_highest_preferred_resolution (monitor_manager);
|
||||
return find_monitor_with_highest_preferred_resolution (monitor_manager,
|
||||
MONITOR_MATCH_ALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
monitor = meta_monitor_manager_get_primary_monitor (monitor_manager);
|
||||
if (monitor)
|
||||
return monitor;
|
||||
|
||||
monitor = meta_monitor_manager_get_laptop_panel (monitor_manager);
|
||||
if (monitor)
|
||||
return monitor;
|
||||
|
||||
return find_monitor_with_highest_preferred_resolution (monitor_manager,
|
||||
MONITOR_MATCH_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
static MetaMonitorConfig *
|
||||
@ -421,6 +458,10 @@ meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_mana
|
||||
if (monitor == primary_monitor)
|
||||
continue;
|
||||
|
||||
if (meta_monitor_is_laptop_panel (monitor) &&
|
||||
meta_monitor_manager_is_lid_closed (monitor_manager))
|
||||
continue;
|
||||
|
||||
logical_monitor_config =
|
||||
create_preferred_logical_monitor_config (monitor, x, 0);
|
||||
config->logical_monitor_configs =
|
||||
|
@ -284,6 +284,9 @@ power_save_mode_changed (MetaMonitorManager *manager,
|
||||
void
|
||||
meta_monitor_manager_lid_is_closed_changed (MetaMonitorManager *manager)
|
||||
{
|
||||
if (manager->config_manager)
|
||||
meta_monitor_manager_ensure_configured (manager);
|
||||
|
||||
g_signal_emit (manager, signals[LID_IS_CLOSED_CHANGED], 0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user