1
0
Fork 0

monitor-manager: Rename *Info structs to *Assignment

MetaCrtcInfo and MetaOutputInfo did not represent information about
MetaCrtc and MetaOutput, but the result of the monitor configuration
assignment algorithm, thus rename it to MetaCrtcAssignment and
MetaOutputAssignment.

The purpose for this is to be able to introduce a struct that actually
carries information about the CRTCs and outputs, as retrieved from the
backend implementations.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287
This commit is contained in:
Jonas Ådahl 2020-02-25 20:30:46 +01:00 committed by Georges Basile Stavracas Neto
parent f71316c850
commit b69111d8e6
15 changed files with 278 additions and 257 deletions

View file

@ -44,8 +44,9 @@ typedef struct _MetaGpu MetaGpu;
typedef struct _MetaCrtc MetaCrtc;
typedef struct _MetaOutput MetaOutput;
typedef struct _MetaCrtcMode MetaCrtcMode;
typedef struct _MetaCrtcInfo MetaCrtcInfo;
typedef struct _MetaOutputInfo MetaOutputInfo;
typedef struct _MetaCrtcAssignment MetaCrtcAssignment;
typedef struct _MetaOutputAssignment MetaOutputAssignment;
typedef struct _MetaTileInfo MetaTileInfo;
typedef struct _MetaRenderer MetaRenderer;

View file

