summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-11-15 11:24:59 -0500
committerTim Flynn <trflynn89@pm.me>2022-11-15 13:25:51 -0500
commit05f41382bb527fbf2bb47340ad065b36f2e7409f (patch)
tree3da51238f398d92fc289351837cd26699bdad21f /Userland/Services
parentb1ea418d14b4392741720914b834c61322cdb5b4 (diff)
downloadserenity-05f41382bb527fbf2bb47340ad065b36f2e7409f.zip
Userland: Properly define IPC::encode and IPC::decode specializations
In order to avoid the base encode/decode methods from being used (and failing a static assertion), we must be sure to declare/define the custom type implementations as template specializations. After this, LibIPC is no longer sensitive to include order.
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/WindowServer/ScreenLayout.h7
-rw-r--r--Userland/Services/WindowServer/ScreenLayout.ipp8
2 files changed, 13 insertions, 2 deletions
diff --git a/Userland/Services/WindowServer/ScreenLayout.h b/Userland/Services/WindowServer/ScreenLayout.h
index c4d7bd92b2..132794d78d 100644
--- a/Userland/Services/WindowServer/ScreenLayout.h
+++ b/Userland/Services/WindowServer/ScreenLayout.h
@@ -73,9 +73,16 @@ public:
namespace IPC {
+template<>
bool encode(Encoder&, WindowServer::ScreenLayout::Screen const&);
+
+template<>
ErrorOr<void> decode(Decoder&, WindowServer::ScreenLayout::Screen&);
+
+template<>
bool encode(Encoder&, WindowServer::ScreenLayout const&);
+
+template<>
ErrorOr<void> decode(Decoder&, WindowServer::ScreenLayout&);
}
diff --git a/Userland/Services/WindowServer/ScreenLayout.ipp b/Userland/Services/WindowServer/ScreenLayout.ipp
index 65d950d3c2..476c630d17 100644
--- a/Userland/Services/WindowServer/ScreenLayout.ipp
+++ b/Userland/Services/WindowServer/ScreenLayout.ipp
@@ -394,12 +394,14 @@ bool ScreenLayout::try_auto_add_display_connector(String const& device_path)
namespace IPC {
-bool encode(Encoder& encoder, const WindowServer::ScreenLayout::Screen& screen)
+template<>
+bool encode(Encoder& encoder, WindowServer::ScreenLayout::Screen const& screen)
{
encoder << screen.mode << screen.device << screen.location << screen.resolution << screen.scale_factor;
return true;
}
+template<>
ErrorOr<void> decode(Decoder& decoder, WindowServer::ScreenLayout::Screen& screen)
{
WindowServer::ScreenLayout::Screen::Mode mode;
@@ -416,12 +418,14 @@ ErrorOr<void> decode(Decoder& decoder, WindowServer::ScreenLayout::Screen& scree
return {};
}
-bool encode(Encoder& encoder, const WindowServer::ScreenLayout& screen_layout)
+template<>
+bool encode(Encoder& encoder, WindowServer::ScreenLayout const& screen_layout)
{
encoder << screen_layout.screens << screen_layout.main_screen_index;
return true;
}
+template<>
ErrorOr<void> decode(Decoder& decoder, WindowServer::ScreenLayout& screen_layout)
{
Vector<WindowServer::ScreenLayout::Screen> screens;