Commit graph

34 commits

Author SHA1 Message Date
alexei-zebra
56a225fe15
Draw the window frame on windows and on x11
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.
2026-10-10 15:30:55 +03:00
alexei-zebra
ab7f542d61
Add display settings for the wayland window frame
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().
2026-10-10 12:23:42 +03:00
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
4731ac0706
keep the window framebuffer opaque
Both backends asked for an alpha channel (GLFW defaults to 8 alpha
bits, the Wayland EGL config requested 8), so everything the engine
draws with alpha - the UI panels, the water post effect - lowered the
window's own alpha and the compositor blended the desktop through it.
Visible on wine/Proton, where the whole window is composited.

Both now ask for an opaque framebuffer: GLFW_ALPHA_BITS 0, and
EGL_ALPHA_SIZE 0 with a fallback to an alpha config if the driver
provides none. Checked the result through the back buffer attachment:
alpha size is 0 on Wayland and on X11.
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
alexei-zebra
1e689e88b1
add native Wayland window backend
Wayland support was missing a proper windowing layer: the GLFW backend
leaves the known platform gaps (cursor themes, window icon, window
position, fullscreen output selection).

The new backend talks to the compositor directly:
- xdg-shell, EGL, xkbcommon (keyboard, repeat, layout) instead of GLFW;
- cursors through wp_cursor_shape_manager_v1, so no cursor theme lookup
  is required and no "standard cursor shape unavailable" errors appear;
- window icon and title are drawn by the engine itself, since Wayland
  has no window icon protocol and GNOME provides no server-side
  decorations;
- fullscreen requests the current output (set_fullscreen with NULL), so
  the window no longer jumps to another monitor;
- interactive resize presents a cached frame scaled to the new size
  while the pointer is down and refreshes the real frame when the drag
  pauses, keeping the window glued to the cursor.

libdecor is not used: libdecor_frame_commit() redraws the whole
decoration and acks the configure in the same call, and mutter sends
200-330 configures per second during an interactive resize, so the
decoration was redrawn hundreds of times per second (measured: 2 s of
work per second, loop stalls up to 6 s). The decorations are drawn by
the engine instead, which measured 2.3 ms average configure-to-present
latency during a real drag.

GLFW stays the backend for X11 and Windows; VOXEL_WINDOW_BACKEND=x11
forces it on Wayland sessions.
2026-10-10 12:23:18 +03:00
MihailRis
cf35023adf fix 'mouse:' input prefix is not available 2026-10-06 12:53:50 +03:00
MihailRis
b4c8469264 Merge branch 'main' into client-side-tests 2026-07-07 18:53:27 +03:00
MihailRis
a8ed3cb36f
fix macos build (#859)
* update macos.yml

* update macos.yml

* update macos.yml

* update macos.yml

* update macos.yml

* update macos.yml

* update workflows

* update test

* fix unused function warning

* update test

* fixes

* update test

* update test

* update macos.yml

* Revert "update workflows"

This reverts commit ae78ff3ca2.
2026-07-07 17:42:24 +03:00
MihailRis
3429435ff5 add 'test' library for e2e tests purposes 2026-06-05 23:25:10 +03:00
MihailRis
6896fa433c fix: cursor is not hidden in wayland if previously changed by glfwSetCursor 2026-04-05 11:05:20 +03:00
MihailRis
305f44d1c6 Merge branch 'main' into volume-renderer 2026-01-10 23:28:28 +03:00
MihailRis
e371153288 fix conditional jump or move depends on uninitialised value in GLFWWindow 2026-01-05 19:19:10 +03:00
MihailRis
163a0a8c93 rename ImageFormat enum items 2025-12-21 19:05:14 +03:00
MihailRis
c42d661223 add app.focus function 2025-11-15 21:22:18 +03:00
MihailRis
fb78e9f694 replace glfwWaitEvents with glfwWaitEventsTimeout 2025-11-12 01:17:10 +03:00
MihailRis
7d367a9793 add app.set_title 2025-11-10 20:48:26 +03:00
MihailRis
be5a9077ca fix 2025-11-10 00:16:06 +03:00
MihailRis
0e6fb878bf add app.reset_content 'non_reset_packs' optional argument 2025-11-09 23:04:50 +03:00
MihailRis
7fc3703ad2 feat: refresh on demand in menu (adaptive framerate) 2025-11-09 22:22:24 +03:00
MihailRis
24931770d3
fix warnings (#648)
* fix unknown command line argument

* fix warnings settings for gcc

* fix -Wzero-as-null-pointer-constant

* revert CMakeLists.txt
2025-10-10 23:12:01 +03:00
ChancellorIkseew
b30b19e836
Add borderless window mode (from tasks) (#630) 2025-09-30 23:53:15 +03:00
clasher113
4362f1c912 fix: viewport size on toggle fullscreen 2025-08-29 19:39:41 +03:00
clasher113
5990617803 fix: fullscreen monitor refresh rate 2025-08-29 19:38:57 +03:00
MihailRis
4f549999f5 temporary fix 2025-07-21 19:30:30 +03:00
MihailRis
ac9772cd67 fix render advanced pipeline issues 2025-07-12 17:31:55 +03:00
MihailRis
7c976a573b fix InputBindBox 2025-06-30 20:59:17 +03:00
ChancellorIkseew
a16c4fcf8b input minor refactoring 2025-04-09 02:48:09 +10:00
unkn0t
74af48bdd4 Fix issue with incorrect scaling on Wayland 2025-04-03 14:31:42 +05:00
MihailRis
881edb7b28 rename keycode, mousecode enumerations 2025-04-02 17:39:31 +03:00
MihailRis
105561ad77 refactor GLFWWindow 2025-04-02 15:05:36 +03:00
MihailRis
7262119f5b refactor GLFWWindow 2025-04-02 15:01:24 +03:00
MihailRis
0b8d56afe1 cleanup 2025-04-02 14:59:53 +03:00
MihailRis
9694a59649 refactor: add Window interface 2025-04-02 14:59:53 +03:00