diff --git a/src/macos/include/display_device/macos/mac_api_layer.h b/src/macos/include/display_device/macos/mac_api_layer.h index 60fbbc4..608480b 100644 --- a/src/macos/include/display_device/macos/mac_api_layer.h +++ b/src/macos/include/display_device/macos/mac_api_layer.h @@ -48,6 +48,11 @@ namespace display_device { */ [[nodiscard]] std::string getDeviceId(MacDisplayId display_id) const override; + /** + * @copydoc MacApiLayerInterface::getDeviceIdAlias + */ + [[nodiscard]] std::string getDeviceIdAlias(MacDisplayId display_id) const override; + /** * @copydoc MacApiLayerInterface::getCurrentDisplayMode */ diff --git a/src/macos/include/display_device/macos/mac_api_layer_interface.h b/src/macos/include/display_device/macos/mac_api_layer_interface.h index 6d77e2c..e8f761c 100644 --- a/src/macos/include/display_device/macos/mac_api_layer_interface.h +++ b/src/macos/include/display_device/macos/mac_api_layer_interface.h @@ -66,6 +66,16 @@ namespace display_device { */ [[nodiscard]] virtual std::string getDeviceId(MacDisplayId display_id) const = 0; + /** + * @brief Get the other device id a display may have been saved under. + * + * A "macos-cg-*" id depends on whether another online display reports the same vendor, model + * and serial, so a display that stays connected can have had a different id when it was saved. + * @param display_id Display to query. + * @returns The other device id, or empty string if the display only has one. + */ + [[nodiscard]] virtual std::string getDeviceIdAlias(MacDisplayId display_id) const = 0; + /** * @brief Get the current display mode. * @param display_id Display to query. diff --git a/src/macos/include/display_device/macos/mac_api_utils.h b/src/macos/include/display_device/macos/mac_api_utils.h index de71b31..e9bbb64 100644 --- a/src/macos/include/display_device/macos/mac_api_utils.h +++ b/src/macos/include/display_device/macos/mac_api_utils.h @@ -4,6 +4,12 @@ */ #pragma once +// system includes +#include +#include +#include +#include + // local includes #include "types.h" @@ -33,4 +39,51 @@ namespace display_device::mac_utils { * @returns True if resolution matches exactly and refresh rate is close enough. */ [[nodiscard]] bool fuzzyCompareModes(const MacDisplayMode &lhs, const MacDisplayMode &rhs); + + /** + * @brief CoreGraphics values that identify a display without an EDID or IOKit metadata. + */ + struct CgDisplayInfo { + MacDisplayId m_display_id; ///< Display id (reassigned when a display reconnects). + std::uint32_t m_vendor; ///< CGDisplayVendorNumber value. + std::uint32_t m_model; ///< CGDisplayModelNumber value. + std::uint32_t m_serial; ///< CGDisplaySerialNumber value. + std::uint32_t m_unit; ///< CGDisplayUnitNumber value (depends on connection order). + }; + + /** + * @brief Check whether a CGDisplaySerialNumber value identifies a display. + * @param serial CGDisplaySerialNumber value. + * @returns False for 0 (no serial) and 0xFFFFFFFF (documented by Apple as an exception value). + */ + [[nodiscard]] bool isUsableCgSerial(std::uint32_t serial); + + /** + * @brief Build the identity text hashed into a "macos-cg-*" device id. + * + * Used when a display has neither an EDID nor IOKit metadata, which on Apple Silicon is most + * displays (there are no IODisplayConnect services) and every virtual display. The display id + * and unit number change when a display reconnects or a virtual display is recreated, so they are + * left out when vendor, model and serial identify the display on their own: the serial is usable + * and no other online display reports the same vendor, model and serial. Otherwise they are kept, + * so displays that can't be told apart by serial still get distinct ids. + * @param display Display to build the identity for. + * @param online_displays Every online display (may include `display` itself). + * @returns Text to hash. + */ + [[nodiscard]] std::string makeCgDeviceIdentity(const CgDisplayInfo &display, const std::vector &online_displays); + + /** + * @brief Build the other identity text a display's "macos-cg-*" device id may have been saved with. + * + * Whether makeCgDeviceIdentity() includes the display id and unit number depends on whether + * another online display reports the same vendor, model and serial, so a display that stays + * connected while such a display is plugged in or unplugged switches between the two forms. This + * returns the form makeCgDeviceIdentity() does not currently give, so a saved id can still be + * matched. Displays without a usable serial only ever have one form. + * @param display Display to build the identity for. + * @param online_displays Every online display (may include `display` itself). + * @returns The other identity text, or nothing if the display has only one. + */ + [[nodiscard]] std::optional makeCgDeviceIdentityAlias(const CgDisplayInfo &display, const std::vector &online_displays); } // namespace display_device::mac_utils diff --git a/src/macos/include/display_device/macos/mac_display_device.h b/src/macos/include/display_device/macos/mac_display_device.h index 3089965..1249831 100644 --- a/src/macos/include/display_device/macos/mac_display_device.h +++ b/src/macos/include/display_device/macos/mac_display_device.h @@ -92,6 +92,9 @@ namespace display_device { private: /** * @brief Resolve a library device id to a CoreGraphics display id. + * + * Matches the display's current device id first, then its alias (see + * MacApiLayerInterface::getDeviceIdAlias) if exactly one online display has it. * @param device_id Device id to resolve. * @param query_type Display list type to search. * @return Display id, or empty optional if not found. diff --git a/src/macos/mac_api_layer.cpp b/src/macos/mac_api_layer.cpp index 925b826..b301b7a 100644 --- a/src/macos/mac_api_layer.cpp +++ b/src/macos/mac_api_layer.cpp @@ -20,6 +20,7 @@ #include #include #include +#include // local includes #include "display_device/logging.h" @@ -460,6 +461,28 @@ namespace display_device { [[nodiscard]] std::string makeDeviceId(const std::string_view prefix, const std::uint64_t hash) { return std::format("macos-{}-{:016x}", prefix, hash); } + + /** + * @brief Read the CoreGraphics identity values of a display. + * @param display_id Display id. + * @return Identity values. + */ + [[nodiscard]] mac_utils::CgDisplayInfo makeCgDisplayInfo(const MacDisplayId display_id) { + return {display_id, CGDisplayVendorNumber(display_id), CGDisplayModelNumber(display_id), CGDisplaySerialNumber(display_id), CGDisplayUnitNumber(display_id)}; + } + + /** + * @brief Read the CoreGraphics identity values of every online display. + * @param layer API layer to list the displays with. + * @return Identity values. + */ + [[nodiscard]] std::vector makeOnlineCgDisplayInfos(const MacApiLayer &layer) { + std::vector online_displays; + for (const auto online_id : layer.getDisplayIds(MacQueryType::Online)) { + online_displays.push_back(makeCgDisplayInfo(online_id)); + } + return online_displays; + } } // namespace bool MacApiLayer::isApiAccessAvailable() const { @@ -588,13 +611,20 @@ namespace display_device { } } - std::ostringstream fallback; - fallback << "vendor=" << CGDisplayVendorNumber(display_id) << ';' - << "model=" << CGDisplayModelNumber(display_id) << ';' - << "serial=" << CGDisplaySerialNumber(display_id) << ';' - << "unit=" << CGDisplayUnitNumber(display_id) << ';' - << "display=" << display_id; - return makeDeviceId("cg", hashText(fallback.str())); + return makeDeviceId("cg", hashText(mac_utils::makeCgDeviceIdentity(makeCgDisplayInfo(display_id), makeOnlineCgDisplayInfos(*this)))); + } + + std::string MacApiLayer::getDeviceIdAlias(const MacDisplayId display_id) const { + // Only "macos-cg-*" ids have an alias; keep in step with getDeviceId(). + if (!getEdid(display_id).empty()) { + return {}; + } + if (const auto dictionary {copyDisplayInfo(display_id)}; dictionary && !makeIokitMetadata(dictionary.get()).empty()) { + return {}; + } + + const auto alias {mac_utils::makeCgDeviceIdentityAlias(makeCgDisplayInfo(display_id), makeOnlineCgDisplayInfos(*this))}; + return alias ? makeDeviceId("cg", hashText(*alias)) : std::string {}; } std::optional MacApiLayer::getCurrentDisplayMode(const MacDisplayId display_id) const { diff --git a/src/macos/mac_api_utils.cpp b/src/macos/mac_api_utils.cpp index eec9b97..af2da9f 100644 --- a/src/macos/mac_api_utils.cpp +++ b/src/macos/mac_api_utils.cpp @@ -6,7 +6,9 @@ #include "display_device/macos/mac_api_utils.h" // system includes +#include #include +#include namespace display_device::mac_utils { bool isSuccess(const MacApiError error_code) { @@ -27,4 +29,62 @@ namespace display_device::mac_utils { return lhs.m_resolution == rhs.m_resolution && fuzzyCompareRefreshRates(lhs.m_refresh_rate, rhs.m_refresh_rate); } + + bool isUsableCgSerial(const std::uint32_t serial) { + return serial != 0 && serial != 0xFFFFFFFF; + } + + namespace { + /** + * @brief Build the identity text from vendor, model and serial only. + * @param display Display to build the identity for. + * @returns Identity text. + */ + [[nodiscard]] std::string makeSerialIdentity(const CgDisplayInfo &display) { + std::ostringstream identity; + identity << "vendor=" << display.m_vendor << ';' + << "model=" << display.m_model << ';' + << "serial=" << display.m_serial; + return identity.str(); + } + + /** + * @brief Build the identity text that also includes the unit number and display id. + * @param display Display to build the identity for. + * @returns Identity text. + */ + [[nodiscard]] std::string makeQualifiedIdentity(const CgDisplayInfo &display) { + std::ostringstream identity; + identity << makeSerialIdentity(display) << ';' + << "unit=" << display.m_unit << ';' + << "display=" << display.m_display_id; + return identity.str(); + } + + /** + * @brief Check whether another online display reports the same vendor, model and serial. + * @param display Display to check. + * @param online_displays Every online display (may include `display` itself). + * @returns True if such a display is online. + */ + [[nodiscard]] bool hasTwinOnline(const CgDisplayInfo &display, const std::vector &online_displays) { + return std::ranges::any_of(online_displays, [&display](const CgDisplayInfo &other) { + return other.m_display_id != display.m_display_id && other.m_vendor == display.m_vendor && other.m_model == display.m_model && other.m_serial == display.m_serial; + }); + } + } // namespace + + std::string makeCgDeviceIdentity(const CgDisplayInfo &display, const std::vector &online_displays) { + if (!isUsableCgSerial(display.m_serial) || hasTwinOnline(display, online_displays)) { + return makeQualifiedIdentity(display); + } + return makeSerialIdentity(display); + } + + std::optional makeCgDeviceIdentityAlias(const CgDisplayInfo &display, const std::vector &online_displays) { + if (!isUsableCgSerial(display.m_serial)) { + return std::nullopt; + } + return hasTwinOnline(display, online_displays) ? makeSerialIdentity(display) : makeQualifiedIdentity(display); + } } // namespace display_device::mac_utils diff --git a/src/macos/mac_display_device_general.cpp b/src/macos/mac_display_device_general.cpp index 506da51..5e3a12b 100644 --- a/src/macos/mac_display_device_general.cpp +++ b/src/macos/mac_display_device_general.cpp @@ -6,6 +6,7 @@ #include "display_device/macos/mac_display_device.h" // system includes +#include #include // local includes @@ -78,12 +79,31 @@ namespace display_device { return std::nullopt; } - for (const auto display_id : m_m_api->getDisplayIds(query_type)) { + const auto display_ids {m_m_api->getDisplayIds(query_type)}; + for (const auto display_id : display_ids) { if (m_m_api->getDeviceId(display_id) == device_id) { return display_id; } } - return std::nullopt; + // The id may have been saved while a display with the same vendor, model and serial was (or + // wasn't) online, in which case it is now the display's alias. Twins can't be told apart, so + // accept the alias only if exactly one online display has it. + std::optional alias_match; + for (const auto display_id : query_type == MacQueryType::Online ? display_ids : m_m_api->getDisplayIds(MacQueryType::Online)) { + if (m_m_api->getDeviceIdAlias(display_id) != device_id) { + continue; + } + if (alias_match) { + DD_LOG(warning) << "Device id " << device_id << " matches more than one display with the same vendor, model and serial; not resolving it."; + return std::nullopt; + } + alias_match = display_id; + } + + if (alias_match && std::ranges::find(display_ids, *alias_match) == std::ranges::end(display_ids)) { + return std::nullopt; + } + return alias_match; } } // namespace display_device diff --git a/tests/unit/macos/test_mac_api_utils.cpp b/tests/unit/macos/test_mac_api_utils.cpp index 593ae6d..4032769 100644 --- a/tests/unit/macos/test_mac_api_utils.cpp +++ b/tests/unit/macos/test_mac_api_utils.cpp @@ -1,3 +1,6 @@ +// system includes +#include + // local includes #include "display_device/macos/mac_api_utils.h" #include "fixtures/fixtures.h" @@ -25,3 +28,65 @@ TEST_S(FuzzyCompareModes) { EXPECT_FALSE(display_device::mac_utils::fuzzyCompareModes({{1920, 720}, {60, 1}}, {{1920, 1080}, {60, 1}})); EXPECT_FALSE(display_device::mac_utils::fuzzyCompareModes({{1920, 1080}, {60, 1}}, {{1920, 1080}, {50, 1}})); } + +TEST_S(IsUsableCgSerial) { + EXPECT_TRUE(display_device::mac_utils::isUsableCgSerial(1398099505)); + EXPECT_FALSE(display_device::mac_utils::isUsableCgSerial(0)); + EXPECT_FALSE(display_device::mac_utils::isUsableCgSerial(0xFFFFFFFF)); +} + +TEST_S(MakeCgDeviceIdentity) { + using display_device::mac_utils::CgDisplayInfo; + using display_device::mac_utils::makeCgDeviceIdentity; + + // A unique serial: the identity survives the display id and unit number changing (reconnects, + // virtual displays being recreated). + const CgDisplayInfo virtual_display {9, 22084, 1, 1398099505, 2}; + const CgDisplayInfo recreated {30, 22084, 1, 1398099505, 3}; + const CgDisplayInfo other_panel {1, 1552, 41007, 7, 0}; + EXPECT_EQ(makeCgDeviceIdentity(virtual_display, {virtual_display, other_panel}), "vendor=22084;model=1;serial=1398099505"); + EXPECT_EQ(makeCgDeviceIdentity(virtual_display, {virtual_display}), makeCgDeviceIdentity(recreated, {recreated})); + + // No usable serial (0, or Apple's 0xFFFFFFFF exception value): the display id and unit number + // are all that tell identical displays apart. + for (const auto serial : {0U, 0xFFFFFFFFU}) { + const CgDisplayInfo first {1, 1552, 41007, serial, 0}; + const CgDisplayInfo second {2, 1552, 41007, serial, 1}; + EXPECT_EQ(makeCgDeviceIdentity(first, {first}), std::format("vendor=1552;model=41007;serial={};unit=0;display=1", serial)); + EXPECT_NE(makeCgDeviceIdentity(first, {first, second}), makeCgDeviceIdentity(second, {first, second})); + } + + // Two online displays reporting the same vendor, model and serial keep distinct identities. + const CgDisplayInfo twin_a {4, 1552, 41007, 16843009, 0}; + const CgDisplayInfo twin_b {5, 1552, 41007, 16843009, 1}; + EXPECT_EQ(makeCgDeviceIdentity(twin_a, {twin_a, twin_b}), "vendor=1552;model=41007;serial=16843009;unit=0;display=4"); + EXPECT_NE(makeCgDeviceIdentity(twin_a, {twin_a, twin_b}), makeCgDeviceIdentity(twin_b, {twin_a, twin_b})); + // Once the twin is gone, the remaining display gets the stable identity again. + EXPECT_EQ(makeCgDeviceIdentity(twin_a, {twin_a}), "vendor=1552;model=41007;serial=16843009"); +} + +TEST_S(MakeCgDeviceIdentityAlias) { + using display_device::mac_utils::CgDisplayInfo; + using display_device::mac_utils::makeCgDeviceIdentity; + using display_device::mac_utils::makeCgDeviceIdentityAlias; + + const CgDisplayInfo twin_a {4, 1552, 41007, 16843009, 0}; + const CgDisplayInfo twin_b {5, 1552, 41007, 16843009, 1}; + + // A saved alone, then B plugged in: A's saved id becomes its alias, and B has the same alias. + const auto saved_alone {makeCgDeviceIdentity(twin_a, {twin_a})}; + EXPECT_EQ(makeCgDeviceIdentityAlias(twin_a, {twin_a, twin_b}), saved_alone); + EXPECT_EQ(makeCgDeviceIdentityAlias(twin_b, {twin_a, twin_b}), saved_alone); + + // A saved with B online, then B unplugged (A keeps its display id and unit): A's saved id becomes + // its alias, which only A has. + const auto saved_with_twin {makeCgDeviceIdentity(twin_a, {twin_a, twin_b})}; + EXPECT_EQ(makeCgDeviceIdentityAlias(twin_a, {twin_a}), saved_with_twin); + EXPECT_NE(makeCgDeviceIdentityAlias(twin_b, {twin_b}), saved_with_twin); + + // No usable serial: only one form. + for (const auto serial : {0U, 0xFFFFFFFFU}) { + const CgDisplayInfo display {1, 1552, 41007, serial, 0}; + EXPECT_EQ(makeCgDeviceIdentityAlias(display, {display}), std::nullopt); + } +} diff --git a/tests/unit/macos/test_mac_display_device.cpp b/tests/unit/macos/test_mac_display_device.cpp index 0d9e31a..2b8adca 100644 --- a/tests/unit/macos/test_mac_display_device.cpp +++ b/tests/unit/macos/test_mac_display_device.cpp @@ -204,6 +204,40 @@ TEST_F_S(EnumAvailableDevices) { EXPECT_EQ(m_mac_dd.enumAvailableDevices(), expected_list); } +TEST_F_S(EnumAvailableDevices, IdenticalSerialsStayDistinct) { + // Two fallback displays that report the same vendor, model and serial (e.g. two identical panels + // with a fixed serial) must both be listed, and each id must resolve to its own display. + using display_device::mac_utils::CgDisplayInfo; + const CgDisplayInfo twin_a {1, 1552, 41007, 16843009, 0}; + const CgDisplayInfo twin_b {2, 1552, 41007, 16843009, 1}; + const std::string id_a {display_device::mac_utils::makeCgDeviceIdentity(twin_a, {twin_a, twin_b})}; + const std::string id_b {display_device::mac_utils::makeCgDeviceIdentity(twin_b, {twin_a, twin_b})}; + + EXPECT_CALL(*m_layer, getDisplayIds(display_device::MacQueryType::Online)) + .WillRepeatedly(Return(display_device::MacDisplayIdList {1, 2})); + EXPECT_CALL(*m_layer, getDeviceId(1)) + .WillRepeatedly(Return(id_a)); + EXPECT_CALL(*m_layer, getDeviceId(2)) + .WillRepeatedly(Return(id_b)); + EXPECT_CALL(*m_layer, getDisplayName(1)) + .WillRepeatedly(Return("1")); + EXPECT_CALL(*m_layer, getDisplayName(2)) + .WillRepeatedly(Return("2")); + EXPECT_CALL(*m_layer, getFriendlyName(::testing::_)) + .WillRepeatedly(Return("Panel")); + EXPECT_CALL(*m_layer, getEdid(::testing::_)) + .WillRepeatedly(Return(std::vector {})); + EXPECT_CALL(*m_layer, isActive(::testing::_)) + .WillRepeatedly(Return(false)); + + const auto devices {m_mac_dd.enumAvailableDevices()}; + ASSERT_EQ(devices.size(), 2); + EXPECT_EQ(devices[0].m_device_id, id_a); + EXPECT_EQ(devices[1].m_device_id, id_b); + EXPECT_EQ(m_mac_dd.getDisplayName(id_a), "1"); + EXPECT_EQ(m_mac_dd.getDisplayName(id_b), "2"); +} + TEST_F_S(GetDisplayName) { EXPECT_CALL(*m_layer, getDisplayIds(display_device::MacQueryType::Online)) .Times(1) @@ -228,10 +262,60 @@ TEST_F_S(GetDisplayNameUnknownDevice) { EXPECT_CALL(*m_layer, getDeviceId(1)) .Times(1) .WillOnce(Return("DeviceId1")); + EXPECT_CALL(*m_layer, getDeviceIdAlias(1)) + .Times(1) + .WillOnce(Return("")); EXPECT_EQ(m_mac_dd.getDisplayName("DeviceId2"), ""); } +TEST_F_S(GetDisplayName, ResolvesUniqueAlias) { + // Saved while a twin was online; the twin has since been unplugged, so the display's current id + // is the serial-only one and the saved id is its alias. + EXPECT_CALL(*m_layer, getDisplayIds(display_device::MacQueryType::Online)) + .Times(1) + .WillOnce(Return(display_device::MacDisplayIdList {1, 2})); + EXPECT_CALL(*m_layer, getDeviceId(1)) + .Times(1) + .WillOnce(Return("SerialId1")); + EXPECT_CALL(*m_layer, getDeviceId(2)) + .Times(1) + .WillOnce(Return("DeviceId2")); + EXPECT_CALL(*m_layer, getDeviceIdAlias(1)) + .Times(1) + .WillOnce(Return("QualifiedId1")); + EXPECT_CALL(*m_layer, getDeviceIdAlias(2)) + .Times(1) + .WillOnce(Return("")); + EXPECT_CALL(*m_layer, getDisplayName(1)) + .Times(1) + .WillOnce(Return("1")); + + EXPECT_EQ(m_mac_dd.getDisplayName("QualifiedId1"), "1"); +} + +TEST_F_S(GetDisplayName, AmbiguousAliasUnresolved) { + // Saved while the display was the only one with its serial; an identical twin has since been + // plugged in, so both now have the saved serial-only id as their alias. Neither may be picked. + EXPECT_CALL(*m_layer, getDisplayIds(display_device::MacQueryType::Online)) + .Times(1) + .WillOnce(Return(display_device::MacDisplayIdList {1, 2})); + EXPECT_CALL(*m_layer, getDeviceId(1)) + .Times(1) + .WillOnce(Return("QualifiedId1")); + EXPECT_CALL(*m_layer, getDeviceId(2)) + .Times(1) + .WillOnce(Return("QualifiedId2")); + EXPECT_CALL(*m_layer, getDeviceIdAlias(1)) + .Times(1) + .WillOnce(Return("SerialId")); + EXPECT_CALL(*m_layer, getDeviceIdAlias(2)) + .Times(1) + .WillOnce(Return("SerialId")); + + EXPECT_EQ(m_mac_dd.getDisplayName("SerialId"), ""); +} + TEST_F_S(TopologyRead) { EXPECT_CALL(*m_layer, getDisplayIds(display_device::MacQueryType::Active)) .Times(1) @@ -314,6 +398,19 @@ TEST_F_S(SetDisplayModes, EmptyModes) { TEST_F_S(SetDisplayModes, InactiveDisplay) { Sequence sequence; expectActiveDeviceLookup(sequence, "DeviceId2"); + EXPECT_CALL(*m_layer, getDisplayIds(display_device::MacQueryType::Online)) + .Times(1) + .InSequence(sequence) + .WillOnce(Return(display_device::MacDisplayIdList {1, 2})); + EXPECT_CALL(*m_layer, getDeviceIdAlias(1)) + .Times(1) + .InSequence(sequence) + .WillOnce(Return("")); + // The id is the alias of an online display that isn't active, so it must not resolve. + EXPECT_CALL(*m_layer, getDeviceIdAlias(2)) + .Times(1) + .InSequence(sequence) + .WillOnce(Return("DeviceId1")); EXPECT_FALSE(m_mac_dd.setDisplayModes({{"DeviceId1", {{1920, 1080}, {60, 1}}}})); } diff --git a/tests/unit/macos/utils/mock_mac_api_layer.h b/tests/unit/macos/utils/mock_mac_api_layer.h index 37f86d8..ef8aed1 100644 --- a/tests/unit/macos/utils/mock_mac_api_layer.h +++ b/tests/unit/macos/utils/mock_mac_api_layer.h @@ -16,6 +16,7 @@ namespace display_device { MOCK_METHOD(std::optional, createDisplaySleepAssertion, (const std::string &), (override)); MOCK_METHOD(bool, releasePowerAssertion, (MacPowerAssertionId), (override)); MOCK_METHOD(std::string, getDeviceId, (MacDisplayId), (const, override)); + MOCK_METHOD(std::string, getDeviceIdAlias, (MacDisplayId), (const, override)); MOCK_METHOD(std::optional, getCurrentDisplayMode, (MacDisplayId), (const, override)); MOCK_METHOD(MacDisplayModeList, getDisplayModes, (MacDisplayId), (const, override)); MOCK_METHOD(std::string, getDisplayName, (MacDisplayId), (const, override));