MCPcopy Create free account
hub / github.com/crownengine/crown / init

Method init

src/device/main_linux.cpp:702–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700 }
701
702 int init() override
703 {
704 wl_lib = os::library_open("libwayland-client.so");
705#define DL_IMPORT_FUNC(func_name, return_type, params) \
706 ::crown_ ## func_name = (PROTO_ ## func_name)os::library_symbol(wl_lib, # func_name); \
707 CE_ENSURE(func_name != NULL);
708 WAYLAND_IMPORT();
709#undef DL_IMPORT_FUNC
710 for (u32 i = 0; i < countof(xdg_shell_types); ++i) {
711 if (xdg_shell_types[i] == (void *)1)
712 xdg_shell_types[i] = &wl_surface_interface;
713 if (xdg_shell_types[i] == (void *)2)
714 xdg_shell_types[i] = &wl_seat_interface;
715 if (xdg_shell_types[i] == (void *)3)
716 xdg_shell_types[i] = &wl_output_interface;
717 }
718
719 xkb.lib = os::library_open("libxkbcommon.so");
720#define DL_IMPORT_FUNC(func_name, return_type, params) \
721 func_name = (PROTO_ ## func_name)os::library_symbol(xkb.lib, # func_name); \
722 CE_ENSURE(func_name != NULL);
723 XKBCOMMON_IMPORT();
724#undef DL_IMPORT_FUNC
725
726 decor.lib = os::library_open("libdecor-0.so.0");
727#define DL_IMPORT_FUNC(func_name, return_type, params) \
728 func_name = (PROTO_ ## func_name)os::library_symbol(decor.lib, # func_name); \
729 CE_ENSURE(func_name != NULL);
730 DECOR_IMPORT();
731#undef DL_IMPORT_FUNC
732
733 xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
734 CE_ASSERT(xkb.context != NULL, "xkb_context_new: error");
735
736 wl_cursor_lib = os::library_open("libwayland-cursor.so.0");
737 if (!wl_cursor_lib)
738 wl_cursor_lib = os::library_open("libwayland-cursor.so");
739
740 if (wl_cursor_lib) {
741#define DL_IMPORT_FUNC(func_name, return_type, params) \
742 func_name = (PROTO_ ## func_name)os::library_symbol(wl_cursor_lib, # func_name); \
743 CE_ENSURE(func_name != NULL);
744 WAYLAND_CURSOR_IMPORT();
745#undef DL_IMPORT_FUNC
746 }
747
748 display = wl_display_connect(NULL);
749 CE_ASSERT(display != NULL, "wl_display_connect: error");
750 display_fd = wl_display_get_fd(display);
751
752 registry = wl_display_get_registry(display);
753 wl_registry_add_listener(registry, &_wl_registry_listener, this);
754
755 decor.context = libdecor_new(display, decor.iface);
756 CE_ASSERT(decor.context != NULL, "libdecor_new: error");
757 decor.fd = libdecor_get_fd(decor.context);
758
759 wl_display_roundtrip(display);

Callers

nothing calls this directly

Calls 4

library_openFunction · 0.85
wl_display_get_registryFunction · 0.85
wl_registry_add_listenerFunction · 0.85

Tested by

no test coverage detected