monitor: Add backlight abstraction
This allows higher levels to deal with backlight on a monitor bases, instead of having to deal with the fact that some monitors might have multiple outputs. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3861>
This commit is contained in:
parent
68dd168e33
commit
c22816393c
2 changed files with 68 additions and 0 deletions
|
@ -2401,3 +2401,61 @@ out:
|
||||||
*out_refresh_rate = refresh_rate;
|
*out_refresh_rate = refresh_rate;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_monitor_get_backlight_info (MetaMonitor *monitor,
|
||||||
|
int *backlight_min,
|
||||||
|
int *backlight_max)
|
||||||
|
{
|
||||||
|
MetaOutput *main_output;
|
||||||
|
int value;
|
||||||
|
|
||||||
|
main_output = meta_monitor_get_main_output (monitor);
|
||||||
|
value = meta_output_get_backlight (main_output);
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
const MetaOutputInfo *output_info = meta_output_get_info (main_output);
|
||||||
|
if (backlight_min)
|
||||||
|
*backlight_min = output_info->backlight_min;
|
||||||
|
if (backlight_max)
|
||||||
|
*backlight_max = output_info->backlight_max;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_monitor_set_backlight (MetaMonitor *monitor,
|
||||||
|
int value)
|
||||||
|
{
|
||||||
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
for (l = priv->outputs; l; l = l->next)
|
||||||
|
{
|
||||||
|
MetaOutput *output = l->data;
|
||||||
|
|
||||||
|
meta_output_set_backlight (output, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_monitor_get_backlight (MetaMonitor *monitor,
|
||||||
|
int *value)
|
||||||
|
{
|
||||||
|
if (meta_monitor_get_backlight_info (monitor, NULL, NULL))
|
||||||
|
{
|
||||||
|
MetaOutput *main_output;
|
||||||
|
|
||||||
|
main_output = meta_monitor_get_main_output (monitor);
|
||||||
|
*value = meta_output_get_backlight (main_output);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -335,3 +335,13 @@ gboolean meta_parse_monitor_mode (const char *string,
|
||||||
int *out_height,
|
int *out_height,
|
||||||
float *out_refresh_rate,
|
float *out_refresh_rate,
|
||||||
float fallback_refresh_rate);
|
float fallback_refresh_rate);
|
||||||
|
|
||||||
|
gboolean meta_monitor_get_backlight_info (MetaMonitor *monitor,
|
||||||
|
int *backlight_min,
|
||||||
|
int *backlight_max);
|
||||||
|
|
||||||
|
void meta_monitor_set_backlight (MetaMonitor *monitor,
|
||||||
|
int value);
|
||||||
|
|
||||||
|
gboolean meta_monitor_get_backlight (MetaMonitor *monitor,
|
||||||
|
int *value);
|
||||||
|
|
Loading…
Reference in a new issue