backends: Centralize panel autorotation in a DisplayConfig property
Instead of having everyone check net.hadess.SensorProxy themselves, have this all controlled by the MetaOrientationManager, and proxied everywhere else via a readonly property in org.gnome.Mutter.DisplayConfig. We want to attach more complex policies here, and it seems better to centralize the handling of the autorotation feature rather than implementing policy changes all over the place. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1311
This commit is contained in:
parent
7f9949a5e3
commit
1acf744473
@ -129,6 +129,8 @@ struct _MetaMonitorManager
|
|||||||
|
|
||||||
int persistent_timeout_id;
|
int persistent_timeout_id;
|
||||||
|
|
||||||
|
guint panel_orientation_managed : 1;
|
||||||
|
|
||||||
MetaMonitorConfigManager *config_manager;
|
MetaMonitorConfigManager *config_manager;
|
||||||
|
|
||||||
GnomePnpIds *pnp_ids;
|
GnomePnpIds *pnp_ids;
|
||||||
|
@ -67,6 +67,7 @@ enum
|
|||||||
PROP_0,
|
PROP_0,
|
||||||
|
|
||||||
PROP_BACKEND,
|
PROP_BACKEND,
|
||||||
|
PROP_PANEL_ORIENTATION_MANAGED,
|
||||||
|
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
@ -748,6 +749,28 @@ experimental_features_changed (MetaSettings *settings,
|
|||||||
meta_settings_update_ui_scaling_factor (settings);
|
meta_settings_update_ui_scaling_factor (settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_panel_orientation_managed (MetaMonitorManager *manager)
|
||||||
|
{
|
||||||
|
MetaOrientationManager *orientation_manager;
|
||||||
|
gboolean panel_orientation_managed;
|
||||||
|
|
||||||
|
orientation_manager = meta_backend_get_orientation_manager (manager->backend);
|
||||||
|
|
||||||
|
panel_orientation_managed =
|
||||||
|
meta_orientation_manager_has_accelerometer (orientation_manager);
|
||||||
|
|
||||||
|
if (manager->panel_orientation_managed == panel_orientation_managed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
manager->panel_orientation_managed = panel_orientation_managed;
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (manager),
|
||||||
|
obj_props[PROP_PANEL_ORIENTATION_MANAGED]);
|
||||||
|
|
||||||
|
meta_dbus_display_config_set_panel_orientation_managed (manager->display_config,
|
||||||
|
manager->panel_orientation_managed);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_monitor_manager_setup (MetaMonitorManager *manager)
|
meta_monitor_manager_setup (MetaMonitorManager *manager)
|
||||||
{
|
{
|
||||||
@ -788,6 +811,11 @@ meta_monitor_manager_constructed (GObject *object)
|
|||||||
G_CALLBACK (orientation_changed),
|
G_CALLBACK (orientation_changed),
|
||||||
manager, 0);
|
manager, 0);
|
||||||
|
|
||||||
|
g_signal_connect_object (meta_backend_get_orientation_manager (backend),
|
||||||
|
"notify::has-accelerometer",
|
||||||
|
G_CALLBACK (update_panel_orientation_managed), manager,
|
||||||
|
G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
g_signal_connect_object (backend,
|
g_signal_connect_object (backend,
|
||||||
"lid-is-closed-changed",
|
"lid-is-closed-changed",
|
||||||
G_CALLBACK (lid_is_closed_changed),
|
G_CALLBACK (lid_is_closed_changed),
|
||||||
@ -848,6 +876,7 @@ meta_monitor_manager_set_property (GObject *object,
|
|||||||
case PROP_BACKEND:
|
case PROP_BACKEND:
|
||||||
manager->backend = g_value_get_object (value);
|
manager->backend = g_value_get_object (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_PANEL_ORIENTATION_MANAGED:
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
}
|
}
|
||||||
@ -866,6 +895,9 @@ meta_monitor_manager_get_property (GObject *object,
|
|||||||
case PROP_BACKEND:
|
case PROP_BACKEND:
|
||||||
g_value_set_object (value, manager->backend);
|
g_value_set_object (value, manager->backend);
|
||||||
break;
|
break;
|
||||||
|
case PROP_PANEL_ORIENTATION_MANAGED:
|
||||||
|
g_value_set_boolean (value, manager->panel_orientation_managed);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
}
|
}
|
||||||
@ -925,6 +957,15 @@ meta_monitor_manager_class_init (MetaMonitorManagerClass *klass)
|
|||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
G_PARAM_STATIC_STRINGS);
|
G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
|
obj_props[PROP_PANEL_ORIENTATION_MANAGED] =
|
||||||
|
g_param_spec_boolean ("panel-orientation-managed",
|
||||||
|
"Panel orientation managed",
|
||||||
|
"Panel orientation is managed",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READABLE |
|
||||||
|
G_PARAM_EXPLICIT_NOTIFY |
|
||||||
|
G_PARAM_STATIC_STRINGS);
|
||||||
g_object_class_install_properties (object_class, PROP_LAST, obj_props);
|
g_object_class_install_properties (object_class, PROP_LAST, obj_props);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3175,3 +3216,11 @@ meta_monitor_manager_get_vendor_name (MetaMonitorManager *manager,
|
|||||||
|
|
||||||
return gnome_pnp_ids_get_pnp_id (manager->pnp_ids, vendor);
|
return gnome_pnp_ids_get_pnp_id (manager->pnp_ids, vendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_monitor_manager_get_panel_orientation_managed (MetaMonitorManager *manager)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (META_IS_MONITOR_MANAGER (manager), FALSE);
|
||||||
|
|
||||||
|
return manager->panel_orientation_managed;
|
||||||
|
}
|
||||||
|
@ -62,4 +62,7 @@ MetaMonitorSwitchConfigType meta_monitor_manager_get_switch_config (MetaMonitorM
|
|||||||
META_EXPORT
|
META_EXPORT
|
||||||
gint meta_monitor_manager_get_display_configuration_timeout (void);
|
gint meta_monitor_manager_get_display_configuration_timeout (void);
|
||||||
|
|
||||||
|
META_EXPORT
|
||||||
|
gboolean meta_monitor_manager_get_panel_orientation_managed (MetaMonitorManager *manager);
|
||||||
|
|
||||||
#endif /* META_MONITOR_MANAGER_H */
|
#endif /* META_MONITOR_MANAGER_H */
|
||||||
|
@ -282,6 +282,14 @@
|
|||||||
-->
|
-->
|
||||||
<property name="PowerSaveMode" type="i" access="readwrite" />
|
<property name="PowerSaveMode" type="i" access="readwrite" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
PanelOrientationManaged:
|
||||||
|
|
||||||
|
Whether the built-in panel orientation is automatically managed
|
||||||
|
by mutter.
|
||||||
|
-->
|
||||||
|
<property name="PanelOrientationManaged" type="b" access="read" />
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
MonitorsChanged:
|
MonitorsChanged:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user