platform_misc.h (1000B)
1 // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com> 2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) 3 4 #include "window_info.h" 5 6 #include <optional> 7 8 class Error; 9 10 namespace PlatformMisc { 11 bool InitializeSocketSupport(Error* error); 12 void SuspendScreensaver(); 13 void ResumeScreensaver(); 14 15 /// Returns the size of pages for the current host. 16 size_t GetRuntimePageSize(); 17 18 /// Abstracts platform-specific code for asynchronously playing a sound. 19 /// On Windows, this will use PlaySound(). On Linux, it will shell out to aplay. On MacOS, it uses NSSound. 20 bool PlaySoundAsync(const char* path); 21 } // namespace PlatformMisc 22 23 namespace Host { 24 /// Return the current window handle. Needed for DInput. 25 std::optional<WindowInfo> GetTopLevelWindowInfo(); 26 } // namespace Host 27 28 // TODO: Move all the other Cocoa stuff in here. 29 namespace CocoaTools { 30 /// Returns the refresh rate of the display the window is placed on. 31 std::optional<float> GetViewRefreshRate(const WindowInfo& wi); 32 }