native: Rename MetaMonitorManagerKms to MetaMonitorManagerNative

We'll sooner or later start managing not only KMS backend monitors, but
virtual / remote ones too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
This commit is contained in:
Jonas Ådahl 2020-12-17 22:12:41 +01:00 committed by Marge Bot
parent 42d614f6fa
commit 3091cd89dc
6 changed files with 131 additions and 115 deletions

View File

@ -53,7 +53,7 @@
#include "backends/native/meta-kms.h"
#include "backends/native/meta-kms-device.h"
#include "backends/native/meta-launcher.h"
#include "backends/native/meta-monitor-manager-kms.h"
#include "backends/native/meta-monitor-manager-native.h"
#include "backends/native/meta-renderer-native.h"
#include "backends/native/meta-seat-native.h"
#include "backends/native/meta-stage-native.h"
@ -214,7 +214,7 @@ meta_backend_native_create_monitor_manager (MetaBackend *backend,
{
MetaMonitorManager *manager;
manager = g_initable_new (META_TYPE_MONITOR_MANAGER_KMS, NULL, error,
manager = g_initable_new (META_TYPE_MONITOR_MANAGER_NATIVE, NULL, error,
"backend", backend,
NULL);
if (!manager)
@ -638,8 +638,8 @@ meta_backend_native_pause (MetaBackendNative *native)
MetaBackend *backend = META_BACKEND (native);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerKms *monitor_manager_kms =
META_MONITOR_MANAGER_KMS (monitor_manager);
MetaMonitorManagerNative *monitor_manager_native =
META_MONITOR_MANAGER_NATIVE (monitor_manager);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
MetaSeatNative *seat =
META_SEAT_NATIVE (clutter_backend_get_default_seat (clutter_backend));
@ -653,7 +653,7 @@ meta_backend_native_pause (MetaBackendNative *native)
disconnect_udev_device_added_handler (native);
meta_monitor_manager_kms_pause (monitor_manager_kms);
meta_monitor_manager_native_pause (monitor_manager_native);
}
void meta_backend_native_resume (MetaBackendNative *native)
@ -662,8 +662,8 @@ void meta_backend_native_resume (MetaBackendNative *native)
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerKms *monitor_manager_kms =
META_MONITOR_MANAGER_KMS (monitor_manager);
MetaMonitorManagerNative *monitor_manager_native =
META_MONITOR_MANAGER_NATIVE (monitor_manager);
MetaIdleMonitor *idle_monitor;
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
MetaSeatNative *seat =
@ -674,7 +674,7 @@ void meta_backend_native_resume (MetaBackendNative *native)
COGL_TRACE_BEGIN_SCOPED (MetaBackendNativeResume,
"Backend (resume)");
meta_monitor_manager_kms_resume (monitor_manager_kms);
meta_monitor_manager_native_resume (monitor_manager_native);
meta_kms_resume (native->kms);
connect_udev_device_added_handler (native);

View File

@ -34,7 +34,7 @@
#include "backends/native/meta-kms-plane.h"
#include "backends/native/meta-kms-update.h"
#include "backends/native/meta-kms.h"
#include "backends/native/meta-monitor-manager-kms.h"
#include "backends/native/meta-monitor-manager-native.h"
#define ALL_TRANSFORMS_MASK ((1 << META_MONITOR_N_TRANSFORMS) - 1)
@ -187,8 +187,8 @@ meta_crtc_kms_maybe_set_gamma (MetaCrtcKms *crtc_kms,
MetaBackend *backend = meta_gpu_get_backend (gpu);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerKms *monitor_manager_kms =
META_MONITOR_MANAGER_KMS (monitor_manager);
MetaMonitorManagerNative *monitor_manager_native =
META_MONITOR_MANAGER_NATIVE (monitor_manager);
MetaKms *kms = meta_kms_device_get_kms (kms_device);
MetaKmsUpdate *kms_update;
MetaKmsCrtcGamma *gamma;
@ -196,7 +196,7 @@ meta_crtc_kms_maybe_set_gamma (MetaCrtcKms *crtc_kms,
if (crtc_kms->is_gamma_valid)
return;
gamma = meta_monitor_manager_kms_get_cached_crtc_gamma (monitor_manager_kms,
gamma = meta_monitor_manager_native_get_cached_crtc_gamma (monitor_manager_native,
crtc_kms);
if (!gamma)
return;

View File

@ -23,11 +23,11 @@
*/
/**
* SECTION:meta-monitor-manager-kms
* @title: MetaMonitorManagerKms
* SECTION:meta-monitor-manager-native
* @title: MetaMonitorManagerNative
* @short_description: A subclass of #MetaMonitorManager using Linux DRM
*
* #MetaMonitorManagerKms is a subclass of #MetaMonitorManager which
* #MetaMonitorManagerNative is a subclass of #MetaMonitorManager which
* implements its functionality "natively": it uses the appropriate
* functions of the Linux DRM kernel module and using a udev client.
*
@ -36,7 +36,7 @@
#include "config.h"
#include "backends/native/meta-monitor-manager-kms.h"
#include "backends/native/meta-monitor-manager-native.h"
#include <drm.h>
#include <errno.h>
@ -63,7 +63,7 @@
#include "meta/main.h"
#include "meta/meta-x11-errors.h"
struct _MetaMonitorManagerKms
struct _MetaMonitorManagerNative
{
MetaMonitorManager parent_instance;
@ -72,7 +72,7 @@ struct _MetaMonitorManagerKms
GHashTable *crtc_gamma_cache;
};
struct _MetaMonitorManagerKmsClass
struct _MetaMonitorManagerNativeClass
{
MetaMonitorManagerClass parent_class;
};
@ -80,23 +80,23 @@ struct _MetaMonitorManagerKmsClass
static void
initable_iface_init (GInitableIface *initable_iface);
G_DEFINE_TYPE_WITH_CODE (MetaMonitorManagerKms, meta_monitor_manager_kms,
G_DEFINE_TYPE_WITH_CODE (MetaMonitorManagerNative, meta_monitor_manager_native,
META_TYPE_MONITOR_MANAGER,
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
initable_iface_init))
static GBytes *
meta_monitor_manager_kms_read_edid (MetaMonitorManager *manager,
meta_monitor_manager_native_read_edid (MetaMonitorManager *manager,
MetaOutput *output)
{
return meta_output_kms_read_edid (META_OUTPUT_KMS (output));
}
static void
meta_monitor_manager_kms_read_current_state (MetaMonitorManager *manager)
meta_monitor_manager_native_read_current_state (MetaMonitorManager *manager)
{
MetaMonitorManagerClass *parent_class =
META_MONITOR_MANAGER_CLASS (meta_monitor_manager_kms_parent_class);
META_MONITOR_MANAGER_CLASS (meta_monitor_manager_native_parent_class);
MetaPowerSave power_save_mode;
power_save_mode = meta_monitor_manager_get_power_save_mode (manager);
@ -129,7 +129,7 @@ meta_power_save_to_dpms_state (MetaPowerSave power_save)
}
static void
meta_monitor_manager_kms_set_power_save_mode (MetaMonitorManager *manager,
meta_monitor_manager_native_set_power_save_mode (MetaMonitorManager *manager,
MetaPowerSave mode)
{
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
@ -174,7 +174,7 @@ meta_monitor_manager_kms_set_power_save_mode (MetaMonitorManager *manager,
}
static void
meta_monitor_manager_kms_ensure_initial_config (MetaMonitorManager *manager)
meta_monitor_manager_native_ensure_initial_config (MetaMonitorManager *manager)
{
MetaMonitorsConfig *config;
@ -286,7 +286,7 @@ update_screen_size (MetaMonitorManager *manager,
}
static gboolean
meta_monitor_manager_kms_apply_monitors_config (MetaMonitorManager *manager,
meta_monitor_manager_native_apply_monitors_config (MetaMonitorManager *manager,
MetaMonitorsConfig *config,
MetaMonitorsConfigMethod method,
GError **error)
@ -339,7 +339,7 @@ meta_monitor_manager_kms_apply_monitors_config (MetaMonitorManager *manager
}
static void
meta_monitor_manager_kms_get_crtc_gamma (MetaMonitorManager *manager,
meta_monitor_manager_native_get_crtc_gamma (MetaMonitorManager *manager,
MetaCrtc *crtc,
gsize *size,
unsigned short **red,
@ -422,32 +422,33 @@ generate_gamma_ramp_string (size_t size,
}
MetaKmsCrtcGamma *
meta_monitor_manager_kms_get_cached_crtc_gamma (MetaMonitorManagerKms *manager_kms,
meta_monitor_manager_native_get_cached_crtc_gamma (MetaMonitorManagerNative *manager_native,
MetaCrtcKms *crtc_kms)
{
uint64_t crtc_id;
crtc_id = meta_crtc_get_id (META_CRTC (crtc_kms));
return g_hash_table_lookup (manager_kms->crtc_gamma_cache,
return g_hash_table_lookup (manager_native->crtc_gamma_cache,
GUINT_TO_POINTER (crtc_id));
}
static void
meta_monitor_manager_kms_set_crtc_gamma (MetaMonitorManager *manager,
meta_monitor_manager_native_set_crtc_gamma (MetaMonitorManager *manager,
MetaCrtc *crtc,
gsize size,
unsigned short *red,
unsigned short *green,
unsigned short *blue)
{
MetaMonitorManagerKms *manager_kms = META_MONITOR_MANAGER_KMS (manager);
MetaMonitorManagerNative *manager_native =
META_MONITOR_MANAGER_NATIVE (manager);
MetaCrtcKms *crtc_kms = META_CRTC_KMS (crtc);
MetaKmsCrtc *kms_crtc = meta_crtc_kms_get_kms_crtc (META_CRTC_KMS (crtc));
g_autofree char *gamma_ramp_string = NULL;
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
g_hash_table_replace (manager_kms->crtc_gamma_cache,
g_hash_table_replace (manager_native->crtc_gamma_cache,
GUINT_TO_POINTER (meta_crtc_get_id (crtc)),
meta_kms_crtc_gamma_new (kms_crtc, size,
red, green, blue));
@ -474,43 +475,43 @@ on_kms_resources_changed (MetaKms *kms,
}
static void
meta_monitor_manager_kms_connect_hotplug_handler (MetaMonitorManagerKms *manager_kms)
meta_monitor_manager_native_connect_hotplug_handler (MetaMonitorManagerNative *manager_native)
{
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_native);
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
MetaKms *kms = meta_backend_native_get_kms (backend_native);
manager_kms->kms_resources_changed_handler_id =
manager_native->kms_resources_changed_handler_id =
g_signal_connect (kms, "resources-changed",
G_CALLBACK (on_kms_resources_changed), manager);
}
static void
meta_monitor_manager_kms_disconnect_hotplug_handler (MetaMonitorManagerKms *manager_kms)
meta_monitor_manager_native_disconnect_hotplug_handler (MetaMonitorManagerNative *manager_native)
{
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_native);
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
MetaKms *kms = meta_backend_native_get_kms (backend_native);
g_clear_signal_handler (&manager_kms->kms_resources_changed_handler_id, kms);
g_clear_signal_handler (&manager_native->kms_resources_changed_handler_id, kms);
}
void
meta_monitor_manager_kms_pause (MetaMonitorManagerKms *manager_kms)
meta_monitor_manager_native_pause (MetaMonitorManagerNative *manager_native)
{
meta_monitor_manager_kms_disconnect_hotplug_handler (manager_kms);
meta_monitor_manager_native_disconnect_hotplug_handler (manager_native);
}
void
meta_monitor_manager_kms_resume (MetaMonitorManagerKms *manager_kms)
meta_monitor_manager_native_resume (MetaMonitorManagerNative *manager_native)
{
meta_monitor_manager_kms_connect_hotplug_handler (manager_kms);
meta_monitor_manager_native_connect_hotplug_handler (manager_native);
}
static gboolean
meta_monitor_manager_kms_is_transform_handled (MetaMonitorManager *manager,
meta_monitor_manager_native_is_transform_handled (MetaMonitorManager *manager,
MetaCrtc *crtc,
MetaMonitorTransform transform)
{
@ -518,7 +519,7 @@ meta_monitor_manager_kms_is_transform_handled (MetaMonitorManager *manager,
}
static float
meta_monitor_manager_kms_calculate_monitor_mode_scale (MetaMonitorManager *manager,
meta_monitor_manager_native_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
{
@ -526,7 +527,7 @@ meta_monitor_manager_kms_calculate_monitor_mode_scale (MetaMonitorManager *manag
}
static float *
meta_monitor_manager_kms_calculate_supported_scales (MetaMonitorManager *manager,
meta_monitor_manager_native_calculate_supported_scales (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
@ -550,7 +551,7 @@ meta_monitor_manager_kms_calculate_supported_scales (MetaMonitorManager
}
static MetaMonitorManagerCapability
meta_monitor_manager_kms_get_capabilities (MetaMonitorManager *manager)
meta_monitor_manager_native_get_capabilities (MetaMonitorManager *manager)
{
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
MetaSettings *settings = meta_backend_get_settings (backend);
@ -566,7 +567,7 @@ meta_monitor_manager_kms_get_capabilities (MetaMonitorManager *manager)
}
static gboolean
meta_monitor_manager_kms_get_max_screen_size (MetaMonitorManager *manager,
meta_monitor_manager_native_get_max_screen_size (MetaMonitorManager *manager,
int *max_width,
int *max_height)
{
@ -574,7 +575,7 @@ meta_monitor_manager_kms_get_max_screen_size (MetaMonitorManager *manager,
}
static MetaLogicalMonitorLayoutMode
meta_monitor_manager_kms_get_default_layout_mode (MetaMonitorManager *manager)
meta_monitor_manager_native_get_default_layout_mode (MetaMonitorManager *manager)
{
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
MetaSettings *settings = meta_backend_get_settings (backend);
@ -588,28 +589,30 @@ meta_monitor_manager_kms_get_default_layout_mode (MetaMonitorManager *manager)
}
static void
meta_monitor_manager_kms_dispose (GObject *object)
meta_monitor_manager_native_dispose (GObject *object)
{
MetaMonitorManagerKms *manager_kms = META_MONITOR_MANAGER_KMS (object);
MetaMonitorManagerNative *manager_native =
META_MONITOR_MANAGER_NATIVE (object);
g_clear_pointer (&manager_kms->crtc_gamma_cache,
g_clear_pointer (&manager_native->crtc_gamma_cache,
g_hash_table_unref);
G_OBJECT_CLASS (meta_monitor_manager_kms_parent_class)->dispose (object);
G_OBJECT_CLASS (meta_monitor_manager_native_parent_class)->dispose (object);
}
static gboolean
meta_monitor_manager_kms_initable_init (GInitable *initable,
meta_monitor_manager_native_initable_init (GInitable *initable,
GCancellable *cancellable,
GError **error)
{
MetaMonitorManagerKms *manager_kms = META_MONITOR_MANAGER_KMS (initable);
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
MetaMonitorManagerNative *manager_native =
META_MONITOR_MANAGER_NATIVE (initable);
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_native);
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
gboolean can_have_outputs;
GList *l;
meta_monitor_manager_kms_connect_hotplug_handler (manager_kms);
meta_monitor_manager_native_connect_hotplug_handler (manager_native);
can_have_outputs = FALSE;
for (l = meta_backend_get_gpus (backend); l; l = l->next)
@ -629,7 +632,7 @@ meta_monitor_manager_kms_initable_init (GInitable *initable,
return FALSE;
}
manager_kms->crtc_gamma_cache =
manager_native->crtc_gamma_cache =
g_hash_table_new_full (NULL, NULL,
NULL,
(GDestroyNotify) meta_kms_crtc_gamma_free);
@ -640,33 +643,46 @@ meta_monitor_manager_kms_initable_init (GInitable *initable,
static void
initable_iface_init (GInitableIface *initable_iface)
{
initable_iface->init = meta_monitor_manager_kms_initable_init;
initable_iface->init = meta_monitor_manager_native_initable_init;
}
static void
meta_monitor_manager_kms_init (MetaMonitorManagerKms *manager_kms)
meta_monitor_manager_native_init (MetaMonitorManagerNative *manager_native)
{
}
static void
meta_monitor_manager_kms_class_init (MetaMonitorManagerKmsClass *klass)
meta_monitor_manager_native_class_init (MetaMonitorManagerNativeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
MetaMonitorManagerClass *manager_class = META_MONITOR_MANAGER_CLASS (klass);
object_class->dispose = meta_monitor_manager_kms_dispose;
object_class->dispose = meta_monitor_manager_native_dispose;
manager_class->read_edid = meta_monitor_manager_kms_read_edid;
manager_class->read_current_state = meta_monitor_manager_kms_read_current_state;
manager_class->ensure_initial_config = meta_monitor_manager_kms_ensure_initial_config;
manager_class->apply_monitors_config = meta_monitor_manager_kms_apply_monitors_config;
manager_class->set_power_save_mode = meta_monitor_manager_kms_set_power_save_mode;
manager_class->get_crtc_gamma = meta_monitor_manager_kms_get_crtc_gamma;
manager_class->set_crtc_gamma = meta_monitor_manager_kms_set_crtc_gamma;
manager_class->is_transform_handled = meta_monitor_manager_kms_is_transform_handled;
manager_class->calculate_monitor_mode_scale = meta_monitor_manager_kms_calculate_monitor_mode_scale;
manager_class->calculate_supported_scales = meta_monitor_manager_kms_calculate_supported_scales;
manager_class->get_capabilities = meta_monitor_manager_kms_get_capabilities;
manager_class->get_max_screen_size = meta_monitor_manager_kms_get_max_screen_size;
manager_class->get_default_layout_mode = meta_monitor_manager_kms_get_default_layout_mode;
manager_class->read_edid =
meta_monitor_manager_native_read_edid;
manager_class->read_current_state =
meta_monitor_manager_native_read_current_state;
manager_class->ensure_initial_config =
meta_monitor_manager_native_ensure_initial_config;
manager_class->apply_monitors_config =
meta_monitor_manager_native_apply_monitors_config;
manager_class->set_power_save_mode =
meta_monitor_manager_native_set_power_save_mode;
manager_class->get_crtc_gamma =
meta_monitor_manager_native_get_crtc_gamma;
manager_class->set_crtc_gamma =
meta_monitor_manager_native_set_crtc_gamma;
manager_class->is_transform_handled =
meta_monitor_manager_native_is_transform_handled;
manager_class->calculate_monitor_mode_scale =
meta_monitor_manager_native_calculate_monitor_mode_scale;
manager_class->calculate_supported_scales =
meta_monitor_manager_native_calculate_supported_scales;
manager_class->get_capabilities =
meta_monitor_manager_native_get_capabilities;
manager_class->get_max_screen_size =
meta_monitor_manager_native_get_max_screen_size;
manager_class->get_default_layout_mode =
meta_monitor_manager_native_get_default_layout_mode;
}

View File

@ -20,8 +20,8 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef META_MONITOR_MANAGER_KMS_H
#define META_MONITOR_MANAGER_KMS_H
#ifndef META_MONITOR_MANAGER_NATIVE_H
#define META_MONITOR_MANAGER_NATIVE_H
#include <xf86drm.h>
#include <xf86drmMode.h>
@ -32,18 +32,18 @@
typedef struct _MetaGpuKms MetaGpuKms;
#define META_TYPE_MONITOR_MANAGER_KMS (meta_monitor_manager_kms_get_type ())
G_DECLARE_FINAL_TYPE (MetaMonitorManagerKms, meta_monitor_manager_kms,
META, MONITOR_MANAGER_KMS,
#define META_TYPE_MONITOR_MANAGER_NATIVE (meta_monitor_manager_native_get_type ())
G_DECLARE_FINAL_TYPE (MetaMonitorManagerNative, meta_monitor_manager_native,
META, MONITOR_MANAGER_NATIVE,
MetaMonitorManager)
void meta_monitor_manager_kms_pause (MetaMonitorManagerKms *manager_kms);
void meta_monitor_manager_native_pause (MetaMonitorManagerNative *manager_native);
void meta_monitor_manager_kms_resume (MetaMonitorManagerKms *manager_kms);
void meta_monitor_manager_native_resume (MetaMonitorManagerNative *manager_native);
uint64_t meta_power_save_to_dpms_state (MetaPowerSave power_save);
MetaKmsCrtcGamma * meta_monitor_manager_kms_get_cached_crtc_gamma (MetaMonitorManagerKms *manager_kms,
MetaKmsCrtcGamma * meta_monitor_manager_native_get_cached_crtc_gamma (MetaMonitorManagerNative *manager_native,
MetaCrtcKms *crtc_kms);
#endif /* META_MONITOR_MANAGER_KMS_H */
#endif /* META_MONITOR_MANAGER_NATIVE_H */

View File

@ -31,7 +31,7 @@
#include "backends/meta-renderer.h"
#include "backends/native/meta-gpu-kms.h"
#include "backends/native/meta-monitor-manager-kms.h"
#include "backends/native/meta-monitor-manager-native.h"
#define META_TYPE_RENDERER_NATIVE (meta_renderer_native_get_type ())
G_DECLARE_FINAL_TYPE (MetaRendererNative, meta_renderer_native,

View File

@ -670,8 +670,8 @@ if have_native_backend
'backends/native/meta-keymap-native.h',
'backends/native/meta-launcher.c',
'backends/native/meta-launcher.h',
'backends/native/meta-monitor-manager-kms.c',
'backends/native/meta-monitor-manager-kms.h',
'backends/native/meta-monitor-manager-native.c',
'backends/native/meta-monitor-manager-native.h',
'backends/native/meta-output-kms.c',
'backends/native/meta-output-kms.h',
'backends/native/meta-kms-connector-private.h',