@ -52,10 +52,10 @@ G_DEFINE_TYPE (MetaMonitorsConfig, meta_monitors_config,
G_TYPE_OBJECT)
static void
meta_crtc_info_free (MetaCrtcInfo *info);
meta_crtc_assignment_free (MetaCrtcAssignment *assignment);
static void
meta_output_info_free (MetaOutputInfo *info);
meta_output_assignment_free (MetaOutputAssignment *assignment);
MetaMonitorConfigManager *
meta_monitor_config_manager_new (MetaMonitorManager *monitor_manager)
@ -96,15 +96,16 @@ is_crtc_reserved (MetaCrtc *crtc,
static gboolean
is_crtc_assigned (MetaCrtc *crtc,
GPtrArray *crtc_infos)
GPtrArray *crtc_assignments)
{
unsigned int i;
for (i = 0; i < crtc_infos->len; i++)
for (i = 0; i < crtc_assignments->len; i++)
{
MetaCrtcInfo *assigned_crtc_info = g_ptr_array_index (crtc_infos, i);
MetaCrtcAssignment *assigned_crtc_assignment =
g_ptr_array_index (crtc_assignments, i);
if (assigned_crtc_info->crtc == crtc)
if (assigned_crtc_assignment->crtc == crtc)
return TRUE;
}
@ -113,14 +114,14 @@ is_crtc_assigned (MetaCrtc *crtc,
static MetaCrtc *
find_unassigned_crtc (MetaOutput *output,
GPtrArray *crtc_infos,
GPtrArray *crtc_assignments,
GArray *reserved_crtcs)
{
MetaCrtc *crtc;
unsigned int i;
crtc = meta_output_get_assigned_crtc (output);
if (crtc && !is_crtc_assigned (crtc, crtc_infos))
if (crtc && !is_crtc_assigned (crtc, crtc_assignments))
return crtc;
/* then try to assign a CRTC that wasn't used */
@ -128,7 +129,7 @@ find_unassigned_crtc (MetaOutput *output,
{
crtc = output->possible_crtcs[i];
if (is_crtc_assigned (crtc, crtc_infos))
if (is_crtc_assigned (crtc, crtc_assignments))
continue;
if (is_crtc_reserved (crtc, reserved_crtcs))
@ -142,7 +143,7 @@ find_unassigned_crtc (MetaOutput *output,
{
crtc = output->possible_crtcs[i];
if (is_crtc_assigned (crtc, crtc_infos))
if (is_crtc_assigned (crtc, crtc_assignments))
continue;
return crtc;
@ -157,8 +158,8 @@ typedef struct
MetaMonitorsConfig *config;
MetaLogicalMonitorConfig *logical_monitor_config;
MetaMonitorConfig *monitor_config;
GPtrArray *crtc_infos;
GPtrArray *output_infos;
GPtrArray *crtc_assignments;
GPtrArray *output_assignments;
GArray *reserved_crtcs;
} MonitorAssignmentData;
@ -181,15 +182,17 @@ assign_monitor_crtc (MetaMonitor *monitor,
float width, height;
MetaCrtcMode *crtc_mode;
graphene_rect_t crtc_layout;
MetaCrtcInfo *crtc_info;
MetaOutputInfo *output_info;
MetaCrtcAssignment *crtc_assignment;
MetaOutputAssignment *output_assignment;
MetaMonitorConfig *first_monitor_config;
gboolean assign_output_as_primary;
gboolean assign_output_as_presentation;
output = monitor_crtc_mode->output;
crtc = find_unassigned_crtc (output, data->crtc_infos, data->reserved_crtcs);
crtc = find_unassigned_crtc (output,
data->crtc_assignments,
data->reserved_crtcs);
if (!crtc)
{
@ -244,15 +247,15 @@ assign_monitor_crtc (MetaMonitor *monitor,
width,
height);
crtc_info = g_slice_new0 (MetaCrtcInfo);
*crtc_info = (MetaCrtcInfo) {
crtc_assignment = g_slice_new0 (MetaCrtcAssignment);
*crtc_assignment = (MetaCrtcAssignment) {
.crtc = crtc,
.mode = crtc_mode,
.layout = crtc_layout,
.transform = crtc_hw_transform,
.outputs = g_ptr_array_new ()
};
g_ptr_array_add (crtc_info->outputs, output);
g_ptr_array_add (crtc_assignment->outputs, output);
/*
* Only one output can be marked as primary (due to Xrandr limitation),
@ -272,16 +275,16 @@ assign_monitor_crtc (MetaMonitor *monitor,
else
assign_output_as_presentation = FALSE;
output_info = g_slice_new0 (MetaOutputInfo);
*output_info = (MetaOutputInfo) {
output_assignment = g_slice_new0 (MetaOutputAssignment);
*output_assignment = (MetaOutputAssignment) {
.output = output,
.is_primary = assign_output_as_primary,
.is_presentation = assign_output_as_presentation,
.is_underscanning = data->monitor_config->enable_underscanning
};
g_ptr_array_add (data->crtc_infos, crtc_info);
g_ptr_array_add (data->output_infos, output_info);
g_ptr_array_add (data->crtc_assignments, crtc_assignment);
g_ptr_array_add (data->output_assignments, output_assignment);
return TRUE;
}
@ -291,8 +294,8 @@ assign_monitor_crtcs (MetaMonitorManager *manager,
MetaMonitorsConfig *config,
MetaLogicalMonitorConfig *logical_monitor_config,
MetaMonitorConfig *monitor_config,
GPtrArray *crtc_infos,
GPtrArray *output_infos,
GPtrArray *crtc_assignments,
GPtrArray *output_assignments,
GArray *reserved_crtcs,
GError **error)
{
@ -327,8 +330,8 @@ assign_monitor_crtcs (MetaMonitorManager *manager,
.config = config,
.logical_monitor_config = logical_monitor_config,
.monitor_config = monitor_config,
.crtc_infos = crtc_infos,
.output_infos = output_infos,
.crtc_assignments = crtc_assignments,
.output_assignments = output_assignments,
.reserved_crtcs = reserved_crtcs
};
if (!meta_monitor_mode_foreach_crtc (monitor, monitor_mode,
@ -344,8 +347,8 @@ static gboolean
assign_logical_monitor_crtcs (MetaMonitorManager *manager,
MetaMonitorsConfig *config,
MetaLogicalMonitorConfig *logical_monitor_config,
GPtrArray *crtc_infos,
GPtrArray *output_infos,
GPtrArray *crtc_assignments,
GPtrArray *output_assignments,
GArray *reserved_crtcs,
GError **error)
{
@ -359,7 +362,7 @@ assign_logical_monitor_crtcs (MetaMonitorManager *manager,
config,
logical_monitor_config,
monitor_config,
crtc_infos, output_infos,
crtc_assignments, output_assignments,
reserved_crtcs, error))
return FALSE;
}
@ -370,19 +373,19 @@ assign_logical_monitor_crtcs (MetaMonitorManager *manager,
gboolean
meta_monitor_config_manager_assign (MetaMonitorManager *manager,
MetaMonitorsConfig *config,
GPtrArray **out_crtc_infos,
GPtrArray **out_output_infos,
GPtrArray **out_crtc_assignments,
GPtrArray **out_output_assignments,
GError **error)
{
GPtrArray *crtc_infos;
GPtrArray *output_infos;
GPtrArray *crtc_assignments;
GPtrArray *output_assignments;
GArray *reserved_crtcs;
GList *l;
crtc_infos =
g_ptr_array_new_with_free_func ((GDestroyNotify) meta_crtc_info_free);
output_infos =
g_ptr_array_new_with_free_func ((GDestroyNotify) meta_output_info_free);
crtc_assignments =
g_ptr_array_new_with_free_func ((GDestroyNotify) meta_crtc_assignment_free);
output_assignments =
g_ptr_array_new_with_free_func ((GDestroyNotify) meta_output_assignment_free);
reserved_crtcs = g_array_new (FALSE, FALSE, sizeof (uint64_t));
for (l = config->logical_monitor_configs; l; l = l->next)
@ -421,11 +424,11 @@ meta_monitor_config_manager_assign (MetaMonitorManager *manager,
if (!assign_logical_monitor_crtcs (manager,
config, logical_monitor_config,
crtc_infos, output_infos,
crtc_assignments, output_assignments,
reserved_crtcs, error))
{
g_ptr_array_free (crtc_infos, TRUE);
g_ptr_array_free (output_infos, TRUE);
g_ptr_array_free (crtc_assignments, TRUE);
g_ptr_array_free (output_assignments, TRUE);
g_array_free (reserved_crtcs, TRUE);
return FALSE;
}
@ -433,8 +436,8 @@ meta_monitor_config_manager_assign (MetaMonitorManager *manager,
g_array_free (reserved_crtcs, TRUE);
*out_crtc_infos = crtc_infos;
*out_output_infos = output_infos;
*out_crtc_assignments = crtc_assignments;
*out_output_assignments = output_assignments;
return TRUE;
}
@ -1563,16 +1566,16 @@ meta_monitors_config_class_init (MetaMonitorsConfigClass *klass)
}
static void
meta_crtc_info_free (MetaCrtcInfo *info)
meta_crtc_assignment_free (MetaCrtcAssignment *assignment)
{
g_ptr_array_free (info->outputs, TRUE);
g_slice_free (MetaCrtcInfo, info);
g_ptr_array_free (assignment->outputs, TRUE);
g_slice_free (MetaCrtcAssignment, assignment);
}
static void
meta_output_info_free (MetaOutputInfo *info)
meta_output_assignment_free (MetaOutputAssignment *assignment)
{
g_slice_free (MetaOutputInfo, info);
g_slice_free (MetaOutputAssignment, assignment);
}
gboolean

View file

@ -87,8 +87,8 @@ MetaMonitorConfigStore * meta_monitor_config_manager_get_store (MetaMonitorConfi
META_EXPORT_TEST
gboolean meta_monitor_config_manager_assign (MetaMonitorManager *manager,
MetaMonitorsConfig *config,
GPtrArray **crtc_infos,
GPtrArray **output_infos,
GPtrArray **crtc_assignments,
GPtrArray **output_assignments,
GError **error);
META_EXPORT_TEST

View file

@ -498,11 +498,11 @@ meta_monitor_manager_dummy_ensure_initial_config (MetaMonitorManager *manager)
}
static void
apply_crtc_assignments (MetaMonitorManager *manager,
MetaCrtcInfo **crtcs,
unsigned int n_crtcs,
MetaOutputInfo **outputs,
unsigned int n_outputs)
apply_crtc_assignments (MetaMonitorManager *manager,
MetaCrtcAssignment **crtcs,
unsigned int n_crtcs,
MetaOutputAssignment **outputs,
unsigned int n_outputs)
{
g_autoptr (GList) to_configure_outputs = NULL;
g_autoptr (GList) to_configure_crtcs = NULL;
@ -513,12 +513,12 @@ apply_crtc_assignments (MetaMonitorManager *manager,
for (i = 0; i < n_crtcs; i++)
{
MetaCrtcInfo *crtc_info = crtcs[i];
MetaCrtc *crtc = crtc_info->crtc;
MetaCrtcAssignment *crtc_assignment = crtcs[i];
MetaCrtc *crtc = crtc_assignment->crtc;
to_configure_crtcs = g_list_remove (to_configure_crtcs, crtc);
if (crtc_info->mode == NULL)
if (crtc_assignment->mode == NULL)
{
meta_crtc_unset_config (crtc);
}
@ -527,22 +527,24 @@ apply_crtc_assignments (MetaMonitorManager *manager,
unsigned int j;
meta_crtc_set_config (crtc,
&crtc_info->layout,
crtc_info->mode,
crtc_info->transform);
&crtc_assignment->layout,
crtc_assignment->mode,
crtc_assignment->transform);
for (j = 0; j < crtc_info->outputs->len; j++)
for (j = 0; j < crtc_assignment->outputs->len; j++)
{
MetaOutput *output;
MetaOutputInfo *output_info;
MetaOutputAssignment *output_assignment;
output = ((MetaOutput**)crtc_info->outputs->pdata)[j];
output = ((MetaOutput**) crtc_assignment->outputs->pdata)[j];
to_configure_outputs = g_list_remove (to_configure_outputs,
output);
output_info = meta_find_output_info (outputs, n_outputs, output);
meta_output_assign_crtc (output, crtc, output_info);
output_assignment = meta_find_output_assignment (outputs,
n_outputs,
output);
meta_output_assign_crtc (output, crtc, output_assignment);
}
}
}
@ -590,8 +592,8 @@ meta_monitor_manager_dummy_apply_monitors_config (MetaMonitorManager *manag
MetaMonitorsConfigMethod method,
GError **error)
{
GPtrArray *crtc_infos;
GPtrArray *output_infos;
GPtrArray *crtc_assignments;
GPtrArray *output_assignments;
if (!config)
{
@ -603,25 +605,26 @@ meta_monitor_manager_dummy_apply_monitors_config (MetaMonitorManager *manag
}
if (!meta_monitor_config_manager_assign (manager, config,
&crtc_infos, &output_infos,
&crtc_assignments,
&output_assignments,
error))
return FALSE;
if (method == META_MONITORS_CONFIG_METHOD_VERIFY)
{
g_ptr_array_free (crtc_infos, TRUE);
g_ptr_array_free (output_infos, TRUE);
g_ptr_array_free (crtc_assignments, TRUE);
g_ptr_array_free (output_assignments, TRUE);
return TRUE;
}
apply_crtc_assignments (manager,
(MetaCrtcInfo **) crtc_infos->pdata,
crtc_infos->len,
(MetaOutputInfo **) output_infos->pdata,
output_infos->len);
(MetaCrtcAssignment **) crtc_assignments->pdata,
crtc_assignments->len,
(MetaOutputAssignment **) output_assignments->pdata,
output_assignments->len);
g_ptr_array_free (crtc_infos, TRUE);
g_ptr_array_free (output_infos, TRUE);
g_ptr_array_free (crtc_assignments, TRUE);
g_ptr_array_free (output_assignments, TRUE);
update_screen_size (manager, config);
meta_monitor_manager_rebuild (manager, config);

View file

@ -63,12 +63,12 @@ typedef enum _MetaLogicalMonitorLayoutMode
} MetaLogicalMonitorLayoutMode;
/*
* MetaCrtcInfo:
* MetaCrtcAssignment:
*
* A representation of a CRTC configuration, generated by
* MetaMonitorConfigManager.
*/
struct _MetaCrtcInfo
struct _MetaCrtcAssignment
{
MetaCrtc *crtc;
MetaCrtcMode *mode;
@ -78,12 +78,12 @@ struct _MetaCrtcInfo
};
/*
* MetaOutputInfo:
* MetaOutputAssignment:
*
* A representation of a connector configuration, generated by
* MetaMonitorConfigManager.
*/
struct _MetaOutputInfo
struct _MetaOutputAssignment
{
MetaOutput *output;
gboolean is_primary;
@ -387,19 +387,19 @@ gboolean meta_monitor_has_aspect_as_size (MetaMonitor *monitor);
char * meta_monitor_manager_get_vendor_name (MetaMonitorManager *manager,
const char *vendor);
static inline MetaOutputInfo *
meta_find_output_info (MetaOutputInfo **outputs,
unsigned int n_outputs,
MetaOutput *output)
static inline MetaOutputAssignment *
meta_find_output_assignment (MetaOutputAssignment **outputs,
unsigned int n_outputs,
MetaOutput *output)
{
unsigned int i;
for (i = 0; i < n_outputs; i++)
{
MetaOutputInfo *output_info = outputs[i];
MetaOutputAssignment *output_assignment = outputs[i];
if (output == output_info->output)
return output_info;
if (output == output_assignment->output)
return output_assignment;
}
return NULL;

View file

@ -116,9 +116,9 @@ meta_output_get_backlight (MetaOutput *output)
}
void
meta_output_assign_crtc (MetaOutput *output,
MetaCrtc *crtc,
const MetaOutputInfo *output_info)
meta_output_assign_crtc (MetaOutput *output,
MetaCrtc *crtc,
const MetaOutputAssignment *output_assignment)
{
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
@ -126,9 +126,9 @@ meta_output_assign_crtc (MetaOutput *output,
g_set_object (&priv->crtc, crtc);
priv->is_primary = output_info->is_primary;
priv->is_presentation = output_info->is_presentation;
priv->is_underscanning = output_info->is_underscanning;
priv->is_primary = output_assignment->is_primary;
priv->is_presentation = output_assignment->is_presentation;
priv->is_underscanning = output_assignment->is_underscanning;
}
void

View file

@ -130,9 +130,9 @@ void meta_output_set_backlight (MetaOutput *output,
int meta_output_get_backlight (MetaOutput *output);
META_EXPORT_TEST
void meta_output_assign_crtc (MetaOutput *output,
MetaCrtc *crtc,
const MetaOutputInfo *output_info);
void meta_output_assign_crtc (MetaOutput *output,
MetaCrtc *crtc,
const MetaOutputAssignment *output_assignment);
META_EXPORT_TEST
void meta_output_unassign_crtc (MetaOutput *output);

View file

@ -169,11 +169,11 @@ meta_monitor_manager_kms_ensure_initial_config (MetaMonitorManager *manager)
}
static void
apply_crtc_assignments (MetaMonitorManager *manager,
MetaCrtcInfo **crtcs,
unsigned int n_crtcs,
MetaOutputInfo **outputs,
unsigned int n_outputs)
apply_crtc_assignments (MetaMonitorManager *manager,
MetaCrtcAssignment **crtcs,
unsigned int n_crtcs,
MetaOutputAssignment **outputs,
unsigned int n_outputs)
{
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
g_autoptr (GList) to_configure_outputs = NULL;
@ -198,12 +198,12 @@ apply_crtc_assignments (MetaMonitorManager *manager,
for (i = 0; i < n_crtcs; i++)
{
MetaCrtcInfo *crtc_info = crtcs[i];
MetaCrtc *crtc = crtc_info->crtc;
MetaCrtcAssignment *crtc_assignment = crtcs[i];
MetaCrtc *crtc = crtc_assignment->crtc;
to_configure_crtcs = g_list_remove (to_configure_crtcs, crtc);
if (crtc_info->mode == NULL)
if (crtc_assignment->mode == NULL)
{
meta_crtc_unset_config (crtc);
}
@ -212,20 +212,23 @@ apply_crtc_assignments (MetaMonitorManager *manager,
unsigned int j;
meta_crtc_set_config (crtc,
&crtc_info->layout,
crtc_info->mode,
crtc_info->transform);
&crtc_assignment->layout,
crtc_assignment->mode,
crtc_assignment->transform);
for (j = 0; j < crtc_info->outputs->len; j++)
for (j = 0; j < crtc_assignment->outputs->len; j++)
{
MetaOutput *output = g_ptr_array_index (crtc_info->outputs, j);
MetaOutputInfo *output_info;
MetaOutput *output = g_ptr_array_index (crtc_assignment->outputs,
j);
MetaOutputAssignment *output_assignment;
to_configure_outputs = g_list_remove (to_configure_outputs,
output);
output_info = meta_find_output_info (outputs, n_outputs, output);
meta_output_assign_crtc (output, crtc, output_info);
output_assignment = meta_find_output_assignment (outputs,
n_outputs,
output);
meta_output_assign_crtc (output, crtc, output_assignment);
}
}
}
@ -273,8 +276,8 @@ meta_monitor_manager_kms_apply_monitors_config (MetaMonitorManager *manager
MetaMonitorsConfigMethod method,
GError **error)
{
GPtrArray *crtc_infos;
GPtrArray *output_infos;
GPtrArray *crtc_assignments;
GPtrArray *output_assignments;
if (!config)
{
@ -285,25 +288,26 @@ meta_monitor_manager_kms_apply_monitors_config (MetaMonitorManager *manager
}
if (!meta_monitor_config_manager_assign (manager, config,
&crtc_infos, &output_infos,
&crtc_assignments,
&output_assignments,
error))
return FALSE;
if (method == META_MONITORS_CONFIG_METHOD_VERIFY)
{
g_ptr_array_free (crtc_infos, TRUE);
g_ptr_array_free (output_infos, TRUE);
g_ptr_array_free (crtc_assignments, TRUE);
g_ptr_array_free (output_assignments, TRUE);
return TRUE;
}
apply_crtc_assignments (manager,
(MetaCrtcInfo **) crtc_infos->pdata,
crtc_infos->len,
(MetaOutputInfo **) output_infos->pdata,
output_infos->len);
(MetaCrtcAssignment **) crtc_assignments->pdata,
crtc_assignments->len,
(MetaOutputAssignment **) output_assignments->pdata,
output_assignments->len);
g_ptr_array_free (crtc_infos, TRUE);
g_ptr_array_free (output_infos, TRUE);
g_ptr_array_free (crtc_assignments, TRUE);
g_ptr_array_free (output_assignments, TRUE);
update_screen_size (manager, config);
meta_monitor_manager_rebuild (manager, config);

View file

@ -363,23 +363,23 @@ meta_create_kms_output (MetaGpuKms *gpu_kms,
if (meta_crtc_get_id (crtc) == connector_state->current_crtc_id)
{
MetaOutputInfo output_info;
MetaOutputAssignment output_assignment;
if (old_output)
{
output_info = (MetaOutputInfo) {
output_assignment = (MetaOutputAssignment) {
.is_primary = meta_output_is_primary (old_output),
.is_presentation = meta_output_is_presentation (old_output),
};
}
else
{
output_info = (MetaOutputInfo) {
output_assignment = (MetaOutputAssignment) {
.is_primary = FALSE,
.is_presentation = FALSE,
};
}
meta_output_assign_crtc (output, crtc, &output_info);
meta_output_assign_crtc (output, crtc, &output_assignment);
break;
}
}

View file

@ -183,27 +183,27 @@ meta_monitor_transform_from_xrandr_all (Rotation rotation)
}
gboolean
meta_crtc_xrandr_is_assignment_changed (MetaCrtc *crtc,
MetaCrtcInfo *crtc_info)
meta_crtc_xrandr_is_assignment_changed (MetaCrtc *crtc,
MetaCrtcAssignment *crtc_assignment)
{
MetaCrtcXrandr *crtc_xrandr = crtc->driver_private;
unsigned int i;
if (crtc_xrandr->current_mode != crtc_info->mode)
if (crtc_xrandr->current_mode != crtc_assignment->mode)
return TRUE;
if (crtc_xrandr->rect.x != (int) roundf (crtc_info->layout.origin.x))
if (crtc_xrandr->rect.x != (int) roundf (crtc_assignment->layout.origin.x))
return TRUE;
if (crtc_xrandr->rect.y != (int) roundf (crtc_info->layout.origin.y))
if (crtc_xrandr->rect.y != (int) roundf (crtc_assignment->layout.origin.y))
return TRUE;
if (crtc_xrandr->transform != crtc_info->transform)
if (crtc_xrandr->transform != crtc_assignment->transform)
return TRUE;
for (i = 0; i < crtc_info->outputs->len; i++)
for (i = 0; i < crtc_assignment->outputs->len; i++)
{
MetaOutput *output = ((MetaOutput**) crtc_info->outputs->pdata)[i];
MetaOutput *output = ((MetaOutput**) crtc_assignment->outputs->pdata)[i];
MetaCrtc *assigned_crtc;
assigned_crtc = meta_output_get_assigned_crtc (output);

View file

@ -39,8 +39,8 @@ gboolean meta_crtc_xrandr_set_config (MetaCrtc *crtc,
int n_outputs,
xcb_timestamp_t *out_timestamp);
gboolean meta_crtc_xrandr_is_assignment_changed (MetaCrtc *crtc,
MetaCrtcInfo *crtc_info);
gboolean meta_crtc_xrandr_is_assignment_changed (MetaCrtc *crtc,
MetaCrtcAssignment *crtc_assignment);
MetaCrtcMode * meta_crtc_xrandr_get_current_mode (MetaCrtc *crtc);

View file

@ -241,52 +241,52 @@ xrandr_set_crtc_config (MetaMonitorManagerXrandr *manager_xrandr,
}
static gboolean
is_crtc_assignment_changed (MetaCrtc *crtc,
MetaCrtcInfo **crtc_infos,
unsigned int n_crtc_infos)
is_crtc_assignment_changed (MetaCrtc *crtc,
MetaCrtcAssignment **crtc_assignments,
unsigned int n_crtc_assignments)
{
unsigned int i;
for (i = 0; i < n_crtc_infos; i++)
for (i = 0; i < n_crtc_assignments; i++)
{
MetaCrtcInfo *crtc_info = crtc_infos[i];
MetaCrtcAssignment *crtc_assignment = crtc_assignments[i];
if (crtc_info->crtc != crtc)
if (crtc_assignment->crtc != crtc)
continue;
return meta_crtc_xrandr_is_assignment_changed (crtc, crtc_info);
return meta_crtc_xrandr_is_assignment_changed (crtc, crtc_assignment);
}
return !!meta_crtc_xrandr_get_current_mode (crtc);
}
static gboolean
is_output_assignment_changed (MetaOutput *output,
MetaCrtcInfo **crtc_infos,
unsigned int n_crtc_infos,
MetaOutputInfo **output_infos,
unsigned int n_output_infos)
is_output_assignment_changed (MetaOutput *output,
MetaCrtcAssignment **crtc_assignments,
unsigned int n_crtc_assignments,
MetaOutputAssignment **output_assignments,
unsigned int n_output_assignments)
{
MetaCrtc *assigned_crtc;
gboolean output_is_found = FALSE;
unsigned int i;
for (i = 0; i < n_output_infos; i++)
for (i = 0; i < n_output_assignments; i++)
{
MetaOutputInfo *output_info = output_infos[i];
MetaOutputAssignment *output_assignment = output_assignments[i];
if (output_info->output != output)
if (output_assignment->output != output)
continue;
if (meta_output_is_primary (output) != output_info->is_primary)
if (meta_output_is_primary (output) != output_assignment->is_primary)
return TRUE;
if (meta_output_is_presentation (output) !=
output_info->is_presentation)
output_assignment->is_presentation)
return TRUE;
if (meta_output_is_underscanning (output) !=
output_info->is_underscanning)
output_assignment->is_underscanning)
return TRUE;
output_is_found = TRUE;
@ -297,18 +297,18 @@ is_output_assignment_changed (MetaOutput *output,
if (!output_is_found)
return assigned_crtc != NULL;
for (i = 0; i < n_crtc_infos; i++)
for (i = 0; i < n_crtc_assignments; i++)
{
MetaCrtcInfo *crtc_info = crtc_infos[i];
MetaCrtcAssignment *crtc_assignment = crtc_assignments[i];
unsigned int j;
for (j = 0; j < crtc_info->outputs->len; j++)
for (j = 0; j < crtc_assignment->outputs->len; j++)
{
MetaOutput *crtc_info_output =
((MetaOutput**) crtc_info->outputs->pdata)[j];
MetaOutput *crtc_assignment_output =
((MetaOutput**) crtc_assignment->outputs->pdata)[j];
if (crtc_info_output == output &&
crtc_info->crtc == assigned_crtc)
if (crtc_assignment_output == output &&
crtc_assignment->crtc == assigned_crtc)
return FALSE;
}
}
@ -326,11 +326,11 @@ meta_monitor_manager_xrandr_get_gpu (MetaMonitorManagerXrandr *manager_xrandr)
}
static gboolean
is_assignments_changed (MetaMonitorManager *manager,
MetaCrtcInfo **crtc_infos,
unsigned int n_crtc_infos,
MetaOutputInfo **output_infos,
unsigned int n_output_infos)
is_assignments_changed (MetaMonitorManager *manager,
MetaCrtcAssignment **crtc_assignments,
unsigned int n_crtc_assignments,
MetaOutputAssignment **output_assignments,
unsigned int n_output_assignments)
{
MetaMonitorManagerXrandr *manager_xrandr =
META_MONITOR_MANAGER_XRANDR (manager);
@ -341,7 +341,7 @@ is_assignments_changed (MetaMonitorManager *manager,
{
MetaCrtc *crtc = l->data;
if (is_crtc_assignment_changed (crtc, crtc_infos, n_crtc_infos))
if (is_crtc_assignment_changed (crtc, crtc_assignments, n_crtc_assignments))
return TRUE;
}
@ -350,10 +350,10 @@ is_assignments_changed (MetaMonitorManager *manager,
MetaOutput *output = l->data;
if (is_output_assignment_changed (output,
crtc_infos,
n_crtc_infos,
output_infos,
n_output_infos))
crtc_assignments,
n_crtc_assignments,
output_assignments,
n_output_assignments))
return TRUE;
}
@ -361,12 +361,12 @@ is_assignments_changed (MetaMonitorManager *manager,
}
static void
apply_crtc_assignments (MetaMonitorManager *manager,
gboolean save_timestamp,
MetaCrtcInfo **crtcs,
unsigned int n_crtcs,
MetaOutputInfo **outputs,
unsigned int n_outputs)
apply_crtc_assignments (MetaMonitorManager *manager,
gboolean save_timestamp,
MetaCrtcAssignment **crtcs,
unsigned int n_crtcs,
MetaOutputAssignment **outputs,
unsigned int n_outputs)
{
MetaMonitorManagerXrandr *manager_xrandr = META_MONITOR_MANAGER_XRANDR (manager);
MetaGpu *gpu = meta_monitor_manager_xrandr_get_gpu (manager_xrandr);
@ -385,18 +385,18 @@ apply_crtc_assignments (MetaMonitorManager *manager,
width = 0; height = 0;
for (i = 0; i < n_crtcs; i++)
{
MetaCrtcInfo *crtc_info = crtcs[i];
MetaCrtc *crtc = crtc_info->crtc;
MetaCrtcAssignment *crtc_assignment = crtcs[i];
MetaCrtc *crtc = crtc_assignment->crtc;
if (crtc_info->mode == NULL)
if (crtc_assignment->mode == NULL)
continue;
to_disable_crtcs = g_list_remove (to_disable_crtcs, crtc);
width = MAX (width, (int) roundf (crtc_info->layout.origin.x +
crtc_info->layout.size.width));
height = MAX (height, (int) roundf (crtc_info->layout.origin.y +
crtc_info->layout.size.height));
width = MAX (width, (int) roundf (crtc_assignment->layout.origin.x +
crtc_assignment->layout.size.width));
height = MAX (height, (int) roundf (crtc_assignment->layout.origin.y +
crtc_assignment->layout.size.height));
}
/* Second disable all newly disabled CRTCs, or CRTCs that in the previous
@ -406,8 +406,8 @@ apply_crtc_assignments (MetaMonitorManager *manager,
*/
for (i = 0; i < n_crtcs; i++)
{
MetaCrtcInfo *crtc_info = crtcs[i];
MetaCrtc *crtc = crtc_info->crtc;
MetaCrtcAssignment *crtc_assignment = crtcs[i];
MetaCrtc *crtc = crtc_assignment->crtc;
MetaCrtcConfig *crtc_config;
int x2, y2;
@ -420,7 +420,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
y2 = (int) roundf (crtc_config->layout.origin.y +
crtc_config->layout.size.height);
if (!crtc_info->mode || x2 > width || y2 > height)
if (!crtc_assignment->mode || x2 > width || y2 > height)
{
xrandr_set_crtc_config (manager_xrandr,
crtc,
@ -468,45 +468,52 @@ apply_crtc_assignments (MetaMonitorManager *manager,
for (i = 0; i < n_crtcs; i++)
{
MetaCrtcInfo *crtc_info = crtcs[i];
MetaCrtc *crtc = crtc_info->crtc;
MetaCrtcAssignment *crtc_assignment = crtcs[i];
MetaCrtc *crtc = crtc_assignment->crtc;
if (crtc_info->mode != NULL)
if (crtc_assignment->mode != NULL)
{
MetaCrtcMode *mode;
g_autofree xcb_randr_output_t *output_ids = NULL;
unsigned int j, n_output_ids;
xcb_randr_crtc_t crtc_id;
int x, y;
xcb_randr_rotation_t rotation;
mode = crtc_info->mode;
mode = crtc_assignment->mode;
n_output_ids = crtc_info->outputs->len;
n_output_ids = crtc_assignment->outputs->len;
output_ids = g_new (xcb_randr_output_t, n_output_ids);
for (j = 0; j < n_output_ids; j++)
{
MetaOutput *output;
MetaOutputInfo *output_info;
MetaOutputAssignment *output_assignment;
output = ((MetaOutput**)crtc_info->outputs->pdata)[j];
output = ((MetaOutput**)crtc_assignment->outputs->pdata)[j];
to_configure_outputs = g_list_remove (to_configure_outputs,
output);
output_info = meta_find_output_info (outputs, n_outputs, output);
meta_output_assign_crtc (output, crtc, output_info);
output_assignment = meta_find_output_assignment (outputs,
n_outputs,
output);
meta_output_assign_crtc (output, crtc, output_assignment);
output_ids[j] = meta_output_get_id (output);
}
rotation = meta_monitor_transform_to_xrandr (crtc_info->transform);
crtc_id = (xcb_randr_crtc_t) meta_crtc_get_id (crtc);
x = (int) roundf (crtc_assignment->layout.origin.x);
y = (int) roundf (crtc_assignment->layout.origin.y);
rotation =
meta_monitor_transform_to_xrandr (crtc_assignment->transform);
if (!xrandr_set_crtc_config (manager_xrandr,
crtc,
save_timestamp,
(xcb_randr_crtc_t) meta_crtc_get_id (crtc),
crtc_id,
XCB_CURRENT_TIME,
(int) roundf (crtc_info->layout.origin.x),
(int) roundf (crtc_info->layout.origin.y),
x, y,
(xcb_randr_mode_t) mode->mode_id,
rotation,
output_ids, n_output_ids))
@ -515,23 +522,23 @@ apply_crtc_assignments (MetaMonitorManager *manager,
(unsigned) meta_crtc_get_id (crtc),
(unsigned) mode->mode_id,
mode->width, mode->height, (float)mode->refresh_rate,
(int) roundf (crtc_info->layout.origin.x),
(int) roundf (crtc_info->layout.origin.y),
crtc_info->transform);
(int) roundf (crtc_assignment->layout.origin.x),
(int) roundf (crtc_assignment->layout.origin.y),
crtc_assignment->transform);
continue;
}
meta_crtc_set_config (crtc,
&crtc_info->layout,
&crtc_assignment->layout,
mode,
crtc_info->transform);
crtc_assignment->transform);
}
}
for (i = 0; i < n_outputs; i++)
{
MetaOutputInfo *output_info = outputs[i];
MetaOutput *output = output_info->output;
MetaOutputAssignment *output_assignment = outputs[i];
MetaOutput *output = output_assignment->output;
meta_output_xrandr_apply_mode (output);
}
@ -581,8 +588,8 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
MetaMonitorsConfigMethod method,
GError **error)
{
GPtrArray *crtc_infos;
GPtrArray *output_infos;
GPtrArray *crtc_assignments;
GPtrArray *output_assignments;
if (!config)
{
@ -591,7 +598,8 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
}
if (!meta_monitor_config_manager_assign (manager, config,
&crtc_infos, &output_infos,
&crtc_assignments,
&output_assignments,
error))
return FALSE;
@ -606,17 +614,17 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
* just update the logical state.
*/
if (is_assignments_changed (manager,
(MetaCrtcInfo **) crtc_infos->pdata,
crtc_infos->len,
(MetaOutputInfo **) output_infos->pdata,
output_infos->len))
(MetaCrtcAssignment **) crtc_assignments->pdata,
crtc_assignments->len,
(MetaOutputAssignment **) output_assignments->pdata,
output_assignments->len))
{
apply_crtc_assignments (manager,
TRUE,
(MetaCrtcInfo **) crtc_infos->pdata,
crtc_infos->len,
(MetaOutputInfo **) output_infos->pdata,
output_infos->len);
(MetaCrtcAssignment **) crtc_assignments->pdata,
crtc_assignments->len,
(MetaOutputAssignment **) output_assignments->pdata,
output_assignments->len);
}
else
{
@ -624,8 +632,8 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
}
}
g_ptr_array_free (crtc_infos, TRUE);
g_ptr_array_free (output_infos, TRUE);
g_ptr_array_free (crtc_assignments, TRUE);
g_ptr_array_free (output_assignments, TRUE);
return TRUE;
}

View file

@ -823,14 +823,14 @@ meta_create_xrandr_output (MetaGpuXrandr *gpu_xrandr,
if (assigned_crtc)
{
MetaOutputInfo output_info;
MetaOutputAssignment output_assignment;
output_info = (MetaOutputInfo) {
output_assignment = (MetaOutputAssignment) {
.is_primary = (XID) meta_output_get_id (output) == primary_output,
.is_presentation = output_get_presentation_xrandr (output),
.is_underscanning = output_get_underscanning_xrandr (output),
};
meta_output_assign_crtc (output, assigned_crtc, &output_info);
meta_output_assign_crtc (output, assigned_crtc, &output_assignment);
}
output->n_possible_clones = xrandr_output->nclone;

View file

@ -114,11 +114,11 @@ meta_monitor_manager_test_ensure_initial_config (MetaMonitorManager *manager)
}
static void
apply_crtc_assignments (MetaMonitorManager *manager,
MetaCrtcInfo **crtcs,
unsigned int n_crtcs,
MetaOutputInfo **outputs,
unsigned int n_outputs)
apply_crtc_assignments (MetaMonitorManager *manager,
MetaCrtcAssignment **crtcs,
unsigned int n_crtcs,
MetaOutputAssignment **outputs,
unsigned int n_outputs)
{
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
MetaBackendTest *backend_test = META_BACKEND_TEST (backend);
@ -132,12 +132,12 @@ apply_crtc_assignments (MetaMonitorManager *manager,
for (i = 0; i < n_crtcs; i++)
{
MetaCrtcInfo *crtc_info = crtcs[i];
MetaCrtc *crtc = crtc_info->crtc;
MetaCrtcAssignment *crtc_assignment = crtcs[i];
MetaCrtc *crtc = crtc_assignment->crtc;
to_configure_crtcs = g_list_remove (to_configure_crtcs, crtc);
if (crtc_info->mode == NULL)
if (crtc_assignment->mode == NULL)
{
meta_crtc_unset_config (crtc);
}
@ -146,22 +146,24 @@ apply_crtc_assignments (MetaMonitorManager *manager,
unsigned int j;
meta_crtc_set_config (crtc,
&crtc_info->layout,
crtc_info->mode,
crtc_info->transform);
&crtc_assignment->layout,
crtc_assignment->mode,
crtc_assignment->transform);
for (j = 0; j < crtc_info->outputs->len; j++)
for (j = 0; j < crtc_assignment->outputs->len; j++)
{
MetaOutput *output;
MetaOutputInfo *output_info;
MetaOutputAssignment *output_assignment;
output = ((MetaOutput**)crtc_info->outputs->pdata)[j];
output = ((MetaOutput**) crtc_assignment->outputs->pdata)[j];
to_configure_outputs = g_list_remove (to_configure_outputs,
output);
output_info = meta_find_output_info (outputs, n_outputs, output);
meta_output_assign_crtc (output, crtc, output_info);
output_assignment = meta_find_output_assignment (outputs,
n_outputs,
output);
meta_output_assign_crtc (output, crtc, output_assignment);
}
}
}
@ -209,8 +211,8 @@ meta_monitor_manager_test_apply_monitors_config (MetaMonitorManager *manage
MetaMonitorsConfigMethod method,
GError **error)
{
GPtrArray *crtc_infos;
GPtrArray *output_infos;
GPtrArray *crtc_assignments;
GPtrArray *output_assignments;
if (!config)
{
@ -226,26 +228,26 @@ meta_monitor_manager_test_apply_monitors_config (MetaMonitorManager *manage
}
if (!meta_monitor_config_manager_assign (manager, config,
&crtc_infos,
&output_infos,
&crtc_assignments,
&output_assignments,
error))
return FALSE;
if (method == META_MONITORS_CONFIG_METHOD_VERIFY)
{
g_ptr_array_free (crtc_infos, TRUE);
g_ptr_array_free (output_infos, TRUE);
g_ptr_array_free (crtc_assignments, TRUE);
g_ptr_array_free (output_assignments, TRUE);
return TRUE;
}
apply_crtc_assignments (manager,
(MetaCrtcInfo **) crtc_infos->pdata,
crtc_infos->len,
(MetaOutputInfo **) output_infos->pdata,
output_infos->len);
(MetaCrtcAssignment **) crtc_assignments->pdata,
crtc_assignments->len,
(MetaOutputAssignment **) output_assignments->pdata,
output_assignments->len);
g_ptr_array_free (crtc_infos, TRUE);
g_ptr_array_free (output_infos, TRUE);
g_ptr_array_free (crtc_assignments, TRUE);
g_ptr_array_free (output_assignments, TRUE);
update_screen_size (manager, config);

View file

@ -656,12 +656,12 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup,
if (crtc)
{
MetaOutputInfo output_info;
MetaOutputAssignment output_assignment;
output_info = (MetaOutputInfo) {
output_assignment = (MetaOutputAssignment) {
.is_underscanning = setup->outputs[i].is_underscanning,
};
meta_output_assign_crtc (output, crtc, &output_info);
meta_output_assign_crtc (output, crtc, &output_assignment);
}
output->name = (is_laptop_panel ? g_strdup_printf ("eDP-%d",