mirror of
https://github.com/brl/mutter.git
synced 2025-08-07 00:54:42 +00:00
output: Make implementations inherit MetaOutput
Instead of the home baked "inheritance" system, using a gpointer and a GDestroyNotify function to keep the what effectively is sub type details, make MetaOutput an abstract derivable type, and make the implementations inherit it. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287
This commit is contained in:

committed by
Georges Basile Stavracas Neto

parent
4920b5064d
commit
4a4f2d8264
@@ -163,7 +163,7 @@ meta_test_headless_monitor_connect (void)
|
||||
output_info->possible_crtcs = possible_crtcs;
|
||||
output_info->connector_type = META_CONNECTOR_TYPE_DisplayPort;
|
||||
|
||||
output = g_object_new (META_TYPE_OUTPUT,
|
||||
output = g_object_new (META_TYPE_OUTPUT_TEST,
|
||||
"id", 1,
|
||||
"gpu", gpu,
|
||||
"info", output_info,
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include "backends/meta-output.h"
|
||||
#include "tests/meta-backend-test.h"
|
||||
|
||||
G_DEFINE_TYPE (MetaOutputTest, meta_output_test, META_TYPE_OUTPUT)
|
||||
|
||||
struct _MetaMonitorManagerTest
|
||||
{
|
||||
MetaMonitorManager parent;
|
||||
@@ -296,7 +298,7 @@ meta_monitor_manager_test_calculate_monitor_mode_scale (MetaMonitorManager *mana
|
||||
MetaOutputTest *output_test;
|
||||
|
||||
output = meta_monitor_get_main_output (monitor);
|
||||
output_test = output->driver_private;
|
||||
output_test = META_OUTPUT_TEST (output);
|
||||
|
||||
if (output_test)
|
||||
return output_test->scale;
|
||||
@@ -423,3 +425,14 @@ meta_monitor_manager_test_class_init (MetaMonitorManagerTestClass *klass)
|
||||
manager_class->get_max_screen_size = meta_monitor_manager_test_get_max_screen_size;
|
||||
manager_class->get_default_layout_mode = meta_monitor_manager_test_get_default_layout_mode;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_output_test_init (MetaOutputTest *output_test)
|
||||
{
|
||||
output_test->scale = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_output_test_class_init (MetaOutputTestClass *klass)
|
||||
{
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#define META_MONITOR_MANAGER_TEST_H
|
||||
|
||||
#include "backends/meta-monitor-manager-private.h"
|
||||
#include "backends/meta-output.h"
|
||||
|
||||
typedef struct _MetaMonitorTestSetup
|
||||
{
|
||||
@@ -29,13 +30,20 @@ typedef struct _MetaMonitorTestSetup
|
||||
GList *crtcs;
|
||||
} MetaMonitorTestSetup;
|
||||
|
||||
typedef struct _MetaOutputTest
|
||||
struct _MetaOutputTest
|
||||
{
|
||||
MetaOutput parent;
|
||||
|
||||
float scale;
|
||||
} MetaOutputTest;
|
||||
};
|
||||
|
||||
typedef MetaMonitorTestSetup * (* CreateTestSetupFunc) (void);
|
||||
|
||||
#define META_TYPE_OUTPUT_TEST (meta_output_test_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (MetaOutputTest, meta_output_test,
|
||||
META, OUTPUT_TEST,
|
||||
MetaOutput)
|
||||
|
||||
#define META_TYPE_MONITOR_MANAGER_TEST (meta_monitor_manager_test_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (MetaMonitorManagerTest, meta_monitor_manager_test,
|
||||
META, MONITOR_MANAGER_TEST, MetaMonitorManager)
|
||||
|
@@ -529,12 +529,6 @@ check_monitor_configuration (MonitorTestCaseExpect *expect)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_output_test_destroy_notify (MetaOutput *output)
|
||||
{
|
||||
g_clear_pointer (&output->driver_private, g_free);
|
||||
}
|
||||
|
||||
MetaMonitorTestSetup *
|
||||
create_monitor_test_setup (MonitorTestCaseSetup *setup,
|
||||
MonitorTestFlag flags)
|
||||
@@ -627,16 +621,10 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup,
|
||||
possible_crtc_index);
|
||||
}
|
||||
|
||||
output_test = g_new0 (MetaOutputTest, 1);
|
||||
|
||||
scale = setup->outputs[i].scale;
|
||||
if (scale < 1)
|
||||
scale = 1;
|
||||
|
||||
*output_test = (MetaOutputTest) {
|
||||
.scale = scale
|
||||
};
|
||||
|
||||
is_laptop_panel = setup->outputs[i].is_laptop_panel;
|
||||
|
||||
serial = setup->outputs[i].serial;
|
||||
@@ -679,12 +667,15 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup,
|
||||
output_info->panel_orientation_transform =
|
||||
setup->outputs[i].panel_orientation_transform;
|
||||
|
||||
output = g_object_new (META_TYPE_OUTPUT,
|
||||
output = g_object_new (META_TYPE_OUTPUT_TEST,
|
||||
"id", i,
|
||||
"gpu", test_get_gpu (),
|
||||
"info", output_info,
|
||||
NULL);
|
||||
|
||||
output_test = META_OUTPUT_TEST (output);
|
||||
output_test->scale = scale;
|
||||
|
||||
if (crtc)
|
||||
{
|
||||
MetaOutputAssignment output_assignment;
|
||||
@@ -695,9 +686,6 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup,
|
||||
meta_output_assign_crtc (output, crtc, &output_assignment);
|
||||
}
|
||||
|
||||
output->driver_private = output_test;
|
||||
output->driver_notify = (GDestroyNotify) meta_output_test_destroy_notify;
|
||||
|
||||
test_setup->outputs = g_list_append (test_setup->outputs, output);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user