[gnome-flashback] output: move configureable state to instance private
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] output: move configureable state to instance private
- Date: Sat, 11 Jul 2020 18:42:19 +0000 (UTC)
commit 4f5a05f4058f05c5457b4f3901090e72b52048f4
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Wed Jul 8 08:57:20 2020 +0300
output: move configureable state to instance private
Based on mutter commit:
https://gitlab.gnome.org/GNOME/mutter/-/commit/f71316c8508b3864876f
backends/gf-logical-monitor.c | 3 +-
backends/gf-monitor-manager-xrandr.c | 17 ++++----
backends/gf-monitor-manager.c | 17 ++++----
backends/gf-monitor.c | 4 +-
backends/gf-output-private.h | 39 +++++++++++++++---
backends/gf-output-xrandr.c | 45 +++++++++++++-------
backends/gf-output.c | 79 ++++++++++++++++++++++++++++++++++--
7 files changed, 159 insertions(+), 45 deletions(-)
---
diff --git a/backends/gf-logical-monitor.c b/backends/gf-logical-monitor.c
index 3ed1f73..ffe214a 100644
--- a/backends/gf-logical-monitor.c
+++ b/backends/gf-logical-monitor.c
@@ -217,7 +217,8 @@ gf_logical_monitor_add_monitor (GfLogicalMonitor *logical_monitor,
GfOutput *output;
output = l_output->data;
- is_presentation = is_presentation && output->is_presentation;
+ is_presentation = (is_presentation &&
+ gf_output_is_presentation (output));
}
}
diff --git a/backends/gf-monitor-manager-xrandr.c b/backends/gf-monitor-manager-xrandr.c
index 33e5a68..098ef96 100644
--- a/backends/gf-monitor-manager-xrandr.c
+++ b/backends/gf-monitor-manager-xrandr.c
@@ -234,13 +234,13 @@ is_output_assignment_changed (GfOutput *output,
if (output_info->output != output)
continue;
- if (output->is_primary != output_info->is_primary)
+ if (gf_output_is_primary (output) != output_info->is_primary)
return TRUE;
- if (output->is_presentation != output_info->is_presentation)
+ if (gf_output_is_presentation (output) != output_info->is_presentation)
return TRUE;
- if (output->is_underscanning != output_info->is_underscanning)
+ if (gf_output_is_underscanning (output) != output_info->is_underscanning)
return TRUE;
output_is_found = TRUE;
@@ -494,11 +494,14 @@ apply_crtc_assignments (GfMonitorManager *manager,
for (j = 0; j < n_output_ids; j++)
{
GfOutput *output;
+ GfOutputInfo *output_info;
output = ((GfOutput**) crtc_info->outputs->pdata)[j];
to_configure_outputs = g_list_remove (to_configure_outputs, output);
- gf_output_assign_crtc (output, crtc);
+
+ output_info = gf_find_output_info (outputs, n_outputs, output);
+ gf_output_assign_crtc (output, crtc, output_info);
output_ids[j] = gf_output_get_id (output);
}
@@ -539,20 +542,14 @@ apply_crtc_assignments (GfMonitorManager *manager,
GfOutputInfo *output_info = outputs[i];
GfOutput *output = output_info->output;
- output->is_primary = output_info->is_primary;
- output->is_presentation = output_info->is_presentation;
- output->is_underscanning = output_info->is_underscanning;
-
gf_output_xrandr_apply_mode (output);
}
- /* Disable outputs not mentioned in the list */
for (l = to_configure_outputs; l; l = l->next)
{
GfOutput *output = l->data;
gf_output_unassign_crtc (output);
- output->is_primary = FALSE;
}
XUngrabServer (xrandr->xdisplay);
diff --git a/backends/gf-monitor-manager.c b/backends/gf-monitor-manager.c
index f6fe32f..f9a34bf 100644
--- a/backends/gf-monitor-manager.c
+++ b/backends/gf-monitor-manager.c
@@ -1192,18 +1192,18 @@ gf_monitor_manager_handle_get_resources (GfDBusDisplayConfig *skeleton,
g_variant_builder_add (&properties, "{sv}", "display-name",
g_variant_new_string (output->name));
g_variant_builder_add (&properties, "{sv}", "backlight",
- g_variant_new_int32 (output->backlight));
+ g_variant_new_int32 (gf_output_get_backlight (output)));
g_variant_builder_add (&properties, "{sv}", "min-backlight-step",
g_variant_new_int32 ((output->backlight_max - output->backlight_min) ?
100 / (output->backlight_max - output->backlight_min) :
-1));
g_variant_builder_add (&properties, "{sv}", "primary",
- g_variant_new_boolean (output->is_primary));
+ g_variant_new_boolean (gf_output_is_primary (output)));
g_variant_builder_add (&properties, "{sv}", "presentation",
- g_variant_new_boolean (output->is_presentation));
+ g_variant_new_boolean (gf_output_is_presentation (output)));
g_variant_builder_add (&properties, "{sv}", "connector-type",
g_variant_new_string (get_connector_type_name (output->connector_type)));
g_variant_builder_add (&properties, "{sv}", "underscanning",
- g_variant_new_boolean (output->is_underscanning));
+ g_variant_new_boolean (gf_output_is_underscanning (output)));
g_variant_builder_add (&properties, "{sv}", "supports-underscanning",
g_variant_new_boolean (output->supports_underscanning));
@@ -1291,6 +1291,7 @@ gf_monitor_manager_handle_change_backlight (GfDBusDisplayConfig *skeleton,
GfMonitorManagerClass *manager_class;
GList *combined_outputs;
GfOutput *output;
+ int new_backlight;
manager_class = GF_MONITOR_MANAGER_GET_CLASS (manager);
@@ -1325,7 +1326,7 @@ gf_monitor_manager_handle_change_backlight (GfDBusDisplayConfig *skeleton,
return TRUE;
}
- if (output->backlight == -1 ||
+ if (gf_output_get_backlight (output) == -1 ||
(output->backlight_min == 0 && output->backlight_max == 0))
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
@@ -1336,8 +1337,10 @@ gf_monitor_manager_handle_change_backlight (GfDBusDisplayConfig *skeleton,
manager_class->change_backlight (manager, output, value);
- gf_dbus_display_config_complete_change_backlight (skeleton, invocation,
- output->backlight);
+ new_backlight = gf_output_get_backlight (output);
+ gf_dbus_display_config_complete_change_backlight (skeleton,
+ invocation,
+ new_backlight);
return TRUE;
}
diff --git a/backends/gf-monitor.c b/backends/gf-monitor.c
index 752eb8e..e5c44de 100644
--- a/backends/gf-monitor.c
+++ b/backends/gf-monitor.c
@@ -724,7 +724,7 @@ gf_monitor_is_primary (GfMonitor *monitor)
output = gf_monitor_get_main_output (monitor);
- return output->is_primary;
+ return gf_output_is_primary (output);
}
gboolean
@@ -744,7 +744,7 @@ gf_monitor_is_underscanning (GfMonitor *monitor)
output = gf_monitor_get_main_output (monitor);
- return output->is_underscanning;
+ return gf_output_is_underscanning (output);
}
gboolean
diff --git a/backends/gf-output-private.h b/backends/gf-output-private.h
index 32200c5..11a811e 100644
--- a/backends/gf-output-private.h
+++ b/backends/gf-output-private.h
@@ -78,14 +78,9 @@ struct _GfOutput
GfOutput **possible_clones;
guint n_possible_clones;
- gint backlight;
gint backlight_min;
gint backlight_max;
- /* The low-level bits used to build the high-level info in GfLogicalMonitor */
- gboolean is_primary;
- gboolean is_presentation;
- gboolean is_underscanning;
gboolean supports_underscanning;
gpointer driver_private;
@@ -109,7 +104,8 @@ uint64_t gf_output_get_id (GfOutput *sel
GfGpu *gf_output_get_gpu (GfOutput *output);
void gf_output_assign_crtc (GfOutput *output,
- GfCrtc *crtc);
+ GfCrtc *crtc,
+ const GfOutputInfo *output_info);
void gf_output_unassign_crtc (GfOutput *output);
@@ -126,6 +122,37 @@ GfMonitorTransform gf_output_logical_to_crtc_transform (GfOutput *out
GfMonitorTransform gf_output_crtc_to_logical_transform (GfOutput *output,
GfMonitorTransform transform);
+gboolean gf_output_is_primary (GfOutput *self);
+
+gboolean gf_output_is_presentation (GfOutput *self);
+
+gboolean gf_output_is_underscanning (GfOutput *self);
+
+void gf_output_set_backlight (GfOutput *self,
+ int backlight);
+
+int gf_output_get_backlight (GfOutput *self);
+
+static inline GfOutputInfo *
+gf_find_output_info (GfOutputInfo **outputs,
+ unsigned int n_outputs,
+ GfOutput *output)
+{
+ unsigned int i;
+
+ for (i = 0; i < n_outputs; i++)
+ {
+ GfOutputInfo *output_info;
+
+ output_info = outputs[i];
+
+ if (output == output_info->output)
+ return output_info;
+ }
+
+ return NULL;
+}
+
G_END_DECLS
#endif
diff --git a/backends/gf-output-xrandr.c b/backends/gf-output-xrandr.c
index 99bc598..62158cc 100644
--- a/backends/gf-output-xrandr.c
+++ b/backends/gf-output-xrandr.c
@@ -512,8 +512,9 @@ output_get_modes (GfOutput *output,
}
static void
-output_get_crtcs (GfOutput *output,
- XRROutputInfo *xrandr_output)
+output_get_crtcs (GfOutput *output,
+ XRROutputInfo *xrandr_output,
+ GfCrtc **assigned_crtc)
{
GfGpu *gpu;
guint j;
@@ -548,10 +549,12 @@ output_get_crtcs (GfOutput *output,
if ((XID) gf_crtc_get_id (crtc) == xrandr_output->crtc)
{
- gf_output_assign_crtc (output, crtc);
- break;
+ *assigned_crtc = crtc;
+ return;
}
}
+
+ *assigned_crtc = NULL;
}
static gboolean
@@ -767,6 +770,7 @@ gf_create_xrandr_output (GfGpuXrandr *gpu_xrandr,
{
GfOutput *output;
GBytes *edid;
+ GfCrtc *assigned_crtc;
unsigned int i;
output = g_object_new (GF_TYPE_OUTPUT,
@@ -799,7 +803,20 @@ gf_create_xrandr_output (GfGpuXrandr *gpu_xrandr,
output_get_tile_info (output);
output_get_modes (output, xrandr_output);
- output_get_crtcs (output, xrandr_output);
+ output_get_crtcs (output, xrandr_output, &assigned_crtc);
+
+ if (assigned_crtc)
+ {
+ GfOutputInfo output_info;
+
+ output_info = (GfOutputInfo) {
+ .is_primary = (XID) gf_output_get_id (output) == primary_output,
+ .is_presentation = output_get_presentation_xrandr (output),
+ .is_underscanning = output_get_underscanning_xrandr (output),
+ };
+
+ gf_output_assign_crtc (output, assigned_crtc, &output_info);
+ }
output->n_possible_clones = xrandr_output->nclone;
output->possible_clones = g_new0 (GfOutput *, output->n_possible_clones);
@@ -813,17 +830,12 @@ gf_create_xrandr_output (GfGpuXrandr *gpu_xrandr,
output->possible_clones[i] = GINT_TO_POINTER (xrandr_output->clones[i]);
}
- output->is_primary = ((XID) gf_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 = output_get_supports_underscanning_xrandr (output);
output_get_backlight_limits_xrandr (output);
if (!(output->backlight_min == 0 && output->backlight_max == 0))
- output->backlight = output_get_backlight_xrandr (output);
- else
- output->backlight = -1;
+ gf_output_set_backlight (output, output_get_backlight_xrandr (output));
if (output->n_modes == 0 || output->n_possible_crtcs == 0)
{
@@ -876,16 +888,19 @@ gf_output_xrandr_apply_mode (GfOutput *output)
xdisplay = xdisplay_from_output (output);
- if (output->is_primary)
+ if (gf_output_is_primary (output))
{
XRRSetOutputPrimary (xdisplay, DefaultRootWindow (xdisplay),
(XID) gf_output_get_id (output));
}
- output_set_presentation_xrandr (output, output->is_presentation);
+ output_set_presentation_xrandr (output, gf_output_is_presentation (output));
if (output->supports_underscanning)
- output_set_underscanning_xrandr (output, output->is_underscanning);
+ {
+ output_set_underscanning_xrandr (output,
+ gf_output_is_underscanning (output));
+ }
}
void
@@ -907,5 +922,5 @@ gf_output_xrandr_change_backlight (GfOutput *output,
1, &hw_value);
/* We're not selecting for property notifies, so update the value immediately */
- output->backlight = normalize_backlight (output, hw_value);
+ gf_output_set_backlight (output, normalize_backlight (output, hw_value));
}
diff --git a/backends/gf-output.c b/backends/gf-output.c
index 39cf570..00d8880 100644
--- a/backends/gf-output.c
+++ b/backends/gf-output.c
@@ -38,6 +38,13 @@ typedef struct
/* The CRTC driving this output, NULL if the output is not enabled */
GfCrtc *crtc;
+
+ gboolean is_primary;
+ gboolean is_presentation;
+
+ gboolean is_underscanning;
+
+ int backlight;
} GfOutputPrivate;
enum
@@ -182,8 +189,13 @@ gf_output_class_init (GfOutputClass *output_class)
}
static void
-gf_output_init (GfOutput *output)
+gf_output_init (GfOutput *self)
{
+ GfOutputPrivate *priv;
+
+ priv = gf_output_get_instance_private (self);
+
+ priv->backlight = -1;
}
uint64_t
@@ -207,16 +219,21 @@ gf_output_get_gpu (GfOutput *output)
}
void
-gf_output_assign_crtc (GfOutput *output,
- GfCrtc *crtc)
+gf_output_assign_crtc (GfOutput *self,
+ GfCrtc *crtc,
+ const GfOutputInfo *output_info)
{
GfOutputPrivate *priv;
- priv = gf_output_get_instance_private (output);
+ priv = gf_output_get_instance_private (self);
g_assert (crtc);
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;
}
void
@@ -227,6 +244,9 @@ gf_output_unassign_crtc (GfOutput *output)
priv = gf_output_get_instance_private (output);
g_clear_object (&priv->crtc);
+
+ priv->is_primary = FALSE;
+ priv->is_presentation = FALSE;
}
GfCrtc *
@@ -339,3 +359,54 @@ gf_output_crtc_to_logical_transform (GfOutput *output,
return gf_monitor_transform_transform (transform, inverted_transform);
}
+
+gboolean
+gf_output_is_primary (GfOutput *self)
+{
+ GfOutputPrivate *priv;
+
+ priv = gf_output_get_instance_private (self);
+
+ return priv->is_primary;
+}
+
+gboolean
+gf_output_is_presentation (GfOutput *self)
+{
+ GfOutputPrivate *priv;
+
+ priv = gf_output_get_instance_private (self);
+
+ return priv->is_presentation;
+}
+
+gboolean
+gf_output_is_underscanning (GfOutput *self)
+{
+ GfOutputPrivate *priv;
+
+ priv = gf_output_get_instance_private (self);
+
+ return priv->is_underscanning;
+}
+
+void
+gf_output_set_backlight (GfOutput *self,
+ int backlight)
+{
+ GfOutputPrivate *priv;
+
+ priv = gf_output_get_instance_private (self);
+
+ priv->backlight = backlight;
+}
+
+int
+gf_output_get_backlight (GfOutput *self)
+{
+ GfOutputPrivate *priv;
+
+ priv = gf_output_get_instance_private (self);
+
+ return priv->backlight;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]