From e41c504432150462609a4457c7dd89bce5a55f7b Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Tue, 18 Sep 2018 14:19:42 +0100 Subject: [PATCH 1/7] [Wayland] Remove hard coded values for output geometry (screen orientation and pixel arrangement). (Fixes #601) --- .../frontend_wayland/output_manager.cpp | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/src/server/frontend_wayland/output_manager.cpp b/src/server/frontend_wayland/output_manager.cpp index a23aa9071a8..0c8202dae71 100644 --- a/src/server/frontend_wayland/output_manager.cpp +++ b/src/server/frontend_wayland/output_manager.cpp @@ -60,6 +60,52 @@ bool mf::Output::matches_client_resource(wl_client* client, struct wl_resource* return false; } +namespace +{ +auto as_subpixel_arrangement(MirSubpixelArrangement arrangement) -> wl_output_subpixel +{ + switch (arrangement) + { + default: + case mir_subpixel_arrangement_unknown: + return WL_OUTPUT_SUBPIXEL_UNKNOWN; + + case mir_subpixel_arrangement_horizontal_rgb: + return WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB; + + case mir_subpixel_arrangement_horizontal_bgr: + return WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR; + + case mir_subpixel_arrangement_vertical_rgb: + return WL_OUTPUT_SUBPIXEL_VERTICAL_RGB; + + case mir_subpixel_arrangement_vertical_bgr: + return WL_OUTPUT_SUBPIXEL_VERTICAL_BGR; + + case mir_subpixel_arrangement_none: + return WL_OUTPUT_SUBPIXEL_NONE; + } +} + +auto as_transform(MirOrientation orientation) -> wl_output_transform +{ + switch (orientation) + { + default: + case mir_orientation_normal: + return WL_OUTPUT_TRANSFORM_NORMAL; + + case mir_orientation_left: + return WL_OUTPUT_TRANSFORM_90; + + case mir_orientation_inverted: + return WL_OUTPUT_TRANSFORM_180; + + case mir_orientation_right: + return WL_OUTPUT_TRANSFORM_270; + } +} +} void mf::Output::send_initial_config(wl_resource* client_resource, mg::DisplayConfigurationOutput const& config) { @@ -69,10 +115,10 @@ void mf::Output::send_initial_config(wl_resource* client_resource, mg::DisplayCo config.top_left.y.as_int(), config.physical_size_mm.width.as_int(), config.physical_size_mm.height.as_int(), - WL_OUTPUT_SUBPIXEL_UNKNOWN, + as_subpixel_arrangement(config.subpixel_arrangement), "Fake manufacturer", "Fake model", - WL_OUTPUT_TRANSFORM_NORMAL); + as_transform(config.orientation)); for (size_t i = 0; i < config.modes.size(); ++i) { auto const& mode = config.modes[i]; From efd5d29f7dfa31636c69ceec56521d527a349b25 Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Tue, 18 Sep 2018 14:15:44 +0100 Subject: [PATCH 2/7] Correct size of miral-kiosk splash screen --- examples/example-server-lib/sw_splash.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/example-server-lib/sw_splash.cpp b/examples/example-server-lib/sw_splash.cpp index 5b9a68fb4bb..047284fae73 100644 --- a/examples/example-server-lib/sw_splash.cpp +++ b/examples/example-server-lib/sw_splash.cpp @@ -78,6 +78,14 @@ auto create_window(MirConnection* connection, mir::client::Surface const& surfac MirOutputMode const* mode = mir_output_get_current_mode(output); width = mir_output_mode_get_width(mode); height = mir_output_mode_get_height(mode); + + switch (mir_output_get_orientation(output)) + { + case mir_orientation_left: + case mir_orientation_right: + std::swap(width, height); + default:; + } } }); From 2fd103f7d60a1f3808b3f07e5ef0c17ce506ecd7 Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Tue, 18 Sep 2018 15:06:41 +0100 Subject: [PATCH 3/7] use the right functions --- examples/example-server-lib/sw_splash.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/examples/example-server-lib/sw_splash.cpp b/examples/example-server-lib/sw_splash.cpp index 047284fae73..8e226267de9 100644 --- a/examples/example-server-lib/sw_splash.cpp +++ b/examples/example-server-lib/sw_splash.cpp @@ -74,18 +74,8 @@ auto create_window(MirConnection* connection, mir::client::Surface const& surfac mir_output_is_enabled(output)) { id = mir_output_get_id(output); - - MirOutputMode const* mode = mir_output_get_current_mode(output); - width = mir_output_mode_get_width(mode); - height = mir_output_mode_get_height(mode); - - switch (mir_output_get_orientation(output)) - { - case mir_orientation_left: - case mir_orientation_right: - std::swap(width, height); - default:; - } + width = mir_output_get_logical_width(output); + height = mir_output_get_logical_height(output); } }); From 81bb7996cd35a779d04ab0076c72ce76e1326553 Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Wed, 19 Sep 2018 15:20:53 +0100 Subject: [PATCH 4/7] Hard code touchscreen-output matching --- src/platforms/evdev/libinput_device.cpp | 6 ++++++ src/server/input/basic_seat.cpp | 18 +++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/platforms/evdev/libinput_device.cpp b/src/platforms/evdev/libinput_device.cpp index a4bd3047dd8..fff224954b5 100644 --- a/src/platforms/evdev/libinput_device.cpp +++ b/src/platforms/evdev/libinput_device.cpp @@ -421,8 +421,14 @@ void mie::LibInputDevice::update_device_info() if (contains(caps, mi::DeviceCapability::touchscreen) && !contains(info.capabilities, mi::DeviceCapability::touchscreen)) + { touchscreen = mi::TouchscreenSettings{}; + // FIXME: hack to connect touchscreen to output. {arg} + touchscreen.value().output_id = 1; + touchscreen.value().mapping_mode = mir_touchscreen_mapping_mode_to_output; + } + info = mi::InputDeviceInfo{name, unique_id.str(), caps}; } diff --git a/src/server/input/basic_seat.cpp b/src/server/input/basic_seat.cpp index 972256e2fee..0a7949cce73 100644 --- a/src/server/input/basic_seat.cpp +++ b/src/server/input/basic_seat.cpp @@ -67,21 +67,28 @@ struct mi::BasicSeat::OutputTracker : mg::DisplayConfigurationObserver 1.0f, 0.0f, float(output.top_left.x.as_int()), 0.0f, 1.0f, float(output.top_left.y.as_int())}}; - switch(output.orientation) + switch (output.orientation) { case mir_orientation_left: - output_matrix[3] = -1; - output_matrix[5] += width; - break; - case mir_orientation_right: + output_matrix[0] = 0; output_matrix[1] = -1; output_matrix[2] += height; + output_matrix[3] = 1; + output_matrix[4] = 0; + break; + case mir_orientation_right: + output_matrix[0] = 0; + output_matrix[1] = 1; + output_matrix[3] = -1; + output_matrix[4] = 0; + output_matrix[5] += width; break; case mir_orientation_inverted: output_matrix[0] = -1; output_matrix[2] += width; output_matrix[4] = -1; output_matrix[5] += height; + break; default: break; } @@ -137,6 +144,7 @@ struct mi::BasicSeat::OutputTracker : mg::DisplayConfigurationObserver return pos->second; return OutputInfo{}; } + private: mutable std::mutex output_mutex; mi::SeatInputDeviceTracker& input_state_tracker; From 571057e91f44842a22c91aad96ecb81dea565bdf Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Thu, 20 Sep 2018 07:35:36 +0100 Subject: [PATCH 5/7] Put "lipstick" on the hack. --- src/platforms/evdev/libinput_device.cpp | 4 ++-- src/server/input/basic_seat.cpp | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/platforms/evdev/libinput_device.cpp b/src/platforms/evdev/libinput_device.cpp index fff224954b5..13bb159635c 100644 --- a/src/platforms/evdev/libinput_device.cpp +++ b/src/platforms/evdev/libinput_device.cpp @@ -424,8 +424,8 @@ void mie::LibInputDevice::update_device_info() { touchscreen = mi::TouchscreenSettings{}; - // FIXME: hack to connect touchscreen to output. {arg} - touchscreen.value().output_id = 1; + // FIXME: We need a way to populate output_id sensibly. {arg} + // https://github.com/MirServer/mir/issues/611 touchscreen.value().mapping_mode = mir_touchscreen_mapping_mode_to_output; } diff --git a/src/server/input/basic_seat.cpp b/src/server/input/basic_seat.cpp index 0a7949cce73..b3a2a1575ec 100644 --- a/src/server/input/basic_seat.cpp +++ b/src/server/input/basic_seat.cpp @@ -139,9 +139,21 @@ struct mi::BasicSeat::OutputTracker : mg::DisplayConfigurationObserver mi::OutputInfo get_output_info(uint32_t output) const { std::lock_guard lock(output_mutex); - auto pos = outputs.find(output); - if (pos != end(outputs)) - return pos->second; + if (output) + { + auto pos = outputs.find(output); + if (pos != end(outputs)) + return pos->second; + } + else + { + // Output has not been populated sensibly, that's expected as there's no way to do that (yet). + // FIXME: We just guess (which works with a single touchscreen output). {arg} + // https://github.com/MirServer/mir/issues/611 + auto const pos = begin(outputs); + if (pos != end(outputs)) + return pos->second; + } return OutputInfo{}; } From 9b2c05db4b3123dcc80144839e008c99bd14728b Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Thu, 20 Sep 2018 07:43:51 +0100 Subject: [PATCH 6/7] Use my name --- src/platforms/evdev/libinput_device.cpp | 2 +- src/server/input/basic_seat.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platforms/evdev/libinput_device.cpp b/src/platforms/evdev/libinput_device.cpp index 13bb159635c..abaaaa6305e 100644 --- a/src/platforms/evdev/libinput_device.cpp +++ b/src/platforms/evdev/libinput_device.cpp @@ -424,7 +424,7 @@ void mie::LibInputDevice::update_device_info() { touchscreen = mi::TouchscreenSettings{}; - // FIXME: We need a way to populate output_id sensibly. {arg} + // FIXME: We need a way to populate output_id sensibly. {alan_g} // https://github.com/MirServer/mir/issues/611 touchscreen.value().mapping_mode = mir_touchscreen_mapping_mode_to_output; } diff --git a/src/server/input/basic_seat.cpp b/src/server/input/basic_seat.cpp index b3a2a1575ec..117685c9c48 100644 --- a/src/server/input/basic_seat.cpp +++ b/src/server/input/basic_seat.cpp @@ -148,7 +148,7 @@ struct mi::BasicSeat::OutputTracker : mg::DisplayConfigurationObserver else { // Output has not been populated sensibly, that's expected as there's no way to do that (yet). - // FIXME: We just guess (which works with a single touchscreen output). {arg} + // FIXME: We just guess (which works with a single touchscreen output). {alan_g} // https://github.com/MirServer/mir/issues/611 auto const pos = begin(outputs); if (pos != end(outputs)) From 9494baec8a14f11e97bc63d62f92a3eb3c2a1de5 Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Thu, 20 Sep 2018 09:36:17 +0100 Subject: [PATCH 7/7] Fix test mock to match --- tests/unit-tests/input/evdev/test_libinput_device.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unit-tests/input/evdev/test_libinput_device.cpp b/tests/unit-tests/input/evdev/test_libinput_device.cpp index f5fd503f5a9..831e692264f 100644 --- a/tests/unit-tests/input/evdev/test_libinput_device.cpp +++ b/tests/unit-tests/input/evdev/test_libinput_device.cpp @@ -268,6 +268,17 @@ struct LibInputDeviceOnTouchScreen : public LibInputDevice const float screen_y_pos = 30; const int width = 100; const int height = 200; + + void SetUp() override + { + LibInputDevice::SetUp(); + ON_CALL(mock_sink, output_info(0)) + .WillByDefault(Return( + mi::OutputInfo{ + true, + geom::Size{width, height}, + Matrix{{1.0f, 0.0f, 0, 0.0f, 1.0f, 0}}})); + } }; struct LibInputDeviceOnTouchpad : public LibInputDevice