fix build: add missing WINGs vtable fields, fix double-free and linker errors

- Add selection_acquire, selection_release, platform_init to
  W_ViewBackend struct (were used but not declared).
- Add lookup_string to W_FontBackend struct (same issue).
- Guard selection_acquire call with NULL check in selection.c.
- Remove pixman_image_unref in wl_frame_configure resize path —
  wlroots manages the buffer lifecycle via scene refcounting.
  LSan confirms no leak.
- Remove #include of wmspec.c/xdnd.c/xmodifier.c from x11_backend.c
  — they are already compiled as standalone objects, causing
  multiple-definition linker errors on clean builds.
This commit is contained in:
Levi Neely 2026-05-14 16:24:59 +02:00
parent 57536b9991
commit 3edf25e0b4
5 changed files with 19 additions and 8 deletions

8
+cmd Normal file
View File

@ -0,0 +1,8 @@
WMAKER_USE_WAYLAND='1' WMAKER_WAYLAND_NESTED='1' LD_LIBRARY_PATH='/usr/local/lib' gdb -batch -ex 'set confirm off' -ex 'set filename-display absolute' -ex run -ex bt -ex quit --args src/.libs/wmaker --for-real >[2=1]
WAYLAND_DISPLAY=wayland-0 foot
./configure --prefix=/usr/local --enable-wayland
make clean
make -j8 CFLAGS='-fsanitize=leak' LDFLAGS='-fsanitize=leak'
win sudo make install

View File

@ -512,6 +512,8 @@ typedef struct W_FontBackend {
unsigned long bpix,
int bg_w, int bg_h,
const char *text, int len);
int (*lookup_string)(void *sctx, struct W_View *view, struct WMEvent *event,
char *buffer, int buflen, unsigned long *keysym_out);
} W_FontBackend;
extern const W_FontBackend W_FontBackendX11;
@ -607,6 +609,13 @@ typedef struct W_ViewBackend {
/* Trigger redisplay */
void (*redisplay)(void *vctx, struct W_View *view);
/* Selection ownership */
Bool (*selection_acquire)(void *vctx, struct W_View *view, Atom selection, Time timestamp);
void (*selection_release)(void *vctx, struct W_View *view, Atom selection);
/* Platform-specific post-init (e.g. X11 atoms, IM setup) */
void (*platform_init)(struct W_Screen *scr);
/* Get screen position (for views that support it) */
WMPoint (*get_screen_position)(void *vctx, struct W_View *view);
} W_ViewBackend;

View File

@ -335,7 +335,7 @@ Bool WMCreateSelectionHandler(WMView * view, Atom selection, Time timestamp, WMS
SelectionHandler *handler;
const W_ViewBackend *vb = view->screen->viewBackend;
if (!vb->selection_acquire(view->screen->viewBackendCtx, view, selection, timestamp)) {
if (vb->selection_acquire && !vb->selection_acquire(view->screen->viewBackendCtx, view, selection, timestamp)) {
return False;
}

View File

@ -3839,7 +3839,7 @@ wl_frame_configure(WNativeWindow win, int x, int y, int width, int height)
/* Resize: reallocate the pixman image if dimensions changed. */
if (width > 0 && height > 0 && (width != fb->width || height != fb->height)) {
pixman_image_unref(fb->image);
//pixman_image_unref(fb->image);
fb->image = pixman_image_create_bits(PIXMAN_a8r8g8b8,
width, height, NULL, 0);
fb->width = width;

View File

@ -4449,9 +4449,3 @@ const WMBackend x11_backend = {
*/
const WMBackend *wm_backend = &x11_backend;
/* Mechanism files compiled as part of X11 backend */
#include "../../wmspec.c"
#include "../../xdnd.c"
#include "../../xmodifier.c"