Hud scripts update the first-person hand skeleton, blockwraps and
animations in on_hud_render, which ran after renderFrame, so these
changes were drawn one frame late. With fast camera rotation the hand
visibly lagged and jittered behind the view.
Windows leaves a strip of the native frame behind when WM_NCCALCSIZE
returns without correcting the rectangle it proposes, and that strip stays
black because nothing paints it. The client area is now set to the window
rectangle explicitly, the resize borders still come from WS_THICKFRAME and
from the frame hit test.
WM_SIZE also carries the new client size, which the platform may not have
reported to the engine yet. The frame used to be drawn for the previous
size and was then skipped by the one frame per size check, so the window
seemed to change its size only after the drag was over. The size is passed
to the refresh callback and applied before the frame is drawn.
Install the Wayland development packages in both workflows and bundle the
runtime libraries in the AppImage: the release build had no native Wayland
backend at all, and the engine silently fell back to GLFW there.
Build the window backends on every platform that is not Windows and not
Apple, glob the wayland sources with CONFIGURE_DEPENDS, and report a
missing Wayland dependency with the list of what is missing.
Also drop the dead nested project() calls and the duplicate -no-pie
option, make .dirIcon the file appimagetool expects, and describe the
real Linux dependencies in the README.
The engine draws the window bar on top of the GUI, so a frame as high as
the window lost its top to the bar. GUI::act() limits such a frame to the
content area and places it right below the bar; frames that are smaller
than the window are not touched.
Use util::str2wstr_utf8 for the window title instead of the deprecated
codecvt conversion, choose the bar control icon with a switch, and keep
the frontend layout in sync when a frame is drawn from the refresh
callback the platform calls while it blocks the main loop.
The frame forgets its interaction state when the window mode changes or
the cursor gets locked, a bar click that only moved the window is no
longer a double click, and one frame per size is drawn per resize.
The tooltips of the two window settings were only present in the Russian
locale and under a key the settings page never asks for: they are named
display.<id>.tooltip now and translated in both locales. The version label
of the debug build moves below the bar that covers the menu screen.
Report the errors the display read loop can fail with instead of
dispatching events on a dead connection, and release exactly the keys the
user really holds: BaseInput::pressedKeys is never erased, so the previous
list sent key releases for keys that were never pressed.
The bar is the only owner of the pointer edges now, the fullscreen state
comes from the compositor, and the decorations are enabled once, with the
window geometry published again. The initialization failure paths destroy
their resources exactly once, the screen state is reset on teardown, the
clipboard write does not block the frame loop on a slow reader, and the
gsettings fallback is not retried after it failed.
The stretch blit of the last frame is gone: composeFrame() already paints
the cached content.
The refresh callback is triggered by WM_PAINT, but windows does not send it
while a border is dragged: the window class has neither CS_HREDRAW nor
CS_VREDRAW and nothing invalidates the client area. Only WM_SIZE arrives, so
nothing was drawn during such a resize. The frame is drawn from WM_SIZE now,
after forwarding the message to GLFW so that the new size is already in.
WM_NCHITTEST re-applies the style bits the engine frame needs and which GLFW
drops on every window mode change, taking the drag area with them. Every frame
setup logs whether the subclass had to be installed again, so a lost window
procedure is visible in the log.
The live resize switch is honoured by the GLFW backend as well: with it off the
frame from the message loop is skipped and the window keeps showing what the
system stretches.
They are vendored on purpose: they come from wayland-protocols rather than
libwayland, they are newer than the 1.25 of older distributions, and the build
has to work offline and from a source archive.
The frame is set up again after every window mode change, but it subclassed
the window procedure each time and stored our own procedure as the original
one. Every message we do not handle then went through CallWindowProc straight
back into ourselves: the window hung, and repaint messages were lost with it,
which is what broke the live rendering during a resize.
The subclass is installed once now, while the window style is still re-applied
on every mode change.
New windows are also placed at the center of the monitor work area instead of
the top left corner. This only happens where the platform lets the client place
its window, which wayland does not.
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.
MemoryDevice::lastWriteTime returns file_time_type::min(). Converting
it to the system clock overflows, and on Windows std::localtime returns
nullptr for the resulting time, which was dereferenced
(access violation in zip_files test on MSVC).
Unknown or out of range time is now written as 1980-01-01 00:00,
the earliest MS-DOS date.
glfw3native.h needs the GLFWmonitor, GLFWwindow and GLFWAPI declarations of
glfw3.h, so the windows build failed on the win32 branch. Only that branch
is affected: x11 resolves the GLFW accessors with dlsym and does not include
the native header at all.
The GUI sets the cursor of the hovered widget every frame, and over the
window that widget is usually the background with a plain arrow. The frame
sets its resize cursors on pointer motion, so the GUI replaced them on the
next frame: hovering a window edge did not show a resize cursor, it flickered
and stayed an arrow.
The window now reports whether the frame owns the cursor, and the GUI only
sets the hovered cursor when it does not. The GLFW backend claims it inside
the frame and gives it back in the client area together with the arrow, since
the GUI sets a cursor only while a widget is hovered.
Wayland keeps returning false, so the GUI behaves exactly as before there.
- create_zip from a subdirectory wrote entry names with a leading
'/', so the mounted archive looked empty
- memory_ostream did not support tellp(), so create_zip into a memory
device wrote invalid offsets (-1) to the archive
- ZipFileDevice added missing parent directories for the first entry
only
- ZipFileDevice::exists returned false for the archive root
- MemoryDevice::mkdirs recreated existing directories, dropping their
content (mkdir("a/b") cleared "a"); overwriting a file duplicated its
name in the directory listing
Added dev/tests/zip_files.lua: builds archives with file.create_zip
from memory device root, subdirectories and the real filesystem,
mounts them and checks reading, listing and read-only access.
memory_filesystem.lua got checks for the MemoryDevice issues.
Closes#544
frame_has_native_operations() trusted the X11 accessors of GLFW alone, but a
window manager that does not advertise _NET_WM_MOVERESIZE drops the request
silently: on a plain X11 session the frame asked it to move and resize the
window and nothing happened at all. The root window is checked for the atom
now, and the frame falls back to moving and resizing the window itself.
The resize edges also win over the bar instead of the bar swallowing its top
strip, which made the top edge and the top corners impossible to grab.
Both backends log the active path as
"engine window frame: on, window manager operations are on|off".
The engine already draws the bar on wayland; the GLFW backend now does the
same where the client may move its own window, and keeps the native frame
elsewhere: wayland forbids client side positioning, and macOS has its own
frame.
On windows the native frame is kept and only its caption is hidden, so the
thick frame, the shadow, the animations and the snap layouts keep working.
A window procedure returns HTCAPTION for the bar, HTCLIENT for the controls
and HT* for the edges. On x11 the window manager runs the interactive move
or resize (_NET_WM_MOVERESIZE), which keeps window snapping and tiling
native too. Where neither is available the frame moves and resizes the
window itself, as before.
The X11 accessors of GLFW are resolved with dlsym, so a wayland-only build
still links, and the window manager operations are only compiled in when
X11 is found.
The title of the window is stored on creation now: the bar draws it, and
the GLFW backend used to leave it empty.
VoxelWindowBase only got the src include directory, so BaseInput.cpp could
not find glm/vec2.hpp through window/input.hpp on macOS, where glm lives in
a prefix outside the default include path. VoxelGLFW had glm linked, which
hid the problem on Linux, where glm sits in /usr/include anyway.
The backends now link a single interface target carrying the engine sources
and the third-party headers their public headers pull in, instead of each
backend keeping its own list.
VoxelGLFW, VoxelWindowBase (the input state both backends share) and
VoxelWayland own their sources, dependencies and protocol generation,
while VoxelCoreSrc only sees the Window/Input interfaces and the
factories declared in detail/WindowBackends.hpp.
VOXELCORE_WAYLAND now only selects the subdirectory to add and the
library to link, and the wayland library defines the macro for whoever
links it, so linking the backend is what enables it. The protocol sources
are generated inside build/src/window/wayland, and missing dependencies
only turn the backend off instead of breaking the configuration.
axis_value120 (wl_pointer version 8) and axis_relative_direction (version
9) do not exist in the headers older distributions ship, which broke the
build on ubuntu 22.04.
They are not needed anyway: a pointer inherits the version of its seat,
which is bound at version 7 here, so the compositor cannot send those
events at all. The version cap now documents that the listener covers it
and that raising it requires handling the newer events too.
Without the shadow and the resize border composeFrame() only forced the
alpha channel, so the buffer the driver reallocated after a size change was
presented as it is, which showed up as a black frame on every resize step.
The content is now always painted from the cache and only the shadow itself
is skipped when there are no margins.
The setting is named simple-window and means the opposite of the previous
shadow-and-border: it is off by default, so the window keeps its shadow and
the outer border for resizing.
The frame the native wayland backend draws gets three switches in the
display tab: a narrow 24px bar instead of the 48px one, the shadow with
the outer resize area, and redrawing the content while the window is
resized (off keeps the previous behaviour of stretching the last frame).
The settings are applied at runtime: the bar geometry is rebuilt and the
surface is resized together with the toplevel geometry, no restart needed.
The narrow bar drops the insets and the gap of its controls, so that they
sit flush against the window edge.
The switches are hidden outside of the wayland backend, which reports its
name through Window::getBackendName().
Batch2D cached the bound texture and skipped the bind when the cache
matched, but the render pipeline binds textures of its own and leaves a
non-zero texture unit active. A rectangle drawn without a texture (the
hud hotbar background and slot tiles) was then modulated by whatever
texture was left bound, which made the hotbar darken for a single frame
on every window resize.
The batch now draws from texture unit 0 and compares the cached texture
with the actual binding instead of trusting the cache.
A review of the branch turned up a number of defects, gaps and leftovers;
this commit addresses all of them.
Defects:
- the shadow uniform array held seven entries while eight locations were
written, so the last one landed outside the object;
- CursorShape::LAST stayed in the middle of the enum after the new corner
shapes were appended, which made the GLFW cursor table read out of
bounds; the extra shapes are now mapped onto the ones GLFW knows, and
the table is only filled for those;
- GlStateGuard asked glIsEnabled for an attribute pname, so it always got
GL_INVALID_ENUM and never restored the vertex attribute arrays;
- the early returns in wayland_window_initialize left the global window
and input pointers dangling when falling back to GLFW;
- the icon textures were listed nowhere, so none of them ever loaded;
- a shader failure disabled the shadow after the surface had already been
sized for it, and VOXEL_DECORATIONS outlived the switch cleanup.
Behavior:
- the keyboard now releases every pressed key when it loses focus, and a
repeat rate of zero means no repeat;
- the fourth UTF-8 lead byte is decoded with the right mask, control
characters no longer reach text fields, and a vanished clipboard offer
clears the cached text;
- compositor side decorations disable ours again instead of leaving two
titles, the window destructor releases the rest of the state, and the
content inset is computed before the GUI acts so the HUD and the
container never disagree for a frame; the HUD clamps it;
- the window controls fall back to minimize, maximize and close, and the
icons are drawn from textures only.
Cleanups: one monotonic timer instead of three, one vertex shader shared
by both renderers with a link check, one button layout parser, the inset
rule moved into Screen, the scissor stack moved into the base Window
(about 110 duplicated lines), named shadow and evdev constants, trimmed
includes, a README note about the Wayland dependencies, and the long
lines introduced by this branch wrapped.
The engine-drawn title bar grew to 48 px with 24x24 window controls,
12 px away from the edge and from each other, all sharing one hover
highlight. The controls use textures now (gui/cross, gui/minimize_w,
gui/maximize_w and gui/restore_w when maximized) with the vector icons
kept as a fallback, and the title is centred in the bar, clamped to the
free space between the button groups.
The bar now sits inside invisible margins that carry a drop shadow, so
the window is resizable from outside the visible frame: the surface is
content plus twice SHADOW_MARGIN and xdg_surface.set_window_geometry
tells the compositor which part is the window. The shadow follows
Adwaita's window shadow: a Gaussian blur of 7 px (sigma 3.5) expanded by
1 px, rgba(0,0,0,0.5) focused and 0.3 in the backdrop, plus a 1 px
hairline, symmetric on all four sides - a 16 px wide frame would show a
fatter tail than the reference. Margins exist only while the window is
decorated by us and not maximized or fullscreen.
The engine composes the frame itself: it renders exactly as before, then
the backend copies the frame into a texture, clears the surface, draws
the shadow and puts the content in place with alpha forced to 1, which
keeps the frame opaque without touching a single render pass. Only
frames the engine actually drew are cached, and the EGL window is
resized before its surface size is asked for, so no frame is composed
from a buffer the compositor just replaced - that was the one frame
blink after a resize.
Resize cursors match GNOME: directional shapes for edges and corners
(w/e/n/s/ne/nw/se/sw) instead of the double-headed diagonals, with the
extra CursorShape values appended so the existing GLFW indices stay.
Measured: window 1123x751 opens as saved, fullscreen round trip returns
the same size with the settings untouched, the shadow alpha profile is
0.20/0.10/0.03 at 1/4/7 px from the edge against Adwaita's 0.21/0.095/
0.055, all four sides equal, menu layout baseline unchanged (706),
no errors in the log.
The native Wayland backend had no window controls: no title, no close
button, no way to move or resize the window, and the fullscreen toggle
could throw the window to another monitor. GNOME does not implement
zxdg_decoration_manager_v1, so there is nobody to draw a frame for us:
the backend now falls back to its own decorations when the compositor
offers no server side ones, and the engine draws the visible part.
The bar itself is drawn by the engine (WindowBar.cpp) through the usual
batch and font, so it uses the same assets as the rest of the UI and the
backend only owns the behaviour: hit zones, cursor shapes, click
interception and the xdg-shell requests. Its geometry follows the
desktop's button layout, read and subscribed through
xdg-desktop-portal over sd-bus (libsystemd is an optional dependency,
gsettings is only a startup fallback).
Controls behave like they do elsewhere:
- pressing anywhere on the bar starts a move once the pointer leaves a
5 px radius, so dragging works from the buttons as well;
- a button acts on release, only if the pointer stayed on it;
- a double click on the bar toggles maximize;
- the top edge and the top corners resize, the top 8 px of the sides,
the sides and the bottom are 8 px wide resize strips;
- right and middle clicks and the scroll wheel over the bar never reach
the game.
The in-game user interface is offset below the bar while menus keep the
whole window, so the translucent bar shows the menu background through
itself and never covers the HUD. The HUD lays its elements out against
the content height and the cursor is translated once, which fixes items
following the mouse one row above the pointer in game.
The window size is now written to the settings when the window is
resized in windowed mode and applied on the first configure, so the
window opens with the size it was left with, and leaving fullscreen or
borderless mode restores it instead of overwriting the settings with the
fullscreen size (an unconditional unmaximize made the compositor restore
the maximized geometry).
Measured: menu layout unchanged (706 bright pixels in the same place),
gui viewport 1123x751 in menus against 1123x721 in game, 1123x751 ->
2560x1080 -> 1123x751 round trip keeps the settings, a saved 1000x640
opens as 1000x640, no errors in the log.