1
0
Fork 0

monitor-manager: Move PNP lookup to MetaBackend

It's not really about monitors, even though it is used for monitors.
Lets shrink MetaMonitorManager a bit moving it to the backend.

While at it, stop leaking it too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
This commit is contained in:
Jonas Ådahl 2021-10-28 16:08:25 +02:00 committed by Marge Bot
parent 7ee60e1143
commit 67e7140c25
5 changed files with 40 additions and 39 deletions

View file

@ -216,4 +216,7 @@ gboolean meta_backend_is_hw_cursors_inhibited (MetaBackend *backend);
void meta_backend_update_from_event (MetaBackend *backend,
ClutterEvent *event);
char * meta_backend_get_vendor_name (MetaBackend *backend,
const char *pnp_id);
#endif /* META_BACKEND_PRIVATE_H */

View file

@ -167,6 +167,9 @@ struct _MetaBackendPrivate
#ifdef HAVE_LIBWACOM
WacomDeviceDatabase *wacom_db;
#endif
#ifdef HAVE_GNOME_DESKTOP
GnomePnpIds *pnp_ids;
#endif
ClutterContext *clutter_context;
ClutterSeat *default_seat;
@ -236,6 +239,9 @@ meta_backend_dispose (GObject *object)
#ifdef HAVE_LIBWACOM
g_clear_pointer (&priv->wacom_db, libwacom_database_destroy);
#endif
#ifdef HAVE_GNOME_DESKTOP
g_clear_object (&priv->pnp_ids);
#endif
if (priv->sleep_signal_id)
{
@ -1766,3 +1772,29 @@ meta_backend_update_from_event (MetaBackend *backend,
update_last_device_from_event (backend, event);
update_pointer_visibility_from_event (backend, event);
}
/**
* meta_backend_get_vendor_name:
* @backend: A #MetaBackend object
* @pnp_id: the PNP ID
*
* Find the full vendor name from the given PNP ID.
*
* Returns: (transfer full): A string containing the vendor name,
* or NULL when not found.
*/
char *
meta_backend_get_vendor_name (MetaBackend *backend,
const char *pnp_id)
{
#ifdef HAVE_GNOME_DESKTOP
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
if (!priv->pnp_ids)
priv->pnp_ids = gnome_pnp_ids_new ();
return gnome_pnp_ids_get_pnp_id (priv->pnp_ids, pnp_id);
#else
return g_strdup (pnp_id);
#endif
}

View file

@ -160,10 +160,6 @@ struct _MetaMonitorManager
MetaMonitorConfigManager *config_manager;
#ifdef HAVE_GNOME_DESKTOP
GnomePnpIds *pnp_ids;
#endif
MetaMonitorSwitchConfigType current_switch_config;
MetaPrivacyScreenChangeState privacy_screen_change_state;
@ -430,9 +426,6 @@ void meta_monitor_manager_clear_crtc (MetaCrtc *crtc);
gboolean meta_monitor_has_aspect_as_size (MetaMonitor *monitor);
char * meta_monitor_manager_get_vendor_name (MetaMonitorManager *manager,
const char *vendor);
static inline MetaOutputAssignment *
meta_find_output_assignment (MetaOutputAssignment **outputs,
unsigned int n_outputs,

View file

@ -3879,30 +3879,6 @@ meta_monitor_manager_get_config_manager (MetaMonitorManager *manager)
return manager->config_manager;
}
/**
* meta_monitor_manager_get_vendor_name:
* @manager: A #MetaMonitorManager object
* @vendor: the PNP ID of the monitor
*
* Find the full vendor name from the given monitor PNP ID.
*
* Returns: (transfer full): A string containing the vendor name,
* or NULL when not found.
*/
char *
meta_monitor_manager_get_vendor_name (MetaMonitorManager *manager,
const char *vendor)
{
#ifdef HAVE_GNOME_DESKTOP
if (!manager->pnp_ids)
manager->pnp_ids = gnome_pnp_ids_new ();
return gnome_pnp_ids_get_pnp_id (manager->pnp_ids, vendor);
#else
return g_strdup (vendor);
#endif
}
gboolean
meta_monitor_manager_get_panel_orientation_managed (MetaMonitorManager *manager)
{

View file

@ -237,9 +237,9 @@ diagonal_to_str (double d)
}
static char *
meta_monitor_make_display_name (MetaMonitor *monitor,
MetaMonitorManager *monitor_manager)
meta_monitor_make_display_name (MetaMonitor *monitor)
{
MetaBackend *backend = meta_monitor_get_backend (monitor);
g_autofree char *inches = NULL;
g_autofree char *vendor_name = NULL;
const char *vendor = NULL;
@ -269,8 +269,7 @@ meta_monitor_make_display_name (MetaMonitor *monitor,
vendor = meta_monitor_get_vendor (monitor);
if (vendor)
{
vendor_name = meta_monitor_manager_get_vendor_name (monitor_manager,
vendor);
vendor_name = meta_backend_get_vendor_name (backend, vendor);
if (!vendor_name)
vendor_name = g_strdup (vendor);
@ -839,8 +838,7 @@ meta_monitor_normal_new (MetaMonitorManager *monitor_manager,
meta_monitor_normal_generate_modes (monitor_normal);
monitor_priv->display_name = meta_monitor_make_display_name (monitor,
monitor_manager);
monitor_priv->display_name = meta_monitor_make_display_name (monitor);
return monitor_normal;
}
@ -1538,8 +1536,7 @@ meta_monitor_tiled_new (MetaMonitorManager *monitor_manager,
meta_monitor_tiled_generate_modes (monitor_tiled);
monitor_priv->display_name = meta_monitor_make_display_name (monitor,
monitor_manager);
monitor_priv->display_name = meta_monitor_make_display_name (monitor);
return monitor_tiled;
}