diff --git a/examples/common/entry/entry.h b/examples/common/entry/entry.h index d629b8b87..2fce44f47 100644 --- a/examples/common/entry/entry.h +++ b/examples/common/entry/entry.h @@ -252,7 +252,7 @@ namespace entry void setWindowPos(WindowHandle _handle, int32_t _x, int32_t _y); void setWindowSize(WindowHandle _handle, uint32_t _width, uint32_t _height); void setWindowTitle(WindowHandle _handle, const char* _title); - void toggleWindowFrame(WindowHandle _handle); + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled); void toggleFullscreen(WindowHandle _handle); void setMouseLock(WindowHandle _handle, bool _lock); void setCurrentDir(const char* _dir); diff --git a/examples/common/entry/entry_android.cpp b/examples/common/entry/entry_android.cpp index 1bcb7f11c..644ed4aca 100644 --- a/examples/common/entry/entry_android.cpp +++ b/examples/common/entry/entry_android.cpp @@ -535,9 +535,9 @@ namespace entry BX_UNUSED(_handle, _title); } - void toggleWindowFrame(WindowHandle _handle) + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) { - BX_UNUSED(_handle); + BX_UNUSED(_handle, _flags, _enabled); } void toggleFullscreen(WindowHandle _handle) diff --git a/examples/common/entry/entry_asmjs.cpp b/examples/common/entry/entry_asmjs.cpp index 7188dee85..4434e41c9 100644 --- a/examples/common/entry/entry_asmjs.cpp +++ b/examples/common/entry/entry_asmjs.cpp @@ -381,9 +381,9 @@ namespace entry BX_UNUSED(_handle, _title); } - void toggleWindowFrame(WindowHandle _handle) + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) { - BX_UNUSED(_handle); + BX_UNUSED(_handle, _flags, _enabled); } void toggleFullscreen(WindowHandle _handle) diff --git a/examples/common/entry/entry_glfw.cpp b/examples/common/entry/entry_glfw.cpp index 423afc6ca..27f602053 100644 --- a/examples/common/entry/entry_glfw.cpp +++ b/examples/common/entry/entry_glfw.cpp @@ -813,12 +813,9 @@ namespace entry glfwPostEmptyEvent(); } - void toggleWindowFrame(WindowHandle _handle) + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) { - Msg* msg = new Msg(GLFW_WINDOW_TOGGLE_FRAME); - msg->m_handle = _handle; - s_ctx.m_msgs.push(msg); - glfwPostEmptyEvent(); + BX_UNUSED(_handle, _flags, _enabled); } void toggleFullscreen(WindowHandle _handle) diff --git a/examples/common/entry/entry_ios.mm b/examples/common/entry/entry_ios.mm index d6420aeaa..569e99f51 100644 --- a/examples/common/entry/entry_ios.mm +++ b/examples/common/entry/entry_ios.mm @@ -130,9 +130,9 @@ namespace entry BX_UNUSED(_handle, _title); } - void toggleWindowFrame(WindowHandle _handle) + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) { - BX_UNUSED(_handle); + BX_UNUSED(_handle, _flags, _enabled); } void toggleFullscreen(WindowHandle _handle) diff --git a/examples/common/entry/entry_noop.cpp b/examples/common/entry/entry_noop.cpp index 0f81bde8d..098f1ae19 100644 --- a/examples/common/entry/entry_noop.cpp +++ b/examples/common/entry/entry_noop.cpp @@ -52,9 +52,9 @@ namespace entry BX_UNUSED(_handle, _title); } - void toggleWindowFrame(WindowHandle _handle) + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) { - BX_UNUSED(_handle); + BX_UNUSED(_handle, _flags, _enabled); } void toggleFullscreen(WindowHandle _handle) diff --git a/examples/common/entry/entry_osx.mm b/examples/common/entry/entry_osx.mm index 7675b9f55..015ebf453 100644 --- a/examples/common/entry/entry_osx.mm +++ b/examples/common/entry/entry_osx.mm @@ -593,16 +593,9 @@ namespace entry } } - void toggleWindowFrame(WindowHandle _handle) + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) { - if (s_ctx.isValid(_handle) ) - { - s_ctx.m_style ^= NSTitledWindowMask; - dispatch_async(dispatch_get_main_queue() - , ^{ - [s_ctx.m_window[_handle.idx] setStyleMask: s_ctx.m_style]; - }); - } + BX_UNUSED(_handle, _flags, _enabled); } void toggleFullscreen(WindowHandle _handle) diff --git a/examples/common/entry/entry_sdl.cpp b/examples/common/entry/entry_sdl.cpp index 89c63b6b9..e1a891d80 100644 --- a/examples/common/entry/entry_sdl.cpp +++ b/examples/common/entry/entry_sdl.cpp @@ -281,6 +281,7 @@ namespace entry , m_width(0) , m_height(0) , m_flags(0) + , m_flagsEnabled(false) { } @@ -290,6 +291,7 @@ namespace entry uint32_t m_height; uint32_t m_flags; tinystl::string m_title; + bool m_flagsEnabled; }; static uint32_t s_userEventStart; @@ -299,6 +301,7 @@ namespace entry SDL_USER_WINDOW_CREATE, SDL_USER_WINDOW_DESTROY, SDL_USER_WINDOW_SET_TITLE, + SDL_USER_WINDOW_SET_FLAGS, SDL_USER_WINDOW_SET_POS, SDL_USER_WINDOW_SET_SIZE, SDL_USER_WINDOW_TOGGLE_FRAME, @@ -859,6 +862,23 @@ namespace entry } break; + case SDL_USER_WINDOW_SET_FLAGS: + { + Msg* msg = (Msg*)_lparam; + + if (msg->m_flagsEnabled) + { + m_flags[_wparam] |= msg->m_flags; + } + else + { + m_flags[_wparam] &= ~msg->m_flags; + } + + delete msg; + } + break; + case SDL_USER_WINDOW_SET_POS: { WindowHandle handle = getWindowHandle(uev); @@ -1075,9 +1095,12 @@ namespace entry sdlPostEvent(SDL_USER_WINDOW_SET_TITLE, _handle, msg); } - void toggleWindowFrame(WindowHandle _handle) + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) { - sdlPostEvent(SDL_USER_WINDOW_TOGGLE_FRAME, _handle); + Msg* msg = new Msg; + msg->m_flags = _flags; + msg->m_flagsEnabled = _enabled; + sdlPostEvent(SDL_USER_WINDOW_SET_FLAGS, _handle, msg); } void toggleFullscreen(WindowHandle _handle) diff --git a/examples/common/entry/entry_windows.cpp b/examples/common/entry/entry_windows.cpp index 864fb5387..b69745093 100644 --- a/examples/common/entry/entry_windows.cpp +++ b/examples/common/entry/entry_windows.cpp @@ -266,6 +266,7 @@ namespace entry WM_USER_WINDOW_CREATE = WM_USER, WM_USER_WINDOW_DESTROY, WM_USER_WINDOW_SET_TITLE, + WM_USER_WINDOW_SET_FLAGS, WM_USER_WINDOW_SET_POS, WM_USER_WINDOW_SET_SIZE, WM_USER_WINDOW_TOGGLE_FRAME, @@ -324,6 +325,7 @@ namespace entry , m_width(0) , m_height(0) , m_flags(0) + , m_flagsEnabled(false) { } @@ -333,6 +335,7 @@ namespace entry uint32_t m_height; uint32_t m_flags; tinystl::string m_title; + bool m_flagsEnabled; }; static void mouseCapture(HWND _hwnd, bool _capture) @@ -590,6 +593,23 @@ namespace entry } break; + case WM_USER_WINDOW_SET_FLAGS: + { + Msg* msg = (Msg*)_lparam; + + if (msg->m_flagsEnabled) + { + m_flags[_wparam] |= msg->m_flags; + } + else + { + m_flags[_wparam] &= ~msg->m_flags; + } + + delete msg; + } + break; + case WM_USER_WINDOW_SET_POS: { Msg* msg = (Msg*)_lparam; @@ -1081,9 +1101,12 @@ namespace entry PostMessage(s_ctx.m_hwnd[0], WM_USER_WINDOW_SET_TITLE, _handle.idx, (LPARAM)msg); } - void toggleWindowFrame(WindowHandle _handle) + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) { - PostMessage(s_ctx.m_hwnd[0], WM_USER_WINDOW_TOGGLE_FRAME, _handle.idx, 0); + Msg* msg = new Msg; + msg->m_flags = _flags; + msg->m_flagsEnabled = _enabled; + PostMessage(s_ctx.m_hwnd[0], WM_USER_WINDOW_SET_FLAGS, _handle.idx, (LPARAM)msg); } void toggleFullscreen(WindowHandle _handle) diff --git a/examples/common/entry/entry_winrt.cx b/examples/common/entry/entry_winrt.cx index 53bfe29ce..7e764a695 100644 --- a/examples/common/entry/entry_winrt.cx +++ b/examples/common/entry/entry_winrt.cx @@ -209,9 +209,9 @@ namespace entry BX_UNUSED(_handle, _title); } - void toggleWindowFrame(WindowHandle _handle) + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) { - BX_UNUSED(_handle); + BX_UNUSED(_handle, _flags, _enabled); } void toggleFullscreen(WindowHandle _handle) diff --git a/examples/common/entry/entry_x11.cpp b/examples/common/entry/entry_x11.cpp index d3da47710..155c4dd60 100644 --- a/examples/common/entry/entry_x11.cpp +++ b/examples/common/entry/entry_x11.cpp @@ -758,9 +758,9 @@ namespace entry XStoreName(display, window, _title); } - void toggleWindowFrame(WindowHandle _handle) + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) { - BX_UNUSED(_handle); + BX_UNUSED(_handle, _flags, _enabled); } void toggleFullscreen(WindowHandle _handle) diff --git a/tools/texturev/texturev.cpp b/tools/texturev/texturev.cpp index 0848b08cf..f395d11a9 100644 --- a/tools/texturev/texturev.cpp +++ b/tools/texturev/texturev.cpp @@ -1145,6 +1145,8 @@ int _main_(int _argc, char** _argv) View view; cmdAdd("view", cmdView, &view); + entry::setWindowFlags(entry::WindowHandle{0}, ENTRY_WINDOW_FLAG_ASPECT_RATIO, false); + bgfx::init(); bgfx::reset(width, height, reset);