12 #ifndef GLVIS_SDL_MAIN_HPP
13 #define GLVIS_SDL_MAIN_HPP
16 #include <condition_variable>
23 using Handle = SdlWindow::Handle;
45 int x,
int y,
int w,
int h,
bool legacyGlOnly);
63 struct CreateWindowCmd;
64 struct SdlCtrlCommand;
79 std::unique_lock<std::mutex> platform_lk{event_mtx};
80 event_cv.wait(platform_lk, [
this]() {
return try_create_platform; });
83 platform->SendEvent();
87 void queueWindowEvent(SdlCtrlCommand cmd,
bool sync =
false);
90 Uint32 getWindowID(
const T& eventStruct)
92 return eventStruct.windowID;
95 void setWindowIcon(SDL_Window* hwnd);
97 void handleWindowCmdImpl(SdlCtrlCommand& cmd);
101 void probeGLContextSupport(
bool legacyGlOnly);
103 void getDpi(
const Handle& handle,
int& wdpi,
int& hdpi);
105 void createWindowImpl(CreateWindowCmd& cmd);
107 void handleBackgroundWindowEvent(SDL_WindowEvent e);
109 bool sdl_init {
false};
110 bool sdl_multithread {
true};
112 bool server_mode {
false};
115 bool terminating {
false};
116 unique_ptr<SDL_Window, decltype(&SDL_DestroyWindow)> bg_wnd{
nullptr, SDL_DestroyWindow};
122 mutex window_cmd_mtx;
123 vector<SdlCtrlCommand> window_cmds;
125 int num_windows {-1};
131 unordered_map<int, SdlWindow*> hwnd_to_window;
132 unordered_map<int, vector<SDL_Event>> wnd_events;
133 std::set<SDL_FingerID> fingers;
134 bool disable_mouse {
false};
139 condition_variable event_cv;
140 bool try_create_platform{
false};
141 unique_ptr<SdlNativePlatform> platform;
143 int title_height_offset {0};
thread_local SdlWindow * wnd
void SetWindowTitle(const Handle &handle, std::string title)
SdlNativePlatform * GetPlatform() const
Handle GetHandle(SdlWindow *wnd, const std::string &title, int x, int y, int w, int h, bool legacyGlOnly)
void MainLoop(bool server_mode)
void SetWindowPosition(const Handle &handle, int x, int y)
bool SdlInitialized() const
void DeleteHandle(Handle to_delete)
void SetWindowSize(const Handle &handle, int w, int h)