diff --git a/src/platforms/evdev/libinput_device.cpp b/src/platforms/evdev/libinput_device.cpp index a4bd3047dd8..abaaaa6305e 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: 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; + } + 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..117685c9c48 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; } @@ -132,11 +139,24 @@ 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). {alan_g} + // https://github.com/MirServer/mir/issues/611 + auto const pos = begin(outputs); + if (pos != end(outputs)) + return pos->second; + } return OutputInfo{}; } + private: mutable std::mutex output_mutex; mi::SeatInputDeviceTracker& input_state_tracker; 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