app.dhover×107 error×61all
// F13 libdecor comparison variant (see ../app.d for the hand-rolled CSD this
// is measured against, and ../../../f13-decorations.md for the LOC ledger).
// The sanctioned helper-library exception: libdecor_new + libdecor_decorate
// replace the *entire* shell layer — xdg_surface/xdg_toplevel creation, the
// configure/ack dance, xdg-decoration negotiation, set_window_geometry, title
// bar drawing, move/resize hit zones, themes, shadows, double-click-to-
// maximize all live inside libdecor and its cairo/gtk plugin. The app keeps
// only: connect, bind wl_compositor+wl_shm, paint content, commit, dispatch.
// A maximize/unmaximize storm exercises libdecor's geometry handling.
// Headless-safe: no compositor → SKIP, exit 0.
module 
(module) app
app
;
import c; // ImportC: wayland-client + libdecor.h + wsi_* core helpers
unable to read module `c` Expected 'c.d' or 'c/package.d' in one of the following import paths:
unable to read module `c` Expected 'c.d' or 'c/package.d' in one of the following import paths:
import instrument;
unable to read module `instrument` Expected 'instrument.d' or 'instrument/package.d' in one of the following import paths:
unable to read module `instrument` Expected 'instrument.d' or 'instrument/package.d' in one of the following import paths:
import
(package) core
core
.
(package) core.stdc
stdc
.
(module) core.stdc.stdio

D header file for C99 <stdio.h>

pubs.opengroup.org/onlinepubs/009695399/basedefs/stdio.h.html, stdio.h

Source

core/stdc/stdio.d

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseDistributed under the Boost Software License 1.0. (See accompanying file LICENSE)@authorsSean Kelly, Alex Rønne Petersen@standardsISO/IEC 9899:1999 (E)
stdio
:
(alias) app.printf = int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogc
printf
;
import
(package) core
core
.
(package) core.stdc
stdc
.
(module) core.stdc.stdlib

D header file for C99.

pubs.opengroup.org/onlinepubs/009695399/basedefs/stdlib.h.html, stdlib.h

Source

core/stdc/stdlib.d

@copyrightCopyright Sean Kelly 2005 - 2014.@licenseDistributed under the Boost Software License 1.0. (See accompanying file LICENSE)@authorsSean Kelly@standardsISO/IEC 9899:1999 (E)
stdlib
:
(alias) app.getenv = char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogc
getenv
,
(alias) app.atoi = int core.stdc.stdlib.atoi(scope const(char*) nptr) nothrow @nogc
atoi
;
import
(package) core
core
.
(package) core.stdc
stdc
.
(module) core.stdc.string

D header file for C99.

pubs.opengroup.org/onlinepubs/009695399/basedefs/string.h.html, string.h

Source

