wio

a wayland wm stylised after plan9 rio - forked from git.sr.ht/~srcmpwn/wio
git clone git://src.gearsix.net/wio
Log | Files | Refs | Atom | Submodules | README | LICENSE

commit f65bb0c47b79d9c038d00b7c85be96e6080b6474
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed,  9 Jan 2019 17:15:12 -0500

Initial commit

Diffstat:
A.gitignore | 1+
Ainclude/server.h | 14++++++++++++++
Amain.c | 44++++++++++++++++++++++++++++++++++++++++++++
Ameson.build | 46++++++++++++++++++++++++++++++++++++++++++++++
Aprotocols/meson.build | 46++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 151 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1 @@ +build diff --git a/include/server.h b/include/server.h @@ -0,0 +1,14 @@ +#ifndef _WIO_SERVER_H +#define _WIO_SERVER_H +#include <wayland-server.h> +#include <wlr/backend.h> +#include <wlr/render/wlr_renderer.h> + +struct wio_server { + struct wl_display *wl_display; + + struct wlr_backend *backend; + struct wlr_renderer *renderer; +}; + +#endif diff --git a/main.c b/main.c @@ -0,0 +1,44 @@ +#define _POSIX_C_SOURCE 200112L +#include <stdlib.h> +#include <wayland-server.h> +#include <wlr/backend.h> +#include <wlr/types/wlr_compositor.h> +#include <wlr/types/wlr_data_device.h> +#include <wlr/render/wlr_renderer.h> +#include <wlr/util/log.h> +#include "server.h" + +int main(int argc, char **argv) { + struct wio_server server; + + wlr_log_init(WLR_DEBUG, NULL); + + server.wl_display = wl_display_create(); + server.backend = wlr_backend_autocreate(server.wl_display, NULL); + server.renderer = wlr_backend_get_renderer(server.backend); + wlr_renderer_init_wl_display(server.renderer, server.wl_display); + + wlr_compositor_create(server.wl_display, server.renderer); + wlr_data_device_manager_create(server.wl_display); + + const char *socket = wl_display_add_socket_auto(server.wl_display); + if (!socket) { + wlr_backend_destroy(server.backend); + return 1; + } + + if (!wlr_backend_start(server.backend)) { + wlr_backend_destroy(server.backend); + wl_display_destroy(server.wl_display); + return 1; + } + + setenv("WAYLAND_DISPLAY", socket, true); + wlr_log(WLR_INFO, + "Running Wayland compositor on WAYLAND_DISPLAY=%s", socket); + wl_display_run(server.wl_display); + + wl_display_destroy_clients(server.wl_display); + wl_display_destroy(server.wl_display); + return 0; +} diff --git a/meson.build b/meson.build @@ -0,0 +1,46 @@ +project( + 'wio', + 'c', + license: 'BSD-3-Clause', + default_options: [ + 'c_std=c11', + 'warning_level=2', + 'werror=true', + ], +) + +add_project_arguments( + [ + '-DWL_HIDE_DEPRECATED', + '-DWLR_USE_UNSTABLE', + + '-Wno-unused-parameter', + '-Wno-unused-result', + '-Wundef', + ], + language: 'c', +) + +wlroots = dependency('wlroots', fallback: ['wlroots', 'wlroots']) +wayland_server = dependency('wayland-server') +wayland_protos = dependency('wayland-protocols') + +wio_inc = include_directories('include') + +subdir('protocols') + +wio_sources = files( + 'main.c' +) + +executable( + 'wio', + wio_sources, + include_directories: [wio_inc], + dependencies: [ + wlroots, + wayland_server, + server_protos, + ], + install: true +) diff --git a/protocols/meson.build b/protocols/meson.build @@ -0,0 +1,46 @@ +wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir') + +wayland_scanner = find_program('wayland-scanner') + +# should check wayland_scanner's version, but it is hard to get +if wayland_server.version().version_compare('>=1.14.91') + code_type = 'private-code' +else + code_type = 'code' +endif + +wayland_scanner_code = generator( + wayland_scanner, + output: '@BASENAME@-protocol.c', + arguments: [code_type, '@INPUT@', '@OUTPUT@'], +) + +wayland_scanner_server = generator( + wayland_scanner, + output: '@BASENAME@-protocol.h', + arguments: ['server-header', '@INPUT@', '@OUTPUT@'], +) + +server_protocols = [ + [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'], +] + +server_protos_src = [] +server_protos_headers = [] + +foreach p : server_protocols + xml = join_paths(p) + server_protos_src += wayland_scanner_code.process(xml) + server_protos_headers += wayland_scanner_server.process(xml) +endforeach + +lib_server_protos = static_library( + 'server_protos', + server_protos_src + server_protos_headers, + dependencies: [wayland_server] +) # for the include directory + +server_protos = declare_dependency( + link_with: lib_server_protos, + sources: server_protos_headers, +)