me

/

vendetta Public
17 commits 0 issues 0 pull requests 1 contributor Discussions Projects Snippets LOC history Platform CI

fix untracked src files

diviocity committed last Nov 1 · 59511ca6b236c69a5dcc3242efdcb78549a7d3c1 View patch
Unverified signature 2 files changed +58 -0
src/window_class.v new file +43 -0

@@ -0,0 +1,43 @@

1+import sokol.sapp

2+

3+// Names the window for the desktop. On X11 — also what an XWayland session's

4+// X11 property query sees — launchers, taskbars and the .desktop file's

5+// StartupWMClass match a window against its WM_CLASS resource pair

6+// (instance, class). sokol's own title call goes through Xutf8SetWMProperties

7+// with nil class hints, so the window comes up anonymous and the toolkit

8+// guesses; this writes the vendetta pair instead. The property is exactly

9+// what XSetClassHint itself writes — two null-terminated STRING atoms,

10+// instance then class — against the static atoms XA_WM_CLASS (20) and

11+// XA_STRING (31), so nothing of the XClassHint plumbing is needed. It must

12+// run once sokol has its X11 connection, which is registered inside sokol's

13+// own loop — the first frame is the earliest point vendetta can answer

14+// that. Only the desktop machines sokol runs through X11 are addressed;

15+// macOS and Windows have nothing a .desktop-style file matches, and Android

16+// nothing at all.

17+$if linux || freebsd || openbsd || netbsd || dragonfly || solaris {

18+ #include <X11/Xlib.h>

19+

20+ fn set_window_class() {

21+ display := sapp.x11_get_display()

22+ window := sapp.x11_get_window()

23+ if display == unsafe { nil } || u64(window) == 0 {

24+ return

25+ }

26+ // The class atom is one of XSetClassHint's own interned atoms, not

27+ // one of the root's predefined set; the server interns the property

28+ // contents synchronously, so the byte copy's storage only has to

29+ // outlive this call.

30+ name := 'vendetta'.bytes()

31+ mut data := []u8{len: 2 * (name.len + 1)}

32+ atom := C.XInternAtom(display, c'WM_CLASS', 0)

33+ unsafe {

34+ C.memcpy(&data[0], name.data, name.len)

35+ C.memcpy(&data[name.len + 1], name.data, name.len)

36+ // XA_STRING (31), 8-bit format: the property XSetClassHint

37+ // itself writes, instance then class.

38+ C.XChangeProperty(display, u64(window), atom, 31, 8, 0, &data[0], data.len)

39+ }

40+ }

41+} $else {

42+ fn set_window_class() {}

43+}

src/window_title.v new file +15 -0

@@ -0,0 +1,15 @@

1+// The window-title plumbing, kept apart because the import rule pins it to a

2+// file head: apply_window_title pushes a title onto the OS window, and every

3+// vendetta desktop build renders through ui2's custom GL renderer (the macOS

4+// compile_error guard in main.v leans on it too), whose window is sokol's, so

5+// the title goes through gg's sapp wrapper; android has no title bar and

6+// ignores the call harmlessly.

7+import gg

8+

9+$if android || linux || ((macos || windows) && ui2_custom_rendering ?) {

10+ fn apply_window_title(title string) {

11+ gg.set_window_title(title)

12+ }

13+} $else {

14+ fn apply_window_title(_ string) {}

15+}