[mutter] output: Move winsys_id into instance private and rename to id
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] output: Move winsys_id into instance private and rename to id
- Date: Wed, 10 Jun 2020 19:19:55 +0000 (UTC)
commit e063947a16a1c0a4f603a51599b1984253599da2
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Tue Feb 25 16:13:52 2020 +0100
output: Move winsys_id into instance private and rename to id
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287
src/backends/meta-logical-monitor.c | 4 +-
src/backends/meta-monitor-manager-dummy.c | 8 ++--
src/backends/meta-monitor-manager.c | 2 +-
src/backends/meta-monitor.c | 4 +-
src/backends/meta-output.c | 25 +++++++++++++
src/backends/meta-output.h | 5 ++-
src/backends/native/meta-output-kms.c | 12 +++---
src/backends/x11/meta-gpu-xrandr.c | 2 +-
src/backends/x11/meta-monitor-manager-xrandr.c | 4 +-
src/backends/x11/meta-output-xrandr.c | 52 +++++++++++++++-----------
src/tests/headless-start-test.c | 2 +-
src/tests/monitor-test-utils.c | 6 +--
12 files changed, 81 insertions(+), 45 deletions(-)
---
diff --git a/src/backends/meta-logical-monitor.c b/src/backends/meta-logical-monitor.c
index 15a918103c..77d0f15a80 100644
--- a/src/backends/meta-logical-monitor.c
+++ b/src/backends/meta-logical-monitor.c
@@ -99,7 +99,7 @@ meta_logical_monitor_new (MetaMonitorManager *monitor_manager,
main_output = meta_monitor_get_main_output (first_monitor);
logical_monitor->number = monitor_number;
- logical_monitor->winsys_id = main_output->winsys_id;
+ logical_monitor->winsys_id = meta_output_get_id (main_output);
logical_monitor->scale = logical_monitor_config->scale;
logical_monitor->transform = logical_monitor_config->transform;
logical_monitor->in_fullscreen = -1;
@@ -144,7 +144,7 @@ meta_logical_monitor_new_derived (MetaMonitorManager *monitor_manager,
main_output = meta_monitor_get_main_output (monitor);
logical_monitor->number = monitor_number;
- logical_monitor->winsys_id = main_output->winsys_id;
+ logical_monitor->winsys_id = meta_output_get_id (main_output);
logical_monitor->scale = scale;
logical_monitor->transform = transform;
logical_monitor->in_fullscreen = -1;
diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c
index ee6c193ea8..ebcdc21bbb 100644
--- a/src/backends/meta-monitor-manager-dummy.c
+++ b/src/backends/meta-monitor-manager-dummy.c
@@ -205,7 +205,10 @@ append_monitor (MetaMonitorManager *manager,
crtc->all_transforms = ALL_TRANSFORMS;
*crtcs = g_list_append (*crtcs, crtc);
+ number = g_list_length (*outputs) + 1;
+
output = g_object_new (META_TYPE_OUTPUT,
+ "id", number,
"gpu", gpu,
NULL);
@@ -214,9 +217,6 @@ append_monitor (MetaMonitorManager *manager,
.scale = scale
};
- number = g_list_length (*outputs) + 1;
-
- output->winsys_id = number;
output->name = g_strdup_printf ("LVDS%d", number);
output->vendor = g_strdup ("MetaProducts Inc.");
output->product = g_strdup ("MetaMonitor");
@@ -321,10 +321,10 @@ append_tiled_monitor (MetaMonitorManager *manager,
preferred_mode = g_list_last (*modes)->data;
output = g_object_new (META_TYPE_OUTPUT,
+ "id", number,
"gpu", gpu,
NULL);
- output->winsys_id = number;
output->name = g_strdup_printf ("LVDS%d", number);
output->vendor = g_strdup ("MetaProducts Inc.");
output->product = g_strdup ("MetaMonitor");
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index 18d5216890..060e3ed68e 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -1149,7 +1149,7 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton,
crtc_index = crtc ? g_list_index (combined_crtcs, crtc) : -1;
g_variant_builder_add (&output_builder, "(uxiausauaua{sv})",
i, /* ID */
- (gint64)output->winsys_id,
+ meta_output_get_id (output),
crtc_index,
&crtcs,
output->name,
diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c
index 07857e00bd..92184eea74 100644
--- a/src/backends/meta-monitor.c
+++ b/src/backends/meta-monitor.c
@@ -653,7 +653,7 @@ meta_monitor_normal_new (MetaGpu *gpu,
monitor_priv->gpu = gpu;
monitor_priv->outputs = g_list_append (NULL, g_object_ref (output));
- monitor_priv->winsys_id = output->winsys_id;
+ monitor_priv->winsys_id = meta_output_get_id (output);
meta_monitor_generate_spec (monitor);
meta_monitor_normal_generate_modes (monitor_normal);
@@ -1292,7 +1292,7 @@ meta_monitor_tiled_new (MetaGpu *gpu,
monitor_priv->gpu = gpu;
monitor_tiled->tile_group_id = output->tile_info.group_id;
- monitor_priv->winsys_id = output->winsys_id;
+ monitor_priv->winsys_id = meta_output_get_id (output);
monitor_tiled->origin_output = output;
add_tiled_monitor_outputs (gpu, monitor_tiled);
diff --git a/src/backends/meta-output.c b/src/backends/meta-output.c
index 5a814c61de..6a2ceb71f3 100644
--- a/src/backends/meta-output.c
+++ b/src/backends/meta-output.c
@@ -25,6 +25,7 @@ enum
{
PROP_0,
+ PROP_ID,
PROP_GPU,
N_PROPS
@@ -34,6 +35,8 @@ static GParamSpec *obj_props[N_PROPS];
typedef struct _MetaOutputPrivate
{
+ uint64_t id;
+
MetaGpu *gpu;
/* The CRTC driving this output, NULL if the output is not enabled */
@@ -42,6 +45,14 @@ typedef struct _MetaOutputPrivate
G_DEFINE_TYPE_WITH_PRIVATE (MetaOutput, meta_output, G_TYPE_OBJECT)
+uint64_t
+meta_output_get_id (MetaOutput *output)
+{
+ MetaOutputPrivate *priv = meta_output_get_instance_private (output);
+
+ return priv->id;
+}
+
MetaGpu *
meta_output_get_gpu (MetaOutput *output)
{
@@ -117,6 +128,9 @@ meta_output_set_property (GObject *object,
switch (prop_id)
{
+ case PROP_ID:
+ priv->id = g_value_get_uint64 (value);
+ break;
case PROP_GPU:
priv->gpu = g_value_get_object (value);
break;
@@ -136,6 +150,9 @@ meta_output_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_ID:
+ g_value_set_uint64 (value, priv->id);
+ break;
case PROP_GPU:
g_value_set_object (value, priv->gpu);
break;
@@ -189,6 +206,14 @@ meta_output_class_init (MetaOutputClass *klass)
object_class->dispose = meta_output_dispose;
object_class->finalize = meta_output_finalize;
+ obj_props[PROP_ID] =
+ g_param_spec_uint64 ("id",
+ "id",
+ "CRTC id",
+ 0, UINT64_MAX, 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
obj_props[PROP_GPU] =
g_param_spec_object ("gpu",
"gpu",
diff --git a/src/backends/meta-output.h b/src/backends/meta-output.h
index d2701f92d5..4cf8eef9fa 100644
--- a/src/backends/meta-output.h
+++ b/src/backends/meta-output.h
@@ -64,8 +64,6 @@ struct _MetaOutput
{
GObject parent;
- /* The low-level ID of this output, used to apply back configuration */
- uint64_t winsys_id;
char *name;
char *vendor;
char *product;
@@ -117,6 +115,9 @@ struct _MetaOutput
#define META_TYPE_OUTPUT (meta_output_get_type ())
META_EXPORT_TEST G_DECLARE_FINAL_TYPE (MetaOutput, meta_output, META, OUTPUT, GObject)
+META_EXPORT_TEST
+uint64_t meta_output_get_id (MetaOutput *output);
+
META_EXPORT_TEST
MetaGpu * meta_output_get_gpu (MetaOutput *output);
diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c
index a119cf3490..3b690ec3ed 100644
--- a/src/backends/native/meta-output-kms.c
+++ b/src/backends/native/meta-output-kms.c
@@ -294,15 +294,19 @@ meta_create_kms_output (MetaGpuKms *gpu_kms,
GError **error)
{
MetaGpu *gpu = META_GPU (gpu_kms);
+ uint32_t connector_id;
+ uint32_t gpu_id;
MetaOutput *output;
MetaOutputKms *output_kms;
const MetaKmsConnectorState *connector_state;
- uint32_t connector_id;
GArray *crtcs;
GList *l;
- uint32_t gpu_id;
+
+ gpu_id = meta_gpu_kms_get_id (gpu_kms);
+ connector_id = meta_kms_connector_get_id (kms_connector);
output = g_object_new (META_TYPE_OUTPUT,
+ "id", ((uint64_t) gpu_id << 32) | connector_id,
"gpu", gpu,
NULL);
@@ -312,10 +316,6 @@ meta_create_kms_output (MetaGpuKms *gpu_kms,
output->name = g_strdup (meta_kms_connector_get_name (kms_connector));
- gpu_id = meta_gpu_kms_get_id (gpu_kms);
- connector_id = meta_kms_connector_get_id (kms_connector);
- output->winsys_id = ((uint64_t) gpu_id << 32) | connector_id;
-
output_kms->kms_connector = kms_connector;
connector_state = meta_kms_connector_get_current_state (kms_connector);
diff --git a/src/backends/x11/meta-gpu-xrandr.c b/src/backends/x11/meta-gpu-xrandr.c
index e90189dc00..12fd909259 100644
--- a/src/backends/x11/meta-gpu-xrandr.c
+++ b/src/backends/x11/meta-gpu-xrandr.c
@@ -220,7 +220,7 @@ meta_gpu_xrandr_read_current (MetaGpu *gpu,
{
MetaOutput *possible_clone = k->data;
- if (clone == (XID) possible_clone->winsys_id)
+ if (clone == (XID) meta_output_get_id (possible_clone))
{
output->possible_clones[j] = possible_clone;
break;
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
index af6638f38c..8e074604af 100644
--- a/src/backends/x11/meta-monitor-manager-xrandr.c
+++ b/src/backends/x11/meta-monitor-manager-xrandr.c
@@ -491,7 +491,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
output->is_dirty = TRUE;
meta_output_assign_crtc (output, crtc);
- output_ids[j] = output->winsys_id;
+ output_ids[j] = meta_output_get_id (output);
}
rotation = meta_monitor_transform_to_xrandr (crtc_info->transform);
@@ -793,7 +793,7 @@ meta_monitor_manager_xrandr_tiled_monitor_added (MetaMonitorManager *manager,
{
MetaOutput *output = l->data;
- xrandr_monitor_info->outputs[i] = output->winsys_id;
+ xrandr_monitor_info->outputs[i] = meta_output_get_id (output);
}
XRRSetMonitor (manager_xrandr->xdisplay,
diff --git a/src/backends/x11/meta-output-xrandr.c b/src/backends/x11/meta-output-xrandr.c
index 3c94babf4c..264b3affdd 100644
--- a/src/backends/x11/meta-output-xrandr.c
+++ b/src/backends/x11/meta-output-xrandr.c
@@ -70,7 +70,7 @@ output_set_presentation_xrandr (MetaOutput *output,
atom = XInternAtom (xdisplay, "_MUTTER_PRESENTATION_OUTPUT", False);
xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
- (XID) output->winsys_id,
+ (XID) meta_output_get_id (output),
atom, XCB_ATOM_CARDINAL, 32,
XCB_PROP_MODE_REPLACE,
1, &value);
@@ -90,7 +90,7 @@ output_set_underscanning_xrandr (MetaOutput *output,
valueatom = XInternAtom (xdisplay, value, False);
xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
- (XID) output->winsys_id,
+ (XID) meta_output_get_id (output),
prop, XCB_ATOM_ATOM, 32,
XCB_PROP_MODE_REPLACE,
1, &valueatom);
@@ -111,7 +111,7 @@ output_set_underscanning_xrandr (MetaOutput *output,
border_value = crtc_config->mode->width * 0.05;
xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
- (XID) output->winsys_id,
+ (XID) meta_output_get_id (output),
prop, XCB_ATOM_INTEGER, 32,
XCB_PROP_MODE_REPLACE,
1, &border_value);
@@ -120,7 +120,7 @@ output_set_underscanning_xrandr (MetaOutput *output,
border_value = crtc_config->mode->height * 0.05;
xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
- (XID) output->winsys_id,
+ (XID) meta_output_get_id (output),
prop, XCB_ATOM_INTEGER, 32,
XCB_PROP_MODE_REPLACE,
1, &border_value);
@@ -135,7 +135,7 @@ meta_output_xrandr_apply_mode (MetaOutput *output)
if (output->is_primary)
{
XRRSetOutputPrimary (xdisplay, DefaultRootWindow (xdisplay),
- (XID) output->winsys_id);
+ (XID) meta_output_get_id (output));
}
output_set_presentation_xrandr (output, output->is_presentation);
@@ -166,7 +166,7 @@ meta_output_xrandr_change_backlight (MetaOutput *output,
atom = XInternAtom (xdisplay, "Backlight", False);
xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
- (XID)output->winsys_id,
+ (XID) meta_output_get_id (output),
atom, XCB_ATOM_INTEGER, 32,
XCB_PROP_MODE_REPLACE,
1, &hw_value);
@@ -189,7 +189,7 @@ output_get_integer_property (MetaOutput *output,
atom = XInternAtom (xdisplay, propname, False);
XRRGetOutputProperty (xdisplay,
- (XID)output->winsys_id,
+ (XID) meta_output_get_id (output),
atom,
0, G_MAXLONG, False, False, XA_INTEGER,
&actual_type, &actual_format,
@@ -217,7 +217,7 @@ output_get_property_exists (MetaOutput *output,
atom = XInternAtom (xdisplay, propname, False);
XRRGetOutputProperty (xdisplay,
- (XID)output->winsys_id,
+ (XID) meta_output_get_id (output),
atom,
0, G_MAXLONG, False, False, AnyPropertyType,
&actual_type, &actual_format,
@@ -241,7 +241,7 @@ output_get_boolean_property (MetaOutput *output,
atom = XInternAtom (xdisplay, propname, False);
XRRGetOutputProperty (xdisplay,
- (XID)output->winsys_id,
+ (XID) meta_output_get_id (output),
atom,
0, G_MAXLONG, False, False, XA_CARDINAL,
&actual_type, &actual_format,
@@ -271,7 +271,7 @@ output_get_underscanning_xrandr (MetaOutput *output)
atom = XInternAtom (xdisplay, "underscan", False);
XRRGetOutputProperty (xdisplay,
- (XID)output->winsys_id,
+ (XID) meta_output_get_id (output),
atom,
0, G_MAXLONG, False, False, XA_ATOM,
&actual_type, &actual_format,
@@ -298,7 +298,7 @@ output_get_supports_underscanning_xrandr (MetaOutput *output)
atom = XInternAtom (xdisplay, "underscan", False);
XRRGetOutputProperty (xdisplay,
- (XID)output->winsys_id,
+ (XID) meta_output_get_id (output),
atom,
0, G_MAXLONG, False, False, XA_ATOM,
&actual_type, &actual_format,
@@ -308,7 +308,7 @@ output_get_supports_underscanning_xrandr (MetaOutput *output)
return FALSE;
property_info = XRRQueryOutputProperty (xdisplay,
- (XID) output->winsys_id,
+ (XID) meta_output_get_id (output),
atom);
values = (Atom *) property_info->values;
@@ -341,7 +341,7 @@ output_get_backlight_xrandr (MetaOutput *output)
atom = XInternAtom (xdisplay, "Backlight", False);
XRRGetOutputProperty (xdisplay,
- (XID)output->winsys_id,
+ (XID) meta_output_get_id (output),
atom,
0, G_MAXLONG, False, False, XA_INTEGER,
&actual_type, &actual_format,
@@ -363,14 +363,16 @@ output_get_backlight_limits_xrandr (MetaOutput *output)
Display *xdisplay = xdisplay_from_output (output);
Atom atom;
xcb_connection_t *xcb_conn;
+ xcb_randr_output_t output_id;
xcb_randr_query_output_property_cookie_t cookie;
g_autofree xcb_randr_query_output_property_reply_t *reply = NULL;
atom = XInternAtom (xdisplay, "Backlight", False);
xcb_conn = XGetXCBConnection (xdisplay);
+ output_id = meta_output_get_id (output);
cookie = xcb_randr_query_output_property (xcb_conn,
- (xcb_randr_output_t) output->winsys_id,
+ output_id,
(xcb_atom_t) atom);
reply = xcb_randr_query_output_property_reply (xcb_conn,
cookie,
@@ -434,12 +436,18 @@ meta_output_xrandr_read_edid (MetaOutput *output)
gsize len;
edid_atom = XInternAtom (xdisplay, "EDID", FALSE);
- result = get_edid_property (xdisplay, output->winsys_id, edid_atom, &len);
+ result = get_edid_property (xdisplay,
+ meta_output_get_id (output),
+ edid_atom,
+ &len);
if (!result)
{
edid_atom = XInternAtom (xdisplay, "EDID_DATA", FALSE);
- result = get_edid_property (xdisplay, output->winsys_id, edid_atom, &len);
+ result = get_edid_property (xdisplay,
+ meta_output_get_id (output),
+ edid_atom,
+ &len);
}
if (result)
@@ -527,7 +535,7 @@ output_get_connector_type_from_prop (MetaOutput *output)
atom = XInternAtom (xdisplay, "ConnectorType", False);
XRRGetOutputProperty (xdisplay,
- (XID)output->winsys_id,
+ (XID) meta_output_get_id (output),
atom,
0, G_MAXLONG, False, False, XA_ATOM,
&actual_type, &actual_format,
@@ -623,7 +631,9 @@ output_get_panel_orientation_transform (MetaOutput *output)
g_autofree char *str = NULL;
atom = XInternAtom (xdisplay, "panel orientation", False);
- XRRGetOutputProperty (xdisplay, (XID)output->winsys_id, atom,
+ XRRGetOutputProperty (xdisplay,
+ (XID) meta_output_get_id (output),
+ atom,
0, G_MAXLONG, False, False, XA_ATOM,
&actual_type, &actual_format,
&nitems, &bytes_after, &buffer);
@@ -665,7 +675,7 @@ output_get_tile_info (MetaOutput *output)
tile_atom = XInternAtom (xdisplay, "TILE", FALSE);
XRRGetOutputProperty (xdisplay,
- output->winsys_id,
+ (XID) meta_output_get_id (output),
tile_atom, 0, 100, False,
False, AnyPropertyType,
&actual_type, &actual_format,
@@ -771,9 +781,9 @@ meta_create_xrandr_output (MetaGpuXrandr *gpu_xrandr,
unsigned int i;
output = g_object_new (META_TYPE_OUTPUT,
+ "id", output_id,
"gpu", gpu_xrandr,
NULL);
- output->winsys_id = output_id;
output->name = g_strdup (xrandr_output->name);
edid = meta_output_xrandr_read_edid (output);
@@ -817,7 +827,7 @@ meta_create_xrandr_output (MetaGpuXrandr *gpu_xrandr,
output->possible_clones[i] = GINT_TO_POINTER (xrandr_output->clones[i]);
}
- output->is_primary = ((XID) output->winsys_id == primary_output);
+ output->is_primary = (XID) meta_output_get_id (output) == primary_output;
output->is_presentation = output_get_presentation_xrandr (output);
output->is_underscanning = output_get_underscanning_xrandr (output);
output->supports_underscanning =
diff --git a/src/tests/headless-start-test.c b/src/tests/headless-start-test.c
index 2bb558479b..302ee85573 100644
--- a/src/tests/headless-start-test.c
+++ b/src/tests/headless-start-test.c
@@ -152,9 +152,9 @@ meta_test_headless_monitor_connect (void)
possible_crtcs[0] = g_list_first (test_setup->crtcs)->data;
output = g_object_new (META_TYPE_OUTPUT,
+ "id", 1,
"gpu", gpu,
NULL);
- output->winsys_id = 1;
output->name = g_strdup ("DP-1");
output->vendor = g_strdup ("MetaProduct's Inc.");
output->product = g_strdup ("MetaMonitor");
diff --git a/src/tests/monitor-test-utils.c b/src/tests/monitor-test-utils.c
index cc1642898e..725c336233 100644
--- a/src/tests/monitor-test-utils.c
+++ b/src/tests/monitor-test-utils.c
@@ -93,7 +93,7 @@ read_file (const char *file_path)
static MetaOutput *
output_from_winsys_id (MetaBackend *backend,
- uint64_t winsys_id)
+ uint64_t output_id)
{
MetaGpu *gpu = meta_backend_test_get_gpu (META_BACKEND_TEST (backend));
GList *l;
@@ -102,7 +102,7 @@ output_from_winsys_id (MetaBackend *backend,
{
MetaOutput *output = l->data;
- if (output->winsys_id == winsys_id)
+ if (meta_output_get_id (output) == output_id)
return output;
}
@@ -650,12 +650,12 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup,
serial = "0x123456";
output = g_object_new (META_TYPE_OUTPUT,
+ "id", i,
"gpu", test_get_gpu (),
NULL);
if (crtc)
meta_output_assign_crtc (output, crtc);
- output->winsys_id = i;
output->name = (is_laptop_panel ? g_strdup_printf ("eDP-%d",
++n_laptop_panels)
: g_strdup_printf ("DP-%d",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]