Commit graph

41 commits

Author SHA1 Message Date
alexei-zebra
b5416d1219
Fix the issues found while reviewing the Wayland frame work
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.
2026-10-10 12:23:42 +03:00
alexei-zebra
6c2192b5d8
Draw the window title bar by the engine
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.
2026-10-10 12:23:41 +03:00
alexei-zebra
14fa7e5fd2
fix building without the Wayland backend
The backend sources live in window/wayland and were picked up by the
global source glob, so a build with VOXELENGINE_WAYLAND=OFF (and any
non-Linux build, where the option is skipped entirely) tried to compile
them and failed on the generated protocol headers.

They are now collected separately and added to the target only when the
backend is enabled.

Also restores the CRLF line endings of Engine.cpp, GUI.hpp and
input.cpp, which were rewritten with LF and made their diffs look like
whole-file rewrites.
2026-10-10 12:23:31 +03:00
alexei-zebra
3b337241f5
draw window decorations with the engine GUI
The bar used to be drawn by the Wayland backend with its own shader,
bitmap font and textures, straight into the engine's GL frame. That
leaked GL state (the batch caches bound textures, so the engine kept
sampling the backend texture and all text turned into solid white
rectangles) and it duplicated fonts and styling.

Now the backend only owns the behaviour: hit zones, cursor shapes,
click interception and the compositor requests (move, resize,
minimize, maximize/restore, close). The bar itself is drawn by the
engine in WindowBar.cpp through the regular Batch2D/Font path, so it
looks like the rest of the UI.

Window gained getTitle(), getDecorationHeight() and
getDecorationHoveredButton(); GLFW keeps the defaults, so X11 and
Windows are unaffected. The backend's decoration drawing (bitmap font,
shader, quad batches) is removed: WaylandBar.cpp went from 630 to 140
lines.

Fixes found while debugging:
- GlStateGuard was defined but never used after the file split, so the
  stretched frame left its texture bound and broke text rendering after
  a window mode change; it is now applied around the cache capture and
  the stretched frame;
- takeScreenshot() now reads the front buffer and restores the read
  buffer afterwards.
2026-10-10 12:23:18 +03:00
MihailRis
69edfc8c8a add 'frame' argument to gui.screenshot 2026-09-17 22:07:18 +03:00
MihailRis
9fa6070cce fix: temporary focus fix 2026-08-09 21:26:30 +03:00
MihailRis
239ada8e3d add cursorLocator argument to gui.set_active_frame 2026-02-06 18:05:21 +03:00
MihailRis
8468ab184d add gui.get_active_frame, set_active_frame & update cursor lock behavior 2026-02-06 14:16:30 +03:00
MihailRis
463098aa1e add gui.create_frame 2026-02-04 13:10:49 +03:00
MihailRis
37350a10be remove pages loader from GUI class 2026-01-07 01:36:41 +03:00
MihailRis
55e4e6de02 fix hover elements lifetime 2025-12-15 21:43:04 +03:00
MihailRis
78e0ac5a95 add 'onmouseenter', 'onmouseleave' ui events 2025-12-10 20:03:41 +03:00
MihailRis
50f6c48771 add gui.set_syntax_styles 2025-11-23 18:10:06 +03:00
MihailRis
0a02d3fbec add on_screen_change project script event & fix UIDocument::rebuildIndices & move menu background to project script 2025-08-07 22:14:52 +03:00
MihailRis
0042dbfb3d refactor 2025-06-28 02:16:53 +03:00
MihailRis
71d3756902 add iframe ui element 2025-04-19 18:31:12 +03:00
MihailRis
5253be6c56 feat: custom languages syntax (WIP) 2025-04-13 00:19:38 +03:00
MihailRis
9843a1fc27 remove Viewport class 2025-04-02 17:35:17 +03:00
MihailRis
9694a59649 refactor: add Window interface 2025-04-02 14:59:53 +03:00
MihailRis
b202d1455b refactor: replace references to Events with Input 2025-04-02 14:55:53 +03:00
MihailRis
4c48afbb90 refactor: add GUI instance reference to UI nodes 2025-04-02 14:55:53 +03:00
MihailRis
5af6b91b22 add debug GUI render mode (F8) 2025-03-11 00:39:59 +03:00
MihailRis
c6951e0965 add in-game chat & update gui post-runnables timing & fix panel elements removal 2025-01-18 07:17:52 +03:00
MihailRis
dbf366eca3 fixes 2025-01-07 23:49:09 +03:00
MihailRis
5ffc054d75 refactor 2024-12-09 01:12:41 +03:00
MihailRis
04b6b6b546 minor refactor 2024-12-05 19:18:53 +03:00
MihailRis
de5c75d782 replace include guards with pragma once 2024-08-10 01:57:59 +03:00
MihailRis
f43cc93cd2 update project includes format 2024-08-10 01:37:48 +03:00
InfiniteCoder
d5dc68dd38 Root includes 2024-08-04 10:24:11 +03:00
Pugemon
f25a425cb9 Optimize parameter passing to avoid unnecessary copying 2024-06-07 04:00:38 +03:00
MihailRis
d437b67580 minor refactor 2024-05-25 09:09:31 +03:00
MihailRis
e3989cb178 added 'tooltip-delay' property 2024-05-24 13:18:20 +03:00
MihailRis
eb10904069 added tooltips 2024-05-24 08:03:05 +03:00
MihailRis
a678eddb77 double click support 2024-05-16 06:43:53 +03:00
MihailRis
9522aedeec quick check with linters 2024-05-10 12:34:05 +03:00
MihailRis
1627e21c1d the final rename 2024-05-06 03:38:19 +03:00
MihailRis
bcf2f5029d GfxContext renamed to DrawContext 2024-04-30 00:31:13 +03:00
MihailRis
5669b10036 small fix 2024-04-29 15:30:52 +03:00
MihailRis
c561466f64 InventoryInteraction removed due to redundancy 2024-04-29 00:14:16 +03:00
MihailRis
b1a79e3a6e block.material + minor refactor 2024-04-25 05:12:45 +03:00
MihailRis
051f0b8c6a rename 2024-04-23 18:43:02 +03:00
Renamed from src/graphics/ui/GUI.h (Browse further)