core/stdc/string.d

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseDistributed under the Boost Software License 1.0. (See accompanying file LICENSE)@authorsSean Kelly@standardsISO/IEC 9899:1999 (E)
string
:
(alias) app.strcmp = int core.stdc.string.strcmp(scope const(char*) s1, scope const(char*) s2) pure nothrow @nogc
strcmp
;
enum int
(constant) int app.defaultWidth = 640
defaultWidth
= 640,
(constant) int app.defaultHeight = 480
defaultHeight
= 480;
__gshared { wl_display*
_error_ app.g_display
g_display
;
undefined identifier `wl_display`, did you mean variable `g_display`?
wl_registry*
_error_ app.g_registry
g_registry
;
undefined identifier `wl_registry`, did you mean variable `g_registry`?
wl_compositor*
_error_ app.g_compositor
g_compositor
;
undefined identifier `wl_compositor`, did you mean variable `g_compositor`?
wl_shm*
_error_ app.g_shm
g_shm
;
undefined identifier `wl_shm`, did you mean variable `g_shm`?
wl_surface*
_error_ app.g_surface
g_surface
;
undefined identifier `wl_surface`, did you mean variable `g_surface`?
libdecor*
_error_ app.g_ctx
g_ctx
;
undefined identifier `libdecor`
libdecor_frame*
_error_ app.g_frame
g_frame
;
undefined identifier `libdecor_frame`
wl_buffer*
_error_ app.g_buffer
g_buffer
; // single-buffered: weston/sway release shm fast
undefined identifier `wl_buffer`, did you mean variable `g_buffer`?
uint*
(__gshared global) uint* app.g_pixels
g_pixels
;
(alias) object.size_t = ulong
size_t
(__gshared global) ulong app.g_byteSize
g_byteSize
;
int
(__gshared global) int app.g_width
g_width
= defaultWidth,
(__gshared global) int app.g_height
g_height
= defaultHeight;
int
(__gshared global) int app.g_configures
g_configures
;
bool
(__gshared global) bool app.g_running
g_running
= true;
long
(__gshared global) long app.g_runUsCap
g_runUsCap
= 2_500_000;
bool
(__gshared global) bool app.g_maximizedSent
g_maximizedSent
,
(__gshared global) bool app.g_unmaximizedSent
g_unmaximizedSent
;
} extern (C) void
app.onGlobal
onGlobal
(void* data, wl_registry* reg, uint name,
undefined identifier `wl_registry`, did you mean variable `g_registry`?
const(char)* iface, uint ver) nothrow @nogc { if (strcmp(iface, wl_compositor_interface.name) == 0) g_compositor = cast(wl_compositor*) wsi_registry_bind(reg, name, &wl_compositor_interface, ver < 4 ? ver : 4); else if (strcmp(iface, wl_shm_interface.name) == 0) g_shm = cast(wl_shm*) wsi_registry_bind(reg, name, &wl_shm_interface, 1); } extern (C) void
app.onGlobalRemove
onGlobalRemove
(void* data, wl_registry* reg, uint name) nothrow @nogc
undefined identifier `wl_registry`, did you mean variable `g_registry`?
{ } __gshared wl_registry_listener
_error_ app.g_registryListener
g_registryListener
= {&onGlobal, &onGlobalRemove};
undefined identifier `wl_registry_listener`
void
void app.paintAndCommit() nothrow @nogc
paintAndCommit
() nothrow @nogc
{ immutable
(local variable) immutable(int) stride
stride
=
(__gshared global) int app.g_width
g_width
* 4;
immutable
(local variable) immutable(ulong) size
size
= cast(
(alias) object.size_t = ulong
size_t
)
(local variable) immutable(int) stride
stride
*
(__gshared global) int app.g_height
g_height
;
if (g_buffer !is null) { wsi_buffer_destroy(g_buffer);
undefined identifier `wsi_buffer_destroy`
munmap(g_pixels, g_byteSize);
undefined identifier `munmap`
g_buffer = null; } immutable
(local variable) immutable(_error_) fd
fd
= memfd_create("wsi-f13-libdecor", MFD_CLOEXEC);
undefined identifier `memfd_create`
if (fd < 0 || ftruncate(fd, cast(long) size) != 0)
undefined identifier `ftruncate`
return;
(__gshared global) uint* app.g_pixels
g_pixels
= cast(uint*) mmap(null, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
undefined identifier `mmap`
(__gshared global) ulong app.g_byteSize
g_byteSize
=
(local variable) immutable(ulong) size
size
;
wl_shm_pool*
(local variable) _error_ pool
pool
= wsi_shm_create_pool(g_shm, fd, cast(int) size);
undefined identifier `wl_shm_pool`
undefined identifier `wsi_shm_create_pool`
g_buffer = wsi_shm_pool_create_buffer(pool, 0, g_width, g_height, stride, WL_SHM_FORMAT_ARGB8888); wsi_shm_pool_destroy(pool);
undefined identifier `wsi_shm_pool_destroy`
close(fd);
undefined identifier `close`
foreach (
(local variable) int y
y
; 0 ..
(__gshared global) int app.g_height
g_height
) // content gradient only — NO frame drawing here
{ uint*
(local variable) uint* row
row
=
(__gshared global) uint* app.g_pixels
g_pixels
+ cast(
(alias) object.size_t = ulong
size_t
)
(local variable) int y
y
*
(__gshared global) int app.g_width
g_width
;
immutable uint
(local variable) immutable(uint) g
g
= cast(uint)(
(local variable) int y
y
* 255 / (
(__gshared global) int app.g_height
g_height
- 1)) << 8;
foreach (
(local variable) int x
x
; 0 ..
(__gshared global) int app.g_width
g_width
)
(local variable) uint* row
row
[
(local variable) int x
x
] = 0xff00_0000 | (cast(uint)(
(local variable) int x
x
* 255 / (
(__gshared global) int app.g_width
g_width
- 1)) << 16) |
(local variable) immutable(uint) g
g
;
} wsi_surface_attach(g_surface, g_buffer, 0, 0);
undefined identifier `wsi_surface_attach`
wsi_surface_damage_buffer(g_surface, 0, 0, g_width, g_height);
undefined identifier `wsi_surface_damage_buffer`
wsi_surface_commit(g_surface);
undefined identifier `wsi_surface_commit`
} // ---------------------------------------------------- libdecor callbacks extern (C) void
app.onError
onError
(libdecor* ctx, libdecor_error error, const(char)* message) nothrow @nogc
undefined identifier `libdecor`
undefined identifier `libdecor_error`
{ instrEvent("libdecor_error", "error=%d message=%s", error, message); g_running = false; } /// The whole F13 negotiation, reduced to one callback: libdecor hands over the /// *content* size (frame already subtracted) and takes back a libdecor_state — /// ack_configure + set_window_geometry happen inside libdecor_frame_commit. extern (C) void
app.onConfigure

The whole F13 negotiation, reduced to one callback: libdecor hands over the content size (frame already subtracted) and takes back a libdecor_state — ack_configure + set_window_geometry happen inside libdecor_frame_commit.

onConfigure
(libdecor_frame* frame, libdecor_configuration* conf,
undefined identifier `libdecor_frame`
undefined identifier `libdecor_configuration`
void* userData) nothrow @nogc { int
_error_ w
w
,
_error_ h
h
;
if (!libdecor_configuration_get_content_size(conf, frame, &w, &h)) { w = defaultWidth; h = defaultHeight; } libdecor_window_state
_error_ ws
ws
;
if (!libdecor_configuration_get_window_state(conf, &ws)) ws = LIBDECOR_WINDOW_STATE_NONE; g_configures++; instrEvent("configure", "content=%dx%d window_state=0x%x", w, h, cast(uint) ws); g_width = w; g_height = h; libdecor_state*
_error_ state
state
= libdecor_state_new(w, h);
libdecor_frame_commit(frame, state, conf); libdecor_state_free(state); paintAndCommit(); if (g_configures == 1) instrFirstPixelPresented(); // first content commit; frame is libdecor's } extern (C) void
app.onClose
onClose
(libdecor_frame* frame, void* userData) nothrow @nogc
undefined identifier `libdecor_frame`
{ instrCloseRequested(); g_running = false; } extern (C) void
app.onCommit
onCommit
(libdecor_frame* frame, void* userData) nothrow @nogc
undefined identifier `libdecor_frame`
{ wsi_surface_commit(g_surface); // sync-subsurface decorations need this } extern (C) void
app.onDismissPopup
onDismissPopup
(libdecor_frame* frame, const(char)* seatName, void* userData) nothrow @nogc
undefined identifier `libdecor_frame`
{ } __gshared libdecor_interface
_error_ app.g_iface
g_iface
= {&onError};
undefined identifier `libdecor_interface`
__gshared libdecor_frame_interface
_error_ app.g_frameIface
g_frameIface
= {
undefined identifier `libdecor_frame_interface`
&onConfigure, &onClose, &onCommit, &onDismissPopup }; // --------------------------------------------------------------------- main int
int D main()
main
()
{ instrInit("f13-libdecor");
undefined identifier `instrInit`
const
(local variable) const(char*) autoEnv
autoEnv
=
char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogc
getenv
("WSI_AUTO_EXIT");
immutable
(local variable) immutable(bool) autoExit
autoExit
=
(local variable) const(char*) autoEnv
autoEnv
!is null && *
(local variable) const(char*) autoEnv
autoEnv
== '1';
if (const
(local variable) const(char*) ms
ms
=
char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogc
getenv
("WSI_RUN_MS"))
(__gshared global) long app.g_runUsCap
g_runUsCap
=
int core.stdc.stdlib.atoi(scope const(char*) nptr) nothrow @nogc
atoi
(
(local variable) const(char*) ms
ms
) * 1000L;
g_display = wl_display_connect(null); if (g_display is null) {
int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogc
printf
("SKIP: no Wayland compositor (wl_display_connect returned null)\n");
return 0; } g_registry = wsi_display_get_registry(g_display); wsi_registry_add_listener(g_registry, &g_registryListener, null);
undefined identifier `wsi_registry_add_listener`
wl_display_roundtrip(g_display);
undefined identifier `wl_display_roundtrip`
if (g_compositor is null || g_shm is null) {
int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogc
printf
("SKIP: compositor lacks wl_compositor/wl_shm\n");
wl_display_disconnect(g_display);
undefined identifier `wl_display_disconnect`
return 0; } g_surface = wsi_compositor_create_surface(g_compositor); g_ctx = libdecor_new(g_display, &g_iface); // binds xdg-shell + xdg-deco itself instrEvent("step", "name=libdecor_new");
undefined identifier `instrEvent`, did you mean import `instrument`?
g_frame = libdecor_decorate(g_ctx, g_surface, &g_frameIface, null); instrEvent("step", "name=libdecor_decorate");
undefined identifier `instrEvent`, did you mean import `instrument`?
libdecor_frame_set_title(g_frame, "wsi-f13-libdecor");
undefined identifier `libdecor_frame_set_title`
libdecor_frame_set_app_id(g_frame, "wsi-f13-libdecor");
undefined identifier `libdecor_frame_set_app_id`
libdecor_frame_map(g_frame);
undefined identifier `libdecor_frame_map`
instrWindowCreated();
undefined identifier `instrWindowCreated`
// libdecor owns the event loop entry point: its dispatch wraps the wl // socket *and* the plugin's own timers/frame machinery. while (
(__gshared global) bool app.g_running
g_running
&& libdecor_dispatch(g_ctx, 100) >= 0)
undefined identifier `libdecor_dispatch`
{ immutable
(local variable) immutable(_error_) now
now
= instrNowUs();
undefined identifier `instrNowUs`
if (
(local variable) immutable(bool) autoExit
autoExit
&& !
(__gshared global) bool app.g_maximizedSent
g_maximizedSent
&& now >
(__gshared global) long app.g_runUsCap
g_runUsCap
/ 3)
{
(__gshared global) bool app.g_maximizedSent
g_maximizedSent
= true;
instrEvent("state_request", "kind=set_maximized");
undefined identifier `instrEvent`, did you mean import `instrument`?
libdecor_frame_set_maximized(g_frame);
undefined identifier `libdecor_frame_set_maximized`
} else if (
(local variable) immutable(bool) autoExit
autoExit
&& !
(__gshared global) bool app.g_unmaximizedSent
g_unmaximizedSent
&& now > 2 *
(__gshared global) long app.g_runUsCap
g_runUsCap
/ 3)
{
(__gshared global) bool app.g_unmaximizedSent
g_unmaximizedSent
= true;
instrEvent("state_request", "kind=unset_maximized");
undefined identifier `instrEvent`, did you mean import `instrument`?
libdecor_frame_unset_maximized(g_frame);
undefined identifier `libdecor_frame_unset_maximized`
} if (
(local variable) immutable(bool) autoExit
autoExit
&& now >
(__gshared global) long app.g_runUsCap
g_runUsCap
)
(__gshared global) bool app.g_running
g_running
= false;
} libdecor_frame_unref(g_frame);
undefined identifier `libdecor_frame_unref`
libdecor_unref(g_ctx); // tears down its xdg/decoration objects
undefined identifier `libdecor_unref`
if (g_buffer !is null) { wsi_buffer_destroy(g_buffer);
undefined identifier `wsi_buffer_destroy`
munmap(g_pixels, g_byteSize);
undefined identifier `munmap`
} wsi_surface_destroy(g_surface);
undefined identifier `wsi_surface_destroy`
wl_proxy_destroy(cast(wl_proxy*) g_shm);
undefined identifier `wl_proxy_destroy`
wl_proxy_destroy(cast(wl_proxy*) g_compositor);
undefined identifier `wl_proxy_destroy`
wl_proxy_destroy(cast(wl_proxy*) g_registry);
undefined identifier `wl_proxy_destroy`
wl_display_disconnect(g_display);
undefined identifier `wl_display_disconnect`
int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogc
printf
("ok: %d configures, final content %dx%d\n",
(__gshared global) int app.g_configures
g_configures
,
(__gshared global) int app.g_width
g_width
,
(__gshared global) int app.g_height
g_height
);
return 0; }