mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 09:59:44 +00:00
Fix the engine window frame on windows
Four things came out of testing on windows. The window settings were hidden outside of wayland because the check used the backend name, while the bar height matters wherever the engine draws the frame. The window now reports that (hasEngineFrame: barEnabled on wayland, engineFrame on glfw) and the display page asks for it. Only the live resize switch stays wayland specific, since the glfw backend always draws a fresh frame. The simplified mode is gone: when the frame is active and the surface has alpha, the shadow and the outer resize border are always there. The bar and its controls are drawn even when the font is missing: the early return used to make the whole bar invisible while its hit zones kept working. GLFW rewrites the window style on every mode change and dropped the thick frame the native resize border and snapping need, so the frame is set up again after such a change. Windows runs a modal loop while a window border is dragged and the main loop is blocked inside it, which froze the content during a resize. The backend draws and presents a frame from the refresh callback now, and skips the framerate limit there.
This commit is contained in:
parent
4bc81af726
commit
68d4214627
11 changed files with 96 additions and 52 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <glm/glm.hpp>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -72,6 +73,29 @@ public:
|
|||
return empty;
|
||||
}
|
||||
|
||||
/// @brief Whether the engine draws the window frame itself here
|
||||
///
|
||||
/// The bar height and its buttons only mean something when it does, and
|
||||
/// the window settings are only shown where that is the case.
|
||||
/// @brief Handler the windowing system calls when it wants a repaint
|
||||
///
|
||||
/// Windows runs a modal loop while the user drags a window border and the
|
||||
/// main loop is blocked inside it, so the only way to keep the content
|
||||
/// alive during such a resize is to draw a frame from the message loop.
|
||||
using RefreshHandler = std::function<void()>;
|
||||
|
||||
void setRefreshHandler(RefreshHandler handler) {
|
||||
refreshHandler = std::move(handler);
|
||||
}
|
||||
|
||||
const RefreshHandler& getRefreshHandler() const {
|
||||
return refreshHandler;
|
||||
}
|
||||
|
||||
virtual bool hasEngineFrame() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual const char* getBackendName() const = 0;
|
||||
|
||||
virtual int getDecorationHeight() const {
|
||||
|
|
@ -118,6 +142,7 @@ protected:
|
|||
std::stack<glm::vec4> scissorStack;
|
||||
glm::vec4 scissorArea {};
|
||||
WindowMode mode = WindowMode::WINDOWED;
|
||||
RefreshHandler refreshHandler;
|
||||
};
|
||||
|
||||
namespace display {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue