Skip to content

Commit

Permalink
Merge #612
Browse files Browse the repository at this point in the history
612: Guess output for touchscreen (works with one of each).  (Fixes #605) r=wmww a=AlanGriffiths

Guess output for touchscreen (works with one of each). (Fixes #605)

Co-authored-by: Alan Griffiths <[email protected]>
  • Loading branch information
bors[bot] and AlanGriffiths committed Sep 20, 2018
2 parents a1dc983 + 9494bae commit 5ee48a2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/platforms/evdev/libinput_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}

Expand Down
36 changes: 28 additions & 8 deletions src/server/input/basic_seat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -132,11 +139,24 @@ struct mi::BasicSeat::OutputTracker : mg::DisplayConfigurationObserver
mi::OutputInfo get_output_info(uint32_t output) const
{
std::lock_guard<std::mutex> 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;
Expand Down
11 changes: 11 additions & 0 deletions tests/unit-tests/input/evdev/test_libinput_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5ee48a2

Please sign in to comment.