1
0
Fork 0

DisplayConfig: Add logical monitor transforms

Add the transform as a logical monitor parameter, both when getting the
current state and applying a new configuration. The transform is defined
to be identical to MetaMonitorTransform.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl 2017-03-21 14:29:32 +08:00
parent 17c54c6e03
commit 0ac2eba4d3
2 changed files with 44 additions and 15 deletions

View file

@ -1304,7 +1304,7 @@ meta_monitor_manager_legacy_handle_apply_configuration (MetaDBusDisplayConfig *
#define MONITORS_FORMAT "a" MONITOR_FORMAT #define MONITORS_FORMAT "a" MONITOR_FORMAT
#define LOGICAL_MONITOR_MONITORS_FORMAT "a" MONITOR_SPEC_FORMAT #define LOGICAL_MONITOR_MONITORS_FORMAT "a" MONITOR_SPEC_FORMAT
#define LOGICAL_MONITOR_FORMAT "(iidb" LOGICAL_MONITOR_MONITORS_FORMAT "a{sv})" #define LOGICAL_MONITOR_FORMAT "(iidub" LOGICAL_MONITOR_MONITORS_FORMAT "a{sv})"
#define LOGICAL_MONITORS_FORMAT "a" LOGICAL_MONITOR_FORMAT #define LOGICAL_MONITORS_FORMAT "a" LOGICAL_MONITOR_FORMAT
static gboolean static gboolean
@ -1422,6 +1422,7 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
logical_monitor->rect.x, logical_monitor->rect.x,
logical_monitor->rect.y, logical_monitor->rect.y,
(double) logical_monitor->scale, (double) logical_monitor->scale,
logical_monitor->transform,
logical_monitor->is_primary, logical_monitor->is_primary,
&logical_monitor_monitors_builder, &logical_monitor_monitors_builder,
NULL); NULL);
@ -1583,7 +1584,7 @@ find_monitor_spec (MetaMonitorManager *manager,
#define MONITOR_CONFIG_FORMAT "(s" MONITOR_MODE_SPEC_FORMAT "a{sv})" #define MONITOR_CONFIG_FORMAT "(s" MONITOR_MODE_SPEC_FORMAT "a{sv})"
#define MONITOR_CONFIGS_FORMAT "a" MONITOR_CONFIG_FORMAT #define MONITOR_CONFIGS_FORMAT "a" MONITOR_CONFIG_FORMAT
#define LOGICAL_MONITOR_CONFIG_FORMAT "(iidb" MONITOR_CONFIGS_FORMAT ")" #define LOGICAL_MONITOR_CONFIG_FORMAT "(iidub" MONITOR_CONFIGS_FORMAT ")"
static MetaMonitorConfig * static MetaMonitorConfig *
create_monitor_config_from_variant (MetaMonitorManager *manager, create_monitor_config_from_variant (MetaMonitorManager *manager,
@ -1647,13 +1648,15 @@ create_monitor_config_from_variant (MetaMonitorManager *manager,
static gboolean static gboolean
derive_logical_monitor_size (GList *monitor_configs, derive_logical_monitor_size (GList *monitor_configs,
int *width, int *out_width,
int *height, int *out_height,
double scale, double scale,
MetaMonitorTransform transform,
MetaLogicalMonitorLayoutMode layout_mode, MetaLogicalMonitorLayoutMode layout_mode,
GError **error) GError **error)
{ {
MetaMonitorConfig *monitor_config; MetaMonitorConfig *monitor_config;
int width, height;
if (!monitor_configs) if (!monitor_configs)
{ {
@ -1664,19 +1667,31 @@ derive_logical_monitor_size (GList *monitor_configs,
monitor_config = monitor_configs->data; monitor_config = monitor_configs->data;
if (meta_monitor_transform_is_rotated (transform))
{
width = monitor_config->mode_spec->height;
height = monitor_config->mode_spec->width;
}
else
{
width = monitor_config->mode_spec->width;
height = monitor_config->mode_spec->height;
}
switch (layout_mode) switch (layout_mode)
{ {
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL: case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
*width = monitor_config->mode_spec->width / scale; width /= scale;
*height = monitor_config->mode_spec->height / scale; height /= scale;
return TRUE; break;
case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL: case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL:
*width = monitor_config->mode_spec->width; break;
*height = monitor_config->mode_spec->height;
return TRUE;
} }
g_assert_not_reached (); *out_width = width;
*out_height = height;
return TRUE;
} }
static MetaLogicalMonitorConfig * static MetaLogicalMonitorConfig *
@ -1688,6 +1703,7 @@ create_logical_monitor_config_from_variant (MetaMonitorManager *manager
MetaLogicalMonitorConfig *logical_monitor_config; MetaLogicalMonitorConfig *logical_monitor_config;
int x, y, width, height; int x, y, width, height;
double scale; double scale;
MetaMonitorTransform transform;
gboolean is_primary; gboolean is_primary;
GVariantIter *monitor_configs_iter; GVariantIter *monitor_configs_iter;
GList *monitor_configs = NULL; GList *monitor_configs = NULL;
@ -1696,6 +1712,7 @@ create_logical_monitor_config_from_variant (MetaMonitorManager *manager
&x, &x,
&y, &y,
&scale, &scale,
&transform,
&is_primary, &is_primary,
&monitor_configs_iter); &monitor_configs_iter);
@ -1725,7 +1742,7 @@ create_logical_monitor_config_from_variant (MetaMonitorManager *manager
g_variant_iter_free (monitor_configs_iter); g_variant_iter_free (monitor_configs_iter);
if (!derive_logical_monitor_size (monitor_configs, &width, &height, if (!derive_logical_monitor_size (monitor_configs, &width, &height,
scale, layout_mode, error)) scale, transform, layout_mode, error))
goto err; goto err;
logical_monitor_config = g_new0 (MetaLogicalMonitorConfig, 1); logical_monitor_config = g_new0 (MetaLogicalMonitorConfig, 1);
@ -1736,7 +1753,7 @@ create_logical_monitor_config_from_variant (MetaMonitorManager *manager
.width = width, .width = width,
.height = height .height = height
}, },
.transform = META_MONITOR_TRANSFORM_NORMAL, .transform = transform,
.scale = (int) scale, .scale = (int) scale,
.is_primary = is_primary, .is_primary = is_primary,
.monitor_configs = monitor_configs .monitor_configs = monitor_configs

View file

@ -342,6 +342,7 @@
* i x: x position * i x: x position
* i y: y position * i y: y position
* d scale: scale * d scale: scale
* u transform: transform (see below)
* b primary: true if this is the primary logical monitor * b primary: true if this is the primary logical monitor
* a(sss) monitors: monitors displaying this logical monitor * a(sss) monitors: monitors displaying this logical monitor
* connector: name of the connector (e.g. DP-1, eDP-1 etc) * connector: name of the connector (e.g. DP-1, eDP-1 etc)
@ -350,6 +351,16 @@
* serial: product serial * serial: product serial
* a{sv} properties: possibly other properties * a{sv} properties: possibly other properties
Posisble transform values:
0: normal
1: 90°
2: 180°
3: 270°
4: flipped
5: 90° flipped
6: 180° flipped
7: 270° flipped
@supported_scales is an ordered list of floating point numbers representing @supported_scales is an ordered list of floating point numbers representing
scale factors of logical monitors supported by the display server. scale factors of logical monitors supported by the display server.
@ -387,7 +398,7 @@
<method name="GetCurrentState"> <method name="GetCurrentState">
<arg name="serial" direction="out" type="u" /> <arg name="serial" direction="out" type="u" />
<arg name="monitors" direction="out" type="a((ssss)a(iiddu)a{sv})" /> <arg name="monitors" direction="out" type="a((ssss)a(iiddu)a{sv})" />
<arg name="logical_monitors" direction="out" type="a(iidba(ssss)a{sv})" /> <arg name="logical_monitors" direction="out" type="a(iiduba(ssss)a{sv})" />
<arg name="supported_scales" direction="out" type="ad" /> <arg name="supported_scales" direction="out" type="ad" />
<arg name="properties" direction="out" type="a{sv}" /> <arg name="properties" direction="out" type="a{sv}" />
</method> </method>
@ -412,6 +423,7 @@
* i: layout x position * i: layout x position
* i: layout y position * i: layout y position
* d: scale * d: scale
* u: transform (see GetCurrentState)
* b primary: true if this is the primary logical monitor * b primary: true if this is the primary logical monitor
* a(siida{sv}): a list of monitors, each consisting of: * a(siida{sv}): a list of monitors, each consisting of:
* s: connector * s: connector
@ -432,7 +444,7 @@
<method name="ApplyMonitorsConfig"> <method name="ApplyMonitorsConfig">
<arg name="serial" direction="in" type="u" /> <arg name="serial" direction="in" type="u" />
<arg name="method" direction="in" type="u" /> <arg name="method" direction="in" type="u" />
<arg name="logical_monitors" direction="in" type="a(iidba(s(iid)a{sv}))" /> <arg name="logical_monitors" direction="in" type="a(iiduba(s(iid)a{sv}))" />
<arg name="properties" direction="in" type="a{sv}" /> <arg name="properties" direction="in" type="a{sv}" />
</method> </method>
</interface> </interface>