monitors: change find_primary to return an index
This will make it easier to add tiling support.
This commit is contained in:
parent
2a8563ab23
commit
5c9846c53a
@ -1074,12 +1074,12 @@ meta_monitor_config_apply_stored (MetaMonitorConfig *self,
|
|||||||
* which are internal monitors), or failing that, the one with the
|
* which are internal monitors), or failing that, the one with the
|
||||||
* best resolution
|
* best resolution
|
||||||
*/
|
*/
|
||||||
static MetaOutput *
|
static int
|
||||||
find_primary_output (MetaOutput *outputs,
|
find_primary_output (MetaOutput *outputs,
|
||||||
unsigned n_outputs)
|
unsigned n_outputs)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
MetaOutput *best;
|
int best;
|
||||||
int best_width, best_height;
|
int best_width, best_height;
|
||||||
|
|
||||||
g_assert (n_outputs >= 1);
|
g_assert (n_outputs >= 1);
|
||||||
@ -1087,23 +1087,23 @@ find_primary_output (MetaOutput *outputs,
|
|||||||
for (i = 0; i < n_outputs; i++)
|
for (i = 0; i < n_outputs; i++)
|
||||||
{
|
{
|
||||||
if (outputs[i].is_primary)
|
if (outputs[i].is_primary)
|
||||||
return &outputs[i];
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n_outputs; i++)
|
for (i = 0; i < n_outputs; i++)
|
||||||
{
|
{
|
||||||
if (output_is_laptop (&outputs[i]))
|
if (output_is_laptop (&outputs[i]))
|
||||||
return &outputs[i];
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
best = NULL;
|
best = -1;
|
||||||
best_width = 0; best_height = 0;
|
best_width = 0; best_height = 0;
|
||||||
for (i = 0; i < n_outputs; i++)
|
for (i = 0; i < n_outputs; i++)
|
||||||
{
|
{
|
||||||
if (outputs[i].preferred_mode->width * outputs[i].preferred_mode->height >
|
if (outputs[i].preferred_mode->width * outputs[i].preferred_mode->height >
|
||||||
best_width * best_height)
|
best_width * best_height)
|
||||||
{
|
{
|
||||||
best = &outputs[i];
|
best = i;
|
||||||
best_width = outputs[i].preferred_mode->width;
|
best_width = outputs[i].preferred_mode->width;
|
||||||
best_height = outputs[i].preferred_mode->height;
|
best_height = outputs[i].preferred_mode->height;
|
||||||
}
|
}
|
||||||
@ -1141,7 +1141,7 @@ make_suggested_config (MetaMonitorConfig *self,
|
|||||||
MetaConfiguration *config)
|
MetaConfiguration *config)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
MetaOutput *primary;
|
int primary;
|
||||||
GList *region = NULL;
|
GList *region = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (config != NULL, FALSE);
|
g_return_val_if_fail (config != NULL, FALSE);
|
||||||
@ -1149,7 +1149,7 @@ make_suggested_config (MetaMonitorConfig *self,
|
|||||||
|
|
||||||
for (i = 0; i < n_outputs; i++)
|
for (i = 0; i < n_outputs; i++)
|
||||||
{
|
{
|
||||||
gboolean is_primary = (&outputs[i] == primary);
|
gboolean is_primary = ((int)i == primary);
|
||||||
|
|
||||||
if (outputs[i].suggested_x < 0 || outputs[i].suggested_y < 0)
|
if (outputs[i].suggested_x < 0 || outputs[i].suggested_y < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1184,7 +1184,7 @@ make_linear_config (MetaMonitorConfig *self,
|
|||||||
int max_height,
|
int max_height,
|
||||||
MetaConfiguration *config)
|
MetaConfiguration *config)
|
||||||
{
|
{
|
||||||
MetaOutput *primary;
|
int primary;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
@ -1192,10 +1192,10 @@ make_linear_config (MetaMonitorConfig *self,
|
|||||||
|
|
||||||
primary = find_primary_output (outputs, n_outputs);
|
primary = find_primary_output (outputs, n_outputs);
|
||||||
|
|
||||||
x = primary->preferred_mode->width;
|
x = outputs[primary].preferred_mode->width;
|
||||||
for (i = 0; i < n_outputs; i++)
|
for (i = 0; i < n_outputs; i++)
|
||||||
{
|
{
|
||||||
gboolean is_primary = (&outputs[i] == primary);
|
gboolean is_primary = ((int)i == primary);
|
||||||
|
|
||||||
init_config_from_preferred_mode (&config->outputs[i], &outputs[i]);
|
init_config_from_preferred_mode (&config->outputs[i], &outputs[i]);
|
||||||
config->outputs[i].is_primary = is_primary;
|
config->outputs[i].is_primary = is_primary;
|
||||||
@ -1332,7 +1332,7 @@ ensure_at_least_one_output (MetaMonitorConfig *self,
|
|||||||
unsigned n_outputs)
|
unsigned n_outputs)
|
||||||
{
|
{
|
||||||
MetaConfiguration *config;
|
MetaConfiguration *config;
|
||||||
MetaOutput *primary;
|
int primary;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
/* Check that we have at least one active output */
|
/* Check that we have at least one active output */
|
||||||
@ -1350,7 +1350,7 @@ ensure_at_least_one_output (MetaMonitorConfig *self,
|
|||||||
|
|
||||||
for (i = 0; i < n_outputs; i++)
|
for (i = 0; i < n_outputs; i++)
|
||||||
{
|
{
|
||||||
gboolean is_primary = (&outputs[i] == primary);
|
gboolean is_primary = ((int)i == primary);
|
||||||
|
|
||||||
if (is_primary)
|
if (is_primary)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user