Allow for zero number of dpi values to be set

At least in the DBus API we can't just say "doesn't exist", so let's allow for
a zero-sized list.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2017-10-16 17:55:01 +10:00
committed by Benjamin Tissoires
parent 3e0c803a37
commit 74a5551a8d
2 changed files with 6 additions and 0 deletions

View File

@@ -278,6 +278,9 @@ org.freedesktop.ratbag1.Resolution
the :js:attr:`Resolution` property. This list is always sorted
ascending, the lowest resolution is the first item in the list.
This list may be empty if the device does not support reading and/or
writing to resolutions.
.. js:attribute:: ReportRate
:type: u

View File

@@ -1131,6 +1131,9 @@ ratbag_resolution_get_dpi_list(struct ratbag_resolution *resolution,
assert(nres > 0);
if (resolution->ndpis == 0)
return 0;
memcpy(resolutions, resolution->dpis,
sizeof(unsigned int) * min(nres, resolution->ndpis));