diff options
56 files changed, 511 insertions, 245 deletions
diff --git a/backend/meson.build b/backend/meson.build index 52abe64d..dd1f4df3 100644 --- a/backend/meson.build +++ b/backend/meson.build @@ -1,3 +1,4 @@ +backend_parts = [] backend_files = files( 'backend.c', 'drm/atomic.c', @@ -44,28 +45,17 @@ else backend_files += files('session/direct.c') endif -if conf_data.get('WLR_HAS_SYSTEMD', false) +if logind.found() backend_files += files('session/logind.c') - backend_deps += systemd + backend_deps += logind endif -if conf_data.get('WLR_HAS_X11_BACKEND', false) - backend_files += files( - 'x11/backend.c', - 'x11/input_device.c', - 'x11/output.c', - ) - backend_deps += xcb_xkb -endif - -if conf_data.get('WLR_HAS_ELOGIND', false) - backend_files += files('session/logind.c') - backend_deps += elogind -endif +subdir('x11') lib_wlr_backend = static_library( 'wlr_backend', backend_files, include_directories: wlr_inc, + link_whole: backend_parts, dependencies: backend_deps, ) diff --git a/backend/session/session.c b/backend/session/session.c index f1cce8bc..3fcac3e3 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -79,6 +79,7 @@ struct wlr_session *wlr_session_create(struct wl_display *disp) { session->active = true; wl_signal_init(&session->session_signal); + wl_signal_init(&session->events.destroy); wl_list_init(&session->devices); session->udev = udev_new(); @@ -125,6 +126,7 @@ void wlr_session_destroy(struct wlr_session *session) { return; } + wlr_signal_emit_safe(&session->events.destroy, session); wl_list_remove(&session->display_destroy.link); wl_event_source_remove(session->udev_event); diff --git a/backend/x11/meson.build b/backend/x11/meson.build new file mode 100644 index 00000000..1164df1e --- /dev/null +++ b/backend/x11/meson.build @@ -0,0 +1,44 @@ +x11_libs = [] +x11_required = [ + 'xcb', + 'x11-xcb', +] +x11_optional = [ + 'xcb-xkb', +] + +foreach lib : x11_required + dep = dependency(lib, required: get_option('x11-backend')) + if not dep.found() + subdir_done() + endif + + x11_libs += dep +endforeach + +foreach lib : x11_optional + dep = dependency(lib, required: get_option(lib)) + if dep.found() + x11_libs += dep + conf_data.set('WLR_HAS_' + lib.underscorify().to_upper(), true) + endif +endforeach + +lib_wlr_backend_x11 = static_library( + 'wlr_backend_x11', + files( + 'backend.c', + 'input_device.c', + 'output.c', + ), + include_directories: wlr_inc, + dependencies: [ + wayland_server, + pixman, + xkbcommon, + x11_libs, + ], +) + +backend_parts += lib_wlr_backend_x11 +conf_data.set('WLR_HAS_X11_BACKEND', true) diff --git a/examples/meson.build b/examples/meson.build index 25ad7566..0fb37a9e 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -1,80 +1,102 @@ threads = dependency('threads') wayland_cursor = dependency('wayland-cursor') - libpng = dependency('libpng', required: false) - # These versions correspond to ffmpeg 4.0 libavutil = dependency('libavutil', version: '>=56.14.100', required: false) libavcodec = dependency('libavcodec', version: '>=58.18.100', required: false) libavformat = dependency('libavformat', version: '>=58.12.100', required: false) +# Small hack until https://github.com/mesonbuild/meson/pull/3386/ is merged +foreach dep : ['libpng', 'libavutil', 'libavcodec', 'libavformat'] + if not get_variable(dep).found() + set_variable(dep, disabler()) + endif +endforeach + if not cc.has_header('libavutil/hwcontext_drm.h', dependencies: libavutil) - libavutil = disabler() + libavutil = disabler() endif -executable('simple', 'simple.c', dependencies: wlroots) -executable('pointer', 'pointer.c', dependencies: wlroots) -executable('touch', 'touch.c', 'cat.c', dependencies: wlroots) -executable('tablet', 'tablet.c', dependencies: wlroots) -executable('rotation', 'rotation.c', 'cat.c', dependencies: wlroots) -executable('multi-pointer', 'multi-pointer.c', dependencies: wlroots) -executable('output-layout', 'output-layout.c', 'cat.c', dependencies: wlroots) - -executable( - 'screenshot', - 'screenshot.c', - dependencies: [wayland_client, wlr_protos, wlroots] -) - -executable( - 'idle', - 'idle.c', - dependencies: [wayland_client, wlr_protos, wlroots, threads] -) - -executable( - 'idle-inhibit', - 'idle-inhibit.c', - dependencies: [wayland_client, wlr_protos, wlroots, threads] -) - -executable( - 'layer-shell', - 'layer-shell.c', - dependencies: [wayland_cursor, wayland_client, wlr_protos, wlroots] -) - -executable( - 'input-inhibitor', - 'input-inhibitor.c', - dependencies: [wayland_cursor, wayland_client, wlr_protos, wlroots] -) +examples = { + 'simple': { + 'src': 'simple.c', + 'dep': wlroots, + }, + 'pointer': { + 'src': 'pointer.c', + 'dep': wlroots, + }, + 'touch': { + 'src': ['touch.c', 'cat.c'], + 'dep': wlroots, + }, + 'tablet': { + 'src': 'tablet.c', + 'dep': wlroots, + }, + 'rotation': { + 'src': ['rotation.c', 'cat.c'], + 'dep': wlroots, + }, + 'multi-pointer': { + 'src': 'multi-pointer.c', + 'dep': wlroots, + }, + 'output-layout': { + 'src': ['output-layout.c', 'cat.c'], + 'dep': wlroots, + }, + 'screenshot': { + 'src': 'screenshot.c', + 'dep': [wayland_client, wlr_protos, wlroots], + }, + 'idle': { + 'src': 'idle.c', + 'dep': [wayland_client, wlr_protos, wlroots, threads], + }, + 'idle-inhibit': { + 'src': 'idle-inhibit.c', + 'dep': [wayland_client, wlr_protos, wlroots], + }, + 'layer-shell': { + 'src': 'layer-shell.c', + 'dep': [wayland_client, wayland_cursor, wlr_protos, wlroots], + }, + 'input-inhibitor': { + 'src': 'input-inhibitor.c', + 'dep': [wayland_client, wayland_cursor, wlr_protos, wlroots], + }, + 'gamma-control': { + 'src': 'gamma-control.c', + 'dep': [wayland_client, wayland_cursor, wlr_protos, wlroots], + }, + 'dmabuf-capture': { + 'src': 'dmabuf-capture.c', + 'dep': [ + libavcodec, + libavformat, + libavutil, + threads, + wayland_client, + wlr_protos, + wlroots, + ], + }, + 'screencopy': { + 'src': 'screencopy.c', + 'dep': [libpng, wayland_client, wlr_protos, wlroots], + }, + 'toplevel-decoration': { + 'src': 'toplevel-decoration.c', + 'dep': [wayland_client, wlr_protos, wlroots], + }, +} -executable( - 'gamma-control', - 'gamma-control.c', - dependencies: [wayland_cursor, wayland_client, wlr_protos, wlroots] -) - -if libavutil.found() and libavcodec.found() and libavformat.found() +foreach name, info : examples executable( - 'dmabuf-capture', - 'dmabuf-capture.c', - dependencies: [wayland_client, wlr_protos, libavutil, libavcodec, - libavformat, wlroots, threads ] + name, + info.get('src'), + dependencies: info.get('dep'), + build_by_default: get_option('examples'), ) -endif - -if libpng.found() - executable( - 'screencopy', - 'screencopy.c', - dependencies: [wayland_client, wlr_protos, wlroots, libpng] - ) -endif - -executable( - 'toplevel-decoration', - 'toplevel-decoration.c', - dependencies: [wayland_client, wlr_protos, wlroots] -) +endforeach @@ -7,16 +7,15 @@ # to fail if it can't load the function. You'll need to check if that function # is NULL before using it. -if [ $# -ne 3 ]; then +if [ $# -ne 2 ]; then exit 1 fi SPEC=$1 -OUT_C=$2 -OUT_H=$3 +OUTDIR=$2 BASE=$(basename "$SPEC" .txt) -INCLUDE_GUARD=$(printf %s "$OUT_H" | tr -c [:alnum:] _ | tr [:lower:] [:upper:]) +INCLUDE_GUARD=$(printf %s_%s_H "$OUTDIR" "$BASE" | tr -c [:alnum:] _ | tr [:lower:] [:upper:]) DECL="" DEFN="" @@ -56,9 +55,9 @@ while read -r COMMAND; do if [ $OPTIONAL -eq 0 ]; then LOADER="$LOADER$(printf "\n$CHECK_FMT" "$COMMAND" "$COMMAND")" fi -done < $SPEC +done < "$SPEC" -cat > $OUT_H << EOF +cat > "$OUTDIR/$BASE.h" << EOF #ifndef $INCLUDE_GUARD #define $INCLUDE_GUARD @@ -66,7 +65,6 @@ cat > $OUT_H << EOF #include <EGL/egl.h> #include <EGL/eglext.h> -#include <EGL/eglmesaext.h> #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> @@ -76,9 +74,9 @@ $DECL #endif EOF -cat > $OUT_C << EOF +cat > "$OUTDIR/$BASE.c" << EOF #include <wlr/util/log.h> -#include "$OUT_H" +#include "$BASE.h" $DEFN bool load_$BASE(void) { diff --git a/include/wlr/backend/meson.build b/include/wlr/backend/meson.build new file mode 100644 index 00000000..e005b854 --- /dev/null +++ b/include/wlr/backend/meson.build @@ -0,0 +1,16 @@ +install_headers( + 'drm.h', + 'headless.h', + 'interface.h', + 'libinput.h', + 'multi.h', + 'session.h', + 'wayland.h', + subdir: 'wlr/backend', +) + +if conf_data.get('WLR_HAS_X11_BACKEND', false) + install_headers('x11.h', subdir: 'wlr/backend') +endif + +subdir('session') diff --git a/include/wlr/backend/session.h b/include/wlr/backend/session.h index 1cf41939..7b26f34c 100644 --- a/include/wlr/backend/session.h +++ b/include/wlr/backend/session.h @@ -39,6 +39,10 @@ struct wlr_session { struct wl_list devices; struct wl_listener display_destroy; + + struct { + struct wl_signal destroy; + } events; }; /* diff --git a/include/wlr/backend/session/meson.build b/include/wlr/backend/session/meson.build new file mode 100644 index 00000000..21b5a96b --- /dev/null +++ b/include/wlr/backend/session/meson.build @@ -0,0 +1 @@ +install_headers('interface.h', subdir: 'wlr/backend/session') diff --git a/include/wlr/config.h.in b/include/wlr/config.h.in new file mode 100644 index 00000000..750ad3b7 --- /dev/null +++ b/include/wlr/config.h.in @@ -0,0 +1,19 @@ +#ifndef WLR_CONFIG_H +#define WLR_CONFIG_H + +#mesondefine WLR_HAS_LIBCAP + +#mesondefine WLR_HAS_SYSTEMD +#mesondefine WLR_HAS_ELOGIND + +#mesondefine WLR_HAS_X11_BACKEND + +#mesondefine WLR_HAS_XWAYLAND + +#mesondefine WLR_HAS_XCB_ERRORS +#mesondefine WLR_HAS_XCB_ICCCM +#mesondefine WLR_HAS_XCB_XKB + +#mesondefine WLR_HAS_POSIX_FALLOCATE + +#endif diff --git a/include/wlr/interfaces/meson.build b/include/wlr/interfaces/meson.build new file mode 100644 index 00000000..207896b5 --- /dev/null +++ b/include/wlr/interfaces/meson.build @@ -0,0 +1,10 @@ +install_headers( + 'wlr_input_device.h', + 'wlr_keyboard.h', + 'wlr_output.h', + 'wlr_pointer.h', + 'wlr_tablet_pad.h', + 'wlr_tablet_tool.h', + 'wlr_touch.h', + subdir: 'wlr/interfaces', +) diff --git a/include/wlr/meson.build b/include/wlr/meson.build index 6259c311..43b5aec9 100644 --- a/include/wlr/meson.build +++ b/include/wlr/meson.build @@ -4,11 +4,23 @@ version_data.set_quoted('WLR_VERSION_STR', meson.project_version()) version_data.set('WLR_VERSION_MAJOR', version_array[0]) version_data.set('WLR_VERSION_MINOR', version_array[1]) version_data.set('WLR_VERSION_MICRO', version_array[2]) -version_data.set('WLR_VERSION_NUM', '(WLR_VERSION_MAJOR << 16) | (WLR_VERSION_MINOR << 8) | WLR_VERSION_MICRO') version_data.set('WLR_VERSION_API_CURRENT', so_version[0]) version_data.set('WLR_VERSION_API_REVISION', so_version[1]) version_data.set('WLR_VERSION_API_AGE', so_version[2]) -wlr_inc_dest = join_paths(get_option('includedir'), 'wlr') -configure_file(output: 'config.h', install_dir: wlr_inc_dest, configuration: conf_data) -configure_file(output: 'version.h', install_dir: wlr_inc_dest, configuration: version_data) +install_headers( + configure_file(input: 'config.h.in', output: 'config.h',configuration: conf_data), + configure_file(input: 'version.h.in', output: 'version.h', configuration: version_data), + 'backend.h', + 'xcursor.h', + subdir: 'wlr' +) +if conf_data.get('WLR_HAS_XWAYLAND', false) + install_headers('xwayland.h', subdir: 'wlr') +endif + +subdir('backend') +subdir('interfaces') +subdir('render') +subdir('types') +subdir('util') diff --git a/include/wlr/render/meson.build b/include/wlr/render/meson.build new file mode 100644 index 00000000..05127bb7 --- /dev/null +++ b/include/wlr/render/meson.build @@ -0,0 +1,9 @@ +install_headers( + 'dmabuf.h', + 'egl.h', + 'gles2.h', + 'interface.h', + 'wlr_renderer.h', + 'wlr_texture.h', + subdir: 'wlr/render' +) diff --git a/include/wlr/types/meson.build b/include/wlr/types/meson.build new file mode 100644 index 00000000..8c81cb0e --- /dev/null +++ b/include/wlr/types/meson.build @@ -0,0 +1,42 @@ +install_headers( + 'wlr_box.h', + 'wlr_buffer.h', + 'wlr_compositor.h', + 'wlr_cursor.h', + 'wlr_data_device.h', + 'wlr_export_dmabuf_v1.h', + 'wlr_gamma_control.h', + 'wlr_gamma_control_v1.h', + 'wlr_idle.h', + 'wlr_idle_inhibit_v1.h', + 'wlr_input_device.h', + 'wlr_input_inhibitor.h', + 'wlr_keyboard.h', + 'wlr_layer_shell.h', + 'wlr_linux_dmabuf_v1.h', + 'wlr_list.h', + 'wlr_matrix.h', + 'wlr_output.h', + 'wlr_output_damage.h', + 'wlr_output_layout.h', + 'wlr_pointer.h', + 'wlr_primary_selection.h', + 'wlr_region.h', + 'wlr_screencopy_v1.h', + 'wlr_screenshooter.h', + 'wlr_seat.h', + 'wlr_server_decoration.h', + 'wlr_surface.h', + 'wlr_tablet_pad.h', + 'wlr_tablet_tool.h', + 'wlr_tablet_v2.h', + 'wlr_touch.h', + 'wlr_virtual_keyboard_v1.h', + 'wlr_wl_shell.h', + 'wlr_xcursor_manager.h', + 'wlr_xdg_decoration_v1.h', + 'wlr_xdg_output.h', + 'wlr_xdg_shell.h', + 'wlr_xdg_shell_v6.h', + subdir: 'wlr/types', +) diff --git a/include/wlr/types/wlr_gamma_control.h b/include/wlr/types/wlr_gamma_control.h index ac078b5a..912a413c 100644 --- a/include/wlr/types/wlr_gamma_control.h +++ b/include/wlr/types/wlr_gamma_control.h @@ -17,6 +17,10 @@ struct wlr_gamma_control_manager { struct wl_listener display_destroy; + struct { + struct wl_signal destroy; + } events; + void *data; }; diff --git a/include/wlr/types/wlr_gamma_control_v1.h b/include/wlr/types/wlr_gamma_control_v1.h index 5a173323..f186aa81 100644 --- a/include/wlr/types/wlr_gamma_control_v1.h +++ b/include/wlr/types/wlr_gamma_control_v1.h @@ -10,6 +10,10 @@ struct wlr_gamma_control_manager_v1 { struct wl_listener display_destroy; + struct { + struct wl_signal destroy; + } events; + void *data; }; diff --git a/include/wlr/types/wlr_idle.h b/include/wlr/types/wlr_idle.h index 608b5894..d8c81a60 100644 --- a/include/wlr/types/wlr_idle.h +++ b/include/wlr/types/wlr_idle.h @@ -30,6 +30,7 @@ struct wlr_idle { struct wl_listener display_destroy; struct { struct wl_signal activity_notify; + struct wl_signal destroy; } events; void *data; diff --git a/include/wlr/types/wlr_idle_inhibit_v1.h b/include/wlr/types/wlr_idle_inhibit_v1.h index 9f481e2f..2093eafe 100644 --- a/include/wlr/types/wlr_idle_inhibit_v1.h +++ b/include/wlr/types/wlr_idle_inhibit_v1.h @@ -32,6 +32,7 @@ struct wlr_idle_inhibit_manager_v1 { struct { struct wl_signal new_inhibitor; + struct wl_signal destroy; } events; void *data; diff --git a/include/wlr/types/wlr_input_inhibitor.h b/include/wlr/types/wlr_input_inhibitor.h index 5772f1a5..f3187540 100644 --- a/include/wlr/types/wlr_input_inhibitor.h +++ b/include/wlr/types/wlr_input_inhibitor.h @@ -20,6 +20,7 @@ struct wlr_input_inhibit_manager { struct { struct wl_signal activate; // struct wlr_input_inhibit_manager * struct wl_signal deactivate; // struct wlr_input_inhibit_manager * + struct wl_signal destroy; } events; void *data; diff --git a/include/wlr/types/wlr_layer_shell.h b/include/wlr/types/wlr_layer_shell.h index 029f8cbe..c7ddd180 100644 --- a/include/wlr/types/wlr_layer_shell.h +++ b/include/wlr/types/wlr_layer_shell.h @@ -39,6 +39,7 @@ struct wlr_layer_shell { // Note: the output may be NULL. In this case, it is your // responsibility to assign an output before returning. struct wl_signal new_surface; + struct wl_signal destroy; } events; void *data; diff --git a/include/wlr/types/wlr_output_layout.h b/include/wlr/types/wlr_output_layout.h index 2ac12a6a..cc9d2328 100644 --- a/include/wlr/types/wlr_output_layout.h +++ b/include/wlr/types/wlr_output_layout.h @@ -126,5 +126,8 @@ enum wlr_direction { struct wlr_output *wlr_output_layout_adjacent_output( struct wlr_output_layout *layout, enum wlr_direction direction, struct wlr_output *reference, double ref_lx, double ref_ly); +struct wlr_output *wlr_output_layout_farthest_output( + struct wlr_output_layout *layout, enum wlr_direction direction, + struct wlr_output *reference, double ref_lx, double ref_ly); #endif diff --git a/include/wlr/types/wlr_primary_selection.h b/include/wlr/types/wlr_primary_selection.h index fa9ee843..f33f6368 100644 --- a/include/wlr/types/wlr_primary_selection.h +++ b/include/wlr/types/wlr_primary_selection.h @@ -17,6 +17,10 @@ struct wlr_primary_selection_device_manager { struct wl_listener display_destroy; + struct { + struct wl_signal destroy; + } events; + void *data; }; diff --git a/include/wlr/types/wlr_screencopy_v1.h b/include/wlr/types/wlr_screencopy_v1.h index 8c3b77fd..822fb3d0 100644 --- a/include/wlr/types/wlr_screencopy_v1.h +++ b/include/wlr/types/wlr_screencopy_v1.h @@ -18,6 +18,10 @@ struct wlr_screencopy_manager_v1 { struct wl_listener display_destroy; + struct { + struct wl_signal destroy; + } events; + void *data; }; diff --git a/include/wlr/types/wlr_screenshooter.h b/include/wlr/types/wlr_screenshooter.h index ccdb8cf5..b7b87b39 100644 --- a/include/wlr/types/wlr_screenshooter.h +++ b/include/wlr/types/wlr_screenshooter.h @@ -17,6 +17,10 @@ struct wlr_screenshooter { struct wl_listener display_destroy; + struct { + struct wl_signal destroy; + } events; + void *data; }; diff --git a/include/wlr/types/wlr_server_decoration.h b/include/wlr/types/wlr_server_decoration.h index 2a76b35c..ff8d1369 100644 --- a/include/wlr/types/wlr_server_decoration.h +++ b/include/wlr/types/wlr_server_decoration.h @@ -45,6 +45,7 @@ struct wlr_server_decoration_manager { struct { struct wl_signal new_decoration; + struct wl_signal destroy; } events; void *data; diff --git a/include/wlr/types/wlr_tablet_v2.h b/include/wlr/types/wlr_tablet_v2.h index c332b5b1..3eb40392 100644 --- a/include/wlr/types/wlr_tablet_v2.h +++ b/include/wlr/types/wlr_tablet_v2.h @@ -29,6 +29,10 @@ struct wlr_tablet_manager_v2 { struct wl_listener display_destroy; + struct { + struct wl_signal destroy; + } events; + void *data; }; diff --git a/include/wlr/types/wlr_virtual_keyboard_v1.h b/include/wlr/types/wlr_virtual_keyboard_v1.h index 1df0f3a3..e75ed8ec 100644 --- a/include/wlr/types/wlr_virtual_keyboard_v1.h +++ b/include/wlr/types/wlr_virtual_keyboard_v1.h @@ -22,6 +22,7 @@ struct wlr_virtual_keyboard_manager_v1 { struct { struct wl_signal new_virtual_keyboard; // struct wlr_virtual_keyboard_v1* + struct wl_signal destroy; } events; }; diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 0a52ae3e..dffbb4d7 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -24,6 +24,7 @@ struct wlr_wl_shell { struct { struct wl_signal new_surface; + struct wl_signal destroy; } events; void *data; diff --git a/include/wlr/types/wlr_xdg_decoration_v1.h b/include/wlr/types/wlr_xdg_decoration_v1.h index 10d3a1aa..ba1ad84b 100644 --- a/include/wlr/types/wlr_xdg_decoration_v1.h +++ b/include/wlr/types/wlr_xdg_decoration_v1.h @@ -19,6 +19,7 @@ struct wlr_xdg_decoration_manager_v1 { struct { struct wl_signal new_toplevel_decoration; // struct wlr_xdg_toplevel_decoration * + struct wl_signal destroy; } events; void *data; diff --git a/include/wlr/types/wlr_xdg_output.h b/include/wlr/types/wlr_xdg_output.h index 2754b291..60611307 100644 --- a/include/wlr/types/wlr_xdg_output.h +++ b/include/wlr/types/wlr_xdg_output.h @@ -34,6 +34,10 @@ struct wlr_xdg_output_manager { struct wl_listener layout_add; struct wl_listener layout_change; struct wl_listener layout_destroy; + + struct { + struct wl_signal destroy; + } events; }; struct wlr_xdg_output_manager *wlr_xdg_output_manager_create( diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h index 6304bfc1..1bca9ef3 100644 --- a/include/wlr/types/wlr_xdg_shell.h +++ b/include/wlr/types/wlr_xdg_shell.h @@ -29,6 +29,7 @@ struct wlr_xdg_shell { * surface will be ready to be managed on the `map` event. */ struct wl_signal new_surface; + struct wl_signal destroy; } events; void *data; diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 8fdf5090..a69e488f 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -30,6 +30,7 @@ struct wlr_xdg_shell_v6 { * surface will be ready to be managed on the `map` event. */ struct wl_signal new_surface; + struct wl_signal destroy; } events; void *data; diff --git a/include/wlr/util/meson.build b/include/wlr/util/meson.build new file mode 100644 index 00000000..ee72cbd6 --- /dev/null +++ b/include/wlr/util/meson.build @@ -0,0 +1,6 @@ +install_headers( + 'edges.h', + 'log.h', + 'region.h', + subdir: 'wlr/util', +) diff --git a/include/wlr/version.h.in b/include/wlr/version.h.in new file mode 100644 index 00000000..cdc0fd75 --- /dev/null +++ b/include/wlr/version.h.in @@ -0,0 +1,16 @@ +#ifndef WLR_VERSION_H +#define WLR_VERSION_H + +#mesondefine WLR_VERSION_STR + +#mesondefine WLR_VERSION_MAJOR +#mesondefine WLR_VERSION_MINOR +#mesondefine WLR_VERSION_MICRO + +#define WLR_VERSION_NUM ((WLR_VERSION_MAJOR << 16) | (WLR_VERSION_MINOR << 8) | WLR_VERSION_MICRO) + +#mesondefine WLR_VERSION_API_CURRENT +#mesondefine WLR_VERSION_API_REVISION +#mesondefine WLR_VERSION_API_AGE + +#endif diff --git a/meson.build b/meson.build index 655eb52d..ff4e5e5f 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project( 'c', version: '0.0.1', license: 'MIT', - meson_version: '>=0.44.0', + meson_version: '>=0.47.1', default_options: [ 'c_std=c11', 'warning_level=2', @@ -18,15 +18,7 @@ so_version = ['0', '0', '0'] add_project_arguments('-Wno-unused-parameter', language: 'c') add_project_arguments( - '-DWLR_SRC_DIR="@0@"'.format(meson.source_root()), - language: 'c', -) -add_project_arguments( - '-I@0@'.format(meson.build_root()), - language: 'c', -) -add_project_link_arguments( - '-Wl,-rpath,@0@'.format(meson.build_root()), + '-DWLR_SRC_DIR="@0@"'.format(meson.current_source_dir()), language: 'c', ) add_project_arguments( @@ -36,7 +28,7 @@ add_project_arguments( conf_data = configuration_data() -wlr_inc = include_directories('include') +wlr_inc = include_directories('.', 'include') cc = meson.get_compiler('c') @@ -62,90 +54,37 @@ libinput = dependency('libinput', version: '>=1.7.0') xkbcommon = dependency('xkbcommon') udev = dependency('libudev') pixman = dependency('pixman-1') -libcap = dependency('libcap', required: get_option('enable-libcap') == 'true') -systemd = dependency('libsystemd', required: get_option('enable-systemd') == 'true') -elogind = dependency('libelogind', required: get_option('enable-elogind') == 'true') +libcap = dependency('libcap', required: get_option('libcap')) +logind = dependency('lib' + get_option('logind-provider'), required: get_option('logind')) math = cc.find_library('m', required: false) -exclude_headers = [] wlr_parts = [] wlr_deps = [] -if libcap.found() and get_option('enable-libcap') != 'false' +if libcap.found() conf_data.set('WLR_HAS_LIBCAP', true) wlr_deps += libcap endif -if systemd.found() and get_option('enable-systemd') != 'false' - conf_data.set('WLR_HAS_SYSTEMD', true) - wlr_deps += systemd -endif - -if elogind.found() and get_option('enable-elogind') != 'false' - conf_data.set('WLR_HAS_ELOGIND', true) -endif - -if get_option('enable-x11_backend') or get_option('enable-xwayland') - xcb = dependency('xcb') - xcb_composite = dependency('xcb-composite') - xcb_xfixes = dependency('xcb-xfixes') - xcb_image = dependency('xcb-image') - xcb_render = dependency('xcb-render') - x11_xcb = dependency('x11-xcb') - - xcb_icccm = dependency('xcb-icccm', required: false) - xcb_xkb = dependency('xcb-xkb', required: false) - xcb_errors = dependency('xcb-errors', required: get_option('enable-xcb_errors') == 'true') - - if xcb_icccm.found() - conf_data.set('WLR_HAS_XCB_ICCCM', true) - endif - - if xcb_xkb.found() - conf_data.set('WLR_HAS_XCB_XKB', true) - endif - - if xcb_errors.found() and get_option('enable-xcb_errors') != 'false' - conf_data.set('WLR_HAS_XCB_ERRORS', true) - endif - - wlr_deps += [ - xcb, - xcb_composite, - x11_xcb, - ] -else - add_project_arguments('-DMESA_EGL_NO_X11_HEADERS', language: 'c') -endif - -if get_option('enable-x11_backend') - conf_data.set('WLR_HAS_X11_BACKEND', true) -endif - -if get_option('enable-xwayland') - subdir('xwayland') - wlr_parts += [lib_wlr_xwayland] - conf_data.set('WLR_HAS_XWAYLAND', true) -else - exclude_headers += 'xwayland.h' +if logind.found() + conf_data.set('WLR_HAS_' + get_option('logind-provider').to_upper(), true) + wlr_deps += logind endif if cc.has_header_symbol('fcntl.h', 'posix_fallocate', prefix: '#define _POSIX_C_SOURCE 200112L') conf_data.set('WLR_HAS_POSIX_FALLOCATE', true) endif -includedir = get_option('includedir') -exclude_headers += 'meson.build' -install_subdir('include/wlr', install_dir: includedir, exclude_files: exclude_headers) - - -subdir('include') subdir('protocol') subdir('render') + subdir('backend') subdir('types') subdir('util') subdir('xcursor') +subdir('xwayland') + +subdir('include') wlr_parts += [ lib_wl_protos, @@ -182,6 +121,7 @@ lib_wlr = library( include_directories: wlr_inc, install: true, link_args : symbols_flag, + link_depends: symbols_file, ) wlroots = declare_dependency( @@ -190,7 +130,6 @@ wlroots = declare_dependency( include_directories: wlr_inc, ) - summary = [ '', '----------------', @@ -208,14 +147,8 @@ summary = [ ] message('\n'.join(summary)) - -if get_option('enable-rootston') - subdir('rootston') -endif - -if get_option('enable-examples') - subdir('examples') -endif +subdir('examples') +subdir('rootston') pkgconfig = import('pkgconfig') pkgconfig.generate( @@ -230,26 +163,31 @@ git = find_program('git', required: false) if git.found() all_files = run_command( git, - ['--git-dir=@0@/.git'.format(meson.current_source_dir()), - 'ls-files', - ':/*.[ch]']) + '--git-dir=@0@/.git'.format(meson.current_source_dir()), + 'ls-files', + ':/*.[ch]', + ) all_files = files(all_files.stdout().split()) etags = find_program('etags', required: false) if etags.found() and all_files.length() > 0 - custom_target('etags', + custom_target( + 'etags', build_by_default: true, input: all_files, output: 'TAGS', - command: [etags.path(), '-o', 'TAGS'] + all_files) + command: [etags, '-o', '@OUTPUT@', '@INPUT@'], + ) endif ctags = find_program('ctags', required: false) if ctags.found() and all_files.length() > 0 - custom_target('ctags', + custom_target( + 'ctags', build_by_default: true, input: all_files, output: 'tags', - command: [ctags.path(), '-f', 'tags'] + all_files) + command: [ctags, '-f', '@OUTPUT@', '@INPUT@'], + ) endif endif diff --git a/meson_options.txt b/meson_options.txt index e474b8aa..360c6f6a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,8 +1,10 @@ -option('enable-libcap', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Enable support for capabilities') -option('enable-systemd', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Enable support for logind') -option('enable-elogind', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Enable support for logind') -option('enable-xcb_errors', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Use xcb-errors util library') -option('enable-xwayland', type: 'boolean', value: true, description: 'Enable support X11 applications') -option('enable-x11_backend', type: 'boolean', value: true, description: 'Enable X11 backend') -option('enable-rootston', type: 'boolean', value: true, description: 'Build the rootston example compositor') -option('enable-examples', type: 'boolean', value: true, description: 'Build example applications') +option('libcap', type: 'feature', value: 'auto', description: 'Enable support for rootless session via capabilities (cap_sys_admin)') +option('logind', type: 'feature', value: 'auto', description: 'Enable support for rootless session via logind') +option('logind-provider', type: 'combo', choices: ['systemd', 'elogind'], value: 'systemd', description: 'Provider of logind support library') +option('xcb-errors', type: 'feature', value: 'auto', description: 'Use xcb-errors util library') +option('xcb-icccm', type: 'feature', value: 'auto', description: 'Use xcb-icccm util library') +option('xcb-xkb', type: 'feature', value: 'auto', description: 'Use xcb-xkb util library') +option('xwayland', type: 'feature', value: 'auto', description: 'Enable support for X11 applications') +option('x11-backend', type: 'feature', value: 'auto', description: 'Enable X11 backend') +option('rootston', type: 'boolean', value: true, description: 'Build the rootston example compositor') +option('examples', type: 'boolean', value: true, description: 'Build example applications') diff --git a/protocol/meson.build b/protocol/meson.build index 73a3156a..2d2a73ed 100644 --- a/protocol/meson.build +++ b/protocol/meson.build @@ -1,32 +1,15 @@ wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir') -wayland_scanner = find_program('wayland-scanner') - -wayland_scanner_server = generator( - wayland_scanner, - output: '@BASENAME@-protocol.h', - arguments: ['server-header', '@INPUT@', '@OUTPUT@'], -) - -# 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' +wayland_scanner_dep = dependency('wayland-scanner', required: false, native: true) +if wayland_scanner_dep.found() + wayland_scanner = find_program( + wayland_scanner_dep.get_pkgconfig_variable('wayland_scanner'), + native: true, + ) else - code_type = 'code' + wayland_scanner = find_program('wayland-scanner', native: true) endif -wayland_scanner_code = generator( - wayland_scanner, - output: '@BASENAME@-protocol.c', - arguments: [code_type, '@INPUT@', '@OUTPUT@'], -) - -wayland_scanner_client = generator( - wayland_scanner, - output: '@BASENAME@-client-protocol.h', - arguments: ['client-header', '@INPUT@', '@OUTPUT@'], -) - protocols = [ [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'], [wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'], @@ -67,17 +50,35 @@ wl_protos_headers = [] foreach p : protocols xml = join_paths(p) - wl_protos_src += wayland_scanner_code.process(xml) - wl_protos_headers += wayland_scanner_server.process(xml) + wl_protos_src += custom_target( + xml.underscorify() + '_server_c', + input: xml, + output: '@BASENAME@-protocol.c', + command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'], + ) + wl_protos_headers += custom_target( + xml.underscorify() + '_server_h', + input: xml, + output: '@BASENAME@-protocol.h', + command: [wayland_scanner, 'server-header', '@INPUT@', '@OUTPUT@'], + ) endforeach foreach p : client_protocols xml = join_paths(p) - wl_protos_headers += wayland_scanner_client.process(xml) + wl_protos_headers += custom_target( + xml.underscorify() + '_client_h', + input: xml, + output: '@BASENAME@-client-protocol.h', + command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'], + ) endforeach -lib_wl_protos = static_library('wl_protos', wl_protos_src + wl_protos_headers, - dependencies: [wayland_client]) # for the include directory +lib_wl_protos = static_library( + 'wl_protos', + wl_protos_src + wl_protos_headers, + dependencies: wayland_client.partial_dependency(includes: true), +) wlr_protos = declare_dependency( link_with: lib_wl_protos, diff --git a/render/meson.build b/render/meson.build index 4b90c229..ab66eab0 100644 --- a/render/meson.build +++ b/render/meson.build @@ -1,9 +1,10 @@ glgen = find_program('../glgen.sh') -glapi = custom_target('glapi', +glapi = custom_target( + 'glapi', input: 'glapi.txt', output: ['@BASENAME@.c', '@BASENAME@.h'], - command: [glgen, '@INPUT@', '@OUTPUT0@', '@OUTPUT1@'], + command: [glgen, '@INPUT@', '@OUTDIR@'], ) lib_wlr_render = static_library( @@ -19,8 +20,7 @@ lib_wlr_render = static_library( 'wlr_renderer.c', 'wlr_texture.c', ), - glapi[0], - glapi[1], + glapi, include_directories: wlr_inc, dependencies: [egl, glesv2, pixman, wayland_server], ) diff --git a/rootston/meson.build b/rootston/meson.build index 8ab872b5..9d1decce 100644 --- a/rootston/meson.build +++ b/rootston/meson.build @@ -11,12 +11,17 @@ sources = [ 'seat.c', 'virtual_keyboard.c', 'wl_shell.c', - 'xdg_shell_v6.c', 'xdg_shell.c', + 'xdg_shell_v6.c', ] -if get_option('enable-xwayland') - sources += ['xwayland.c'] + +if conf_data.get('WLR_HAS_XWAYLAND', false) + sources += 'xwayland.c' endif + executable( - 'rootston', sources, dependencies: [wlroots, wlr_protos, pixman] + 'rootston', + sources, + dependencies: [wlroots, wlr_protos, pixman], + build_by_default: get_option('rootston'), ) diff --git a/types/tablet_v2/wlr_tablet_v2.c b/types/tablet_v2/wlr_tablet_v2.c index fa058e79..45036839 100644 --- a/types/tablet_v2/wlr_tablet_v2.c +++ b/types/tablet_v2/wlr_tablet_v2.c @@ -14,6 +14,7 @@ #include <wlr/types/wlr_tablet_v2.h> #include <wlr/util/log.h> #include "tablet-unstable-v2-protocol.h" +#include "util/signal.h" #define TABLET_MANAGER_VERSION 1 @@ -281,6 +282,7 @@ void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager) { wlr_tablet_manager_v2_destroy(pos->resource); } + wlr_signal_emit_safe(&manager->events.destroy, manager); wl_global_destroy(manager->wl_global); free(manager); } @@ -292,6 +294,7 @@ struct wlr_tablet_manager_v2 *wlr_tablet_v2_create(struct wl_display *display) { return NULL; } + wl_signal_init(&tablet->events.destroy); wl_list_init(&tablet->clients); wl_list_init(&tablet->seats); diff --git a/types/wlr_gamma_control.c b/types/wlr_gamma_control.c index 8dbe1c22..40ca2aca 100644 --- a/types/wlr_gamma_control.c +++ b/types/wlr_gamma_control.c @@ -155,11 +155,12 @@ void wlr_gamma_control_manager_destroy( if (!manager) { return; } - wl_list_remove(&manager->display_destroy.link); struct wlr_gamma_control *gamma_control, *tmp; wl_list_for_each_safe(gamma_control, tmp, &manager->controls, link) { gamma_control_destroy(gamma_control); } + wlr_signal_emit_safe(&manager->events.destroy, manager); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); } @@ -186,6 +187,7 @@ struct wlr_gamma_control_manager *wlr_gamma_control_manager_create( } manager->global = global; + wl_signal_init(&manager->events.destroy); wl_list_init(&manager->controls); manager->display_destroy.notify = handle_display_destroy; diff --git a/types/wlr_gamma_control_v1.c b/types/wlr_gamma_control_v1.c index 54ab7e9d..9f049a0b 100644 --- a/types/wlr_gamma_control_v1.c +++ b/types/wlr_gamma_control_v1.c @@ -219,11 +219,12 @@ void wlr_gamma_control_manager_v1_destroy( if (!manager) { return; } - wl_list_remove(&manager->display_destroy.link); struct wlr_gamma_control_v1 *gamma_control, *tmp; wl_list_for_each_safe(gamma_control, tmp, &manager->controls, link) { wl_resource_destroy(gamma_control->resource); } + wlr_signal_emit_safe(&manager->events.destroy, manager); + wl_list_remove(&manager->display_destroy.link); struct wl_resource *resource, *resource_tmp; wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) { wl_resource_destroy(resource); @@ -254,6 +255,7 @@ struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create( return NULL; } + wl_signal_init(&manager->events.destroy); wl_list_init(&manager->resources); wl_list_init(&manager->controls); diff --git a/types/wlr_idle.c b/types/wlr_idle.c index b4e00451..2d0e8eed 100644 --- a/types/wlr_idle.c +++ b/types/wlr_idle.c @@ -187,6 +187,7 @@ void wlr_idle_destroy(struct wlr_idle *idle) { if (!idle) { return; } + wlr_signal_emit_safe(&idle->events.destroy, idle); wl_list_remove(&idle->display_destroy.link); struct wlr_idle_timeout *timer, *tmp; wl_list_for_each_safe(timer, tmp, &idle->idle_timers, link) { @@ -208,6 +209,7 @@ struct wlr_idle *wlr_idle_create(struct wl_display *display) { } wl_list_init(&idle->idle_timers); wl_signal_init(&idle->events.activity_notify); + wl_signal_init(&idle->events.destroy); idle->enabled = true; idle->event_loop = wl_display_get_event_loop(display); diff --git a/types/wlr_idle_inhibit_v1.c b/types/wlr_idle_inhibit_v1.c index 4cee3029..5f3d3d40 100644 --- a/types/wlr_idle_inhibit_v1.c +++ b/types/wlr_idle_inhibit_v1.c @@ -144,14 +144,15 @@ void wlr_idle_inhibit_v1_destroy(struct wlr_idle_inhibit_manager_v1 *idle_inhibi return; } - wl_list_remove(&idle_inhibit->display_destroy.link); - struct wlr_idle_inhibitor_v1 *inhibitor; struct wlr_idle_inhibitor_v1 *tmp; wl_list_for_each_safe(inhibitor, tmp, &idle_inhibit->inhibitors, link) { idle_inhibitor_v1_destroy(inhibitor); } + wlr_signal_emit_safe(&idle_inhibit->events.destroy, idle_inhibit); + wl_list_remove(&idle_inhibit->display_destroy.link); + struct wl_resource *resource; struct wl_resource *tmp_resource; wl_resource_for_each_safe(resource, tmp_resource, &idle_inhibit->resources) { @@ -175,6 +176,7 @@ struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display idle_inhibit->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &idle_inhibit->display_destroy); wl_signal_init(&idle_inhibit->events.new_inhibitor); + wl_signal_init(&idle_inhibit->events.destroy); idle_inhibit->global = wl_global_create(display, &zwp_idle_inhibit_manager_v1_interface, 1, diff --git a/types/wlr_input_inhibitor.c b/types/wlr_input_inhibitor.c index dc5175f8..fa692d6c 100644 --- a/types/wlr_input_inhibitor.c +++ b/types/wlr_input_inhibitor.c @@ -112,6 +112,7 @@ void wlr_input_inhibit_manager_destroy( input_inhibitor_destroy(manager->active_client, manager->active_inhibitor); } + wlr_signal_emit_safe(&manager->events.destroy, manager); wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -143,6 +144,7 @@ struct wlr_input_inhibit_manager *wlr_input_inhibit_manager_create( wl_signal_init(&manager->events.activate); wl_signal_init(&manager->events.deactivate); + wl_signal_init(&manager->events.destroy); manager->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &manager->display_destroy); diff --git a/types/wlr_layer_shell.c b/types/wlr_layer_shell.c index 5d610ece..52e5088e 100644 --- a/types/wlr_layer_shell.c +++ b/types/wlr_layer_shell.c @@ -449,6 +449,7 @@ struct wlr_layer_shell *wlr_layer_shell_create(struct wl_display *display) { layer_shell->global = global; wl_signal_init(&layer_shell->events.new_surface); + wl_signal_init(&layer_shell->events.destroy); layer_shell->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &layer_shell->display_destroy); @@ -464,6 +465,7 @@ void wlr_layer_shell_destroy(struct wlr_layer_shell *layer_shell) { wl_resource_for_each_safe(client, tmp, &layer_shell->client_resources) { wl_resource_destroy(client); } + wlr_signal_emit_safe(&layer_shell->events.destroy, layer_shell); wl_list_remove(&layer_shell->display_destroy.link); wl_global_destroy(layer_shell->global); free(layer_shell); diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 5ad0c99e..e634d2b2 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -430,15 +430,20 @@ struct wlr_output *wlr_output_layout_get_center_output( return wlr_output_layout_output_at(layout, dest_x, dest_y); } +enum distance_selection_method { + NEAREST, + FARTHEST +}; -struct wlr_output *wlr_output_layout_adjacent_output( +struct wlr_output *wlr_output_layout_output_in_direction( struct wlr_output_layout *layout, enum wlr_direction direction, - struct wlr_output *reference, double ref_lx, double ref_ly) { + struct wlr_output *reference, double ref_lx, double ref_ly, + enum distance_selection_method distance_method) { assert(reference); struct wlr_box *ref_box = wlr_output_layout_get_box(layout, reference); - double min_distance = DBL_MAX; + double min_distance = (distance_method == NEAREST) ? DBL_MAX : DBL_MIN; struct wlr_output *closest_output = NULL; struct wlr_output_layout_output *l_output; wl_list_for_each(l_output, &layout->outputs, link) { @@ -471,10 +476,28 @@ struct wlr_output *wlr_output_layout_adjacent_output( ref_lx, ref_ly, &x, &y); double distance = (x - ref_lx) * (x - ref_lx) + (y - ref_ly) * (y - ref_ly); - if (distance < min_distance) { + + if ((distance_method == NEAREST) + ? distance < min_distance + : distance > min_distance) { min_distance = distance; closest_output = l_output->output; } } return closest_output; } + +struct wlr_output *wlr_output_layout_adjacent_output( + struct wlr_output_layout *layout, enum wlr_direction direction, + struct wlr_output *reference, double ref_lx, double ref_ly) { + return wlr_output_layout_output_in_direction(layout, direction, + reference, ref_lx, ref_ly, NEAREST); +} + +struct wlr_output *wlr_output_layout_farthest_output( + struct wlr_output_layout *layout, enum wlr_direction direction, + struct wlr_output *reference, double ref_lx, double ref_ly) { + return wlr_output_layout_output_in_direction(layout, direction, + reference, ref_lx, ref_ly, FARTHEST); +} + diff --git a/types/wlr_primary_selection.c b/types/wlr_primary_selection.c index 750f9ab4..e561852f 100644 --- a/types/wlr_primary_selection.c +++ b/types/wlr_primary_selection.c @@ -408,6 +408,8 @@ struct wlr_primary_selection_device_manager * return NULL; } + wl_signal_init(&manager->events.destroy); + manager->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &manager->display_destroy); @@ -419,6 +421,7 @@ void wlr_primary_selection_device_manager_destroy( if (manager == NULL) { return; } + wlr_signal_emit_safe(&manager->events.destroy, manager); wl_list_remove(&manager->display_destroy.link); // TODO: free resources wl_global_destroy(manager->global); diff --git a/types/wlr_screencopy_v1.c b/types/wlr_screencopy_v1.c index bd3dfe9a..4f044eba 100644 --- a/types/wlr_screencopy_v1.c +++ b/types/wlr_screencopy_v1.c @@ -5,6 +5,7 @@ #include <wlr/types/wlr_screencopy_v1.h> #include <wlr/backend.h> #include "wlr-screencopy-unstable-v1-protocol.h" +#include "util/signal.h" #define SCREENCOPY_MANAGER_VERSION 1 @@ -295,6 +296,8 @@ struct wlr_screencopy_manager_v1 *wlr_screencopy_manager_v1_create( wl_list_init(&manager->resources); wl_list_init(&manager->frames); + wl_signal_init(&manager->events.destroy); + manager->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &manager->display_destroy); @@ -306,6 +309,7 @@ void wlr_screencopy_manager_v1_destroy( if (manager == NULL) { return; } + wlr_signal_emit_safe(&manager->events.destroy, manager); wl_list_remove(&manager->display_destroy.link); struct wlr_screencopy_frame_v1 *frame, *tmp_frame; wl_list_for_each_safe(frame, tmp_frame, &manager->frames, link) { diff --git a/types/wlr_screenshooter.c b/types/wlr_screenshooter.c index 37b70538..c85e6ba5 100644 --- a/types/wlr_screenshooter.c +++ b/types/wlr_screenshooter.c @@ -8,6 +8,7 @@ #include <wlr/types/wlr_screenshooter.h> #include <wlr/util/log.h> #include "screenshooter-protocol.h" +#include "util/signal.h" static struct wlr_screenshot *screenshot_from_resource( struct wl_resource *resource) { @@ -177,6 +178,7 @@ void wlr_screenshooter_destroy(struct wlr_screenshooter *screenshooter) { wl_list_for_each_safe(screenshot, tmp, &screenshooter->screenshots, link) { screenshot_destroy(screenshot); } + wlr_signal_emit_safe(&screenshooter->events.destroy, screenshooter); wl_global_destroy(screenshooter->global); free(screenshooter); } @@ -195,6 +197,7 @@ struct wlr_screenshooter *wlr_screenshooter_create(struct wl_display *display) { } wl_list_init(&screenshooter->screenshots); + wl_signal_init(&screenshooter->events.destroy); screenshooter->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &screenshooter->display_destroy); diff --git a/types/wlr_server_decoration.c b/types/wlr_server_decoration.c index fceb1638..fd92fd04 100644 --- a/types/wlr_server_decoration.c +++ b/types/wlr_server_decoration.c @@ -167,12 +167,13 @@ void wlr_server_decoration_manager_destroy( if (manager == NULL) { return; } - wl_list_remove(&manager->display_destroy.link); struct wlr_server_decoration *decoration, *tmp_decoration; wl_list_for_each_safe(decoration, tmp_decoration, &manager->decorations, link) { server_decoration_destroy(decoration); } + wlr_signal_emit_safe(&manager->events.destroy, manager); + wl_list_remove(&manager->display_destroy.link); struct wl_resource *resource, *tmp_resource; wl_resource_for_each_safe(resource, tmp_resource, &manager->resources) { server_decoration_manager_destroy_resource(resource); @@ -205,6 +206,7 @@ struct wlr_server_decoration_manager *wlr_server_decoration_manager_create( wl_list_init(&manager->resources); wl_list_init(&manager->decorations); wl_signal_init(&manager->events.new_decoration); + wl_signal_init(&manager->events.destroy); manager->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &manager->display_destroy); diff --git a/types/wlr_virtual_keyboard_v1.c b/types/wlr_virtual_keyboard_v1.c index 89291b12..e5463295 100644 --- a/types/wlr_virtual_keyboard_v1.c +++ b/types/wlr_virtual_keyboard_v1.c @@ -223,6 +223,7 @@ struct wlr_virtual_keyboard_manager_v1* wl_list_init(&manager->virtual_keyboards); wl_signal_init(&manager->events.new_virtual_keyboard); + wl_signal_init(&manager->events.destroy); manager->global = wl_global_create(display, &zwp_virtual_keyboard_manager_v1_interface, 1, manager, virtual_keyboard_manager_bind); @@ -231,6 +232,7 @@ struct wlr_virtual_keyboard_manager_v1* void wlr_virtual_keyboard_manager_v1_destroy( struct wlr_virtual_keyboard_manager_v1 *manager) { + wlr_signal_emit_safe(&manager->events.destroy, manager); wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); struct wl_resource *resource, *resource_tmp; diff --git a/types/wlr_xdg_decoration_v1.c b/types/wlr_xdg_decoration_v1.c index d6aecb87..f5182daa 100644 --- a/types/wlr_xdg_decoration_v1.c +++ b/types/wlr_xdg_decoration_v1.c @@ -275,6 +275,7 @@ struct wlr_xdg_decoration_manager_v1 * wl_list_init(&manager->resources); wl_list_init(&manager->decorations); wl_signal_init(&manager->events.new_toplevel_decoration); + wl_signal_init(&manager->events.destroy); manager->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &manager->display_destroy); @@ -287,6 +288,7 @@ void wlr_xdg_decoration_manager_v1_destroy( if (manager == NULL) { return; } + wlr_signal_emit_safe(&manager->events.destroy, manager); wl_list_remove(&manager->display_destroy.link); struct wlr_xdg_toplevel_decoration_v1 *decoration, *tmp_decoration; wl_list_for_each_safe(decoration, tmp_decoration, &manager->decorations, diff --git a/types/wlr_xdg_output.c b/types/wlr_xdg_output.c index ad62fe11..8c7a1fcb 100644 --- a/types/wlr_xdg_output.c +++ b/types/wlr_xdg_output.c @@ -6,6 +6,7 @@ #include <wlr/types/wlr_xdg_output.h> #include <wlr/util/log.h> #include "xdg-output-unstable-v1-protocol.h" +#include "util/signal.h" #define OUTPUT_MANAGER_VERSION 2 @@ -227,6 +228,8 @@ struct wlr_xdg_output_manager *wlr_xdg_output_manager_create( add_output(manager, layout_output); } + wl_signal_init(&manager->events.destroy); + manager->layout_add.notify = handle_layout_add; wl_signal_add(&layout->events.add, &manager->layout_add); manager->layout_change.notify = handle_layout_change; @@ -245,6 +248,7 @@ void wlr_xdg_output_manager_destroy(struct wlr_xdg_output_manager *manager) { wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) { wl_resource_destroy(resource); } + wlr_signal_emit_safe(&manager->events.destroy, manager); wl_list_remove(&manager->layout_add.link); wl_list_remove(&manager->layout_change.link); wl_list_remove(&manager->layout_destroy.link); diff --git a/types/xdg_shell/wlr_xdg_shell.c b/types/xdg_shell/wlr_xdg_shell.c index 601e728c..58dc376c 100644 --- a/types/xdg_shell/wlr_xdg_shell.c +++ b/types/xdg_shell/wlr_xdg_shell.c @@ -155,6 +155,7 @@ struct wlr_xdg_shell *wlr_xdg_shell_create(struct wl_display *display) { xdg_shell->global = global; wl_signal_init(&xdg_shell->events.new_surface); + wl_signal_init(&xdg_shell->events.destroy); xdg_shell->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &xdg_shell->display_destroy); @@ -166,6 +167,7 @@ void wlr_xdg_shell_destroy(struct wlr_xdg_shell *xdg_shell) { if (!xdg_shell) { return; } + wlr_signal_emit_safe(&xdg_shell->events.destroy, xdg_shell); wl_list_remove(&xdg_shell->display_destroy.link); wl_global_destroy(xdg_shell->global); free(xdg_shell); diff --git a/types/xdg_shell_v6/wlr_xdg_shell_v6.c b/types/xdg_shell_v6/wlr_xdg_shell_v6.c index d61b5dc2..fce8e96a 100644 --- a/types/xdg_shell_v6/wlr_xdg_shell_v6.c +++ b/types/xdg_shell_v6/wlr_xdg_shell_v6.c @@ -156,6 +156,7 @@ struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display) { xdg_shell->global = global; wl_signal_init(&xdg_shell->events.new_surface); + wl_signal_init(&xdg_shell->events.destroy); xdg_shell->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &xdg_shell->display_destroy); @@ -167,6 +168,7 @@ void wlr_xdg_shell_v6_destroy(struct wlr_xdg_shell_v6 *xdg_shell) { if (!xdg_shell) { return; } + wlr_signal_emit_safe(&xdg_shell->events.destroy, xdg_shell); wl_list_remove(&xdg_shell->display_destroy.link); wl_global_destroy(xdg_shell->global); free(xdg_shell); diff --git a/xwayland/meson.build b/xwayland/meson.build index ec486f58..0bd88924 100644 --- a/xwayland/meson.build +++ b/xwayland/meson.build @@ -1,3 +1,32 @@ +xwayland_libs = [] +xwayland_required = [ + 'xcb', + 'xcb-composite', + 'xcb-render', + 'xcb-xfixes', +] +xwayland_optional = [ + 'xcb-errors', + 'xcb-icccm', +] + +foreach lib : xwayland_required + dep = dependency(lib, required: get_option('xwayland')) + if not dep.found() + subdir_done() + endif + + xwayland_libs += dep +endforeach + +foreach lib : xwayland_optional + dep = dependency(lib, required: get_option(lib)) + if dep.found() + xwayland_libs += dep + conf_data.set('WLR_HAS_' + lib.underscorify().to_upper(), true) + endif +endforeach + lib_wlr_xwayland = static_library( 'wlr_xwayland', files( @@ -12,14 +41,11 @@ lib_wlr_xwayland = static_library( include_directories: wlr_inc, dependencies: [ wayland_server, - xcb, - xcb_composite, - xcb_xfixes, - xcb_image, - xcb_render, - xcb_icccm, - xcb_errors, + xwayland_libs, xkbcommon, pixman, ], ) + +wlr_parts += lib_wlr_xwayland +conf_data.set('WLR_HAS_XWAYLAND', true) |