mirror of
https://github.com/brl/mutter.git
synced 2025-08-03 15:14:46 +00:00
monitor: Add support to privacy screen
Some monitors support hardware features to enable the privacy screen mode that allows users to toggle (via software or hardware button) a state in which the display may be harder to see to people not sitting in front of it. Expose then this capability to the monitor level so that we can get its state and set it. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
This commit is contained in:

committed by
Marge Bot

parent
8ebdae8092
commit
f231672084
@@ -419,6 +419,50 @@ meta_output_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (meta_output_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
MetaPrivacyScreenState
|
||||
meta_output_get_privacy_screen_state (MetaOutput *output)
|
||||
{
|
||||
MetaOutputClass *output_class = META_OUTPUT_GET_CLASS (output);
|
||||
|
||||
if (!output_class->get_privacy_screen_state)
|
||||
return META_PRIVACY_SCREEN_UNAVAILABLE;
|
||||
|
||||
return output_class->get_privacy_screen_state (output);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_output_set_privacy_screen_enabled (MetaOutput *output,
|
||||
gboolean enabled,
|
||||
GError **error)
|
||||
{
|
||||
MetaOutputClass *output_class = META_OUTPUT_GET_CLASS (output);
|
||||
MetaPrivacyScreenState state;
|
||||
|
||||
state = meta_output_get_privacy_screen_state (output);
|
||||
|
||||
if (state == META_PRIVACY_SCREEN_UNAVAILABLE)
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"The privacy screen is not supported by this output");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert (output_class->set_privacy_screen_enabled != NULL);
|
||||
|
||||
if (state & META_PRIVACY_SCREEN_LOCKED)
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
|
||||
"The privacy screen is locked at hardware level, "
|
||||
"impossible to set it");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!!(state & META_PRIVACY_SCREEN_ENABLED) == enabled)
|
||||
return TRUE;
|
||||
|
||||
return output_class->set_privacy_screen_enabled (output, enabled, error);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_output_init (MetaOutput *output)
|
||||
{
|
||||
|
Reference in New Issue
Block a user