├── .builds ├── alpine.yml ├── archlinux.yml └── freebsd.yml ├── .editorconfig ├── .gitignore ├── .gitlab-ci.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── backend ├── backend.c ├── drm │ ├── atomic.c │ ├── backend.c │ ├── cvt.c │ ├── drm.c │ ├── legacy.c │ ├── meson.build │ ├── monitor.c │ ├── properties.c │ ├── renderer.c │ └── util.c ├── headless │ ├── backend.c │ ├── meson.build │ └── output.c ├── libinput │ ├── backend.c │ ├── events.c │ ├── keyboard.c │ ├── meson.build │ ├── pointer.c │ ├── switch.c │ ├── tablet_pad.c │ ├── tablet_tool.c │ └── touch.c ├── meson.build ├── multi │ ├── backend.c │ └── meson.build ├── session │ ├── meson.build │ └── session.c ├── wayland │ ├── backend.c │ ├── meson.build │ ├── output.c │ ├── pointer.c │ ├── seat.c │ └── tablet_v2.c └── x11 │ ├── backend.c │ ├── input_device.c │ ├── meson.build │ └── output.c ├── docs └── env_vars.md ├── examples ├── .gitignore ├── cat.c ├── cat.h ├── dmabuf-capture.c ├── egl_common.c ├── egl_common.h ├── foreign-toplevel.c ├── fullscreen-shell.c ├── gamma-control.c ├── idle-inhibit.c ├── idle.c ├── input-inhibitor.c ├── input-method-keyboard-grab.c ├── input-method.c ├── keyboard-shortcuts-inhibit.c ├── layer-shell.c ├── meson.build ├── multi-pointer.c ├── output-layout.c ├── output-power-management.c ├── pointer-constraints.c ├── pointer.c ├── quads.c ├── relative-pointer-unstable-v1.c ├── rotation.c ├── scene-graph.c ├── screencopy-dmabuf.c ├── screencopy.c ├── simple.c ├── tablet.c ├── text-input.c ├── toplevel-decoration.c ├── touch.c └── virtual-pointer.c ├── include ├── backend │ ├── backend.h │ ├── drm │ │ ├── cvt.h │ │ ├── drm.h │ │ ├── iface.h │ │ ├── monitor.h │ │ ├── properties.h │ │ ├── renderer.h │ │ └── util.h │ ├── headless.h │ ├── libinput.h │ ├── multi.h │ ├── session │ │ └── session.h │ ├── wayland.h │ └── x11.h ├── interfaces │ └── wlr_input_device.h ├── meson.build ├── render │ ├── allocator │ │ ├── allocator.h │ │ ├── drm_dumb.h │ │ ├── gbm.h │ │ └── shm.h │ ├── drm_format_set.h │ ├── egl.h │ ├── eglstreams_allocator.h │ ├── gles2.h │ ├── pixel_format.h │ ├── pixman.h │ ├── swapchain.h │ ├── vulkan.h │ └── wlr_renderer.h ├── types │ ├── wlr_buffer.h │ ├── wlr_data_device.h │ ├── wlr_keyboard.h │ ├── wlr_matrix.h │ ├── wlr_output.h │ ├── wlr_region.h │ ├── wlr_scene.h │ ├── wlr_seat.h │ ├── wlr_tablet_v2.h │ └── wlr_xdg_shell.h ├── util │ ├── array.h │ ├── global.h │ ├── shm.h │ ├── signal.h │ ├── time.h │ └── token.h ├── wlr │ ├── backend.h │ ├── backend │ │ ├── drm.h │ │ ├── headless.h │ │ ├── interface.h │ │ ├── libinput.h │ │ ├── multi.h │ │ ├── session.h │ │ ├── wayland.h │ │ └── x11.h │ ├── config.h.in │ ├── interfaces │ │ ├── wlr_buffer.h │ │ ├── wlr_keyboard.h │ │ ├── wlr_output.h │ │ ├── wlr_pointer.h │ │ ├── wlr_switch.h │ │ ├── wlr_tablet_pad.h │ │ ├── wlr_tablet_tool.h │ │ └── wlr_touch.h │ ├── meson.build │ ├── render │ │ ├── allocator.h │ │ ├── dmabuf.h │ │ ├── drm_format_set.h │ │ ├── egl.h │ │ ├── gles2.h │ │ ├── interface.h │ │ ├── pixman.h │ │ ├── vulkan.h │ │ ├── wlr_renderer.h │ │ └── wlr_texture.h │ ├── types │ │ ├── wlr_buffer.h │ │ ├── wlr_compositor.h │ │ ├── wlr_cursor.h │ │ ├── wlr_damage_ring.h │ │ ├── wlr_data_control_v1.h │ │ ├── wlr_data_device.h │ │ ├── wlr_drm.h │ │ ├── wlr_drm_lease_v1.h │ │ ├── wlr_export_dmabuf_v1.h │ │ ├── wlr_foreign_toplevel_management_v1.h │ │ ├── wlr_fullscreen_shell_v1.h │ │ ├── wlr_gamma_control_v1.h │ │ ├── wlr_idle.h │ │ ├── wlr_idle_inhibit_v1.h │ │ ├── wlr_input_device.h │ │ ├── wlr_input_inhibitor.h │ │ ├── wlr_input_method_v2.h │ │ ├── wlr_keyboard.h │ │ ├── wlr_keyboard_group.h │ │ ├── wlr_keyboard_shortcuts_inhibit_v1.h │ │ ├── wlr_layer_shell_v1.h │ │ ├── wlr_linux_dmabuf_v1.h │ │ ├── wlr_matrix.h │ │ ├── wlr_output.h │ │ ├── wlr_output_damage.h │ │ ├── wlr_output_layout.h │ │ ├── wlr_output_management_v1.h │ │ ├── wlr_output_power_management_v1.h │ │ ├── wlr_pointer.h │ │ ├── wlr_pointer_constraints_v1.h │ │ ├── wlr_pointer_gestures_v1.h │ │ ├── wlr_presentation_time.h │ │ ├── wlr_primary_selection.h │ │ ├── wlr_primary_selection_v1.h │ │ ├── wlr_region.h │ │ ├── wlr_relative_pointer_v1.h │ │ ├── wlr_scene.h │ │ ├── wlr_screencopy_v1.h │ │ ├── wlr_seat.h │ │ ├── wlr_server_decoration.h │ │ ├── wlr_session_lock_v1.h │ │ ├── wlr_single_pixel_buffer_v1.h │ │ ├── wlr_subcompositor.h │ │ ├── wlr_surface.h │ │ ├── wlr_switch.h │ │ ├── wlr_tablet_pad.h │ │ ├── wlr_tablet_tool.h │ │ ├── wlr_tablet_v2.h │ │ ├── wlr_text_input_v3.h │ │ ├── wlr_touch.h │ │ ├── wlr_viewporter.h │ │ ├── wlr_virtual_keyboard_v1.h │ │ ├── wlr_virtual_pointer_v1.h │ │ ├── wlr_xcursor_manager.h │ │ ├── wlr_xdg_activation_v1.h │ │ ├── wlr_xdg_decoration_v1.h │ │ ├── wlr_xdg_foreign_registry.h │ │ ├── wlr_xdg_foreign_v1.h │ │ ├── wlr_xdg_foreign_v2.h │ │ ├── wlr_xdg_output_v1.h │ │ └── wlr_xdg_shell.h │ ├── util │ │ ├── addon.h │ │ ├── box.h │ │ ├── edges.h │ │ ├── log.h │ │ └── region.h │ ├── version.h.in │ ├── xcursor.h │ └── xwayland.h ├── xcursor │ ├── cursor_data.h │ └── xcursor.h └── xwayland │ ├── meson.build │ ├── selection.h │ └── xwm.h ├── meson.build ├── meson_options.txt ├── protocol ├── drm.xml ├── idle.xml ├── input-method-unstable-v2.xml ├── meson.build ├── server-decoration.xml ├── virtual-keyboard-unstable-v1.xml ├── wayland-eglstream-controller.xml ├── wlr-data-control-unstable-v1.xml ├── wlr-export-dmabuf-unstable-v1.xml ├── wlr-foreign-toplevel-management-unstable-v1.xml ├── wlr-gamma-control-unstable-v1.xml ├── wlr-input-inhibitor-unstable-v1.xml ├── wlr-layer-shell-unstable-v1.xml ├── wlr-output-management-unstable-v1.xml ├── wlr-output-power-management-unstable-v1.xml ├── wlr-screencopy-unstable-v1.xml ├── wlr-virtual-pointer-unstable-v1.xml └── xwayland-keyboard-grab-unstable-v1.xml ├── render ├── allocator │ ├── allocator.c │ ├── drm_dumb.c │ ├── gbm.c │ ├── meson.build │ └── shm.c ├── dmabuf.c ├── drm_format_set.c ├── egl.c ├── eglstreams_allocator.c ├── gles2 │ ├── meson.build │ ├── pixel_format.c │ ├── renderer.c │ ├── shaders.c │ └── texture.c ├── meson.build ├── pixel_format.c ├── pixman │ ├── meson.build │ ├── pixel_format.c │ └── renderer.c ├── swapchain.c ├── vulkan │ ├── meson.build │ ├── pixel_format.c │ ├── renderer.c │ ├── shaders │ │ ├── common.vert │ │ ├── meson.build │ │ ├── quad.frag │ │ └── texture.frag │ ├── texture.c │ ├── util.c │ └── vulkan.c ├── wlr_renderer.c └── wlr_texture.c ├── tinywl ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── meson.build └── tinywl.c ├── types ├── data_device │ ├── wlr_data_device.c │ ├── wlr_data_offer.c │ ├── wlr_data_source.c │ └── wlr_drag.c ├── meson.build ├── output │ ├── cursor.c │ ├── output.c │ ├── render.c │ ├── state.c │ └── transform.c ├── scene │ ├── layer_shell_v1.c │ ├── output_layout.c │ ├── subsurface_tree.c │ ├── surface.c │ ├── wlr_scene.c │ └── xdg_shell.c ├── seat │ ├── wlr_seat.c │ ├── wlr_seat_keyboard.c │ ├── wlr_seat_pointer.c │ └── wlr_seat_touch.c ├── tablet_v2 │ ├── wlr_tablet_v2.c │ ├── wlr_tablet_v2_pad.c │ ├── wlr_tablet_v2_tablet.c │ └── wlr_tablet_v2_tool.c ├── wlr_buffer.c ├── wlr_compositor.c ├── wlr_cursor.c ├── wlr_damage_ring.c ├── wlr_data_control_v1.c ├── wlr_drm.c ├── wlr_drm_lease_v1.c ├── wlr_export_dmabuf_v1.c ├── wlr_foreign_toplevel_management_v1.c ├── wlr_fullscreen_shell_v1.c ├── wlr_gamma_control_v1.c ├── wlr_idle.c ├── wlr_idle_inhibit_v1.c ├── wlr_input_device.c ├── wlr_input_inhibitor.c ├── wlr_input_method_v2.c ├── wlr_keyboard.c ├── wlr_keyboard_group.c ├── wlr_keyboard_shortcuts_inhibit_v1.c ├── wlr_layer_shell_v1.c ├── wlr_linux_dmabuf_v1.c ├── wlr_matrix.c ├── wlr_output_damage.c ├── wlr_output_layout.c ├── wlr_output_management_v1.c ├── wlr_output_power_management_v1.c ├── wlr_pointer.c ├── wlr_pointer_constraints_v1.c ├── wlr_pointer_gestures_v1.c ├── wlr_presentation_time.c ├── wlr_primary_selection.c ├── wlr_primary_selection_v1.c ├── wlr_region.c ├── wlr_relative_pointer_v1.c ├── wlr_screencopy_v1.c ├── wlr_server_decoration.c ├── wlr_session_lock_v1.c ├── wlr_single_pixel_buffer_v1.c ├── wlr_subcompositor.c ├── wlr_switch.c ├── wlr_tablet_pad.c ├── wlr_tablet_tool.c ├── wlr_text_input_v3.c ├── wlr_touch.c ├── wlr_viewporter.c ├── wlr_virtual_keyboard_v1.c ├── wlr_virtual_pointer_v1.c ├── wlr_xcursor_manager.c ├── wlr_xdg_activation_v1.c ├── wlr_xdg_decoration_v1.c ├── wlr_xdg_foreign_registry.c ├── wlr_xdg_foreign_v1.c ├── wlr_xdg_foreign_v2.c ├── wlr_xdg_output_v1.c └── xdg_shell │ ├── wlr_xdg_popup.c │ ├── wlr_xdg_positioner.c │ ├── wlr_xdg_shell.c │ ├── wlr_xdg_surface.c │ └── wlr_xdg_toplevel.c ├── util ├── addon.c ├── array.c ├── box.c ├── global.c ├── log.c ├── meson.build ├── region.c ├── shm.c ├── signal.c ├── time.c └── token.c ├── wlroots.syms ├── xcursor ├── meson.build ├── wlr_xcursor.c └── xcursor.c └── xwayland ├── meson.build ├── selection ├── dnd.c ├── incoming.c ├── outgoing.c └── selection.c ├── server.c ├── sockets.c ├── sockets.h ├── xwayland.c ├── xwayland_keyboard_grab_unstable.c ├── xwayland_keyboard_grab_unstable.h └── xwm.c /.builds/alpine.yml: -------------------------------------------------------------------------------- 1 | image: alpine/edge 2 | packages: 3 | - eudev-dev 4 | - ffmpeg-dev 5 | - glslang 6 | - libinput-dev 7 | - libxkbcommon-dev 8 | - mesa-dev 9 | - meson 10 | - pixman-dev 11 | - vulkan-headers 12 | - vulkan-loader-dev 13 | - wayland-dev 14 | - wayland-protocols 15 | - xcb-util-image-dev 16 | - xcb-util-renderutil-dev 17 | - xcb-util-wm-dev 18 | - xwayland 19 | - libseat-dev 20 | sources: 21 | - https://gitlab.freedesktop.org/wlroots/wlroots.git 22 | tasks: 23 | - setup: | 24 | cd wlroots 25 | meson build --fatal-meson-warnings --default-library=both -Dauto_features=enabled -Dxcb-errors=disabled 26 | - build: | 27 | cd wlroots 28 | ninja -C build 29 | sudo ninja -C build install 30 | - build-features-disabled: | 31 | cd wlroots 32 | meson build --reconfigure -Dauto_features=disabled 33 | ninja -C build 34 | - tinywl: | 35 | cd wlroots/tinywl 36 | make 37 | -------------------------------------------------------------------------------- /.builds/archlinux.yml: -------------------------------------------------------------------------------- 1 | image: archlinux 2 | packages: 3 | - clang 4 | - ffmpeg 5 | - libinput 6 | - libxkbcommon 7 | - mesa 8 | - meson 9 | - pixman 10 | - wayland 11 | - wayland-protocols 12 | - xcb-util-errors 13 | - xcb-util-image 14 | - xcb-util-renderutil 15 | - xcb-util-wm 16 | - xorg-xwayland 17 | - seatd 18 | - vulkan-icd-loader 19 | - vulkan-headers 20 | - glslang 21 | sources: 22 | - https://gitlab.freedesktop.org/wlroots/wlroots.git 23 | tasks: 24 | - setup: | 25 | cd wlroots 26 | CC=gcc meson build-gcc --fatal-meson-warnings --default-library=both -Dauto_features=enabled --prefix /usr -Db_sanitize=address,undefined 27 | CC=clang meson build-clang --fatal-meson-warnings -Dauto_features=enabled 28 | - gcc: | 29 | cd wlroots/build-gcc 30 | ninja 31 | sudo ninja install 32 | cd ../tinywl 33 | CFLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer" make 34 | - clang: | 35 | cd wlroots/build-clang 36 | ninja 37 | - smoke-test: | 38 | cd wlroots/tinywl 39 | sudo modprobe vkms 40 | udevadm settle 41 | export WLR_BACKENDS=drm 42 | export WLR_RENDERER=pixman 43 | export WLR_DRM_DEVICES=/dev/dri/by-path/platform-vkms-card 44 | sudo chmod ugo+rw /dev/dri/by-path/platform-vkms-card 45 | sudo -E seatd-launch -- ./tinywl -s 'kill $PPID' || [ $? = 143 ] 46 | -------------------------------------------------------------------------------- /.builds/freebsd.yml: -------------------------------------------------------------------------------- 1 | image: freebsd/latest 2 | packages: 3 | - devel/evdev-proto 4 | - devel/libepoll-shim 5 | - devel/libudev-devd 6 | - devel/meson # implies ninja 7 | - devel/pkgconf 8 | - graphics/glslang 9 | - graphics/libdrm 10 | - graphics/mesa-libs 11 | - graphics/png 12 | - graphics/vulkan-headers 13 | - graphics/vulkan-loader 14 | - graphics/wayland 15 | - graphics/wayland-protocols 16 | - multimedia/ffmpeg 17 | - x11/libX11 18 | - x11/libinput 19 | - x11/libxcb 20 | - x11/libxkbcommon 21 | - x11/pixman 22 | - x11/xcb-util-errors 23 | - x11/xcb-util-renderutil 24 | - x11/xcb-util-wm 25 | - x11-servers/xwayland 26 | - sysutils/seatd 27 | - gmake 28 | sources: 29 | - https://gitlab.freedesktop.org/wlroots/wlroots.git 30 | tasks: 31 | - wlroots: | 32 | cd wlroots 33 | meson build --fatal-meson-warnings -Dauto_features=enabled 34 | ninja -C build 35 | sudo ninja -C build install 36 | - tinywl: | 37 | cd wlroots/tinywl 38 | gmake 39 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | indent_style = tab 9 | indent_size = 4 10 | max_line_length = 80 11 | 12 | [*.xml] 13 | indent_style = space 14 | indent_size = 2 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /subprojects/ 2 | .clang_complete 3 | *.o 4 | *.a 5 | bin/ 6 | test/ 7 | build/ 8 | build-*/ 9 | wayland-*-protocol.* 10 | wlr-example.ini 11 | .cache/ 12 | .vscode/ 13 | compile_commands.json 14 | *.c~ 15 | *.h~ 16 | 17 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | include: https://git.sr.ht/~emersion/dalligi/blob/master/templates/multi.yml 2 | alpine: 3 | extends: .dalligi 4 | archlinux: 5 | extends: .dalligi 6 | freebsd: 7 | extends: .dalligi 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, 2018 Drew DeVault 2 | Copyright (c) 2014 Jari Vetoniemi 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | this software and associated documentation files (the "Software"), to deal in 6 | the Software without restriction, including without limitation the rights to 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | of the Software, and to permit persons to whom the Software is furnished to do 9 | so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /backend/drm/meson.build: -------------------------------------------------------------------------------- 1 | wlr_files += files( 2 | 'atomic.c', 3 | 'backend.c', 4 | 'cvt.c', 5 | 'drm.c', 6 | 'legacy.c', 7 | 'monitor.c', 8 | 'properties.c', 9 | 'renderer.c', 10 | 'util.c', 11 | ) 12 | 13 | features += { 'drm-backend': true } 14 | -------------------------------------------------------------------------------- /backend/headless/meson.build: -------------------------------------------------------------------------------- 1 | wlr_files += files( 2 | 'backend.c', 3 | 'output.c', 4 | ) 5 | -------------------------------------------------------------------------------- /backend/libinput/keyboard.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "backend/libinput.h" 6 | 7 | struct wlr_libinput_input_device *device_from_keyboard( 8 | struct wlr_keyboard *kb) { 9 | assert(kb->impl == &libinput_keyboard_impl); 10 | 11 | struct wlr_libinput_input_device *dev = wl_container_of(kb, dev, keyboard); 12 | return dev; 13 | } 14 | 15 | static void keyboard_set_leds(struct wlr_keyboard *wlr_kb, uint32_t leds) { 16 | struct wlr_libinput_input_device *dev = device_from_keyboard(wlr_kb); 17 | libinput_device_led_update(dev->handle, leds); 18 | } 19 | 20 | const struct wlr_keyboard_impl libinput_keyboard_impl = { 21 | .name = "libinput-keyboard", 22 | .led_update = keyboard_set_leds 23 | }; 24 | 25 | void init_device_keyboard(struct wlr_libinput_input_device *dev) { 26 | const char *name = libinput_device_get_name(dev->handle); 27 | struct wlr_keyboard *wlr_kb = &dev->keyboard; 28 | wlr_keyboard_init(wlr_kb, &libinput_keyboard_impl, name); 29 | wlr_kb->base.vendor = libinput_device_get_id_vendor(dev->handle); 30 | wlr_kb->base.product = libinput_device_get_id_product(dev->handle); 31 | 32 | libinput_device_led_update(dev->handle, 0); 33 | } 34 | 35 | void handle_keyboard_key(struct libinput_event *event, 36 | struct wlr_keyboard *kb) { 37 | struct libinput_event_keyboard *kbevent = 38 | libinput_event_get_keyboard_event(event); 39 | struct wlr_keyboard_key_event wlr_event = { 0 }; 40 | wlr_event.time_msec = 41 | usec_to_msec(libinput_event_keyboard_get_time_usec(kbevent)); 42 | wlr_event.keycode = libinput_event_keyboard_get_key(kbevent); 43 | enum libinput_key_state state = 44 | libinput_event_keyboard_get_key_state(kbevent); 45 | switch (state) { 46 | case LIBINPUT_KEY_STATE_RELEASED: 47 | wlr_event.state = WL_KEYBOARD_KEY_STATE_RELEASED; 48 | break; 49 | case LIBINPUT_KEY_STATE_PRESSED: 50 | wlr_event.state = WL_KEYBOARD_KEY_STATE_PRESSED; 51 | break; 52 | } 53 | wlr_event.update_state = true; 54 | wlr_keyboard_notify_key(kb, &wlr_event); 55 | } 56 | -------------------------------------------------------------------------------- /backend/libinput/meson.build: -------------------------------------------------------------------------------- 1 | msg = ['Required for libinput backend support.'] 2 | if 'libinput' in backends 3 | msg += 'Install "libinput" or disable the libinput backend.' 4 | endif 5 | 6 | libinput = dependency( 7 | 'libinput', 8 | version: '>=1.14.0', 9 | required: 'libinput' in backends, 10 | not_found_message: '\n'.join(msg), 11 | ) 12 | 13 | if not libinput.found() 14 | subdir_done() 15 | endif 16 | 17 | wlr_files += files( 18 | 'backend.c', 19 | 'events.c', 20 | 'keyboard.c', 21 | 'pointer.c', 22 | 'switch.c', 23 | 'tablet_pad.c', 24 | 'tablet_tool.c', 25 | 'touch.c', 26 | ) 27 | 28 | features += { 'libinput-backend': true } 29 | wlr_deps += libinput 30 | 31 | # libinput hold gestures and high resolution scroll are available since 1.19.0 32 | add_project_arguments([ 33 | '-DLIBINPUT_HAS_HOLD_GESTURES=@0@'.format(libinput.version().version_compare('>=1.19.0').to_int()), 34 | '-DLIBINPUT_HAS_SCROLL_VALUE120=@0@'.format(libinput.version().version_compare('>=1.19.0').to_int()), 35 | ], language: 'c') 36 | -------------------------------------------------------------------------------- /backend/libinput/switch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "backend/libinput.h" 5 | #include "util/signal.h" 6 | 7 | const struct wlr_switch_impl libinput_switch_impl = { 8 | .name = "libinput-switch", 9 | }; 10 | 11 | void init_device_switch(struct wlr_libinput_input_device *dev) { 12 | const char *name = libinput_device_get_name(dev->handle); 13 | struct wlr_switch *wlr_switch = &dev->switch_device; 14 | wlr_switch_init(wlr_switch, &libinput_switch_impl, name); 15 | wlr_switch->base.vendor = libinput_device_get_id_vendor(dev->handle); 16 | wlr_switch->base.product = libinput_device_get_id_product(dev->handle); 17 | } 18 | 19 | struct wlr_libinput_input_device *device_from_switch( 20 | struct wlr_switch *wlr_switch) { 21 | assert(wlr_switch->impl == &libinput_switch_impl); 22 | 23 | struct wlr_libinput_input_device *dev = 24 | wl_container_of(wlr_switch, dev, switch_device); 25 | return dev; 26 | } 27 | 28 | void handle_switch_toggle(struct libinput_event *event, 29 | struct wlr_switch *wlr_switch) { 30 | struct libinput_event_switch *sevent = 31 | libinput_event_get_switch_event (event); 32 | struct wlr_switch_toggle_event wlr_event = { 0 }; 33 | switch (libinput_event_switch_get_switch(sevent)) { 34 | case LIBINPUT_SWITCH_LID: 35 | wlr_event.switch_type = WLR_SWITCH_TYPE_LID; 36 | break; 37 | case LIBINPUT_SWITCH_TABLET_MODE: 38 | wlr_event.switch_type = WLR_SWITCH_TYPE_TABLET_MODE; 39 | break; 40 | } 41 | switch (libinput_event_switch_get_switch_state(sevent)) { 42 | case LIBINPUT_SWITCH_STATE_OFF: 43 | wlr_event.switch_state = WLR_SWITCH_STATE_OFF; 44 | break; 45 | case LIBINPUT_SWITCH_STATE_ON: 46 | wlr_event.switch_state = WLR_SWITCH_STATE_ON; 47 | break; 48 | } 49 | wlr_event.time_msec = 50 | usec_to_msec(libinput_event_switch_get_time_usec(sevent)); 51 | wlr_signal_emit_safe(&wlr_switch->events.toggle, &wlr_event); 52 | } 53 | -------------------------------------------------------------------------------- /backend/meson.build: -------------------------------------------------------------------------------- 1 | wlr_files += files('backend.c') 2 | 3 | all_backends = ['drm', 'libinput', 'x11'] 4 | backends = get_option('backends') 5 | if 'auto' in backends and get_option('auto_features').enabled() 6 | backends = all_backends 7 | elif 'auto' in backends and get_option('auto_features').disabled() 8 | backends = [] 9 | endif 10 | 11 | foreach backend : all_backends 12 | if backend in backends or 'auto' in backends 13 | subdir(backend) 14 | endif 15 | endforeach 16 | 17 | subdir('multi') 18 | subdir('wayland') 19 | subdir('headless') 20 | 21 | subdir('session') 22 | -------------------------------------------------------------------------------- /backend/multi/meson.build: -------------------------------------------------------------------------------- 1 | wlr_files += files('backend.c') 2 | -------------------------------------------------------------------------------- /backend/session/meson.build: -------------------------------------------------------------------------------- 1 | libseat = dependency('libseat', 2 | version: '>=0.2.0', 3 | fallback: 'seatd', 4 | default_options: ['server=disabled', 'man-pages=disabled'], 5 | ) 6 | wlr_files += files('session.c') 7 | wlr_deps += libseat 8 | -------------------------------------------------------------------------------- /backend/wayland/meson.build: -------------------------------------------------------------------------------- 1 | wayland_client = dependency('wayland-client', 2 | fallback: 'wayland', 3 | default_options: wayland_project_options, 4 | ) 5 | wlr_deps += wayland_client 6 | 7 | wlr_files += files( 8 | 'backend.c', 9 | 'output.c', 10 | 'seat.c', 11 | 'pointer.c', 12 | 'tablet_v2.c', 13 | ) 14 | 15 | client_protos = [ 16 | 'drm', 17 | 'linux-dmabuf-unstable-v1', 18 | 'pointer-gestures-unstable-v1', 19 | 'presentation-time', 20 | 'relative-pointer-unstable-v1', 21 | 'tablet-unstable-v2', 22 | 'xdg-activation-v1', 23 | 'xdg-decoration-unstable-v1', 24 | 'xdg-shell', 25 | ] 26 | 27 | foreach proto : client_protos 28 | wlr_files += protocols_client_header[proto] 29 | endforeach 30 | -------------------------------------------------------------------------------- /backend/x11/meson.build: -------------------------------------------------------------------------------- 1 | x11_libs = [] 2 | x11_required = [ 3 | 'xcb', 4 | 'xcb-dri3', 5 | 'xcb-present', 6 | 'xcb-render', 7 | 'xcb-renderutil', 8 | 'xcb-shm', 9 | 'xcb-xfixes', 10 | 'xcb-xinput', 11 | ] 12 | 13 | msg = ['Required for X11 backend support.'] 14 | if 'x11' in backends 15 | msg += 'Install "@0@" or disable the X11 backend.' 16 | endif 17 | 18 | foreach lib : x11_required 19 | dep = dependency(lib, 20 | required: 'x11' in backends, 21 | not_found_message: '\n'.join(msg).format(lib), 22 | ) 23 | if not dep.found() 24 | subdir_done() 25 | endif 26 | 27 | x11_libs += dep 28 | endforeach 29 | 30 | wlr_files += files( 31 | 'backend.c', 32 | 'input_device.c', 33 | 'output.c', 34 | ) 35 | wlr_deps += x11_libs 36 | features += { 'x11-backend': true } 37 | -------------------------------------------------------------------------------- /docs/env_vars.md: -------------------------------------------------------------------------------- 1 | wlroots reads these environment variables 2 | 3 | # wlroots specific 4 | 5 | * *WLR_BACKENDS*: comma-separated list of backends to use (available backends: 6 | libinput, drm, wayland, x11, headless) 7 | * *WLR_NO_HARDWARE_CURSORS*: set to 1 to use software cursors instead of 8 | hardware cursors 9 | * *WLR_XWAYLAND*: specifies the path to an Xwayland binary to be used (instead 10 | of following shell search semantics for "Xwayland") 11 | * *WLR_RENDERER*: forces the creation of a specified renderer (available 12 | renderers: gles2, pixman, vulkan) 13 | * *WLR_RENDER_DRM_DEVICE*: specifies the DRM node to use for 14 | hardware-accelerated renderers. 15 | 16 | ## DRM backend 17 | 18 | * *WLR_DRM_DEVICES*: specifies the DRM devices (as a colon separated list) 19 | instead of auto probing them. The first existing device in this list is 20 | considered the primary DRM device. 21 | * *WLR_DRM_NO_ATOMIC*: set to 1 to use legacy DRM interface instead of atomic 22 | mode setting 23 | * *WLR_DRM_NO_MODIFIERS*: set to 1 to always allocate planes without modifiers, 24 | this can fix certain modeset failures because of bandwidth restrictions. 25 | 26 | ## Headless backend 27 | 28 | * *WLR_HEADLESS_OUTPUTS*: when using the headless backend specifies the number 29 | of outputs 30 | 31 | ## libinput backend 32 | 33 | * *WLR_LIBINPUT_NO_DEVICES*: set to 1 to not fail without any input devices 34 | 35 | ## Wayland backend 36 | 37 | * *WLR_WL_OUTPUTS*: when using the wayland backend specifies the number of outputs 38 | 39 | ## X11 backend 40 | 41 | * *WLR_X11_OUTPUTS*: when using the X11 backend specifies the number of outputs 42 | 43 | ## gles2 renderer 44 | 45 | * *WLR_RENDERER_ALLOW_SOFTWARE*: allows the gles2 renderer to use software 46 | rendering 47 | 48 | ## scenes 49 | 50 | * *WLR_SCENE_DEBUG_DAMAGE*: specifies debug options for screen damage related 51 | tasks for compositors that use scenes (available options: none, rerender, 52 | highlight) 53 | * *WLR_SCENE_DISABLE_DIRECT_SCANOUT*: disables direct scan-out for debugging. 54 | 55 | # Generic 56 | 57 | * *DISPLAY*: if set probe X11 backend in `wlr_backend_autocreate` 58 | * *WAYLAND_DISPLAY*, *WAYLAND_SOCKET*: if set probe Wayland backend in 59 | `wlr_backend_autocreate` 60 | * *XCURSOR_PATH*: directory where xcursors are located 61 | * *XDG_SESSION_ID*: if set, session ID used by the logind session 62 | -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | /compositor/protocols 2 | -------------------------------------------------------------------------------- /examples/cat.h: -------------------------------------------------------------------------------- 1 | #ifndef _CAT_H 2 | #define _CAT_H 3 | 4 | struct gimp_texture { 5 | unsigned int width; 6 | unsigned int height; 7 | unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */ 8 | unsigned char pixel_data[128 * 128 * 4 + 1]; 9 | }; 10 | 11 | extern const struct gimp_texture cat_tex; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /examples/egl_common.h: -------------------------------------------------------------------------------- 1 | #ifndef _EGL_COMMON_H 2 | #define _EGL_COMMON_H 3 | #endif 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | extern EGLDisplay egl_display; 12 | extern EGLConfig egl_config; 13 | extern EGLContext egl_context; 14 | 15 | extern PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC eglCreatePlatformWindowSurfaceEXT; 16 | 17 | bool egl_init(struct wl_display *display); 18 | 19 | void egl_finish(void); 20 | -------------------------------------------------------------------------------- /include/backend/backend.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKEND_WLR_BACKEND_H 2 | #define BACKEND_WLR_BACKEND_H 3 | 4 | #include 5 | 6 | /** 7 | * Get the supported buffer capabilities. 8 | * 9 | * This functions returns a bitfield of supported wlr_buffer_cap. 10 | */ 11 | uint32_t backend_get_buffer_caps(struct wlr_backend *backend); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/backend/drm/cvt.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKEND_DRM_CVT_H 2 | #define BACKEND_DRM_CVT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | void generate_cvt_mode(drmModeModeInfo *mode, int hdisplay, int vdisplay, 11 | float vrefresh, bool reduced, bool interlaced); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/backend/drm/iface.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKEND_DRM_IFACE_H 2 | #define BACKEND_DRM_IFACE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct wlr_drm_backend; 10 | struct wlr_drm_connector; 11 | struct wlr_drm_crtc; 12 | struct wlr_drm_connector_state; 13 | 14 | // Used to provide atomic or legacy DRM functions 15 | struct wlr_drm_interface { 16 | // Commit all pending changes on a CRTC. 17 | bool (*crtc_commit)(struct wlr_drm_connector *conn, 18 | const struct wlr_drm_connector_state *state, uint32_t flags, 19 | bool test_only); 20 | }; 21 | 22 | extern const struct wlr_drm_interface atomic_iface; 23 | extern const struct wlr_drm_interface legacy_iface; 24 | 25 | bool drm_legacy_crtc_set_gamma(struct wlr_drm_backend *drm, 26 | struct wlr_drm_crtc *crtc, size_t size, uint16_t *lut); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/backend/drm/monitor.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKEND_DRM_MONITOR_H 2 | #define BACKEND_DRM_MONITOR_H 3 | 4 | #include 5 | 6 | /** 7 | * Helper to create new DRM sub-backends on GPU hotplug. 8 | */ 9 | struct wlr_drm_backend_monitor { 10 | struct wlr_backend *multi; 11 | struct wlr_backend *primary_drm; 12 | struct wlr_session *session; 13 | 14 | struct wl_listener multi_destroy; 15 | struct wl_listener primary_drm_destroy; 16 | struct wl_listener session_destroy; 17 | struct wl_listener session_add_drm_card; 18 | }; 19 | 20 | struct wlr_drm_backend_monitor *drm_backend_monitor_create( 21 | struct wlr_backend *multi, struct wlr_backend *primary_drm, 22 | struct wlr_session *session); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/backend/drm/properties.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKEND_DRM_PROPERTIES_H 2 | #define BACKEND_DRM_PROPERTIES_H 3 | 4 | #include 5 | #include 6 | 7 | /* 8 | * These types contain the property ids for several DRM objects. 9 | * See https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-kms.html#kms-properties 10 | * for more details. 11 | */ 12 | 13 | union wlr_drm_connector_props { 14 | struct { 15 | uint32_t edid; 16 | uint32_t dpms; 17 | uint32_t link_status; // not guaranteed to exist 18 | uint32_t path; 19 | uint32_t vrr_capable; // not guaranteed to exist 20 | uint32_t subconnector; // not guaranteed to exist 21 | uint32_t non_desktop; 22 | uint32_t panel_orientation; // not guaranteed to exist 23 | uint32_t content_type; // not guaranteed to exist 24 | uint32_t max_bpc; // not guaranteed to exist 25 | 26 | // atomic-modesetting only 27 | 28 | uint32_t crtc_id; 29 | }; 30 | uint32_t props[4]; 31 | }; 32 | 33 | union wlr_drm_crtc_props { 34 | struct { 35 | // Neither of these are guaranteed to exist 36 | uint32_t vrr_enabled; 37 | uint32_t gamma_lut; 38 | uint32_t gamma_lut_size; 39 | 40 | // atomic-modesetting only 41 | 42 | uint32_t active; 43 | uint32_t mode_id; 44 | }; 45 | uint32_t props[6]; 46 | }; 47 | 48 | union wlr_drm_plane_props { 49 | struct { 50 | uint32_t type; 51 | uint32_t rotation; // Not guaranteed to exist 52 | uint32_t in_formats; // Not guaranteed to exist 53 | 54 | // atomic-modesetting only 55 | 56 | uint32_t src_x; 57 | uint32_t src_y; 58 | uint32_t src_w; 59 | uint32_t src_h; 60 | uint32_t crtc_x; 61 | uint32_t crtc_y; 62 | uint32_t crtc_w; 63 | uint32_t crtc_h; 64 | uint32_t fb_id; 65 | uint32_t crtc_id; 66 | uint32_t fb_damage_clips; 67 | }; 68 | uint32_t props[14]; 69 | }; 70 | 71 | bool get_drm_connector_props(int fd, uint32_t id, 72 | union wlr_drm_connector_props *out); 73 | bool get_drm_crtc_props(int fd, uint32_t id, union wlr_drm_crtc_props *out); 74 | bool get_drm_plane_props(int fd, uint32_t id, union wlr_drm_plane_props *out); 75 | 76 | bool get_drm_prop(int fd, uint32_t obj, uint32_t prop, uint64_t *ret); 77 | void *get_drm_prop_blob(int fd, uint32_t obj, uint32_t prop, size_t *ret_len); 78 | char *get_drm_prop_enum(int fd, uint32_t obj, uint32_t prop); 79 | 80 | bool introspect_drm_prop_range(int fd, uint32_t prop_id, 81 | uint64_t *min, uint64_t *max); 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /include/backend/drm/renderer.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKEND_DRM_RENDERER_H 2 | #define BACKEND_DRM_RENDERER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct wlr_drm_backend; 11 | struct wlr_drm_plane; 12 | struct wlr_buffer; 13 | 14 | struct wlr_drm_renderer { 15 | struct wlr_drm_backend *backend; 16 | 17 | struct wlr_renderer *wlr_rend; 18 | struct wlr_allocator *allocator; 19 | }; 20 | 21 | struct wlr_drm_surface { 22 | struct wlr_drm_renderer *renderer; 23 | struct wlr_swapchain *swapchain; 24 | }; 25 | 26 | struct wlr_drm_fb { 27 | struct wlr_buffer *wlr_buf; 28 | struct wlr_addon addon; 29 | struct wlr_drm_backend *backend; 30 | struct wl_list link; // wlr_drm_backend.fbs 31 | 32 | uint32_t id; 33 | 34 | uint32_t handle; 35 | }; 36 | 37 | bool init_drm_renderer(struct wlr_drm_backend *drm, 38 | struct wlr_drm_renderer *renderer); 39 | void finish_drm_renderer(struct wlr_drm_renderer *renderer); 40 | 41 | struct wlr_drm_format; 42 | bool init_drm_surface(struct wlr_drm_surface *surf, 43 | struct wlr_drm_renderer *renderer, int width, int height, 44 | const struct wlr_drm_format *drm_format, const struct wlr_drm_plane *plane); 45 | 46 | bool drm_fb_import(struct wlr_drm_fb **fb, struct wlr_drm_backend *drm, 47 | struct wlr_buffer *buf, const struct wlr_drm_format_set *formats); 48 | void drm_fb_destroy(struct wlr_drm_fb *fb); 49 | 50 | void drm_fb_clear(struct wlr_drm_fb **fb); 51 | void drm_fb_move(struct wlr_drm_fb **new, struct wlr_drm_fb **old); 52 | 53 | struct wlr_buffer *drm_surface_blit(struct wlr_drm_surface *surf, 54 | struct wlr_buffer *buffer); 55 | 56 | struct wlr_drm_format *drm_plane_pick_render_format( 57 | struct wlr_drm_plane *plane, struct wlr_drm_renderer *renderer); 58 | void drm_plane_finish_surface(struct wlr_drm_plane *plane); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/backend/drm/util.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKEND_DRM_UTIL_H 2 | #define BACKEND_DRM_UTIL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | struct wlr_drm_connector; 9 | 10 | // Calculates a more accurate refresh rate (mHz) than what mode itself provides 11 | int32_t calculate_refresh_rate(const drmModeModeInfo *mode); 12 | // Populates the make/model/phys_{width,height} of output from the edid data 13 | void parse_edid(struct wlr_drm_connector *conn, size_t len, const uint8_t *data); 14 | 15 | // Part of match_obj 16 | enum { 17 | UNMATCHED = (uint32_t)-1, 18 | SKIP = (uint32_t)-2, 19 | }; 20 | 21 | /* 22 | * Tries to match some DRM objects with some other DRM resource. 23 | * e.g. Match CRTCs with Encoders, CRTCs with Planes. 24 | * 25 | * objs contains a bit array which resources it can be matched with. 26 | * e.g. Bit 0 set means can be matched with res[0] 27 | * 28 | * res contains an index of which objs it is matched with or UNMATCHED. 29 | * 30 | * This solution is left in out. 31 | * Returns the total number of matched solutions. 32 | */ 33 | size_t match_obj(size_t num_objs, const uint32_t objs[static restrict num_objs], 34 | size_t num_res, const uint32_t res[static restrict num_res], 35 | uint32_t out[static restrict num_res]); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/backend/headless.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKEND_HEADLESS_H 2 | #define BACKEND_HEADLESS_H 3 | 4 | #include 5 | #include 6 | 7 | #define HEADLESS_DEFAULT_REFRESH (60 * 1000) // 60 Hz 8 | 9 | struct wlr_headless_backend { 10 | struct wlr_backend backend; 11 | struct wl_display *display; 12 | struct wl_list outputs; 13 | size_t last_output_num; 14 | struct wl_listener display_destroy; 15 | bool started; 16 | }; 17 | 18 | struct wlr_headless_output { 19 | struct wlr_output wlr_output; 20 | 21 | struct wlr_headless_backend *backend; 22 | struct wl_list link; 23 | 24 | struct wl_event_source *frame_timer; 25 | int frame_delay; // ms 26 | }; 27 | 28 | struct wlr_headless_backend *headless_backend_from_backend( 29 | struct wlr_backend *wlr_backend); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/backend/multi.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKEND_MULTI_H 2 | #define BACKEND_MULTI_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct wlr_multi_backend { 10 | struct wlr_backend backend; 11 | struct wlr_session *session; 12 | 13 | struct wl_list backends; 14 | 15 | struct wl_listener display_destroy; 16 | 17 | struct { 18 | struct wl_signal backend_add; 19 | struct wl_signal backend_remove; 20 | } events; 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/backend/session/session.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKEND_SESSION_SESSION_H 2 | #define BACKEND_SESSION_SESSION_H 3 | 4 | struct wlr_session; 5 | 6 | struct wlr_session *libseat_session_create(struct wl_display *disp); 7 | void libseat_session_destroy(struct wlr_session *base); 8 | int libseat_session_open_device(struct wlr_session *base, const char *path); 9 | void libseat_session_close_device(struct wlr_session *base, int fd); 10 | bool libseat_change_vt(struct wlr_session *base, unsigned vt); 11 | 12 | void session_init(struct wlr_session *session); 13 | 14 | struct wlr_device *session_open_if_kms(struct wlr_session *restrict session, 15 | const char *restrict path); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/interfaces/wlr_input_device.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACES_INPUT_DEVICE_H 2 | #define INTERFACES_INPUT_DEVICE_H 3 | 4 | #include 5 | 6 | /** 7 | * Initializes a given wlr_input_device. Allocates memory for the name and sets 8 | * its vendor and product id to 0. 9 | * wlr_device must be non-NULL. 10 | */ 11 | void wlr_input_device_init(struct wlr_input_device *wlr_device, 12 | enum wlr_input_device_type type, const char *name); 13 | 14 | /** 15 | * Cleans up all the memory owned by a given wlr_input_device and signals 16 | * the destroy event. 17 | */ 18 | void wlr_input_device_finish(struct wlr_input_device *wlr_device); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/meson.build: -------------------------------------------------------------------------------- 1 | subdir('wlr') 2 | 3 | exclude_files = ['meson.build', 'config.h.in', 'version.h.in'] 4 | if not features.get('drm-backend') 5 | exclude_files += 'backend/drm.h' 6 | endif 7 | if not features.get('libinput-backend') 8 | exclude_files += 'backend/libinput.h' 9 | endif 10 | if not features.get('x11-backend') 11 | exclude_files += 'backend/x11.h' 12 | endif 13 | if not features.get('xwayland') 14 | exclude_files += 'xwayland.h' 15 | else 16 | subdir('xwayland') 17 | endif 18 | if not features.get('gles2-renderer') 19 | exclude_files += ['render/egl.h', 'render/gles2.h'] 20 | endif 21 | if not features.get('vulkan-renderer') 22 | exclude_files += 'render/vulkan.h' 23 | endif 24 | 25 | install_subdir('wlr', 26 | install_dir: get_option('includedir'), 27 | exclude_files: exclude_files, 28 | ) 29 | -------------------------------------------------------------------------------- /include/render/allocator/allocator.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDER_ALLOCATOR_ALLOCATOR_H 2 | #define RENDER_ALLOCATOR_ALLOCATOR_H 3 | 4 | #include 5 | 6 | struct wlr_allocator *allocator_autocreate_with_drm_fd( 7 | struct wlr_backend *backend, struct wlr_renderer *renderer, int drm_fd); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /include/render/allocator/drm_dumb.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDER_ALLOCATOR_DRM_DUMB_H 2 | #define RENDER_ALLOCATOR_DRM_DUMB_H 3 | 4 | #include 5 | #include 6 | #include "render/allocator/allocator.h" 7 | 8 | struct wlr_drm_dumb_buffer { 9 | struct wlr_buffer base; 10 | struct wl_list link; // wlr_drm_dumb_allocator::buffers 11 | 12 | int drm_fd; // -1 if the allocator has been destroyed 13 | struct wlr_dmabuf_attributes dmabuf; 14 | 15 | uint32_t format; 16 | uint32_t handle; 17 | uint32_t stride; 18 | uint32_t width, height; 19 | 20 | uint64_t size; 21 | void *data; 22 | }; 23 | 24 | struct wlr_drm_dumb_allocator { 25 | struct wlr_allocator base; 26 | struct wl_list buffers; // wlr_drm_dumb_buffer::link 27 | int drm_fd; 28 | }; 29 | 30 | /** 31 | * Creates a new drm dumb allocator from a DRM FD. 32 | * 33 | * Does not take ownership over the FD. 34 | */ 35 | struct wlr_allocator *wlr_drm_dumb_allocator_create(int fd); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/render/allocator/gbm.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDER_ALLOCATOR_GBM_H 2 | #define RENDER_ALLOCATOR_GBM_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "render/allocator/allocator.h" 8 | 9 | struct wlr_gbm_buffer { 10 | struct wlr_buffer base; 11 | 12 | struct wl_list link; // wlr_gbm_allocator.buffers 13 | 14 | struct gbm_bo *gbm_bo; // NULL if the gbm_device has been destroyed 15 | struct wlr_dmabuf_attributes dmabuf; 16 | }; 17 | 18 | struct wlr_gbm_allocator { 19 | struct wlr_allocator base; 20 | 21 | int fd; 22 | struct gbm_device *gbm_device; 23 | 24 | struct wl_list buffers; // wlr_gbm_buffer.link 25 | }; 26 | 27 | /** 28 | * Creates a new GBM allocator from a DRM FD. 29 | * 30 | * Takes ownership over the FD. 31 | */ 32 | struct wlr_allocator *wlr_gbm_allocator_create(int drm_fd); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/render/allocator/shm.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDER_ALLOCATOR_SHM_H 2 | #define RENDER_ALLOCATOR_SHM_H 3 | 4 | #include 5 | #include "render/allocator/allocator.h" 6 | 7 | struct wlr_shm_buffer { 8 | struct wlr_buffer base; 9 | struct wlr_shm_attributes shm; 10 | void *data; 11 | size_t size; 12 | }; 13 | 14 | struct wlr_shm_allocator { 15 | struct wlr_allocator base; 16 | }; 17 | 18 | /** 19 | * Creates a new shared memory allocator. 20 | */ 21 | struct wlr_allocator *wlr_shm_allocator_create(void); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/render/drm_format_set.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDER_DRM_FORMAT_SET_H 2 | #define RENDER_DRM_FORMAT_SET_H 3 | 4 | #include 5 | 6 | struct wlr_drm_format *wlr_drm_format_create(uint32_t format); 7 | bool wlr_drm_format_has(const struct wlr_drm_format *fmt, uint64_t modifier); 8 | bool wlr_drm_format_add(struct wlr_drm_format **fmt_ptr, uint64_t modifier); 9 | struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format); 10 | /** 11 | * Intersect modifiers for two DRM formats. 12 | * 13 | * Both arguments must have the same format field. If the formats aren't 14 | * compatible, NULL is returned. If either format doesn't support any modifier, 15 | * a format that doesn't support any modifier is returned. 16 | */ 17 | struct wlr_drm_format *wlr_drm_format_intersect( 18 | const struct wlr_drm_format *a, const struct wlr_drm_format *b); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/render/eglstreams_allocator.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef RENDER_EGLSTREAM_ALLOCATOR_H 3 | #define RENDER_EGLSTREAM_ALLOCATOR_H 4 | 5 | #include 6 | #include "render/allocator/allocator.h" 7 | #include "render/egl.h" 8 | 9 | 10 | struct wlr_eglstreams_allocator; 11 | 12 | struct wlr_eglstream_plane { 13 | struct wlr_eglstream stream; 14 | uint32_t id; 15 | struct wl_list link; // wlr_eglstreams_allocator.planes 16 | uint32_t locks; 17 | struct wlr_eglstreams_allocator *alloc; 18 | int width; 19 | int height; 20 | }; 21 | 22 | struct wlr_eglstream_buffer { 23 | struct wlr_buffer base; 24 | struct wlr_eglstream_plane *plane; 25 | }; 26 | 27 | struct wlr_eglstreams_allocator { 28 | struct wlr_allocator base; 29 | 30 | struct wlr_drm_backend *drm; 31 | struct wlr_egl *egl; 32 | struct wl_list planes; 33 | }; 34 | 35 | /** 36 | * Creates a new EGLStreams allocator from a DRM Renderer. 37 | */ 38 | struct wlr_allocator * 39 | wlr_eglstreams_allocator_create(struct wlr_backend *backend, 40 | struct wlr_renderer *renderer, 41 | uint32_t buffer_caps); 42 | 43 | /** 44 | * Returns configured plane for given id if any. 45 | */ 46 | struct wlr_eglstream_plane *wlr_eglstream_plane_for_id( 47 | struct wlr_allocator *wlr_alloc, uint32_t plane_id); 48 | 49 | void wlr_eglstream_dispose_planes(struct wlr_allocator *wlr_alloc); 50 | void wlr_eglstream_recreate_planes(struct wlr_allocator *wlr_alloc); 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /include/render/pixel_format.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDER_PIXEL_FORMAT_H 2 | #define RENDER_PIXEL_FORMAT_H 3 | 4 | #include 5 | 6 | struct wlr_pixel_format_info { 7 | uint32_t drm_format; 8 | 9 | /* Equivalent of the format if it has an alpha channel, 10 | * DRM_FORMAT_INVALID (0) if NA 11 | */ 12 | uint32_t opaque_substitute; 13 | 14 | /* Bits per pixels */ 15 | uint32_t bpp; 16 | 17 | /* True if the format has an alpha channel */ 18 | bool has_alpha; 19 | }; 20 | 21 | const struct wlr_pixel_format_info *drm_get_pixel_format_info(uint32_t fmt); 22 | 23 | uint32_t convert_wl_shm_format_to_drm(enum wl_shm_format fmt); 24 | enum wl_shm_format convert_drm_format_to_wl_shm(uint32_t fmt); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /include/render/pixman.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDER_PIXMAN_H 2 | #define RENDER_PIXMAN_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "render/pixel_format.h" 8 | 9 | struct wlr_pixman_pixel_format { 10 | uint32_t drm_format; 11 | pixman_format_code_t pixman_format; 12 | }; 13 | 14 | struct wlr_pixman_buffer; 15 | 16 | struct wlr_pixman_renderer { 17 | struct wlr_renderer wlr_renderer; 18 | 19 | struct wl_list buffers; // wlr_pixman_buffer.link 20 | struct wl_list textures; // wlr_pixman_texture.link 21 | 22 | struct wlr_pixman_buffer *current_buffer; 23 | int32_t width, height; 24 | 25 | struct wlr_drm_format_set drm_formats; 26 | }; 27 | 28 | struct wlr_pixman_buffer { 29 | struct wlr_buffer *buffer; 30 | struct wlr_pixman_renderer *renderer; 31 | 32 | pixman_image_t *image; 33 | 34 | struct wl_listener buffer_destroy; 35 | struct wl_list link; // wlr_pixman_renderer.buffers 36 | }; 37 | 38 | struct wlr_pixman_texture { 39 | struct wlr_texture wlr_texture; 40 | struct wlr_pixman_renderer *renderer; 41 | struct wl_list link; // wlr_pixman_renderer.textures 42 | 43 | pixman_image_t *image; 44 | pixman_format_code_t format; 45 | const struct wlr_pixel_format_info *format_info; 46 | 47 | void *data; // if created via texture_from_pixels 48 | struct wlr_buffer *buffer; // if created via texture_from_buffer 49 | }; 50 | 51 | pixman_format_code_t get_pixman_format_from_drm(uint32_t fmt); 52 | uint32_t get_drm_format_from_pixman(pixman_format_code_t fmt); 53 | const uint32_t *get_pixman_drm_formats(size_t *len); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/render/swapchain.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDER_SWAPCHAIN_H 2 | #define RENDER_SWAPCHAIN_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define WLR_SWAPCHAIN_CAP 4 9 | 10 | struct wlr_swapchain_slot { 11 | struct wlr_buffer *buffer; 12 | bool acquired; // waiting for release 13 | int age; 14 | 15 | struct wl_listener release; 16 | }; 17 | 18 | struct wlr_swapchain { 19 | struct wlr_allocator *allocator; // NULL if destroyed 20 | 21 | int width, height; 22 | struct wlr_drm_format *format; 23 | void *backend_data; 24 | 25 | struct wlr_swapchain_slot slots[WLR_SWAPCHAIN_CAP]; 26 | 27 | struct wl_listener allocator_destroy; 28 | }; 29 | 30 | struct wlr_swapchain *wlr_swapchain_create( 31 | struct wlr_allocator *alloc, int width, int height, 32 | const struct wlr_drm_format *format, void *backend_data); 33 | void wlr_swapchain_destroy(struct wlr_swapchain *swapchain); 34 | /** 35 | * Acquire a buffer from the swap chain. 36 | * 37 | * The returned buffer is locked. When the caller is done with it, they must 38 | * unlock it by calling wlr_buffer_unlock. 39 | */ 40 | struct wlr_buffer *wlr_swapchain_acquire(struct wlr_swapchain *swapchain, 41 | int *age); 42 | /** 43 | * Mark the buffer as submitted for presentation. This needs to be called by 44 | * swap chain users on frame boundaries. 45 | * 46 | * If the buffer hasn't been created via the swap chain, the call is ignored. 47 | */ 48 | void wlr_swapchain_set_buffer_submitted(struct wlr_swapchain *swapchain, 49 | struct wlr_buffer *buffer); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/render/wlr_renderer.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDER_WLR_RENDERER_H 2 | #define RENDER_WLR_RENDERER_H 3 | 4 | #include 5 | 6 | /** 7 | * Automatically select and create a renderer suitable for the DRM FD. 8 | */ 9 | struct wlr_renderer *renderer_autocreate_with_drm_fd(int drm_fd); 10 | /** 11 | * Bind a buffer to the renderer. 12 | * 13 | * All subsequent rendering operations will operate on the supplied buffer. 14 | * After rendering operations are done, the caller must unbind a buffer by 15 | * calling renderer_bind_buffer with a NULL buffer. 16 | */ 17 | bool renderer_bind_buffer(struct wlr_renderer *r, struct wlr_buffer *buffer); 18 | /** 19 | * Get the supported render formats. Buffers allocated with a format from this 20 | * list may be attached via wlr_renderer_begin_with_buffer. 21 | */ 22 | const struct wlr_drm_format_set *wlr_renderer_get_render_formats( 23 | struct wlr_renderer *renderer); 24 | /** 25 | * Get the supported buffer capabilities. 26 | * 27 | * This functions returns a bitfield of supported wlr_buffer_cap. 28 | */ 29 | uint32_t renderer_get_render_buffer_caps(struct wlr_renderer *renderer); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/types/wlr_buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_WLR_BUFFER 2 | #define TYPES_WLR_BUFFER 3 | 4 | #include 5 | 6 | struct wlr_shm_client_buffer { 7 | struct wlr_buffer base; 8 | 9 | uint32_t format; 10 | size_t stride; 11 | 12 | // The following fields are NULL if the client has destroyed the wl_buffer 13 | struct wl_resource *resource; 14 | struct wl_shm_buffer *shm_buffer; 15 | 16 | // This is used to keep the backing storage alive after the client has 17 | // destroyed the wl_buffer 18 | struct wl_shm_pool *saved_shm_pool; 19 | void *saved_data; 20 | 21 | struct wl_listener resource_destroy; 22 | struct wl_listener release; 23 | }; 24 | 25 | /** 26 | * A read-only buffer that holds a data pointer. 27 | * 28 | * This is suitable for passing raw pixel data to a function that accepts a 29 | * wlr_buffer. 30 | */ 31 | struct wlr_readonly_data_buffer { 32 | struct wlr_buffer base; 33 | 34 | const void *data; 35 | uint32_t format; 36 | size_t stride; 37 | 38 | void *saved_data; 39 | }; 40 | 41 | /** 42 | * Wraps a read-only data pointer into a wlr_buffer. The data pointer may be 43 | * accessed until readonly_data_buffer_drop() is called. 44 | */ 45 | struct wlr_readonly_data_buffer *readonly_data_buffer_create(uint32_t format, 46 | size_t stride, uint32_t width, uint32_t height, const void *data); 47 | /** 48 | * Drops ownership of the buffer (see wlr_buffer_drop() for more details) and 49 | * perform a copy of the data pointer if a consumer still has the buffer locked. 50 | */ 51 | bool readonly_data_buffer_drop(struct wlr_readonly_data_buffer *buffer); 52 | 53 | struct wlr_dmabuf_buffer { 54 | struct wlr_buffer base; 55 | struct wlr_dmabuf_attributes dmabuf; 56 | bool saved; 57 | }; 58 | 59 | /** 60 | * Wraps a DMA-BUF into a wlr_buffer. The DMA-BUF may be accessed until 61 | * dmabuf_buffer_drop() is called. 62 | */ 63 | struct wlr_dmabuf_buffer *dmabuf_buffer_create( 64 | struct wlr_dmabuf_attributes *dmabuf); 65 | /** 66 | * Drops ownership of the buffer (see wlr_buffer_drop() for more details) and 67 | * takes a reference to the DMA-BUF (by dup'ing its file descriptors) if a 68 | * consumer still has the buffer locked. 69 | */ 70 | bool dmabuf_buffer_drop(struct wlr_dmabuf_buffer *buffer); 71 | 72 | /** 73 | * Check whether a buffer is fully opaque. 74 | * 75 | * When true is returned, the buffer is guaranteed to be fully opaque, but the 76 | * reverse is not true: false may be returned in cases where the buffer is fully 77 | * opaque. 78 | */ 79 | bool buffer_is_opaque(struct wlr_buffer *buffer); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /include/types/wlr_data_device.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_WLR_DATA_DEVICE_H 2 | #define TYPES_WLR_DATA_DEVICE_H 3 | 4 | #include 5 | 6 | #define DATA_DEVICE_ALL_ACTIONS (WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY | \ 7 | WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE | \ 8 | WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK) 9 | 10 | struct wlr_client_data_source { 11 | struct wlr_data_source source; 12 | struct wlr_data_source_impl impl; 13 | struct wl_resource *resource; 14 | bool finalized; 15 | }; 16 | 17 | extern const struct wlr_surface_role drag_icon_surface_role; 18 | 19 | struct wlr_data_offer *data_offer_create(struct wl_resource *device_resource, 20 | struct wlr_data_source *source, enum wlr_data_offer_type type); 21 | void data_offer_update_action(struct wlr_data_offer *offer); 22 | void data_offer_destroy(struct wlr_data_offer *offer); 23 | 24 | struct wlr_client_data_source *client_data_source_create( 25 | struct wl_client *client, uint32_t version, uint32_t id, 26 | struct wl_list *resource_list); 27 | struct wlr_client_data_source *client_data_source_from_resource( 28 | struct wl_resource *resource); 29 | void data_source_notify_finish(struct wlr_data_source *source); 30 | 31 | struct wlr_seat_client *seat_client_from_data_device_resource( 32 | struct wl_resource *resource); 33 | /** 34 | * Creates a new wl_data_offer if there is a wl_data_source currently set as 35 | * the seat selection and sends it to the seat client, followed by the 36 | * wl_data_device.selection() event. If there is no current selection, the 37 | * wl_data_device.selection() event will carry a NULL wl_data_offer. If the 38 | * client does not have a wl_data_device for the seat nothing will be done. 39 | */ 40 | void seat_client_send_selection(struct wlr_seat_client *seat_client); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/types/wlr_keyboard.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void keyboard_key_update(struct wlr_keyboard *keyboard, 4 | struct wlr_keyboard_key_event *event); 5 | 6 | bool keyboard_modifier_update(struct wlr_keyboard *keyboard); 7 | 8 | void keyboard_led_update(struct wlr_keyboard *keyboard); 9 | -------------------------------------------------------------------------------- /include/types/wlr_matrix.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_WLR_MATRIX_H 2 | #define TYPES_WLR_MATRIX_H 3 | 4 | #include 5 | 6 | /** 7 | * Writes a 2D orthographic projection matrix to mat of (width, height) with a 8 | * specified wl_output_transform. 9 | * 10 | * Equivalent to glOrtho(0, width, 0, height, 1, -1) with the transform applied. 11 | */ 12 | void matrix_projection(float mat[static 9], int width, int height, 13 | enum wl_output_transform transform); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/types/wlr_output.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_WLR_OUTPUT_H 2 | #define TYPES_WLR_OUTPUT_H 3 | 4 | #include 5 | #include 6 | 7 | void output_pending_resolution(struct wlr_output *output, 8 | const struct wlr_output_state *state, int *width, int *height); 9 | void output_state_attach_buffer(struct wlr_output_state *state, 10 | struct wlr_buffer *buffer); 11 | 12 | struct wlr_drm_format *output_pick_format(struct wlr_output *output, 13 | const struct wlr_drm_format_set *display_formats, uint32_t format); 14 | void output_clear_back_buffer(struct wlr_output *output); 15 | bool output_ensure_buffer(struct wlr_output *output, 16 | const struct wlr_output_state *state, bool *new_back_buffer); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/types/wlr_region.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_WLR_REGION_H 2 | #define TYPES_WLR_REGION_H 3 | 4 | #include 5 | 6 | /* 7 | * Creates a new region resource with the provided new ID. 8 | */ 9 | struct wl_resource *region_create(struct wl_client *client, 10 | uint32_t version, uint32_t id); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/types/wlr_scene.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_WLR_SCENE_H 2 | #define TYPES_WLR_SCENE_H 3 | 4 | #include 5 | 6 | struct wlr_scene *scene_node_get_root(struct wlr_scene_node *node); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /include/types/wlr_seat.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_WLR_SEAT_H 2 | #define TYPES_WLR_SEAT_H 3 | 4 | #include 5 | #include 6 | 7 | extern const struct wlr_pointer_grab_interface default_pointer_grab_impl; 8 | extern const struct wlr_keyboard_grab_interface default_keyboard_grab_impl; 9 | extern const struct wlr_touch_grab_interface default_touch_grab_impl; 10 | 11 | void seat_client_create_pointer(struct wlr_seat_client *seat_client, 12 | uint32_t version, uint32_t id); 13 | void seat_client_destroy_pointer(struct wl_resource *resource); 14 | void seat_client_send_pointer_leave_raw(struct wlr_seat_client *seat_client, 15 | struct wlr_surface *surface); 16 | 17 | void seat_client_create_keyboard(struct wlr_seat_client *seat_client, 18 | uint32_t version, uint32_t id); 19 | void seat_client_destroy_keyboard(struct wl_resource *resource); 20 | void seat_client_send_keyboard_leave_raw(struct wlr_seat_client *seat_client, 21 | struct wlr_surface *surface); 22 | 23 | void seat_client_create_touch(struct wlr_seat_client *seat_client, 24 | uint32_t version, uint32_t id); 25 | void seat_client_destroy_touch(struct wl_resource *resource); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/types/wlr_xdg_shell.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_WLR_XDG_SHELL_H 2 | #define TYPES_WLR_XDG_SHELL_H 3 | 4 | #include 5 | #include 6 | #include "xdg-shell-protocol.h" 7 | 8 | extern const struct wlr_surface_role xdg_toplevel_surface_role; 9 | extern const struct wlr_surface_role xdg_popup_surface_role; 10 | 11 | struct wlr_xdg_surface *create_xdg_surface( 12 | struct wlr_xdg_client *client, struct wlr_surface *wlr_surface, 13 | uint32_t id); 14 | void unmap_xdg_surface(struct wlr_xdg_surface *surface); 15 | void reset_xdg_surface(struct wlr_xdg_surface *surface); 16 | void destroy_xdg_surface(struct wlr_xdg_surface *surface); 17 | void xdg_surface_role_commit(struct wlr_surface *wlr_surface); 18 | void xdg_surface_role_precommit(struct wlr_surface *wlr_surface, 19 | const struct wlr_surface_state *state); 20 | 21 | void create_xdg_positioner(struct wlr_xdg_client *client, uint32_t id); 22 | 23 | void create_xdg_popup(struct wlr_xdg_surface *surface, 24 | struct wlr_xdg_surface *parent, 25 | struct wlr_xdg_positioner *positioner, uint32_t id); 26 | void unmap_xdg_popup(struct wlr_xdg_popup *popup); 27 | void destroy_xdg_popup(struct wlr_xdg_popup *popup); 28 | void handle_xdg_popup_committed(struct wlr_xdg_popup *popup); 29 | struct wlr_xdg_popup_configure *send_xdg_popup_configure( 30 | struct wlr_xdg_popup *popup); 31 | void handle_xdg_popup_ack_configure(struct wlr_xdg_popup *popup, 32 | struct wlr_xdg_popup_configure *configure); 33 | 34 | void create_xdg_toplevel(struct wlr_xdg_surface *surface, 35 | uint32_t id); 36 | void unmap_xdg_toplevel(struct wlr_xdg_toplevel *toplevel); 37 | void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel); 38 | void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel); 39 | struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure( 40 | struct wlr_xdg_toplevel *toplevel); 41 | void handle_xdg_toplevel_ack_configure(struct wlr_xdg_toplevel *toplevel, 42 | struct wlr_xdg_toplevel_configure *configure); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /include/util/array.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_ARRAY_H 2 | #define UTIL_ARRAY_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | size_t push_zeroes_to_end(uint32_t arr[], size_t n); 10 | 11 | /** 12 | * Add `target` to `values` if it doesn't exist 13 | * "set"s should only be modified with set_* functions 14 | * Values MUST be greater than 0 15 | */ 16 | bool set_add(uint32_t values[], size_t *len, size_t cap, uint32_t target); 17 | 18 | /** 19 | * Remove `target` from `values` if it exists 20 | * "set"s should only be modified with set_* functions 21 | * Values MUST be greater than 0 22 | */ 23 | bool set_remove(uint32_t values[], size_t *len, size_t cap, uint32_t target); 24 | 25 | /** 26 | * Remove a chunk of memory of the specified size at the specified offset. 27 | */ 28 | void array_remove_at(struct wl_array *arr, size_t offset, size_t size); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/util/global.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_GLOBAL_H 2 | #define UTIL_GLOBAL_H 3 | 4 | #include 5 | 6 | /** 7 | * Destroy a transient global. 8 | * 9 | * Globals that are created and destroyed on the fly need special handling to 10 | * prevent race conditions with wl_registry. Use this function to destroy them. 11 | */ 12 | void wlr_global_destroy_safe(struct wl_global *global); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/util/shm.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_SHM_H 2 | #define UTIL_SHM_H 3 | 4 | #include 5 | 6 | int create_shm_file(void); 7 | int allocate_shm_file(size_t size); 8 | bool allocate_shm_file_pair(size_t size, int *rw_fd, int *ro_fd); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /include/util/signal.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_SIGNAL_H 2 | #define UTIL_SIGNAL_H 3 | 4 | #include 5 | 6 | void wlr_signal_emit_safe(struct wl_signal *signal, void *data); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /include/util/time.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_TIME_H 2 | #define UTIL_TIME_H 3 | 4 | #include 5 | 6 | /** 7 | * Get the current time, in milliseconds. 8 | */ 9 | uint32_t get_current_time_msec(void); 10 | 11 | /** 12 | * Convert a timespec to milliseconds. 13 | */ 14 | int64_t timespec_to_msec(const struct timespec *a); 15 | 16 | /** 17 | * Convert nanoseconds to a timespec. 18 | */ 19 | void timespec_from_nsec(struct timespec *r, int64_t nsec); 20 | 21 | /** 22 | * Subtracts timespec `b` from timespec `a`, and stores the difference in `r`. 23 | */ 24 | void timespec_sub(struct timespec *r, const struct timespec *a, 25 | const struct timespec *b); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/util/token.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_TOKEN_H 2 | #define UTIL_TOKEN_H 3 | 4 | #include 5 | 6 | #define TOKEN_STRLEN 33 7 | bool generate_token(char out[static TOKEN_STRLEN]); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /include/wlr/backend.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_BACKEND_H 10 | #define WLR_BACKEND_H 11 | 12 | #include 13 | #include 14 | 15 | struct wlr_backend_impl; 16 | 17 | /** 18 | * A backend provides a set of input and output devices. 19 | */ 20 | struct wlr_backend { 21 | const struct wlr_backend_impl *impl; 22 | 23 | struct { 24 | /** Raised when destroyed */ 25 | struct wl_signal destroy; 26 | /** Raised when new inputs are added, passed the struct wlr_input_device */ 27 | struct wl_signal new_input; 28 | /** Raised when new outputs are added, passed the struct wlr_output */ 29 | struct wl_signal new_output; 30 | } events; 31 | }; 32 | 33 | /** 34 | * Automatically initializes the most suitable backend given the environment. 35 | * Will always return a multi-backend. The backend is created but not started. 36 | * Returns NULL on failure. 37 | */ 38 | struct wlr_backend *wlr_backend_autocreate(struct wl_display *display); 39 | /** 40 | * Start the backend. This may signal new_input or new_output immediately, but 41 | * may also wait until the display's event loop begins. Returns false on 42 | * failure. 43 | */ 44 | bool wlr_backend_start(struct wlr_backend *backend); 45 | /** 46 | * Destroy the backend and clean up all of its resources. Normally called 47 | * automatically when the struct wl_display is destroyed. 48 | */ 49 | void wlr_backend_destroy(struct wlr_backend *backend); 50 | /** 51 | * Obtains the struct wlr_session reference from this backend if there is any. 52 | * Might return NULL for backends that don't use a session. 53 | */ 54 | struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend); 55 | /** 56 | * Returns the clock used by the backend for presentation feedback. 57 | */ 58 | clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend); 59 | /** 60 | * Returns the DRM node file descriptor used by the backend's underlying 61 | * platform. Can be used by consumers for additional rendering operations. 62 | * The consumer must not close the file descriptor since the backend continues 63 | * to have ownership of it. 64 | */ 65 | int wlr_backend_get_drm_fd(struct wlr_backend *backend); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /include/wlr/backend/drm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_BACKEND_DRM_H 10 | #define WLR_BACKEND_DRM_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | struct wlr_drm_backend; 18 | 19 | struct wlr_drm_lease { 20 | int fd; 21 | uint32_t lessee_id; 22 | struct wlr_drm_backend *backend; 23 | 24 | struct { 25 | struct wl_signal destroy; 26 | } events; 27 | 28 | void *data; 29 | }; 30 | 31 | /** 32 | * Creates a DRM backend using the specified GPU file descriptor (typically from 33 | * a device node in /dev/dri). 34 | * 35 | * To slave this to another DRM backend, pass it as the parent (which _must_ be 36 | * a DRM backend, other kinds of backends raise SIGABRT). 37 | */ 38 | struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, 39 | struct wlr_session *session, struct wlr_device *dev, 40 | struct wlr_backend *parent); 41 | 42 | bool wlr_backend_is_drm(struct wlr_backend *backend); 43 | bool wlr_output_is_drm(struct wlr_output *output); 44 | 45 | /** 46 | * Get the KMS connector object ID. 47 | */ 48 | uint32_t wlr_drm_connector_get_id(struct wlr_output *output); 49 | 50 | /** 51 | * Tries to open non-master DRM FD. The compositor must not call drmSetMaster() 52 | * on the returned FD. 53 | * 54 | * Returns a valid opened DRM FD, or -1 on error. 55 | */ 56 | int wlr_drm_backend_get_non_master_fd(struct wlr_backend *backend); 57 | 58 | /** 59 | * Leases the given outputs to the caller. The outputs must be from the 60 | * associated DRM backend. 61 | * 62 | * Returns NULL on error. 63 | */ 64 | struct wlr_drm_lease *wlr_drm_create_lease(struct wlr_output **outputs, 65 | size_t n_outputs, int *lease_fd); 66 | 67 | /** 68 | * Terminates and destroys a given lease. 69 | * 70 | * The outputs will be owned again by the backend. 71 | */ 72 | void wlr_drm_lease_terminate(struct wlr_drm_lease *lease); 73 | 74 | /** 75 | * Add mode to the list of available modes. 76 | */ 77 | typedef struct _drmModeModeInfo drmModeModeInfo; 78 | struct wlr_output_mode *wlr_drm_connector_add_mode(struct wlr_output *output, 79 | const drmModeModeInfo *mode); 80 | 81 | /** 82 | * Get the connector's panel orientation. 83 | * 84 | * On some devices the panel is mounted in the casing in such a way that the 85 | * top side of the panel does not match with the top side of the device. This 86 | * function returns the output transform which needs to be applied to compensate 87 | * for this. 88 | */ 89 | enum wl_output_transform wlr_drm_connector_get_panel_orientation( 90 | struct wlr_output *output); 91 | 92 | bool wlr_output_is_eglstreams(struct wlr_output *output); 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /include/wlr/backend/headless.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_BACKEND_HEADLESS_H 10 | #define WLR_BACKEND_HEADLESS_H 11 | 12 | #include 13 | #include 14 | 15 | /** 16 | * Creates a headless backend. A headless backend has no outputs or inputs by 17 | * default. 18 | */ 19 | struct wlr_backend *wlr_headless_backend_create(struct wl_display *display); 20 | /** 21 | * Create a new headless output. 22 | * 23 | * The buffers presented on the output won't be displayed to the user. 24 | */ 25 | struct wlr_output *wlr_headless_add_output(struct wlr_backend *backend, 26 | unsigned int width, unsigned int height); 27 | 28 | bool wlr_backend_is_headless(struct wlr_backend *backend); 29 | bool wlr_output_is_headless(struct wlr_output *output); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/wlr/backend/interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_BACKEND_INTERFACE_H 10 | #define WLR_BACKEND_INTERFACE_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | struct wlr_backend_impl { 17 | bool (*start)(struct wlr_backend *backend); 18 | void (*destroy)(struct wlr_backend *backend); 19 | struct wlr_session *(*get_session)(struct wlr_backend *backend); 20 | clockid_t (*get_presentation_clock)(struct wlr_backend *backend); 21 | int (*get_drm_fd)(struct wlr_backend *backend); 22 | uint32_t (*get_buffer_caps)(struct wlr_backend *backend); 23 | }; 24 | 25 | /** 26 | * Initializes common state on a struct wlr_backend and sets the implementation 27 | * to the provided struct wlr_backend_impl reference. 28 | */ 29 | void wlr_backend_init(struct wlr_backend *backend, 30 | const struct wlr_backend_impl *impl); 31 | /** 32 | * Emit the destroy event and clean up common backend state. 33 | */ 34 | void wlr_backend_finish(struct wlr_backend *backend); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/wlr/backend/libinput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_BACKEND_LIBINPUT_H 10 | #define WLR_BACKEND_LIBINPUT_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | struct wlr_input_device; 18 | 19 | struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display, 20 | struct wlr_session *session); 21 | /** 22 | * Gets the underlying struct libinput_device handle for the given input device. 23 | */ 24 | struct libinput_device *wlr_libinput_get_device_handle( 25 | struct wlr_input_device *dev); 26 | 27 | bool wlr_backend_is_libinput(struct wlr_backend *backend); 28 | bool wlr_input_device_is_libinput(struct wlr_input_device *device); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/wlr/backend/multi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_BACKEND_MULTI_H 10 | #define WLR_BACKEND_MULTI_H 11 | 12 | #include 13 | #include 14 | 15 | /** 16 | * Creates a multi-backend. Multi-backends wrap an arbitrary number of backends 17 | * and aggregate their new_output/new_input signals. 18 | */ 19 | struct wlr_backend *wlr_multi_backend_create(struct wl_display *display); 20 | /** 21 | * Adds the given backend to the multi backend. This should be done before the 22 | * new backend is started. 23 | */ 24 | bool wlr_multi_backend_add(struct wlr_backend *multi, 25 | struct wlr_backend *backend); 26 | 27 | void wlr_multi_backend_remove(struct wlr_backend *multi, 28 | struct wlr_backend *backend); 29 | 30 | bool wlr_backend_is_multi(struct wlr_backend *backend); 31 | bool wlr_multi_is_empty(struct wlr_backend *backend); 32 | 33 | void wlr_multi_for_each_backend(struct wlr_backend *backend, 34 | void (*callback)(struct wlr_backend *backend, void *data), void *data); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/wlr/backend/wayland.h: -------------------------------------------------------------------------------- 1 | #ifndef WLR_BACKEND_WAYLAND_H 2 | #define WLR_BACKEND_WAYLAND_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct wlr_input_device; 10 | 11 | /** 12 | * Creates a new Wayland backend. This backend will be created with no outputs; 13 | * you must use wlr_wl_output_create() to add them. 14 | * 15 | * The `remote` argument is the name of the host compositor wayland socket. Set 16 | * to NULL for the default behaviour (WAYLAND_DISPLAY env variable or wayland-0 17 | * default). 18 | */ 19 | struct wlr_backend *wlr_wl_backend_create(struct wl_display *display, 20 | const char *remote); 21 | 22 | /** 23 | * Returns the remote struct wl_display used by the Wayland backend. 24 | */ 25 | struct wl_display *wlr_wl_backend_get_remote_display(struct wlr_backend *backend); 26 | 27 | /** 28 | * Adds a new output to this backend. You may remove outputs by destroying them. 29 | * Note that if called before initializing the backend, this will return NULL 30 | * and your outputs will be created during initialization (and given to you via 31 | * the new_output signal). 32 | */ 33 | struct wlr_output *wlr_wl_output_create(struct wlr_backend *backend); 34 | 35 | /** 36 | * Check whether the provided backend is a Wayland backend. 37 | */ 38 | bool wlr_backend_is_wl(struct wlr_backend *backend); 39 | 40 | /** 41 | * Check whether the provided input device is a Wayland input device. 42 | */ 43 | bool wlr_input_device_is_wl(struct wlr_input_device *device); 44 | 45 | /** 46 | * Check whether the provided output device is a Wayland output device. 47 | */ 48 | bool wlr_output_is_wl(struct wlr_output *output); 49 | 50 | /** 51 | * Sets the title of a struct wlr_output which is a Wayland toplevel. 52 | */ 53 | void wlr_wl_output_set_title(struct wlr_output *output, const char *title); 54 | 55 | /** 56 | * Returns the remote struct wl_surface used by the Wayland output. 57 | */ 58 | struct wl_surface *wlr_wl_output_get_surface(struct wlr_output *output); 59 | 60 | /** 61 | * Returns the remote struct wl_seat for a Wayland input device. 62 | */ 63 | struct wl_seat *wlr_wl_input_device_get_seat(struct wlr_input_device *dev); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/wlr/backend/x11.h: -------------------------------------------------------------------------------- 1 | #ifndef WLR_BACKEND_X11_H 2 | #define WLR_BACKEND_X11_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | struct wlr_input_device; 12 | 13 | /** 14 | * Creates a new X11 backend. This backend will be created with no outputs; 15 | * you must use wlr_x11_output_create() to add them. 16 | * 17 | * The `x11_display` argument is the name of the X Display socket. Set 18 | * to NULL for the default behaviour of XOpenDisplay(). 19 | */ 20 | struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, 21 | const char *x11_display); 22 | 23 | /** 24 | * Adds a new output to this backend. You may remove outputs by destroying them. 25 | * Note that if called before initializing the backend, this will return NULL 26 | * and your outputs will be created during initialization (and given to you via 27 | * the new_output signal). 28 | */ 29 | struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend); 30 | 31 | /** 32 | * Check whether this backend is an X11 backend. 33 | */ 34 | bool wlr_backend_is_x11(struct wlr_backend *backend); 35 | 36 | /** 37 | * Check whether this input device is an X11 input device. 38 | */ 39 | bool wlr_input_device_is_x11(struct wlr_input_device *device); 40 | 41 | /** 42 | * Check whether this output device is an X11 output device. 43 | */ 44 | bool wlr_output_is_x11(struct wlr_output *output); 45 | 46 | /** 47 | * Sets the title of a struct wlr_output which is an X11 window. 48 | */ 49 | void wlr_x11_output_set_title(struct wlr_output *output, const char *title); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/wlr/config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef WLR_CONFIG_H 2 | #define WLR_CONFIG_H 3 | 4 | #mesondefine WLR_HAS_DRM_BACKEND 5 | #mesondefine WLR_HAS_LIBINPUT_BACKEND 6 | #mesondefine WLR_HAS_X11_BACKEND 7 | 8 | #mesondefine WLR_HAS_GLES2_RENDERER 9 | #mesondefine WLR_HAS_VULKAN_RENDERER 10 | 11 | #mesondefine WLR_HAS_GBM_ALLOCATOR 12 | 13 | #mesondefine WLR_HAS_XWAYLAND 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/wlr/interfaces/wlr_buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_INTERFACES_WLR_BUFFER_H 10 | #define WLR_INTERFACES_WLR_BUFFER_H 11 | 12 | #include 13 | 14 | struct wlr_buffer_impl { 15 | void (*destroy)(struct wlr_buffer *buffer); 16 | bool (*get_dmabuf)(struct wlr_buffer *buffer, 17 | struct wlr_dmabuf_attributes *attribs); 18 | bool (*get_shm)(struct wlr_buffer *buffer, 19 | struct wlr_shm_attributes *attribs); 20 | bool (*begin_data_ptr_access)(struct wlr_buffer *buffer, uint32_t flags, 21 | void **data, uint32_t *format, size_t *stride); 22 | void (*end_data_ptr_access)(struct wlr_buffer *buffer); 23 | }; 24 | 25 | struct wlr_buffer_resource_interface { 26 | const char *name; 27 | bool (*is_instance)(struct wl_resource *resource); 28 | struct wlr_buffer *(*from_resource)(struct wl_resource *resource); 29 | }; 30 | 31 | /** 32 | * Initialize a buffer. This function should be called by producers. The 33 | * initialized buffer is referenced: once the producer is done with the buffer 34 | * they should call wlr_buffer_drop(). 35 | */ 36 | void wlr_buffer_init(struct wlr_buffer *buffer, 37 | const struct wlr_buffer_impl *impl, int width, int height); 38 | 39 | /** 40 | * Allows the registration of a struct wl_resource implementation. 41 | * 42 | * The matching function will be called for the struct wl_resource when creating 43 | * a struct wlr_buffer from a struct wl_resource. 44 | */ 45 | void wlr_buffer_register_resource_interface( 46 | const struct wlr_buffer_resource_interface *iface); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/wlr/interfaces/wlr_keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_INTERFACES_WLR_KEYBOARD_H 10 | #define WLR_INTERFACES_WLR_KEYBOARD_H 11 | 12 | #include 13 | #include 14 | 15 | struct wlr_keyboard_impl { 16 | const char *name; 17 | void (*led_update)(struct wlr_keyboard *keyboard, uint32_t leds); 18 | }; 19 | 20 | void wlr_keyboard_init(struct wlr_keyboard *keyboard, 21 | const struct wlr_keyboard_impl *impl, const char *name); 22 | 23 | /** 24 | * Cleans up all of the resources owned by the struct wlr_keyboard. 25 | */ 26 | void wlr_keyboard_finish(struct wlr_keyboard *keyboard); 27 | 28 | void wlr_keyboard_notify_key(struct wlr_keyboard *keyboard, 29 | struct wlr_keyboard_key_event *event); 30 | void wlr_keyboard_notify_modifiers(struct wlr_keyboard *keyboard, 31 | uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, 32 | uint32_t group); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/wlr/interfaces/wlr_pointer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_INTERFACES_WLR_POINTER_H 10 | #define WLR_INTERFACES_WLR_POINTER_H 11 | 12 | #include 13 | 14 | struct wlr_pointer_impl { 15 | const char *name; 16 | }; 17 | 18 | void wlr_pointer_init(struct wlr_pointer *pointer, 19 | const struct wlr_pointer_impl *impl, const char *name); 20 | void wlr_pointer_finish(struct wlr_pointer *pointer); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/wlr/interfaces/wlr_switch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_INTERFACES_WLR_SWITCH_H 10 | #define WLR_INTERFACES_WLR_SWITCH_H 11 | 12 | #include 13 | 14 | struct wlr_switch_impl { 15 | const char *name; 16 | }; 17 | 18 | void wlr_switch_init(struct wlr_switch *switch_device, 19 | const struct wlr_switch_impl *impl, const char *name); 20 | void wlr_switch_finish(struct wlr_switch *switch_device); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/wlr/interfaces/wlr_tablet_pad.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_INTERFACES_WLR_TABLET_PAD_H 10 | #define WLR_INTERFACES_WLR_TABLET_PAD_H 11 | 12 | #include 13 | 14 | struct wlr_tablet_pad_impl { 15 | const char *name; 16 | }; 17 | 18 | void wlr_tablet_pad_init(struct wlr_tablet_pad *pad, 19 | const struct wlr_tablet_pad_impl *impl, const char *name); 20 | 21 | /** 22 | * Cleans up the resources owned by a struct wlr_tablet_pad. 23 | * 24 | * This function will not clean the memory allocated by 25 | * struct wlr_tablet_pad_group, it's the responsibility of the caller to clean 26 | * it. 27 | */ 28 | void wlr_tablet_pad_finish(struct wlr_tablet_pad *pad); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/wlr/interfaces/wlr_tablet_tool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_INTERFACES_WLR_TABLET_TOOL_H 10 | #define WLR_INTERFACES_WLR_TABLET_TOOL_H 11 | 12 | #include 13 | 14 | struct wlr_tablet_impl { 15 | const char *name; 16 | }; 17 | 18 | void wlr_tablet_init(struct wlr_tablet *tablet, 19 | const struct wlr_tablet_impl *impl, const char *name); 20 | void wlr_tablet_finish(struct wlr_tablet *tablet); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/wlr/interfaces/wlr_touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_INTERFACES_WLR_TOUCH_H 10 | #define WLR_INTERFACES_WLR_TOUCH_H 11 | 12 | #include 13 | 14 | struct wlr_touch_impl { 15 | const char *name; 16 | }; 17 | 18 | void wlr_touch_init(struct wlr_touch *touch, 19 | const struct wlr_touch_impl *impl, const char *name); 20 | void wlr_touch_finish(struct wlr_touch *touch); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/wlr/meson.build: -------------------------------------------------------------------------------- 1 | version_base = meson.project_version().split('-')[0] 2 | version_array = version_base.split('.') 3 | version_data = configuration_data() 4 | version_data.set_quoted('WLR_VERSION_STR', meson.project_version()) 5 | version_data.set('WLR_VERSION_MAJOR', version_array[0]) 6 | version_data.set('WLR_VERSION_MINOR', version_array[1]) 7 | version_data.set('WLR_VERSION_MICRO', version_array[2]) 8 | 9 | conf_data = configuration_data() 10 | foreach name, have : features 11 | conf_data.set10('WLR_HAS_' + name.underscorify().to_upper(), have) 12 | endforeach 13 | 14 | conf_h = configure_file( 15 | input: 'config.h.in', 16 | output: 'config.h', 17 | configuration: conf_data, 18 | ) 19 | ver_h = configure_file( 20 | input: 'version.h.in', 21 | output: 'version.h', 22 | configuration: version_data, 23 | ) 24 | 25 | install_headers(conf_h, ver_h, subdir: 'wlr') 26 | -------------------------------------------------------------------------------- /include/wlr/render/allocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_ALLOCATOR_H 10 | #define WLR_ALLOCATOR_H 11 | 12 | #include 13 | 14 | struct wlr_allocator; 15 | struct wlr_backend; 16 | struct wlr_drm_format; 17 | struct wlr_renderer; 18 | 19 | struct wlr_allocator_interface { 20 | struct wlr_buffer *(*create_buffer)(struct wlr_allocator *alloc, 21 | int width, int height, const struct wlr_drm_format *format, 22 | void *data); 23 | void (*destroy)(struct wlr_allocator *alloc); 24 | }; 25 | 26 | void wlr_allocator_init(struct wlr_allocator *alloc, 27 | const struct wlr_allocator_interface *impl, uint32_t buffer_caps); 28 | 29 | struct wlr_allocator { 30 | const struct wlr_allocator_interface *impl; 31 | 32 | // Capabilities of the buffers created with this allocator 33 | uint32_t buffer_caps; 34 | 35 | struct { 36 | struct wl_signal destroy; 37 | } events; 38 | }; 39 | 40 | /** 41 | * Creates the adequate struct wlr_allocator given a backend and a renderer. 42 | */ 43 | struct wlr_allocator *wlr_allocator_autocreate(struct wlr_backend *backend, 44 | struct wlr_renderer *renderer); 45 | /** 46 | * Destroy the allocator. 47 | */ 48 | void wlr_allocator_destroy(struct wlr_allocator *alloc); 49 | 50 | /** 51 | * Allocate a new buffer. 52 | * 53 | * When the caller is done with it, they must unreference it by calling 54 | * wlr_buffer_drop(). 55 | * 56 | * The `format` passed in indicates the format to use and the list of 57 | * acceptable modifiers. The order in which modifiers are listed is not 58 | * significant. 59 | * 60 | * When running with legacy drivers which don't support explicit modifiers, the 61 | * allocator must recognize two modifiers: INVALID (for implicit tiling and/or 62 | * compression) and LINEAR. 63 | * 64 | * The allocator must return a buffer using one of the modifiers listed. In 65 | * particular, allocators must not return a buffer with an implicit modifier 66 | * unless the user has allowed it by passing INVALID in the modifier list. 67 | */ 68 | struct wlr_buffer *wlr_allocator_create_buffer(struct wlr_allocator *alloc, 69 | int width, int height, const struct wlr_drm_format *format, void *data); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /include/wlr/render/dmabuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_RENDER_DMABUF_H 10 | #define WLR_RENDER_DMABUF_H 11 | 12 | #include 13 | #include 14 | 15 | #define WLR_DMABUF_MAX_PLANES 4 16 | 17 | /** 18 | * A Linux DMA-BUF pixel buffer. 19 | * 20 | * If the buffer was allocated with explicit modifiers enabled, the `modifier` 21 | * field must not be INVALID. 22 | * 23 | * If the buffer was allocated with explicit modifiers disabled (either because 24 | * the driver doesn't support it, or because the user didn't specify a valid 25 | * modifier list), the `modifier` field can have two values: INVALID means that 26 | * an implicit vendor-defined modifier is in use, LINEAR means that the buffer 27 | * is linear. The `modifier` field must not have any other value. 28 | * 29 | * When importing a DMA-BUF, users must not ignore the modifier unless it's 30 | * INVALID or LINEAR. In particular, users must not import a DMA-BUF to a 31 | * legacy API which doesn't support specifying an explicit modifier unless the 32 | * modifier is set to INVALID or LINEAR. 33 | */ 34 | struct wlr_dmabuf_attributes { 35 | int32_t width, height; 36 | uint32_t format; // FourCC code, see DRM_FORMAT_* in 37 | uint64_t modifier; // see DRM_FORMAT_MOD_* in 38 | 39 | int n_planes; 40 | uint32_t offset[WLR_DMABUF_MAX_PLANES]; 41 | uint32_t stride[WLR_DMABUF_MAX_PLANES]; 42 | int fd[WLR_DMABUF_MAX_PLANES]; 43 | }; 44 | 45 | /** 46 | * Closes all file descriptors in the DMA-BUF attributes. 47 | */ 48 | void wlr_dmabuf_attributes_finish(struct wlr_dmabuf_attributes *attribs); 49 | /** 50 | * Clones the DMA-BUF attributes. 51 | */ 52 | bool wlr_dmabuf_attributes_copy(struct wlr_dmabuf_attributes *dst, 53 | const struct wlr_dmabuf_attributes *src); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/wlr/render/drm_format_set.h: -------------------------------------------------------------------------------- 1 | #ifndef WLR_RENDER_DRM_FORMAT_SET_H 2 | #define WLR_RENDER_DRM_FORMAT_SET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /** A single DRM format, with a set of modifiers attached. */ 9 | struct wlr_drm_format { 10 | // The actual DRM format, from `drm_fourcc.h` 11 | uint32_t format; 12 | // The number of modifiers 13 | size_t len; 14 | // The capacity of the array; do not use. 15 | size_t capacity; 16 | // The actual modifiers 17 | uint64_t modifiers[]; 18 | }; 19 | 20 | /** 21 | * A set of DRM formats and modifiers. 22 | * 23 | * This is used to describe the supported format + modifier combinations. For 24 | * instance, backends will report the set they can display, and renderers will 25 | * report the set they can render to. For a more general overview of formats 26 | * and modifiers, see: 27 | * https://lore.kernel.org/dri-devel/20210905122742.86029-1-daniels@collabora.com/ 28 | * 29 | * For compatibility with legacy drivers which don't support explicit 30 | * modifiers, the special modifier DRM_FORMAT_MOD_INVALID is used to indicate 31 | * that implicit modifiers are supported. Legacy drivers can also support the 32 | * DRM_FORMAT_MOD_LINEAR modifier, which forces the buffer to have a linear 33 | * layout. 34 | * 35 | * Users must not assume that implicit modifiers are supported unless INVALID 36 | * is listed in the modifier list. 37 | */ 38 | struct wlr_drm_format_set { 39 | // The number of formats 40 | size_t len; 41 | // The capacity of the array; private to wlroots 42 | size_t capacity; 43 | // A pointer to an array of `struct wlr_drm_format *` of length `len`. 44 | struct wlr_drm_format **formats; 45 | }; 46 | 47 | /** 48 | * Free all of the DRM formats in the set, making the set empty. Does not 49 | * free the set itself. 50 | */ 51 | void wlr_drm_format_set_finish(struct wlr_drm_format_set *set); 52 | 53 | /** 54 | * Return a pointer to a member of this struct wlr_drm_format_set of format 55 | * `format`, or NULL if none exists. 56 | */ 57 | const struct wlr_drm_format *wlr_drm_format_set_get( 58 | const struct wlr_drm_format_set *set, uint32_t format); 59 | 60 | bool wlr_drm_format_set_has(const struct wlr_drm_format_set *set, 61 | uint32_t format, uint64_t modifier); 62 | 63 | bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format, 64 | uint64_t modifier); 65 | 66 | /** 67 | * Intersect two DRM format sets `a` and `b`, storing in the destination set 68 | * `dst` the format + modifier pairs which are in both source sets. 69 | * 70 | * Returns false on failure or when the intersection is empty. 71 | */ 72 | bool wlr_drm_format_set_intersect(struct wlr_drm_format_set *dst, 73 | const struct wlr_drm_format_set *a, const struct wlr_drm_format_set *b); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /include/wlr/render/egl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_RENDER_EGL_H 10 | #define WLR_RENDER_EGL_H 11 | 12 | #ifndef EGL_NO_X11 13 | #define EGL_NO_X11 14 | #endif 15 | #ifndef EGL_NO_PLATFORM_SPECIFIC_TYPES 16 | #define EGL_NO_PLATFORM_SPECIFIC_TYPES 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | struct wlr_egl; 30 | struct wlr_eglstream; 31 | 32 | /** 33 | * Create a struct wlr_egl with an existing EGL display and context. 34 | * 35 | * This is typically used by compositors which want to customize EGL 36 | * initialization. 37 | */ 38 | struct wlr_egl *wlr_egl_create_with_context(EGLDisplay display, 39 | EGLContext context); 40 | 41 | /** 42 | * Get the EGL display used by the struct wlr_egl. 43 | * 44 | * This is typically used by compositors which need to perform custom OpenGL 45 | * operations. 46 | */ 47 | EGLDisplay wlr_egl_get_display(struct wlr_egl *egl); 48 | 49 | /** 50 | * Get the EGL context used by the struct wlr_egl. 51 | * 52 | * This is typically used by compositors which need to perform custom OpenGL 53 | * operations. 54 | */ 55 | EGLContext wlr_egl_get_context(struct wlr_egl *egl); 56 | 57 | /** 58 | * Sets up EGLSurface for passed egl_stream 59 | * Expects egl_stream->drm and egl_stream->egl to be valid 60 | */ 61 | bool wlr_egl_create_eglstreams_surface(struct wlr_eglstream *egl_stream, 62 | uint32_t plane_id, int width, int height); 63 | 64 | /** 65 | * Destroys egl_stream and frees resources used 66 | */ 67 | void wlr_egl_destroy_eglstreams_surface(struct wlr_eglstream *egl_stream); 68 | 69 | /** 70 | * Flips EGLStream for presentation. Updated buffers ages. 71 | * Expects EGLStream surface to be current 72 | */ 73 | struct wlr_output; 74 | bool wlr_egl_flip_eglstreams_page(struct wlr_output *output); 75 | 76 | /** 77 | * Load and initialized nvidia eglstream controller. 78 | * for mapping client EGL surfaces. 79 | */ 80 | void init_eglstream_controller(struct wl_display *display); 81 | 82 | /** 83 | * Gets the parameters of wayland egl buffer. 84 | */ 85 | bool wlr_egl_wl_buffer_get_params(struct wlr_egl *egl, 86 | struct wl_resource *buffer, int *width, int *height, int *inverted_y); 87 | #endif 88 | -------------------------------------------------------------------------------- /include/wlr/render/gles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_RENDER_GLES2_H 10 | #define WLR_RENDER_GLES2_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | struct wlr_egl; 17 | 18 | struct wlr_renderer *wlr_gles2_renderer_create_with_drm_fd(int drm_fd); 19 | struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl); 20 | 21 | struct wlr_egl *wlr_gles2_renderer_get_egl(struct wlr_renderer *renderer); 22 | bool wlr_gles2_renderer_check_ext(struct wlr_renderer *renderer, 23 | const char *ext); 24 | /** 25 | * Returns the OpenGL FBO of current buffer. 26 | */ 27 | GLuint wlr_gles2_renderer_get_current_fbo(struct wlr_renderer *wlr_renderer); 28 | 29 | struct wlr_gles2_texture_attribs { 30 | GLenum target; /* either GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES */ 31 | GLuint tex; 32 | 33 | bool has_alpha; 34 | bool inverted_y; 35 | }; 36 | 37 | bool wlr_renderer_is_gles2(struct wlr_renderer *wlr_renderer); 38 | bool wlr_texture_is_gles2(struct wlr_texture *texture); 39 | void wlr_gles2_texture_get_attribs(struct wlr_texture *texture, 40 | struct wlr_gles2_texture_attribs *attribs); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/wlr/render/pixman.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_RENDER_PIXMAN_H 10 | #define WLR_RENDER_PIXMAN_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | struct wlr_renderer *wlr_pixman_renderer_create(void); 17 | /** 18 | * Returns the image of current buffer. 19 | */ 20 | pixman_image_t *wlr_pixman_renderer_get_current_image( 21 | struct wlr_renderer *wlr_renderer); 22 | 23 | bool wlr_renderer_is_pixman(struct wlr_renderer *wlr_renderer); 24 | bool wlr_texture_is_pixman(struct wlr_texture *texture); 25 | pixman_image_t *wlr_pixman_texture_get_image(struct wlr_texture *wlr_texture); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/wlr/render/vulkan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_RENDER_VULKAN_H 10 | #define WLR_RENDER_VULKAN_H 11 | 12 | #include 13 | 14 | struct wlr_renderer *wlr_vk_renderer_create_with_drm_fd(int drm_fd); 15 | bool wlr_texture_is_vk(struct wlr_texture *texture); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /include/wlr/render/wlr_texture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_RENDER_WLR_TEXTURE_H 10 | #define WLR_RENDER_WLR_TEXTURE_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | struct wlr_buffer; 18 | struct wlr_renderer; 19 | struct wlr_texture_impl; 20 | 21 | struct wlr_texture { 22 | const struct wlr_texture_impl *impl; 23 | uint32_t width, height; 24 | }; 25 | 26 | /** 27 | * Create a new texture from raw pixel data. `stride` is in bytes. The returned 28 | * texture is mutable. 29 | */ 30 | struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer, 31 | uint32_t fmt, uint32_t stride, uint32_t width, uint32_t height, 32 | const void *data); 33 | 34 | /** 35 | * Create a new texture from a DMA-BUF. The returned texture is immutable. 36 | */ 37 | struct wlr_texture *wlr_texture_from_dmabuf(struct wlr_renderer *renderer, 38 | struct wlr_dmabuf_attributes *attribs); 39 | 40 | /** 41 | * Update a texture with a struct wlr_buffer's contents. 42 | * 43 | * The update might be rejected (in case the texture is immutable, the buffer 44 | * has an unsupported type/format, etc), so callers must be prepared to fall 45 | * back to re-creating the texture from scratch via wlr_texture_from_buffer(). 46 | * 47 | * The damage can be used by the renderer as an optimization: only the supplied 48 | * region needs to be updated. 49 | */ 50 | bool wlr_texture_update_from_buffer(struct wlr_texture *texture, 51 | struct wlr_buffer *buffer, pixman_region32_t *damage); 52 | 53 | /** 54 | * Destroys the texture. 55 | */ 56 | void wlr_texture_destroy(struct wlr_texture *texture); 57 | 58 | /** 59 | * Create a new texture from a buffer. 60 | */ 61 | struct wlr_texture *wlr_texture_from_buffer(struct wlr_renderer *renderer, 62 | struct wlr_buffer *buffer); 63 | 64 | /** 65 | * Create a new buffer texture from a EGLSTREAM_WL resource. 66 | * 67 | * Should not be called in a rendering block like renderer_begin()/end() or 68 | * between attaching a renderer to an output and committing it. 69 | */ 70 | struct wlr_buffer; 71 | struct wlr_buffer *wlr_buffer_from_wl_eglstream(struct wlr_renderer *renderer, 72 | struct wl_resource *resource, struct wl_array *attribs); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_damage_ring.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_DAMAGE_RING_H 10 | #define WLR_TYPES_WLR_DAMAGE_RING_H 11 | 12 | #include 13 | 14 | /* For triple buffering, a history of two frames is required. */ 15 | #define WLR_DAMAGE_RING_PREVIOUS_LEN 2 16 | 17 | struct wlr_box; 18 | 19 | struct wlr_damage_ring { 20 | int32_t width, height; 21 | 22 | // Difference between the current buffer and the previous one 23 | pixman_region32_t current; 24 | 25 | // private state 26 | 27 | pixman_region32_t previous[WLR_DAMAGE_RING_PREVIOUS_LEN]; 28 | size_t previous_idx; 29 | }; 30 | 31 | void wlr_damage_ring_init(struct wlr_damage_ring *ring); 32 | 33 | void wlr_damage_ring_finish(struct wlr_damage_ring *ring); 34 | 35 | /** 36 | * Set ring bounds and damage the ring fully. 37 | * 38 | * Next time damage will be added, it will be cropped to the ring bounds. 39 | * If at least one of the dimensions is 0, bounds are removed. 40 | * 41 | * By default, a damage ring doesn't have bounds. 42 | */ 43 | void wlr_damage_ring_set_bounds(struct wlr_damage_ring *ring, 44 | int32_t width, int32_t height); 45 | 46 | /** 47 | * Add a region to the current damage. 48 | * 49 | * Returns true if the region intersects the ring bounds, false otherwise. 50 | */ 51 | bool wlr_damage_ring_add(struct wlr_damage_ring *ring, 52 | pixman_region32_t *damage); 53 | 54 | /** 55 | * Add a box to the current damage. 56 | * 57 | * Returns true if the box intersects the ring bounds, false otherwise. 58 | */ 59 | bool wlr_damage_ring_add_box(struct wlr_damage_ring *ring, 60 | const struct wlr_box *box); 61 | 62 | /** 63 | * Damage the ring fully. 64 | */ 65 | void wlr_damage_ring_add_whole(struct wlr_damage_ring *ring); 66 | 67 | /** 68 | * Rotate the damage ring. This needs to be called after using the accumulated 69 | * damage, e.g. after rendering to an output's back buffer. 70 | */ 71 | void wlr_damage_ring_rotate(struct wlr_damage_ring *ring); 72 | 73 | /** 74 | * Get accumulated damage, which is the difference between the current buffer 75 | * and the buffer with age of buffer_age; in context of rendering, this is 76 | * the region that needs to be redrawn. 77 | */ 78 | void wlr_damage_ring_get_buffer_damage(struct wlr_damage_ring *ring, 79 | int buffer_age, pixman_region32_t *damage); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_data_control_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_DATA_CONTROL_V1_H 10 | #define WLR_TYPES_WLR_DATA_CONTROL_V1_H 11 | 12 | #include 13 | #include 14 | 15 | struct wlr_data_control_manager_v1 { 16 | struct wl_global *global; 17 | struct wl_list devices; // wlr_data_control_device_v1.link 18 | 19 | struct { 20 | struct wl_signal destroy; 21 | struct wl_signal new_device; // wlr_data_control_device_v1 22 | } events; 23 | 24 | struct wl_listener display_destroy; 25 | }; 26 | 27 | struct wlr_data_control_device_v1 { 28 | struct wl_resource *resource; 29 | struct wlr_data_control_manager_v1 *manager; 30 | struct wl_list link; // wlr_data_control_manager_v1.devices 31 | 32 | struct wlr_seat *seat; 33 | struct wl_resource *selection_offer_resource; // current selection offer 34 | struct wl_resource *primary_selection_offer_resource; // current primary selection offer 35 | 36 | struct wl_listener seat_destroy; 37 | struct wl_listener seat_set_selection; 38 | struct wl_listener seat_set_primary_selection; 39 | }; 40 | 41 | struct wlr_data_control_manager_v1 *wlr_data_control_manager_v1_create( 42 | struct wl_display *display); 43 | 44 | void wlr_data_control_device_v1_destroy( 45 | struct wlr_data_control_device_v1 *device); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_drm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_DRM_H 10 | #define WLR_TYPES_WLR_DRM_H 11 | 12 | #include 13 | 14 | struct wlr_renderer; 15 | 16 | struct wlr_drm_buffer { 17 | struct wlr_buffer base; 18 | 19 | struct wl_resource *resource; // can be NULL if the client destroyed it 20 | struct wlr_dmabuf_attributes dmabuf; 21 | 22 | struct wl_listener release; 23 | }; 24 | 25 | /** 26 | * A stub implementation of Mesa's wl_drm protocol. 27 | * 28 | * It only implements the minimum necessary for modern clients to behave 29 | * properly. In particular, flink handles are left unimplemented. 30 | */ 31 | struct wlr_drm { 32 | struct wl_global *global; 33 | struct wlr_renderer *renderer; 34 | char *node_name; 35 | 36 | struct { 37 | struct wl_signal destroy; 38 | } events; 39 | 40 | struct wl_listener display_destroy; 41 | struct wl_listener renderer_destroy; 42 | }; 43 | 44 | bool wlr_drm_buffer_is_resource(struct wl_resource *resource); 45 | 46 | struct wlr_drm_buffer *wlr_drm_buffer_from_resource( 47 | struct wl_resource *resource); 48 | 49 | struct wlr_drm *wlr_drm_create(struct wl_display *display, 50 | struct wlr_renderer *renderer); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_export_dmabuf_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_EXPORT_DMABUF_V1_H 10 | #define WLR_TYPES_WLR_EXPORT_DMABUF_V1_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | struct wlr_export_dmabuf_manager_v1 { 17 | struct wl_global *global; 18 | struct wl_list frames; // wlr_export_dmabuf_frame_v1.link 19 | 20 | struct wl_listener display_destroy; 21 | 22 | struct { 23 | struct wl_signal destroy; 24 | } events; 25 | }; 26 | 27 | struct wlr_export_dmabuf_frame_v1 { 28 | struct wl_resource *resource; 29 | struct wlr_export_dmabuf_manager_v1 *manager; 30 | struct wl_list link; // wlr_export_dmabuf_manager_v1.frames 31 | 32 | struct wlr_output *output; 33 | 34 | bool cursor_locked; 35 | 36 | struct wl_listener output_commit; 37 | }; 38 | 39 | struct wlr_export_dmabuf_manager_v1 *wlr_export_dmabuf_manager_v1_create( 40 | struct wl_display *display); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_fullscreen_shell_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_FULLSCREEN_SHELL_V1_H 10 | #define WLR_TYPES_WLR_FULLSCREEN_SHELL_V1_H 11 | 12 | #include 13 | #include "fullscreen-shell-unstable-v1-protocol.h" 14 | 15 | struct wlr_fullscreen_shell_v1 { 16 | struct wl_global *global; 17 | 18 | struct { 19 | struct wl_signal destroy; 20 | // struct wlr_fullscreen_shell_v1_present_surface_event 21 | struct wl_signal present_surface; 22 | } events; 23 | 24 | struct wl_listener display_destroy; 25 | 26 | void *data; 27 | }; 28 | 29 | struct wlr_fullscreen_shell_v1_present_surface_event { 30 | struct wl_client *client; 31 | struct wlr_surface *surface; // can be NULL 32 | enum zwp_fullscreen_shell_v1_present_method method; 33 | struct wlr_output *output; // can be NULL 34 | }; 35 | 36 | struct wlr_fullscreen_shell_v1 *wlr_fullscreen_shell_v1_create( 37 | struct wl_display *display); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_gamma_control_v1.h: -------------------------------------------------------------------------------- 1 | #ifndef WLR_TYPES_WLR_GAMMA_CONTROL_V1_H 2 | #define WLR_TYPES_WLR_GAMMA_CONTROL_V1_H 3 | 4 | #include 5 | 6 | struct wlr_gamma_control_manager_v1 { 7 | struct wl_global *global; 8 | struct wl_list controls; // wlr_gamma_control_v1.link 9 | 10 | struct wl_listener display_destroy; 11 | 12 | struct { 13 | struct wl_signal destroy; 14 | } events; 15 | 16 | void *data; 17 | }; 18 | 19 | struct wlr_gamma_control_v1 { 20 | struct wl_resource *resource; 21 | struct wlr_output *output; 22 | struct wl_list link; 23 | 24 | uint16_t *table; 25 | size_t ramp_size; 26 | 27 | struct wl_listener output_commit_listener; 28 | struct wl_listener output_destroy_listener; 29 | 30 | void *data; 31 | }; 32 | 33 | struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create( 34 | struct wl_display *display); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_idle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_IDLE_H 10 | #define WLR_TYPES_WLR_IDLE_H 11 | 12 | #include 13 | #include 14 | 15 | /** 16 | * Idle protocol is used to create timers which will notify the client when the 17 | * compositor does not receive any input for a given time(in milliseconds). Also 18 | * the client will be notified when the timer receives an activity notify and already 19 | * was in idle state. Besides this, the client is able to simulate user activity 20 | * which will reset the timers and at any time can destroy the timer. 21 | */ 22 | 23 | 24 | struct wlr_idle { 25 | struct wl_global *global; 26 | struct wl_list idle_timers; // wlr_idle_timeout.link 27 | struct wl_event_loop *event_loop; 28 | bool enabled; 29 | 30 | struct wl_listener display_destroy; 31 | struct { 32 | struct wl_signal activity_notify; 33 | struct wl_signal destroy; 34 | } events; 35 | 36 | void *data; 37 | }; 38 | 39 | struct wlr_idle_timeout { 40 | struct wl_resource *resource; 41 | struct wl_list link; 42 | struct wlr_seat *seat; 43 | 44 | struct wl_event_source *idle_source; 45 | bool idle_state; 46 | bool enabled; 47 | uint32_t timeout; // milliseconds 48 | 49 | struct { 50 | struct wl_signal idle; 51 | struct wl_signal resume; 52 | struct wl_signal destroy; 53 | } events; 54 | 55 | struct wl_listener input_listener; 56 | struct wl_listener seat_destroy; 57 | 58 | void *data; 59 | }; 60 | 61 | struct wlr_idle *wlr_idle_create(struct wl_display *display); 62 | 63 | /** 64 | * Send notification to restart all timers for the given seat. Called by 65 | * compositor when there is an user activity event on that seat. 66 | */ 67 | void wlr_idle_notify_activity(struct wlr_idle *idle, struct wlr_seat *seat); 68 | 69 | /** 70 | * Enable or disable timers for a given idle resource by seat. 71 | * Passing a NULL seat means update timers for all seats. 72 | */ 73 | void wlr_idle_set_enabled(struct wlr_idle *idle, struct wlr_seat *seat, 74 | bool enabled); 75 | 76 | /** 77 | * Create a new timer on the given seat. The idle event will be called after 78 | * the given amount of milliseconds of inactivity, and the resumed event will 79 | * be sent at the first user activity after the fired event. 80 | */ 81 | struct wlr_idle_timeout *wlr_idle_timeout_create(struct wlr_idle *idle, 82 | struct wlr_seat *seat, uint32_t timeout); 83 | 84 | void wlr_idle_timeout_destroy(struct wlr_idle_timeout *timeout); 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_idle_inhibit_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_IDLE_INHIBIT_V1_H 10 | #define WLR_TYPES_WLR_IDLE_INHIBIT_V1_H 11 | 12 | #include 13 | 14 | /* This interface permits clients to inhibit the idle behavior such as 15 | * screenblanking, locking, and screensaving. 16 | * 17 | * This allows clients to ensure they stay visible instead of being hidden by 18 | * power-saving. 19 | * 20 | * Inhibitors are created for surfaces. They should only be in effect, while 21 | * this surface is visible. 22 | * The effect could also be limited to outputs it is displayed on (e.g. 23 | * dimm/dpms off outputs, except the one a video is displayed on). 24 | */ 25 | 26 | struct wlr_idle_inhibit_manager_v1 { 27 | struct wl_list inhibitors; // wlr_idle_inhibit_inhibitor_v1.link 28 | struct wl_global *global; 29 | 30 | struct wl_listener display_destroy; 31 | 32 | struct { 33 | struct wl_signal new_inhibitor; 34 | struct wl_signal destroy; 35 | } events; 36 | 37 | void *data; 38 | }; 39 | 40 | struct wlr_idle_inhibitor_v1 { 41 | struct wlr_surface *surface; 42 | struct wl_resource *resource; 43 | struct wl_listener surface_destroy; 44 | 45 | struct wl_list link; // wlr_idle_inhibit_manager_v1.inhibitors 46 | 47 | struct { 48 | struct wl_signal destroy; 49 | } events; 50 | 51 | void *data; 52 | }; 53 | 54 | struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_input_device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_INPUT_DEVICE_H 10 | #define WLR_TYPES_WLR_INPUT_DEVICE_H 11 | 12 | #include 13 | 14 | enum wlr_button_state { 15 | WLR_BUTTON_RELEASED, 16 | WLR_BUTTON_PRESSED, 17 | }; 18 | 19 | enum wlr_input_device_type { 20 | WLR_INPUT_DEVICE_KEYBOARD, 21 | WLR_INPUT_DEVICE_POINTER, 22 | WLR_INPUT_DEVICE_TOUCH, 23 | WLR_INPUT_DEVICE_TABLET_TOOL, 24 | WLR_INPUT_DEVICE_TABLET_PAD, 25 | WLR_INPUT_DEVICE_SWITCH, 26 | }; 27 | 28 | struct wlr_input_device { 29 | enum wlr_input_device_type type; 30 | unsigned int vendor, product; 31 | char *name; 32 | 33 | struct { 34 | struct wl_signal destroy; 35 | } events; 36 | 37 | void *data; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_input_inhibitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_INPUT_INHIBITOR_H 10 | #define WLR_TYPES_INPUT_INHIBITOR_H 11 | #include 12 | 13 | struct wlr_input_inhibit_manager { 14 | struct wl_global *global; 15 | struct wl_client *active_client; 16 | struct wl_resource *active_inhibitor; 17 | 18 | struct wl_listener display_destroy; 19 | 20 | struct { 21 | struct wl_signal activate; // struct wlr_input_inhibit_manager * 22 | struct wl_signal deactivate; // struct wlr_input_inhibit_manager * 23 | struct wl_signal destroy; 24 | } events; 25 | 26 | void *data; 27 | }; 28 | 29 | struct wlr_input_inhibit_manager *wlr_input_inhibit_manager_create( 30 | struct wl_display *display); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_keyboard_group.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_KEYBOARD_GROUP_H 10 | #define WLR_TYPES_WLR_KEYBOARD_GROUP_H 11 | 12 | #include 13 | #include 14 | 15 | struct wlr_keyboard_group { 16 | struct wlr_keyboard keyboard; 17 | struct wl_list devices; // keyboard_group_device.link 18 | struct wl_list keys; // keyboard_group_key.link 19 | 20 | struct { 21 | /** 22 | * Sent when a keyboard has entered the group with keys currently 23 | * pressed that are not pressed by any other keyboard in the group. The 24 | * data for this signal will be a struct wl_array containing the key 25 | * codes. This should be used to update the compositor's internal state. 26 | * Bindings should not be triggered based off of these key codes and 27 | * they should also not notify any surfaces of the key press. 28 | */ 29 | struct wl_signal enter; 30 | 31 | /** 32 | * Sent when a keyboard has left the group with keys currently pressed 33 | * that are not pressed by any other keyboard in the group. The data for 34 | * this signal will be a struct wl_array containing the key codes. This 35 | * should be used to update the compositor's internal state. Bindings 36 | * should not be triggered based off of these key codes. Additionally, 37 | * surfaces should only be notified if they received a corresponding key 38 | * press for the key code. 39 | */ 40 | struct wl_signal leave; 41 | } events; 42 | 43 | void *data; 44 | }; 45 | 46 | struct wlr_keyboard_group *wlr_keyboard_group_create(void); 47 | 48 | struct wlr_keyboard_group *wlr_keyboard_group_from_wlr_keyboard( 49 | struct wlr_keyboard *keyboard); 50 | 51 | bool wlr_keyboard_group_add_keyboard(struct wlr_keyboard_group *group, 52 | struct wlr_keyboard *keyboard); 53 | 54 | void wlr_keyboard_group_remove_keyboard(struct wlr_keyboard_group *group, 55 | struct wlr_keyboard *keyboard); 56 | 57 | void wlr_keyboard_group_destroy(struct wlr_keyboard_group *group); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_linux_dmabuf_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_LINUX_DMABUF_H 10 | #define WLR_TYPES_WLR_LINUX_DMABUF_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | struct wlr_surface; 19 | 20 | struct wlr_dmabuf_v1_buffer { 21 | struct wlr_buffer base; 22 | 23 | struct wl_resource *resource; // can be NULL if the client destroyed it 24 | struct wlr_dmabuf_attributes attributes; 25 | 26 | // private state 27 | 28 | struct wl_listener release; 29 | }; 30 | 31 | /** 32 | * Returns true if the given resource was created via the linux-dmabuf 33 | * buffer protocol, false otherwise 34 | */ 35 | bool wlr_dmabuf_v1_resource_is_buffer(struct wl_resource *buffer_resource); 36 | 37 | /** 38 | * Returns the struct wlr_dmabuf_buffer if the given resource was created 39 | * via the linux-dmabuf buffer protocol. 40 | */ 41 | struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_from_buffer_resource( 42 | struct wl_resource *buffer_resource); 43 | 44 | struct wlr_linux_dmabuf_feedback_v1 { 45 | dev_t main_device; 46 | size_t tranches_len; 47 | const struct wlr_linux_dmabuf_feedback_v1_tranche *tranches; 48 | }; 49 | 50 | struct wlr_linux_dmabuf_feedback_v1_tranche { 51 | dev_t target_device; 52 | uint32_t flags; // bitfield of enum zwp_linux_dmabuf_feedback_v1_tranche_flags 53 | const struct wlr_drm_format_set *formats; 54 | }; 55 | 56 | /* the protocol interface */ 57 | struct wlr_linux_dmabuf_v1 { 58 | struct wl_global *global; 59 | struct wlr_renderer *renderer; 60 | 61 | struct { 62 | struct wl_signal destroy; 63 | } events; 64 | 65 | // private state 66 | 67 | struct wlr_linux_dmabuf_feedback_v1_compiled *default_feedback; 68 | struct wl_list surfaces; // wlr_linux_dmabuf_v1_surface.link 69 | 70 | struct wl_listener display_destroy; 71 | struct wl_listener renderer_destroy; 72 | }; 73 | 74 | /** 75 | * Create linux-dmabuf interface. 76 | */ 77 | struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *display, 78 | struct wlr_renderer *renderer); 79 | 80 | /** 81 | * Set a surface's DMA-BUF feedback. 82 | * 83 | * Passing a NULL feedback resets it to the default feedback. 84 | */ 85 | bool wlr_linux_dmabuf_v1_set_surface_feedback( 86 | struct wlr_linux_dmabuf_v1 *linux_dmabuf, struct wlr_surface *surface, 87 | const struct wlr_linux_dmabuf_feedback_v1 *feedback); 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_matrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a stable interface of wlroots. Future changes will be limited to: 3 | * 4 | * - New functions 5 | * - New struct members 6 | * - New enum members 7 | * 8 | * Note that wlroots does not make an ABI compatibility promise - in the future, 9 | * the layout and size of structs used by wlroots may change, requiring code 10 | * depending on this header to be recompiled (but not edited). 11 | * 12 | * Breaking changes are announced in the release notes and follow a 1-year 13 | * deprecation schedule. 14 | */ 15 | 16 | #ifndef WLR_TYPES_WLR_MATRIX_H 17 | #define WLR_TYPES_WLR_MATRIX_H 18 | 19 | #include 20 | 21 | struct wlr_box; 22 | 23 | /** Writes the identity matrix into mat */ 24 | void wlr_matrix_identity(float mat[static 9]); 25 | 26 | /** mat ← a × b */ 27 | void wlr_matrix_multiply(float mat[static 9], const float a[static 9], 28 | const float b[static 9]); 29 | 30 | void wlr_matrix_transpose(float mat[static 9], const float a[static 9]); 31 | 32 | /** Writes a 2D translation matrix to mat of magnitude (x, y) */ 33 | void wlr_matrix_translate(float mat[static 9], float x, float y); 34 | 35 | /** Writes a 2D scale matrix to mat of magnitude (x, y) */ 36 | void wlr_matrix_scale(float mat[static 9], float x, float y); 37 | 38 | /** Writes a 2D rotation matrix to mat at an angle of rad radians */ 39 | void wlr_matrix_rotate(float mat[static 9], float rad); 40 | 41 | /** Writes a transformation matrix which applies the specified 42 | * wl_output_transform to mat */ 43 | void wlr_matrix_transform(float mat[static 9], 44 | enum wl_output_transform transform); 45 | 46 | /** Shortcut for the various matrix operations involved in projecting the 47 | * specified wlr_box onto a given orthographic projection with a given 48 | * rotation. The result is written to mat, which can be applied to each 49 | * coordinate of the box to get a new coordinate from [-1,1]. */ 50 | void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box, 51 | enum wl_output_transform transform, float rotation, 52 | const float projection[static 9]); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_output_power_management_v1.h: -------------------------------------------------------------------------------- 1 | #ifndef WLR_TYPES_WLR_OUTPUT_POWER_MANAGEMENT_V1_H 2 | #define WLR_TYPES_WLR_OUTPUT_POWER_MANAGEMENT_V1_H 3 | 4 | #include 5 | #include "wlr-output-power-management-unstable-v1-protocol.h" 6 | 7 | struct wlr_output_power_manager_v1 { 8 | struct wl_global *global; 9 | struct wl_list output_powers; // wlr_output_power_v1.link 10 | 11 | struct wl_listener display_destroy; 12 | 13 | struct { 14 | struct wl_signal set_mode; // struct wlr_output_power_v1_set_mode_event 15 | struct wl_signal destroy; 16 | } events; 17 | 18 | void *data; 19 | }; 20 | 21 | struct wlr_output_power_v1 { 22 | struct wl_resource *resource; 23 | struct wlr_output *output; 24 | struct wlr_output_power_manager_v1 *manager; 25 | struct wl_list link; // wlr_output_power_manager_v1.output_powers 26 | 27 | struct wl_listener output_destroy_listener; 28 | struct wl_listener output_commit_listener; 29 | 30 | void *data; 31 | }; 32 | 33 | struct wlr_output_power_v1_set_mode_event { 34 | struct wlr_output *output; 35 | enum zwlr_output_power_v1_mode mode; 36 | }; 37 | 38 | struct wlr_output_power_manager_v1 *wlr_output_power_manager_v1_create( 39 | struct wl_display *display); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_pointer_gestures_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_POINTER_GESTURES_V1_H 10 | #define WLR_TYPES_WLR_POINTER_GESTURES_V1_H 11 | 12 | #include 13 | #include 14 | 15 | struct wlr_surface; 16 | 17 | struct wlr_pointer_gestures_v1 { 18 | struct wl_global *global; 19 | struct wl_list swipes; // wl_resource_get_link() 20 | struct wl_list pinches; // wl_resource_get_link() 21 | struct wl_list holds; // wl_resource_get_link() 22 | 23 | struct wl_listener display_destroy; 24 | 25 | struct { 26 | struct wl_signal destroy; 27 | } events; 28 | 29 | void *data; 30 | }; 31 | 32 | struct wlr_pointer_gestures_v1 *wlr_pointer_gestures_v1_create( 33 | struct wl_display *display); 34 | 35 | void wlr_pointer_gestures_v1_send_swipe_begin( 36 | struct wlr_pointer_gestures_v1 *gestures, 37 | struct wlr_seat *seat, 38 | uint32_t time_msec, 39 | uint32_t fingers); 40 | void wlr_pointer_gestures_v1_send_swipe_update( 41 | struct wlr_pointer_gestures_v1 *gestures, 42 | struct wlr_seat *seat, 43 | uint32_t time_msec, 44 | double dx, 45 | double dy); 46 | void wlr_pointer_gestures_v1_send_swipe_end( 47 | struct wlr_pointer_gestures_v1 *gestures, 48 | struct wlr_seat *seat, 49 | uint32_t time_msec, 50 | bool cancelled); 51 | 52 | void wlr_pointer_gestures_v1_send_pinch_begin( 53 | struct wlr_pointer_gestures_v1 *gestures, 54 | struct wlr_seat *seat, 55 | uint32_t time_msec, 56 | uint32_t fingers); 57 | void wlr_pointer_gestures_v1_send_pinch_update( 58 | struct wlr_pointer_gestures_v1 *gestures, 59 | struct wlr_seat *seat, 60 | uint32_t time_msec, 61 | double dx, 62 | double dy, 63 | double scale, 64 | double rotation); 65 | void wlr_pointer_gestures_v1_send_pinch_end( 66 | struct wlr_pointer_gestures_v1 *gestures, 67 | struct wlr_seat *seat, 68 | uint32_t time_msec, 69 | bool cancelled); 70 | 71 | void wlr_pointer_gestures_v1_send_hold_begin( 72 | struct wlr_pointer_gestures_v1 *gestures, 73 | struct wlr_seat *seat, 74 | uint32_t time_msec, 75 | uint32_t fingers); 76 | void wlr_pointer_gestures_v1_send_hold_end( 77 | struct wlr_pointer_gestures_v1 *gestures, 78 | struct wlr_seat *seat, 79 | uint32_t time_msec, 80 | bool cancelled); 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_primary_selection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_PRIMARY_SELECTION_H 10 | #define WLR_TYPES_WLR_PRIMARY_SELECTION_H 11 | 12 | #include 13 | #include 14 | 15 | struct wlr_primary_selection_source; 16 | 17 | /** 18 | * A data source implementation. Only the `send` function is mandatory. 19 | */ 20 | struct wlr_primary_selection_source_impl { 21 | void (*send)(struct wlr_primary_selection_source *source, 22 | const char *mime_type, int fd); 23 | void (*destroy)(struct wlr_primary_selection_source *source); 24 | }; 25 | 26 | /** 27 | * A source is the sending side of a selection. 28 | */ 29 | struct wlr_primary_selection_source { 30 | const struct wlr_primary_selection_source_impl *impl; 31 | 32 | // source metadata 33 | struct wl_array mime_types; 34 | 35 | struct { 36 | struct wl_signal destroy; 37 | } events; 38 | 39 | void *data; 40 | }; 41 | 42 | void wlr_primary_selection_source_init( 43 | struct wlr_primary_selection_source *source, 44 | const struct wlr_primary_selection_source_impl *impl); 45 | void wlr_primary_selection_source_destroy( 46 | struct wlr_primary_selection_source *source); 47 | void wlr_primary_selection_source_send( 48 | struct wlr_primary_selection_source *source, const char *mime_type, 49 | int fd); 50 | 51 | /** 52 | * Request setting the primary selection. If `client` is not null, then the 53 | * serial will be checked against the set of serials sent to the client on that 54 | * seat. 55 | */ 56 | void wlr_seat_request_set_primary_selection(struct wlr_seat *seat, 57 | struct wlr_seat_client *client, 58 | struct wlr_primary_selection_source *source, uint32_t serial); 59 | /** 60 | * Sets the current primary selection for the seat. NULL can be provided to 61 | * clear it. This removes the previous one if there was any. In case the 62 | * selection doesn't come from a client, wl_display_next_serial() can be used to 63 | * generate a serial. 64 | */ 65 | void wlr_seat_set_primary_selection(struct wlr_seat *seat, 66 | struct wlr_primary_selection_source *source, uint32_t serial); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_primary_selection_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_PRIMARY_SELECTION_V1_H 10 | #define WLR_TYPES_WLR_PRIMARY_SELECTION_V1_H 11 | 12 | #include 13 | #include 14 | 15 | struct wlr_primary_selection_v1_device_manager { 16 | struct wl_global *global; 17 | struct wl_list devices; // wlr_primary_selection_v1_device.link 18 | 19 | struct wl_listener display_destroy; 20 | 21 | struct { 22 | struct wl_signal destroy; 23 | } events; 24 | 25 | void *data; 26 | }; 27 | 28 | /** 29 | * A device is a per-seat object used to set and get the current selection. 30 | */ 31 | struct wlr_primary_selection_v1_device { 32 | struct wlr_primary_selection_v1_device_manager *manager; 33 | struct wlr_seat *seat; 34 | struct wl_list link; // wlr_primary_selection_v1_device_manager.devices 35 | struct wl_list resources; // wl_resource_get_link() 36 | 37 | struct wl_list offers; // wl_resource_get_link() 38 | 39 | struct wl_listener seat_destroy; 40 | struct wl_listener seat_focus_change; 41 | struct wl_listener seat_set_primary_selection; 42 | 43 | void *data; 44 | }; 45 | 46 | struct wlr_primary_selection_v1_device_manager * 47 | wlr_primary_selection_v1_device_manager_create(struct wl_display *display); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_region.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a stable interface of wlroots. Future changes will be limited to: 3 | * 4 | * - New functions 5 | * - New struct members 6 | * - New enum members 7 | * 8 | * Note that wlroots does not make an ABI compatibility promise - in the future, 9 | * the layout and size of structs used by wlroots may change, requiring code 10 | * depending on this header to be recompiled (but not edited). 11 | * 12 | * Breaking changes are announced in the release notes and follow a 1-year 13 | * deprecation schedule. 14 | */ 15 | 16 | #ifndef WLR_TYPES_WLR_REGION_H 17 | #define WLR_TYPES_WLR_REGION_H 18 | 19 | #include 20 | 21 | struct wl_resource; 22 | 23 | /** 24 | * Obtain a Pixman region from a wl_region resource. 25 | * 26 | * To allow clients to create wl_region objects, call wlr_compositor_create(). 27 | */ 28 | pixman_region32_t *wlr_region_from_resource(struct wl_resource *resource); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_relative_pointer_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_RELATIVE_POINTER_V1_H 10 | #define WLR_TYPES_WLR_RELATIVE_POINTER_V1_H 11 | 12 | #include 13 | 14 | /** 15 | * This protocol specifies a set of interfaces used for making clients able to 16 | * receive relative pointer events not obstructed by barriers (such as the 17 | * monitor edge or pointer constraints). 18 | */ 19 | 20 | /** 21 | * A global interface used for getting the relative pointer object for a given 22 | * pointer. 23 | */ 24 | struct wlr_relative_pointer_manager_v1 { 25 | struct wl_global *global; 26 | struct wl_list relative_pointers; // wlr_relative_pointer_v1.link 27 | 28 | struct { 29 | struct wl_signal destroy; 30 | struct wl_signal new_relative_pointer; // struct wlr_relative_pointer_v1 31 | } events; 32 | 33 | struct wl_listener display_destroy_listener; 34 | 35 | void *data; 36 | }; 37 | 38 | /** 39 | * A wp_relative_pointer object is an extension to the wl_pointer interface 40 | * used for emitting relative pointer events. It shares the same focus as 41 | * wl_pointer objects of the same seat and will only emit events when it has 42 | * focus. 43 | */ 44 | struct wlr_relative_pointer_v1 { 45 | struct wl_resource *resource; 46 | struct wl_resource *pointer_resource; 47 | struct wlr_seat *seat; 48 | struct wl_list link; // wlr_relative_pointer_manager_v1.relative_pointers 49 | 50 | struct { 51 | struct wl_signal destroy; 52 | } events; 53 | 54 | struct wl_listener seat_destroy; 55 | struct wl_listener pointer_destroy; 56 | 57 | void *data; 58 | }; 59 | 60 | struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_manager_v1_create( 61 | struct wl_display *display); 62 | 63 | /** 64 | * Send a relative motion event to the seat. Time is given in microseconds 65 | * (unlike wl_pointer which uses milliseconds). 66 | */ 67 | void wlr_relative_pointer_manager_v1_send_relative_motion( 68 | struct wlr_relative_pointer_manager_v1 *manager, struct wlr_seat *seat, 69 | uint64_t time_usec, double dx, double dy, 70 | double dx_unaccel, double dy_unaccel); 71 | 72 | /** 73 | * Get a relative pointer from its resource. Returns NULL if inert. 74 | */ 75 | struct wlr_relative_pointer_v1 *wlr_relative_pointer_v1_from_resource( 76 | struct wl_resource *resource); 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_screencopy_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_SCREENCOPY_V1_H 10 | #define WLR_TYPES_WLR_SCREENCOPY_V1_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | struct wlr_screencopy_manager_v1 { 17 | struct wl_global *global; 18 | struct wl_list frames; // wlr_screencopy_frame_v1.link 19 | 20 | struct wl_listener display_destroy; 21 | 22 | struct { 23 | struct wl_signal destroy; 24 | } events; 25 | 26 | void *data; 27 | }; 28 | 29 | struct wlr_screencopy_v1_client { 30 | int ref; 31 | struct wlr_screencopy_manager_v1 *manager; 32 | struct wl_list damages; 33 | }; 34 | 35 | struct wlr_screencopy_frame_v1 { 36 | struct wl_resource *resource; 37 | struct wlr_screencopy_v1_client *client; 38 | struct wl_list link; // wlr_screencopy_manager_v1.frames 39 | 40 | enum wl_shm_format format; 41 | uint32_t fourcc; 42 | struct wlr_box box; 43 | int stride; 44 | 45 | bool overlay_cursor, cursor_locked; 46 | 47 | bool with_damage; 48 | 49 | struct wl_shm_buffer *shm_buffer; 50 | struct wlr_dmabuf_v1_buffer *dma_buffer; 51 | 52 | struct wl_listener buffer_destroy; 53 | 54 | struct wlr_output *output; 55 | struct wl_listener output_commit; 56 | struct wl_listener output_destroy; 57 | struct wl_listener output_enable; 58 | 59 | void *data; 60 | }; 61 | 62 | struct wlr_screencopy_manager_v1 *wlr_screencopy_manager_v1_create( 63 | struct wl_display *display); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_server_decoration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This protocol is obsolete and will be removed in a future version. The 3 | * recommended replacement is xdg-decoration. 4 | */ 5 | 6 | /* 7 | * This an unstable interface of wlroots. No guarantees are made regarding the 8 | * future consistency of this API. 9 | */ 10 | #ifndef WLR_USE_UNSTABLE 11 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 12 | #endif 13 | 14 | #ifndef WLR_TYPES_WLR_SERVER_DECORATION_H 15 | #define WLR_TYPES_WLR_SERVER_DECORATION_H 16 | 17 | #include 18 | 19 | /** 20 | * Possible values to use in request_mode and the event mode. Same as 21 | * org_kde_kwin_server_decoration_manager_mode. 22 | */ 23 | enum wlr_server_decoration_manager_mode { 24 | /** 25 | * Undecorated: The surface is not decorated at all, neither server nor 26 | * client-side. An example is a popup surface which should not be 27 | * decorated. 28 | */ 29 | WLR_SERVER_DECORATION_MANAGER_MODE_NONE = 0, 30 | /** 31 | * Client-side decoration: The decoration is part of the surface and the 32 | * client. 33 | */ 34 | WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT = 1, 35 | /** 36 | * Server-side decoration: The server embeds the surface into a decoration 37 | * frame. 38 | */ 39 | WLR_SERVER_DECORATION_MANAGER_MODE_SERVER = 2, 40 | }; 41 | 42 | /** 43 | * A decoration negotiation interface which implements the KDE protocol. 44 | */ 45 | struct wlr_server_decoration_manager { 46 | struct wl_global *global; 47 | struct wl_list resources; // wl_resource_get_link() 48 | struct wl_list decorations; // wlr_server_decoration.link 49 | 50 | uint32_t default_mode; // enum wlr_server_decoration_manager_mode 51 | 52 | struct wl_listener display_destroy; 53 | 54 | struct { 55 | struct wl_signal new_decoration; 56 | struct wl_signal destroy; 57 | } events; 58 | 59 | void *data; 60 | }; 61 | 62 | struct wlr_server_decoration { 63 | struct wl_resource *resource; 64 | struct wlr_surface *surface; 65 | struct wl_list link; 66 | 67 | uint32_t mode; // enum wlr_server_decoration_manager_mode 68 | 69 | struct { 70 | struct wl_signal destroy; 71 | struct wl_signal mode; 72 | } events; 73 | 74 | struct wl_listener surface_destroy_listener; 75 | 76 | void *data; 77 | }; 78 | 79 | struct wlr_server_decoration_manager *wlr_server_decoration_manager_create( 80 | struct wl_display *display); 81 | void wlr_server_decoration_manager_set_default_mode( 82 | struct wlr_server_decoration_manager *manager, uint32_t default_mode); 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_single_pixel_buffer_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_SINGLE_PIXEL_BUFFER_V1 10 | #define WLR_TYPES_WLR_SINGLE_PIXEL_BUFFER_V1 11 | 12 | #include 13 | 14 | struct wlr_single_pixel_buffer_manager_v1; 15 | 16 | struct wlr_single_pixel_buffer_manager_v1 *wlr_single_pixel_buffer_manager_v1_create( 17 | struct wl_display *display); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_subcompositor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_SUBCOMPOSITOR_H 10 | #define WLR_TYPES_WLR_SUBCOMPOSITOR_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | struct wlr_surface; 17 | 18 | /** 19 | * The sub-surface state describing the sub-surface's relationship with its 20 | * parent. Contrary to other states, this one is not applied on surface commit. 21 | * Instead, it's applied on parent surface commit. 22 | */ 23 | struct wlr_subsurface_parent_state { 24 | int32_t x, y; 25 | struct wl_list link; 26 | }; 27 | 28 | struct wlr_subsurface { 29 | struct wl_resource *resource; 30 | struct wlr_surface *surface; 31 | struct wlr_surface *parent; 32 | 33 | struct wlr_subsurface_parent_state current, pending; 34 | 35 | uint32_t cached_seq; 36 | bool has_cache; 37 | 38 | bool synchronized; 39 | bool reordered; 40 | bool mapped; 41 | bool added; 42 | 43 | struct wl_listener surface_destroy; 44 | struct wl_listener surface_client_commit; 45 | struct wl_listener parent_destroy; 46 | 47 | struct { 48 | struct wl_signal destroy; 49 | struct wl_signal map; 50 | struct wl_signal unmap; 51 | } events; 52 | 53 | void *data; 54 | }; 55 | 56 | struct wlr_subcompositor { 57 | struct wl_global *global; 58 | 59 | struct wl_listener display_destroy; 60 | 61 | struct { 62 | struct wl_signal destroy; 63 | } events; 64 | }; 65 | 66 | /** 67 | * Returns true if the surface has the subsurface role. 68 | */ 69 | bool wlr_surface_is_subsurface(struct wlr_surface *surface); 70 | 71 | /** 72 | * Get a struct wlr_subsurface from a struct wlr_surface. 73 | * Asserts that the surface has the subsurface role. 74 | * May return NULL even if the surface has the subsurface role if the 75 | * corresponding subsurface has been destroyed. 76 | */ 77 | struct wlr_subsurface *wlr_subsurface_from_wlr_surface( 78 | struct wlr_surface *surface); 79 | 80 | struct wlr_subcompositor *wlr_subcompositor_create(struct wl_display *display); 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_surface.h: -------------------------------------------------------------------------------- 1 | #warning "wlr/types/wlr_surface.h has been deprecated and will be removed in the future. Use wlr/types/wlr_compositor.h and wlr/types/wlr_subcompositor.h." 2 | 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_switch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_SWITCH_H 10 | #define WLR_TYPES_WLR_SWITCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | struct wlr_switch_impl; 17 | 18 | struct wlr_switch { 19 | struct wlr_input_device base; 20 | 21 | const struct wlr_switch_impl *impl; 22 | 23 | struct { 24 | struct wl_signal toggle; 25 | } events; 26 | 27 | void *data; 28 | }; 29 | 30 | enum wlr_switch_type { 31 | WLR_SWITCH_TYPE_LID, 32 | WLR_SWITCH_TYPE_TABLET_MODE, 33 | }; 34 | 35 | enum wlr_switch_state { 36 | WLR_SWITCH_STATE_OFF = 0, 37 | WLR_SWITCH_STATE_ON, 38 | }; 39 | 40 | struct wlr_switch_toggle_event { 41 | uint32_t time_msec; 42 | enum wlr_switch_type switch_type; 43 | enum wlr_switch_state switch_state; 44 | }; 45 | 46 | /** 47 | * Get a struct wlr_switch from a struct wlr_input_device. 48 | * 49 | * Asserts that the input device is a switch. 50 | */ 51 | struct wlr_switch *wlr_switch_from_input_device( 52 | struct wlr_input_device *input_device); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_tablet_pad.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_TABLET_PAD_H 10 | #define WLR_TYPES_WLR_TABLET_PAD_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | /* 17 | * NOTE: the wlr tablet pad implementation does not currently support tablets 18 | * with more than one mode. I don't own any such hardware so I cannot test it 19 | * and it is too complicated to make a meaningful implementation of blindly. 20 | */ 21 | 22 | struct wlr_tablet_pad_impl; 23 | 24 | struct wlr_tablet_pad { 25 | struct wlr_input_device base; 26 | 27 | const struct wlr_tablet_pad_impl *impl; 28 | 29 | struct { 30 | struct wl_signal button; 31 | struct wl_signal ring; 32 | struct wl_signal strip; 33 | struct wl_signal attach_tablet; // struct wlr_tablet_tool 34 | } events; 35 | 36 | size_t button_count; 37 | size_t ring_count; 38 | size_t strip_count; 39 | 40 | struct wl_list groups; // wlr_tablet_pad_group.link 41 | struct wl_array paths; // char * 42 | 43 | void *data; 44 | }; 45 | 46 | struct wlr_tablet_pad_group { 47 | struct wl_list link; 48 | 49 | size_t button_count; 50 | unsigned int *buttons; 51 | 52 | size_t strip_count; 53 | unsigned int *strips; 54 | 55 | size_t ring_count; 56 | unsigned int *rings; 57 | 58 | unsigned int mode_count; 59 | }; 60 | 61 | struct wlr_tablet_pad_button_event { 62 | uint32_t time_msec; 63 | uint32_t button; 64 | enum wlr_button_state state; 65 | unsigned int mode; 66 | unsigned int group; 67 | }; 68 | 69 | enum wlr_tablet_pad_ring_source { 70 | WLR_TABLET_PAD_RING_SOURCE_UNKNOWN, 71 | WLR_TABLET_PAD_RING_SOURCE_FINGER, 72 | }; 73 | 74 | struct wlr_tablet_pad_ring_event { 75 | uint32_t time_msec; 76 | enum wlr_tablet_pad_ring_source source; 77 | uint32_t ring; 78 | double position; 79 | unsigned int mode; 80 | }; 81 | 82 | enum wlr_tablet_pad_strip_source { 83 | WLR_TABLET_PAD_STRIP_SOURCE_UNKNOWN, 84 | WLR_TABLET_PAD_STRIP_SOURCE_FINGER, 85 | }; 86 | 87 | struct wlr_tablet_pad_strip_event { 88 | uint32_t time_msec; 89 | enum wlr_tablet_pad_strip_source source; 90 | uint32_t strip; 91 | double position; 92 | unsigned int mode; 93 | }; 94 | 95 | /** 96 | * Get a struct wlr_tablet_pad from a struct wlr_input_device. 97 | * 98 | * Asserts that the input device is a tablet pad. 99 | */ 100 | struct wlr_tablet_pad *wlr_tablet_pad_from_input_device( 101 | struct wlr_input_device *); 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_TOUCH_H 10 | #define WLR_TYPES_WLR_TOUCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | struct wlr_touch_impl; 17 | 18 | struct wlr_touch { 19 | struct wlr_input_device base; 20 | 21 | const struct wlr_touch_impl *impl; 22 | 23 | char *output_name; 24 | double width_mm, height_mm; 25 | 26 | struct { 27 | struct wl_signal down; // struct wlr_touch_down_event 28 | struct wl_signal up; // struct wlr_touch_up_event 29 | struct wl_signal motion; // struct wlr_touch_motion_event 30 | struct wl_signal cancel; // struct wlr_touch_cancel_event 31 | struct wl_signal frame; 32 | } events; 33 | 34 | void *data; 35 | }; 36 | 37 | struct wlr_touch_down_event { 38 | struct wlr_touch *touch; 39 | uint32_t time_msec; 40 | int32_t touch_id; 41 | // From 0..1 42 | double x, y; 43 | }; 44 | 45 | struct wlr_touch_up_event { 46 | struct wlr_touch *touch; 47 | uint32_t time_msec; 48 | int32_t touch_id; 49 | }; 50 | 51 | struct wlr_touch_motion_event { 52 | struct wlr_touch *touch; 53 | uint32_t time_msec; 54 | int32_t touch_id; 55 | // From 0..1 56 | double x, y; 57 | }; 58 | 59 | struct wlr_touch_cancel_event { 60 | struct wlr_touch *touch; 61 | uint32_t time_msec; 62 | int32_t touch_id; 63 | }; 64 | 65 | /** 66 | * Get a struct wlr_touch from a struct wlr_input_device. 67 | * 68 | * Asserts that the input device is a touch device. 69 | */ 70 | struct wlr_touch *wlr_touch_from_input_device( 71 | struct wlr_input_device *input_device); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_viewporter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_VIEWPORTER_H 10 | #define WLR_TYPES_WLR_VIEWPORTER_H 11 | 12 | #include 13 | 14 | /** 15 | * Implementation for the viewporter protocol. 16 | * 17 | * When enabling viewporter, compositors need to update their rendering logic: 18 | * 19 | * - The size of the surface texture may not match the surface size anymore. 20 | * Compositors must use the surface size only. 21 | * - Compositors must call wlr_render_subtexture_with_matrix() when rendering a 22 | * surface texture with the source box returned by 23 | * wlr_surface_get_buffer_source_box(). 24 | */ 25 | struct wlr_viewporter { 26 | struct wl_global *global; 27 | 28 | struct { 29 | struct wl_signal destroy; 30 | } events; 31 | 32 | struct wl_listener display_destroy; 33 | }; 34 | 35 | struct wlr_viewporter *wlr_viewporter_create(struct wl_display *display); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_virtual_keyboard_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_VIRTUAL_KEYBOARD_V1_H 10 | #define WLR_TYPES_WLR_VIRTUAL_KEYBOARD_V1_H 11 | 12 | #include 13 | #include 14 | 15 | struct wlr_virtual_keyboard_manager_v1 { 16 | struct wl_global *global; 17 | struct wl_list virtual_keyboards; // wlr_virtual_keyboard_v1.link 18 | 19 | struct wl_listener display_destroy; 20 | 21 | struct { 22 | struct wl_signal new_virtual_keyboard; // struct wlr_virtual_keyboard_v1 * 23 | struct wl_signal destroy; 24 | } events; 25 | }; 26 | 27 | struct wlr_virtual_keyboard_v1 { 28 | struct wlr_keyboard keyboard; 29 | struct wl_resource *resource; 30 | struct wlr_seat *seat; 31 | bool has_keymap; 32 | 33 | struct wl_list link; // wlr_virtual_keyboard_manager_v1.virtual_keyboards 34 | }; 35 | 36 | struct wlr_virtual_keyboard_manager_v1* wlr_virtual_keyboard_manager_v1_create( 37 | struct wl_display *display); 38 | 39 | struct wlr_virtual_keyboard_v1 *wlr_input_device_get_virtual_keyboard( 40 | struct wlr_input_device *wlr_dev); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_virtual_pointer_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_VIRTUAL_POINTER_V1_H 10 | #define WLR_TYPES_WLR_VIRTUAL_POINTER_V1_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | struct wlr_virtual_pointer_manager_v1 { 18 | struct wl_global *global; 19 | struct wl_list virtual_pointers; // wlr_virtual_pointer_v1.link 20 | 21 | struct wl_listener display_destroy; 22 | 23 | struct { 24 | struct wl_signal new_virtual_pointer; // struct wlr_virtual_pointer_v1_new_pointer_event * 25 | struct wl_signal destroy; 26 | } events; 27 | }; 28 | 29 | struct wlr_virtual_pointer_v1 { 30 | struct wlr_pointer pointer; 31 | struct wl_resource *resource; 32 | /* Vertical and horizontal */ 33 | struct wlr_pointer_axis_event axis_event[2]; 34 | enum wl_pointer_axis axis; 35 | bool axis_valid[2]; 36 | 37 | struct wl_list link; // wlr_virtual_pointer_manager_v1.virtual_pointers 38 | }; 39 | 40 | struct wlr_virtual_pointer_v1_new_pointer_event { 41 | struct wlr_virtual_pointer_v1 *new_pointer; 42 | /** Suggested by client; may be NULL. */ 43 | struct wlr_seat *suggested_seat; 44 | struct wlr_output *suggested_output; 45 | }; 46 | 47 | struct wlr_virtual_pointer_manager_v1* wlr_virtual_pointer_manager_v1_create( 48 | struct wl_display *display); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_xcursor_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_XCURSOR_MANAGER_H 10 | #define WLR_TYPES_WLR_XCURSOR_MANAGER_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | /** 17 | * An XCursor theme at a particular scale factor of the base size. 18 | */ 19 | struct wlr_xcursor_manager_theme { 20 | float scale; 21 | struct wlr_xcursor_theme *theme; 22 | struct wl_list link; 23 | }; 24 | 25 | /** 26 | * struct wlr_xcursor_manager dynamically loads xcursor themes at sizes necessary 27 | * for use on outputs at arbitrary scale factors. You should call 28 | * wlr_xcursor_manager_load() for each output you will show your cursor on, with 29 | * the scale factor parameter set to that output's scale factor. 30 | */ 31 | struct wlr_xcursor_manager { 32 | char *name; 33 | uint32_t size; 34 | struct wl_list scaled_themes; // wlr_xcursor_manager_theme::link 35 | }; 36 | 37 | /** 38 | * Creates a new XCursor manager with the given xcursor theme name and base size 39 | * (for use when scale=1). 40 | */ 41 | struct wlr_xcursor_manager *wlr_xcursor_manager_create(const char *name, 42 | uint32_t size); 43 | 44 | void wlr_xcursor_manager_destroy(struct wlr_xcursor_manager *manager); 45 | 46 | /** 47 | * Ensures an xcursor theme at the given scale factor is loaded in the manager. 48 | */ 49 | bool wlr_xcursor_manager_load(struct wlr_xcursor_manager *manager, 50 | float scale); 51 | 52 | /** 53 | * Retrieves a wlr_xcursor reference for the given cursor name at the given 54 | * scale factor, or NULL if this struct wlr_xcursor_manager has not loaded a 55 | * cursor theme at the requested scale. 56 | */ 57 | struct wlr_xcursor *wlr_xcursor_manager_get_xcursor( 58 | struct wlr_xcursor_manager *manager, const char *name, float scale); 59 | 60 | /** 61 | * Set a struct wlr_cursor's cursor image to the specified cursor name for all 62 | * scale factors. struct wlr_cursor will take over from this point and ensure 63 | * the correct cursor is used on each output, assuming a 64 | * struct wlr_output_layout is attached to it. 65 | */ 66 | void wlr_xcursor_manager_set_cursor_image(struct wlr_xcursor_manager *manager, 67 | const char *name, struct wlr_cursor *cursor); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_xdg_decoration_v1.h: -------------------------------------------------------------------------------- 1 | #ifndef WLR_TYPES_WLR_XDG_DECORATION_V1 2 | #define WLR_TYPES_WLR_XDG_DECORATION_V1 3 | 4 | #include 5 | #include 6 | 7 | enum wlr_xdg_toplevel_decoration_v1_mode { 8 | WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_NONE = 0, 9 | WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE = 1, 10 | WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE = 2, 11 | }; 12 | 13 | struct wlr_xdg_decoration_manager_v1 { 14 | struct wl_global *global; 15 | struct wl_list decorations; // wlr_xdg_toplevel_decoration.link 16 | 17 | struct wl_listener display_destroy; 18 | 19 | struct { 20 | struct wl_signal new_toplevel_decoration; // struct wlr_xdg_toplevel_decoration * 21 | struct wl_signal destroy; 22 | } events; 23 | 24 | void *data; 25 | }; 26 | 27 | struct wlr_xdg_toplevel_decoration_v1_configure { 28 | struct wl_list link; // wlr_xdg_toplevel_decoration.configure_list 29 | struct wlr_xdg_surface_configure *surface_configure; 30 | enum wlr_xdg_toplevel_decoration_v1_mode mode; 31 | }; 32 | 33 | struct wlr_xdg_toplevel_decoration_v1_state { 34 | enum wlr_xdg_toplevel_decoration_v1_mode mode; 35 | }; 36 | 37 | struct wlr_xdg_toplevel_decoration_v1 { 38 | struct wl_resource *resource; 39 | struct wlr_xdg_surface *surface; 40 | struct wlr_xdg_decoration_manager_v1 *manager; 41 | struct wl_list link; // wlr_xdg_decoration_manager_v1.link 42 | 43 | struct wlr_xdg_toplevel_decoration_v1_state current, pending; 44 | 45 | enum wlr_xdg_toplevel_decoration_v1_mode scheduled_mode; 46 | enum wlr_xdg_toplevel_decoration_v1_mode requested_mode; 47 | 48 | bool added; 49 | 50 | struct wl_list configure_list; // wlr_xdg_toplevel_decoration_v1_configure.link 51 | 52 | struct { 53 | struct wl_signal destroy; 54 | struct wl_signal request_mode; 55 | } events; 56 | 57 | struct wl_listener surface_destroy; 58 | struct wl_listener surface_configure; 59 | struct wl_listener surface_ack_configure; 60 | struct wl_listener surface_commit; 61 | 62 | void *data; 63 | }; 64 | 65 | struct wlr_xdg_decoration_manager_v1 * 66 | wlr_xdg_decoration_manager_v1_create(struct wl_display *display); 67 | 68 | uint32_t wlr_xdg_toplevel_decoration_v1_set_mode( 69 | struct wlr_xdg_toplevel_decoration_v1 *decoration, 70 | enum wlr_xdg_toplevel_decoration_v1_mode mode); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_xdg_foreign_registry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_XDG_FOREIGN_REGISTRY_H 10 | #define WLR_TYPES_WLR_XDG_FOREIGN_REGISTRY_H 11 | 12 | #include 13 | 14 | #define WLR_XDG_FOREIGN_HANDLE_SIZE 37 15 | 16 | /** 17 | * struct wlr_xdg_foreign_registry is used for storing a list of exported 18 | * surfaces with the xdg-foreign family of protocols. 19 | * 20 | * It can be used to allow interoperability between clients using different 21 | * versions of the protocol (if all versions use the same registry). 22 | */ 23 | struct wlr_xdg_foreign_registry { 24 | struct wl_list exported_surfaces; // struct wlr_xdg_foreign_exported_surface 25 | 26 | struct wl_listener display_destroy; 27 | struct { 28 | struct wl_signal destroy; 29 | } events; 30 | }; 31 | 32 | struct wlr_xdg_foreign_exported { 33 | struct wl_list link; // wlr_xdg_foreign_registry.exported_surfaces 34 | struct wlr_xdg_foreign_registry *registry; 35 | 36 | struct wlr_surface *surface; 37 | 38 | char handle[WLR_XDG_FOREIGN_HANDLE_SIZE]; 39 | 40 | struct { 41 | struct wl_signal destroy; 42 | } events; 43 | }; 44 | 45 | /** 46 | * Create an empty struct wlr_xdg_foreign_registry. 47 | * 48 | * It will be destroyed when the associated display is destroyed. 49 | */ 50 | struct wlr_xdg_foreign_registry *wlr_xdg_foreign_registry_create( 51 | struct wl_display *display); 52 | 53 | /** 54 | * Add the given exported surface to the registry and assign it a unique handle. 55 | * The caller is responsible for removing the exported surface from the repository 56 | * if it is destroyed. 57 | * 58 | * Returns true if the initialization was successful. 59 | */ 60 | bool wlr_xdg_foreign_exported_init(struct wlr_xdg_foreign_exported *surface, 61 | struct wlr_xdg_foreign_registry *registry); 62 | 63 | /** 64 | * Find an exported surface with the given handle, or NULL if such a surface 65 | * does not exist. 66 | */ 67 | struct wlr_xdg_foreign_exported *wlr_xdg_foreign_registry_find_by_handle( 68 | struct wlr_xdg_foreign_registry *registry, const char *handle); 69 | 70 | /** 71 | * Remove the given surface from the registry it was previously added in. 72 | */ 73 | void wlr_xdg_foreign_exported_finish(struct wlr_xdg_foreign_exported *surface); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_xdg_foreign_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_XDG_FOREIGN_V1_H 10 | #define WLR_TYPES_WLR_XDG_FOREIGN_V1_H 11 | 12 | #include 13 | #include 14 | 15 | struct wlr_xdg_foreign_v1 { 16 | struct { 17 | struct wl_global *global; 18 | struct wl_list objects; // wlr_xdg_exported_v1.link or wlr_xdg_imported_v1.link 19 | } exporter, importer; 20 | 21 | struct wl_listener foreign_registry_destroy; 22 | struct wl_listener display_destroy; 23 | 24 | struct wlr_xdg_foreign_registry *registry; 25 | 26 | struct { 27 | struct wl_signal destroy; 28 | } events; 29 | 30 | void *data; 31 | }; 32 | 33 | struct wlr_xdg_exported_v1 { 34 | struct wlr_xdg_foreign_exported base; 35 | 36 | struct wl_resource *resource; 37 | struct wl_listener xdg_surface_unmap; 38 | 39 | struct wl_list link; // wlr_xdg_foreign_v1.exporter.objects 40 | }; 41 | 42 | struct wlr_xdg_imported_v1 { 43 | struct wlr_xdg_foreign_exported *exported; 44 | struct wl_listener exported_destroyed; 45 | 46 | struct wl_resource *resource; 47 | struct wl_list link; // wlr_xdg_foreign_v1.importer.objects 48 | struct wl_list children; 49 | }; 50 | 51 | struct wlr_xdg_imported_child_v1 { 52 | struct wlr_xdg_imported_v1 *imported; 53 | struct wlr_surface *surface; 54 | 55 | struct wl_list link; // wlr_xdg_imported_v1.children 56 | 57 | struct wl_listener xdg_surface_unmap; 58 | struct wl_listener xdg_toplevel_set_parent; 59 | }; 60 | 61 | struct wlr_xdg_foreign_v1 *wlr_xdg_foreign_v1_create( 62 | struct wl_display *display, struct wlr_xdg_foreign_registry *registry); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_xdg_foreign_v2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_XDG_FOREIGN_V2_H 10 | #define WLR_TYPES_WLR_XDG_FOREIGN_V2_H 11 | 12 | #include 13 | #include 14 | 15 | struct wlr_xdg_foreign_v2 { 16 | struct { 17 | struct wl_global *global; 18 | struct wl_list objects; // wlr_xdg_exported_v2.link or wlr_xdg_imported_v2.link 19 | } exporter, importer; 20 | 21 | struct wl_listener foreign_registry_destroy; 22 | struct wl_listener display_destroy; 23 | 24 | struct wlr_xdg_foreign_registry *registry; 25 | 26 | struct { 27 | struct wl_signal destroy; 28 | } events; 29 | 30 | void *data; 31 | }; 32 | 33 | struct wlr_xdg_exported_v2 { 34 | struct wlr_xdg_foreign_exported base; 35 | 36 | struct wl_resource *resource; 37 | struct wl_listener xdg_surface_unmap; 38 | 39 | struct wl_list link; // wlr_xdg_foreign_v2.exporter.objects 40 | }; 41 | 42 | struct wlr_xdg_imported_v2 { 43 | struct wlr_xdg_foreign_exported *exported; 44 | struct wl_listener exported_destroyed; 45 | 46 | struct wl_resource *resource; 47 | struct wl_list link; // wlr_xdg_foreign_v2.importer.objects 48 | struct wl_list children; 49 | }; 50 | 51 | struct wlr_xdg_imported_child_v2 { 52 | struct wlr_xdg_imported_v2 *imported; 53 | struct wlr_surface *surface; 54 | 55 | struct wl_list link; // wlr_xdg_imported_v2.children 56 | 57 | struct wl_listener xdg_surface_unmap; 58 | struct wl_listener xdg_toplevel_set_parent; 59 | }; 60 | 61 | struct wlr_xdg_foreign_v2 *wlr_xdg_foreign_v2_create( 62 | struct wl_display *display, struct wlr_xdg_foreign_registry *registry); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_xdg_output_v1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_TYPES_WLR_XDG_OUTPUT_V1_H 10 | #define WLR_TYPES_WLR_XDG_OUTPUT_V1_H 11 | #include 12 | #include 13 | 14 | struct wlr_xdg_output_v1 { 15 | struct wlr_xdg_output_manager_v1 *manager; 16 | struct wl_list resources; 17 | struct wl_list link; 18 | 19 | struct wlr_output_layout_output *layout_output; 20 | 21 | int32_t x, y; 22 | int32_t width, height; 23 | 24 | struct wl_listener destroy; 25 | struct wl_listener description; 26 | }; 27 | 28 | struct wlr_xdg_output_manager_v1 { 29 | struct wl_global *global; 30 | struct wlr_output_layout *layout; 31 | 32 | struct wl_list outputs; 33 | 34 | struct { 35 | struct wl_signal destroy; 36 | } events; 37 | 38 | struct wl_listener display_destroy; 39 | struct wl_listener layout_add; 40 | struct wl_listener layout_change; 41 | struct wl_listener layout_destroy; 42 | }; 43 | 44 | struct wlr_xdg_output_manager_v1 *wlr_xdg_output_manager_v1_create( 45 | struct wl_display *display, struct wlr_output_layout *layout); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/wlr/util/addon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This an unstable interface of wlroots. No guarantees are made regarding the 3 | * future consistency of this API. 4 | */ 5 | #ifndef WLR_USE_UNSTABLE 6 | #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 | #endif 8 | 9 | #ifndef WLR_UTIL_ADDON_H 10 | #define WLR_UTIL_ADDON_H 11 | 12 | #include 13 | 14 | struct wlr_addon_set { 15 | // private state 16 | struct wl_list addons; 17 | }; 18 | 19 | struct wlr_addon; 20 | 21 | struct wlr_addon_interface { 22 | const char *name; 23 | // Has to call wlr_addon_finish() 24 | void (*destroy)(struct wlr_addon *addon); 25 | }; 26 | 27 | struct wlr_addon { 28 | const struct wlr_addon_interface *impl; 29 | // private state 30 | const void *owner; 31 | struct wl_list link; 32 | }; 33 | 34 | void wlr_addon_set_init(struct wlr_addon_set *set); 35 | void wlr_addon_set_finish(struct wlr_addon_set *set); 36 | 37 | void wlr_addon_init(struct wlr_addon *addon, struct wlr_addon_set *set, 38 | const void *owner, const struct wlr_addon_interface *impl); 39 | void wlr_addon_finish(struct wlr_addon *addon); 40 | 41 | struct wlr_addon *wlr_addon_find(struct wlr_addon_set *set, const void *owner, 42 | const struct wlr_addon_interface *impl); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /include/wlr/util/edges.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a stable interface of wlroots. Future changes will be limited to: 3 | * 4 | * - New functions 5 | * - New struct members 6 | * - New enum members 7 | * 8 | * Note that wlroots does not make an ABI compatibility promise - in the future, 9 | * the layout and size of structs used by wlroots may change, requiring code 10 | * depending on this header to be recompiled (but not edited). 11 | * 12 | * Breaking changes are announced in the release notes and follow a 1-year 13 | * deprecation schedule. 14 | */ 15 | 16 | #ifndef WLR_UTIL_EDGES_H 17 | #define WLR_UTIL_EDGES_H 18 | 19 | enum wlr_edges { 20 | WLR_EDGE_NONE = 0, 21 | WLR_EDGE_TOP = 1 << 0, 22 | WLR_EDGE_BOTTOM = 1 << 1, 23 | WLR_EDGE_LEFT = 1 << 2, 24 | WLR_EDGE_RIGHT = 1 << 3, 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/wlr/util/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a stable interface of wlroots. Future changes will be limited to: 3 | * 4 | * - New functions 5 | * - New struct members 6 | * - New enum members 7 | * 8 | * Note that wlroots does not make an ABI compatibility promise - in the future, 9 | * the layout and size of structs used by wlroots may change, requiring code 10 | * depending on this header to be recompiled (but not edited). 11 | * 12 | * Breaking changes are announced in the release notes and follow a 1-year 13 | * deprecation schedule. 14 | */ 15 | 16 | #ifndef WLR_UTIL_LOG_H 17 | #define WLR_UTIL_LOG_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | enum wlr_log_importance { 25 | WLR_SILENT = 0, 26 | WLR_ERROR = 1, 27 | WLR_INFO = 2, 28 | WLR_DEBUG = 3, 29 | WLR_LOG_IMPORTANCE_LAST, 30 | }; 31 | 32 | typedef void (*wlr_log_func_t)(enum wlr_log_importance importance, 33 | const char *fmt, va_list args); 34 | 35 | /** 36 | * Set the log verbosity and callback. 37 | * 38 | * Only messages less than or equal to the supplied verbosity will be logged. 39 | * If the callback is NULL, the default logger is used. 40 | * 41 | * This function can be called multiple times to update the verbosity or 42 | * callback function. 43 | */ 44 | void wlr_log_init(enum wlr_log_importance verbosity, wlr_log_func_t callback); 45 | 46 | /** 47 | * Get the current log verbosity configured by wlr_log_init(). 48 | */ 49 | enum wlr_log_importance wlr_log_get_verbosity(void); 50 | 51 | #ifdef __GNUC__ 52 | #define _WLR_ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end))) 53 | #else 54 | #define _WLR_ATTRIB_PRINTF(start, end) 55 | #endif 56 | 57 | void _wlr_log(enum wlr_log_importance verbosity, const char *format, ...) _WLR_ATTRIB_PRINTF(2, 3); 58 | void _wlr_vlog(enum wlr_log_importance verbosity, const char *format, va_list args) _WLR_ATTRIB_PRINTF(2, 0); 59 | 60 | #ifdef WLR_REL_SRC_DIR 61 | // strip prefix from __FILE__, leaving the path relative to the project root 62 | #define _WLR_FILENAME ((const char *)__FILE__ + sizeof(WLR_REL_SRC_DIR) - 1) 63 | #else 64 | #define _WLR_FILENAME __FILE__ 65 | #endif 66 | 67 | #define wlr_log(verb, fmt, ...) \ 68 | _wlr_log(verb, "[%s:%d] " fmt, _WLR_FILENAME, __LINE__, ##__VA_ARGS__) 69 | 70 | #define wlr_vlog(verb, fmt, args) \ 71 | _wlr_vlog(verb, "[%s:%d] " fmt, _WLR_FILENAME, __LINE__, args) 72 | 73 | #define wlr_log_errno(verb, fmt, ...) \ 74 | wlr_log(verb, fmt ": %s", ##__VA_ARGS__, strerror(errno)) 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /include/wlr/util/region.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a stable interface of wlroots. Future changes will be limited to: 3 | * 4 | * - New functions 5 | * - New struct members 6 | * - New enum members 7 | * 8 | * Note that wlroots does not make an ABI compatibility promise - in the future, 9 | * the layout and size of structs used by wlroots may change, requiring code 10 | * depending on this header to be recompiled (but not edited). 11 | * 12 | * Breaking changes are announced in the release notes and follow a 1-year 13 | * deprecation schedule. 14 | */ 15 | 16 | #ifndef WLR_UTIL_REGION_H 17 | #define WLR_UTIL_REGION_H 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | /** 24 | * Scales a region, ie. multiplies all its coordinates by `scale`. 25 | * 26 | * The resulting coordinates are rounded up or down so that the new region is 27 | * at least as big as the original one. 28 | */ 29 | void wlr_region_scale(pixman_region32_t *dst, pixman_region32_t *src, 30 | float scale); 31 | 32 | void wlr_region_scale_xy(pixman_region32_t *dst, pixman_region32_t *src, 33 | float scale_x, float scale_y); 34 | 35 | /** 36 | * Applies a transform to a region inside a box of size `width` x `height`. 37 | */ 38 | void wlr_region_transform(pixman_region32_t *dst, pixman_region32_t *src, 39 | enum wl_output_transform transform, int width, int height); 40 | 41 | /** 42 | * Expands the region of `distance`. If `distance` is negative, it shrinks the 43 | * region. 44 | */ 45 | void wlr_region_expand(pixman_region32_t *dst, pixman_region32_t *src, 46 | int distance); 47 | 48 | /* 49 | * Builds the smallest possible region that contains the region rotated about 50 | * the point (ox, oy). 51 | */ 52 | void wlr_region_rotated_bounds(pixman_region32_t *dst, pixman_region32_t *src, 53 | float rotation, int ox, int oy); 54 | 55 | bool wlr_region_confine(pixman_region32_t *region, double x1, double y1, double x2, 56 | double y2, double *x2_out, double *y2_out); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /include/wlr/version.h.in: -------------------------------------------------------------------------------- 1 | #ifndef WLR_VERSION_H 2 | #define WLR_VERSION_H 3 | 4 | #mesondefine WLR_VERSION_STR 5 | 6 | #mesondefine WLR_VERSION_MAJOR 7 | #mesondefine WLR_VERSION_MINOR 8 | #mesondefine WLR_VERSION_MICRO 9 | 10 | #define WLR_VERSION_NUM ((WLR_VERSION_MAJOR << 16) | (WLR_VERSION_MINOR << 8) | WLR_VERSION_MICRO) 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/xcursor/xcursor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2002 Keith Packard 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice (including the 13 | * next paragraph) shall be included in all copies or substantial 14 | * portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef XCURSOR_H 27 | #define XCURSOR_H 28 | 29 | #include 30 | 31 | typedef int XcursorBool; 32 | typedef uint32_t XcursorUInt; 33 | 34 | typedef XcursorUInt XcursorDim; 35 | typedef XcursorUInt XcursorPixel; 36 | 37 | typedef struct _XcursorImage { 38 | XcursorUInt version; /* version of the image data */ 39 | XcursorDim size; /* nominal size for matching */ 40 | XcursorDim width; /* actual width */ 41 | XcursorDim height; /* actual height */ 42 | XcursorDim xhot; /* hot spot x (must be inside image) */ 43 | XcursorDim yhot; /* hot spot y (must be inside image) */ 44 | XcursorUInt delay; /* animation delay to next frame (ms) */ 45 | XcursorPixel *pixels; /* pointer to pixels */ 46 | } XcursorImage; 47 | 48 | /* 49 | * Other data structures exposed by the library API 50 | */ 51 | typedef struct _XcursorImages { 52 | int nimage; /* number of images */ 53 | XcursorImage **images; /* array of XcursorImage pointers */ 54 | char *name; /* name used to load images */ 55 | } XcursorImages; 56 | 57 | void 58 | XcursorImagesDestroy (XcursorImages *images); 59 | 60 | void 61 | xcursor_load_theme(const char *theme, int size, 62 | void (*load_callback)(XcursorImages *, void *), 63 | void *user_data); 64 | #endif 65 | -------------------------------------------------------------------------------- /include/xwayland/meson.build: -------------------------------------------------------------------------------- 1 | xwayland_feature_names = [ 2 | 'listenfd', 3 | 'no_touch_pointer_emulation', 4 | 'force_xrandr_emulation', 5 | 'terminate_delay', 6 | ] 7 | 8 | xwayland_features = {} 9 | if xwayland.found() 10 | xwayland_path = xwayland.get_variable('xwayland') 11 | foreach name : xwayland_feature_names 12 | have = xwayland.get_variable('have_' + name, default_value: 'false') == 'true' 13 | xwayland_features += { name: have } 14 | endforeach 15 | else 16 | xwayland_path = xwayland_prog.full_path() 17 | foreach name : xwayland_feature_names 18 | xwayland_features += { name: false } 19 | endforeach 20 | endif 21 | 22 | xwayland_config_data = configuration_data() 23 | xwayland_config_data.set_quoted('XWAYLAND_PATH', xwayland_path) 24 | foreach name, have : xwayland_features 25 | xwayland_config_data.set10('HAVE_XWAYLAND_' + name.to_upper(), have) 26 | endforeach 27 | configure_file( 28 | output: 'config.h', 29 | configuration: xwayland_config_data, 30 | ) 31 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('xcb-errors', type: 'feature', value: 'auto', description: 'Use xcb-errors util library') 2 | option('xwayland', type: 'feature', value: 'auto', yield: true, description: 'Enable support for X11 applications') 3 | option('examples', type: 'boolean', value: true, description: 'Build example applications') 4 | option('icon_directory', description: 'Location used to look for cursors (default: ${datadir}/icons)', type: 'string', value: '') 5 | option('renderers', type: 'array', choices: ['auto', 'gles2', 'vulkan'], value: ['auto'], description: 'Select built-in renderers') 6 | option('backends', type: 'array', choices: ['auto', 'drm', 'libinput', 'x11'], value: ['auto'], description: 'Select built-in backends') 7 | option('allocators', type: 'array', choices: ['auto', 'gbm'], value: ['auto'], 8 | description: 'Select built-in allocators') 9 | -------------------------------------------------------------------------------- /protocol/idle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | . 18 | ]]> 19 | 20 | 21 | This interface allows to monitor user idle time on a given seat. The interface 22 | allows to register timers which trigger after no user activity was registered 23 | on the seat for a given interval. It notifies when user activity resumes. 24 | 25 | This is useful for applications wanting to perform actions when the user is not 26 | interacting with the system, e.g. chat applications setting the user as away, power 27 | management features to dim screen, etc.. 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /render/allocator/meson.build: -------------------------------------------------------------------------------- 1 | allocators = get_option('allocators') 2 | if 'auto' in allocators and get_option('auto_features').enabled() 3 | allocators = ['gbm'] 4 | elif 'auto' in allocators and get_option('auto_features').disabled() 5 | allocators = [] 6 | endif 7 | 8 | wlr_files += files( 9 | 'allocator.c', 10 | 'shm.c', 11 | 'drm_dumb.c', 12 | ) 13 | 14 | gbm = disabler() 15 | if 'gbm' in allocators or 'auto' in allocators 16 | gbm = dependency('gbm', version: '>=17.1.0', required: 'gbm' in allocators) 17 | endif 18 | if gbm.found() 19 | wlr_files += files('gbm.c') 20 | wlr_deps += gbm 21 | features += { 'gbm-allocator': true } 22 | 23 | has = cc.has_function('gbm_bo_get_fd_for_plane', dependencies: [gbm]) 24 | add_project_arguments('-DHAS_GBM_BO_GET_FD_FOR_PLANE=@0@'.format(has.to_int()), language: 'c') 25 | endif 26 | -------------------------------------------------------------------------------- /render/dmabuf.c: -------------------------------------------------------------------------------- 1 | #define _POSIX_C_SOURCE 200809L 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | void wlr_dmabuf_attributes_finish(struct wlr_dmabuf_attributes *attribs) { 8 | for (int i = 0; i < attribs->n_planes; ++i) { 9 | close(attribs->fd[i]); 10 | attribs->fd[i] = -1; 11 | } 12 | attribs->n_planes = 0; 13 | } 14 | 15 | bool wlr_dmabuf_attributes_copy(struct wlr_dmabuf_attributes *dst, 16 | const struct wlr_dmabuf_attributes *src) { 17 | memcpy(dst, src, sizeof(struct wlr_dmabuf_attributes)); 18 | 19 | int i; 20 | for (i = 0; i < src->n_planes; ++i) { 21 | dst->fd[i] = fcntl(src->fd[i], F_DUPFD_CLOEXEC, 0); 22 | if (dst->fd[i] < 0) { 23 | wlr_log_errno(WLR_ERROR, "fcntl(F_DUPFD_CLOEXEC) failed"); 24 | goto error; 25 | } 26 | } 27 | 28 | return true; 29 | 30 | error: 31 | for (int j = 0; j < i; j++) { 32 | close(dst->fd[j]); 33 | dst->fd[j] = -1; 34 | } 35 | dst->n_planes = 0; 36 | return false; 37 | } 38 | -------------------------------------------------------------------------------- /render/gles2/meson.build: -------------------------------------------------------------------------------- 1 | glesv2 = dependency('glesv2', required: 'gles2' in renderers) 2 | 3 | if not (glesv2.found() and internal_features['egl']) 4 | subdir_done() 5 | endif 6 | 7 | features += { 'gles2-renderer': true } 8 | wlr_deps += glesv2 9 | 10 | wlr_files += files( 11 | 'pixel_format.c', 12 | 'renderer.c', 13 | 'shaders.c', 14 | 'texture.c', 15 | ) 16 | -------------------------------------------------------------------------------- /render/gles2/shaders.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "render/gles2.h" 3 | 4 | // Colored quads 5 | const GLchar quad_vertex_src[] = 6 | "uniform mat3 proj;\n" 7 | "uniform vec4 color;\n" 8 | "attribute vec2 pos;\n" 9 | "attribute vec2 texcoord;\n" 10 | "varying vec4 v_color;\n" 11 | "varying vec2 v_texcoord;\n" 12 | "\n" 13 | "void main() {\n" 14 | " gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n" 15 | " v_color = color;\n" 16 | " v_texcoord = texcoord;\n" 17 | "}\n"; 18 | 19 | const GLchar quad_fragment_src[] = 20 | "precision mediump float;\n" 21 | "varying vec4 v_color;\n" 22 | "varying vec2 v_texcoord;\n" 23 | "\n" 24 | "void main() {\n" 25 | " gl_FragColor = v_color;\n" 26 | "}\n"; 27 | 28 | // Textured quads 29 | const GLchar tex_vertex_src[] = 30 | "uniform mat3 proj;\n" 31 | "attribute vec2 pos;\n" 32 | "attribute vec2 texcoord;\n" 33 | "varying vec2 v_texcoord;\n" 34 | "\n" 35 | "void main() {\n" 36 | " gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n" 37 | " v_texcoord = texcoord;\n" 38 | "}\n"; 39 | 40 | const GLchar tex_vertex_invert_y_src[] = 41 | "uniform mat3 proj;\n" 42 | "attribute vec2 pos;\n" 43 | "attribute vec2 texcoord;\n" 44 | "varying vec2 v_texcoord;\n" 45 | "\n" 46 | "void main() {\n" 47 | " gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n" 48 | " v_texcoord = vec2(texcoord.x, 1.0 - texcoord.y);\n" 49 | "}\n"; 50 | 51 | const GLchar tex_fragment_src_rgba[] = 52 | "precision mediump float;\n" 53 | "varying vec2 v_texcoord;\n" 54 | "uniform sampler2D tex;\n" 55 | "uniform float alpha;\n" 56 | "\n" 57 | "void main() {\n" 58 | " gl_FragColor = texture2D(tex, v_texcoord) * alpha;\n" 59 | "}\n"; 60 | 61 | const GLchar tex_fragment_src_rgbx[] = 62 | "precision mediump float;\n" 63 | "varying vec2 v_texcoord;\n" 64 | "uniform sampler2D tex;\n" 65 | "uniform float alpha;\n" 66 | "\n" 67 | "void main() {\n" 68 | " gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n" 69 | "}\n"; 70 | 71 | const GLchar tex_fragment_src_external[] = 72 | "#extension GL_OES_EGL_image_external : require\n\n" 73 | "precision mediump float;\n" 74 | "varying vec2 v_texcoord;\n" 75 | "uniform samplerExternalOES texture0;\n" 76 | "uniform float alpha;\n" 77 | "\n" 78 | "void main() {\n" 79 | " gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\n" 80 | "}\n"; 81 | -------------------------------------------------------------------------------- /render/meson.build: -------------------------------------------------------------------------------- 1 | renderers = get_option('renderers') 2 | if 'auto' in renderers and get_option('auto_features').enabled() 3 | renderers = ['gles2', 'vulkan'] 4 | elif 'auto' in renderers and get_option('auto_features').disabled() 5 | renderers = [] 6 | endif 7 | 8 | if 'gles2' not in renderers 9 | renderers += 'gles2' 10 | endif 11 | 12 | wlr_files += files( 13 | 'dmabuf.c', 14 | 'drm_format_set.c', 15 | 'pixel_format.c', 16 | 'swapchain.c', 17 | 'wlr_renderer.c', 18 | 'wlr_texture.c', 19 | 'eglstreams_allocator.c', 20 | ) 21 | 22 | if 'gles2' in renderers or 'auto' in renderers 23 | egl = dependency('egl', required: 'gles2' in renderers) 24 | gbm = dependency('gbm', required: 'gles2' in renderers) 25 | if egl.found() and gbm.found() 26 | wlr_deps += [egl, gbm] 27 | wlr_files += files('egl.c') 28 | internal_features += { 'egl': true } 29 | endif 30 | subdir('gles2') 31 | endif 32 | 33 | if 'vulkan' in renderers or 'auto' in renderers 34 | subdir('vulkan') 35 | endif 36 | 37 | subdir('pixman') 38 | 39 | subdir('allocator') 40 | -------------------------------------------------------------------------------- /render/pixman/meson.build: -------------------------------------------------------------------------------- 1 | pixman = dependency('pixman-1') 2 | 3 | wlr_deps += pixman 4 | 5 | wlr_files += files( 6 | 'pixel_format.c', 7 | 'renderer.c', 8 | ) 9 | -------------------------------------------------------------------------------- /render/vulkan/meson.build: -------------------------------------------------------------------------------- 1 | msg = [] 2 | if 'vulkan' in renderers 3 | msg += 'Install "@0@" or pass "-Dvulkan=disabled" to disable it.' 4 | else 5 | msg += 'Required for vulkan renderer support.' 6 | endif 7 | 8 | dep_vulkan = dependency('vulkan', 9 | version: '>=1.2.182', 10 | required: 'vulkan' in renderers, 11 | not_found_message: '\n'.join(msg).format('vulkan') 12 | ) 13 | if not dep_vulkan.found() 14 | subdir_done() 15 | endif 16 | 17 | # Vulkan headers are installed separately from the loader (which ships the 18 | # pkg-config file) 19 | if not cc.check_header('vulkan/vulkan.h', dependencies: dep_vulkan) 20 | if 'vulkan' in renderers 21 | error('\n'.join(msg).format('vulkan-headers')) 22 | else 23 | subdir_done() 24 | endif 25 | endif 26 | 27 | glslang = find_program('glslangValidator', native: true, required: false) 28 | if not glslang.found() 29 | if 'vulkan' in renderers 30 | error('\n'.join(msg).format('glslang')) 31 | else 32 | subdir_done() 33 | endif 34 | endif 35 | 36 | glslang_version_info = run_command(glslang, '--version', check: true).stdout() 37 | glslang_version = glslang_version_info.split('\n')[0].split(':')[-1] 38 | 39 | wlr_files += files( 40 | 'renderer.c', 41 | 'texture.c', 42 | 'vulkan.c', 43 | 'util.c', 44 | 'pixel_format.c', 45 | ) 46 | 47 | wlr_deps += dep_vulkan 48 | features += { 'vulkan-renderer': true } 49 | 50 | subdir('shaders') 51 | -------------------------------------------------------------------------------- /render/vulkan/shaders/common.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | // we use a mat4 since it uses the same size as mat3 due to 4 | // alignment. Easier to deal with (tighly-packed) mat4 though. 5 | layout(push_constant, row_major) uniform UBO { 6 | mat4 proj; 7 | vec2 uv_offset; 8 | vec2 uv_size; 9 | } data; 10 | 11 | layout(location = 0) out vec2 uv; 12 | 13 | void main() { 14 | vec2 pos = vec2(float((gl_VertexIndex + 1) & 2) * 0.5f, 15 | float(gl_VertexIndex & 2) * 0.5f); 16 | uv = data.uv_offset + pos * data.uv_size; 17 | gl_Position = data.proj * vec4(pos, 0.0, 1.0); 18 | } 19 | -------------------------------------------------------------------------------- /render/vulkan/shaders/meson.build: -------------------------------------------------------------------------------- 1 | vulkan_shaders_src = [ 2 | 'common.vert', 3 | 'texture.frag', 4 | 'quad.frag', 5 | ] 6 | 7 | vulkan_shaders = [] 8 | foreach shader : vulkan_shaders_src 9 | name = shader.underscorify() + '_data' 10 | args = [glslang, '-V', '@INPUT@', '-o', '@OUTPUT@', '--vn', name] 11 | if glslang_version.version_compare('>=11.0.0') 12 | args += '--quiet' 13 | endif 14 | header = custom_target( 15 | shader + '_spv', 16 | output: shader + '.h', 17 | input: shader, 18 | command: args) 19 | 20 | vulkan_shaders += [header] 21 | endforeach 22 | 23 | wlr_files += vulkan_shaders 24 | -------------------------------------------------------------------------------- /render/vulkan/shaders/quad.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) out vec4 out_color; 4 | layout(push_constant) uniform UBO { 5 | layout(offset = 80) vec4 color; 6 | } data; 7 | 8 | void main() { 9 | out_color = data.color; 10 | } 11 | -------------------------------------------------------------------------------- /render/vulkan/shaders/texture.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(set = 0, binding = 0) uniform sampler2D tex; 4 | 5 | layout(location = 0) in vec2 uv; 6 | layout(location = 0) out vec4 out_color; 7 | 8 | layout(push_constant) uniform UBO { 9 | layout(offset = 80) float alpha; 10 | } data; 11 | 12 | void main() { 13 | out_color = textureLod(tex, uv, 0); 14 | out_color *= data.alpha; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /tinywl/.gitignore: -------------------------------------------------------------------------------- 1 | tinywl 2 | *-protocol.c 3 | *-protocol.h 4 | -------------------------------------------------------------------------------- /tinywl/Makefile: -------------------------------------------------------------------------------- 1 | WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols) 2 | WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner) 3 | LIBS=\ 4 | $(shell pkg-config --cflags --libs wlroots) \ 5 | $(shell pkg-config --cflags --libs wayland-server) \ 6 | $(shell pkg-config --cflags --libs xkbcommon) 7 | 8 | # wayland-scanner is a tool which generates C headers and rigging for Wayland 9 | # protocols, which are specified in XML. wlroots requires you to rig these up 10 | # to your build system yourself and provide them in the include path. 11 | xdg-shell-protocol.h: 12 | $(WAYLAND_SCANNER) server-header \ 13 | $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ 14 | 15 | tinywl: tinywl.c xdg-shell-protocol.h 16 | $(CC) $(CFLAGS) \ 17 | -g -Werror -I. \ 18 | -DWLR_USE_UNSTABLE \ 19 | -o $@ $< \ 20 | $(LIBS) 21 | 22 | clean: 23 | rm -f tinywl xdg-shell-protocol.h xdg-shell-protocol.c 24 | 25 | .DEFAULT_GOAL=tinywl 26 | .PHONY: clean 27 | -------------------------------------------------------------------------------- /tinywl/README.md: -------------------------------------------------------------------------------- 1 | # TinyWL 2 | 3 | This is the "minimum viable product" Wayland compositor based on wlroots. It 4 | aims to implement a Wayland compositor in the fewest lines of code possible, 5 | while still supporting a reasonable set of features. Reading this code is the 6 | best starting point for anyone looking to build their own Wayland compositor 7 | based on wlroots. 8 | 9 | ## Building TinyWL 10 | 11 | TinyWL is disconnected from the main wlroots build system, in order to make it 12 | easier to understand the build requirements for your own Wayland compositors. 13 | Simply install the dependencies: 14 | 15 | - wlroots 16 | - wayland-protocols 17 | 18 | And run `make`. 19 | 20 | ## Running TinyWL 21 | 22 | You can run TinyWL with `./tinywl`. In an existing Wayland or X11 session, 23 | tinywl will open a Wayland or X11 window respectively to act as a virtual 24 | display. You can then open Wayland windows by setting `WAYLAND_DISPLAY` to the 25 | value shown in the logs. You can also run `./tinywl` from a TTY. 26 | 27 | In either case, you will likely want to specify `-s [cmd]` to run a command at 28 | startup, such as a terminal emulator. This will be necessary to start any new 29 | programs from within the compositor, as TinyWL does not support any custom 30 | keybindings. TinyWL supports the following keybindings: 31 | 32 | - `Alt+Escape`: Terminate the compositor 33 | - `Alt+F1`: Cycle between windows 34 | 35 | ## Limitations 36 | 37 | Notable omissions from TinyWL: 38 | 39 | - HiDPI support 40 | - Any kind of configuration, e.g. output layout 41 | - Any protocol other than xdg-shell (e.g. layer-shell, for 42 | panels/taskbars/etc; or Xwayland, for proxied X11 windows) 43 | - Optional protocols, e.g. screen capture, primary selection, virtual 44 | keyboard, etc. Most of these are plug-and-play with wlroots, but they're 45 | omitted for brevity. 46 | -------------------------------------------------------------------------------- /tinywl/meson.build: -------------------------------------------------------------------------------- 1 | executable( 2 | 'tinywl', 3 | ['tinywl.c', protocols_client_header['xdg-shell']], 4 | dependencies: wlroots, 5 | ) 6 | -------------------------------------------------------------------------------- /types/meson.build: -------------------------------------------------------------------------------- 1 | wlr_files += files( 2 | 'data_device/wlr_data_device.c', 3 | 'data_device/wlr_data_offer.c', 4 | 'data_device/wlr_data_source.c', 5 | 'data_device/wlr_drag.c', 6 | 'output/cursor.c', 7 | 'output/output.c', 8 | 'output/render.c', 9 | 'output/state.c', 10 | 'output/transform.c', 11 | 'scene/subsurface_tree.c', 12 | 'scene/surface.c', 13 | 'scene/wlr_scene.c', 14 | 'scene/output_layout.c', 15 | 'scene/xdg_shell.c', 16 | 'scene/layer_shell_v1.c', 17 | 'seat/wlr_seat_keyboard.c', 18 | 'seat/wlr_seat_pointer.c', 19 | 'seat/wlr_seat_touch.c', 20 | 'seat/wlr_seat.c', 21 | 'tablet_v2/wlr_tablet_v2_pad.c', 22 | 'tablet_v2/wlr_tablet_v2_tablet.c', 23 | 'tablet_v2/wlr_tablet_v2_tool.c', 24 | 'tablet_v2/wlr_tablet_v2.c', 25 | 'xdg_shell/wlr_xdg_popup.c', 26 | 'xdg_shell/wlr_xdg_positioner.c', 27 | 'xdg_shell/wlr_xdg_shell.c', 28 | 'xdg_shell/wlr_xdg_surface.c', 29 | 'xdg_shell/wlr_xdg_toplevel.c', 30 | 'wlr_buffer.c', 31 | 'wlr_compositor.c', 32 | 'wlr_cursor.c', 33 | 'wlr_damage_ring.c', 34 | 'wlr_data_control_v1.c', 35 | 'wlr_drm.c', 36 | 'wlr_export_dmabuf_v1.c', 37 | 'wlr_foreign_toplevel_management_v1.c', 38 | 'wlr_fullscreen_shell_v1.c', 39 | 'wlr_gamma_control_v1.c', 40 | 'wlr_idle_inhibit_v1.c', 41 | 'wlr_idle.c', 42 | 'wlr_input_device.c', 43 | 'wlr_input_inhibitor.c', 44 | 'wlr_input_method_v2.c', 45 | 'wlr_keyboard.c', 46 | 'wlr_keyboard_group.c', 47 | 'wlr_keyboard_shortcuts_inhibit_v1.c', 48 | 'wlr_layer_shell_v1.c', 49 | 'wlr_linux_dmabuf_v1.c', 50 | 'wlr_matrix.c', 51 | 'wlr_output_damage.c', 52 | 'wlr_output_layout.c', 53 | 'wlr_output_management_v1.c', 54 | 'wlr_output_power_management_v1.c', 55 | 'wlr_pointer_constraints_v1.c', 56 | 'wlr_pointer_gestures_v1.c', 57 | 'wlr_pointer.c', 58 | 'wlr_presentation_time.c', 59 | 'wlr_primary_selection_v1.c', 60 | 'wlr_primary_selection.c', 61 | 'wlr_region.c', 62 | 'wlr_relative_pointer_v1.c', 63 | 'wlr_screencopy_v1.c', 64 | 'wlr_server_decoration.c', 65 | 'wlr_session_lock_v1.c', 66 | 'wlr_single_pixel_buffer_v1.c', 67 | 'wlr_subcompositor.c', 68 | 'wlr_switch.c', 69 | 'wlr_tablet_pad.c', 70 | 'wlr_tablet_tool.c', 71 | 'wlr_text_input_v3.c', 72 | 'wlr_touch.c', 73 | 'wlr_viewporter.c', 74 | 'wlr_virtual_keyboard_v1.c', 75 | 'wlr_virtual_pointer_v1.c', 76 | 'wlr_xcursor_manager.c', 77 | 'wlr_xdg_activation_v1.c', 78 | 'wlr_xdg_decoration_v1.c', 79 | 'wlr_xdg_foreign_v1.c', 80 | 'wlr_xdg_foreign_v2.c', 81 | 'wlr_xdg_foreign_registry.c', 82 | 'wlr_xdg_output_v1.c', 83 | ) 84 | 85 | if features.get('drm-backend') 86 | wlr_files += files( 87 | 'wlr_drm_lease_v1.c', 88 | ) 89 | endif 90 | -------------------------------------------------------------------------------- /types/output/state.c: -------------------------------------------------------------------------------- 1 | #include "types/wlr_output.h" 2 | 3 | void wlr_output_state_set_enabled(struct wlr_output_state *state, 4 | bool enabled) { 5 | state->committed |= WLR_OUTPUT_STATE_ENABLED; 6 | state->enabled = enabled; 7 | } 8 | 9 | void wlr_output_state_set_mode(struct wlr_output_state *state, 10 | struct wlr_output_mode *mode) { 11 | state->committed |= WLR_OUTPUT_STATE_MODE; 12 | state->mode_type = WLR_OUTPUT_STATE_MODE_FIXED; 13 | state->mode = mode; 14 | } 15 | 16 | void wlr_output_state_set_custom_mode(struct wlr_output_state *state, 17 | int32_t width, int32_t height, int32_t refresh) { 18 | state->committed |= WLR_OUTPUT_STATE_MODE; 19 | state->mode_type = WLR_OUTPUT_STATE_MODE_CUSTOM; 20 | state->custom_mode.width = width; 21 | state->custom_mode.height = height; 22 | state->custom_mode.refresh = refresh; 23 | } 24 | 25 | void wlr_output_state_set_scale(struct wlr_output_state *state, float scale) { 26 | state->committed |= WLR_OUTPUT_STATE_SCALE; 27 | state->scale = scale; 28 | } 29 | 30 | void wlr_output_state_set_transform(struct wlr_output_state *state, 31 | enum wl_output_transform transform) { 32 | state->committed |= WLR_OUTPUT_STATE_TRANSFORM; 33 | state->transform = transform; 34 | } 35 | 36 | void wlr_output_state_set_adaptive_sync_enabled(struct wlr_output_state *state, 37 | bool enabled) { 38 | state->committed |= WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED; 39 | state->adaptive_sync_enabled = enabled; 40 | } 41 | 42 | void wlr_output_state_set_render_format(struct wlr_output_state *state, 43 | uint32_t format) { 44 | state->committed |= WLR_OUTPUT_STATE_RENDER_FORMAT; 45 | state->render_format = format; 46 | } 47 | 48 | void wlr_output_state_set_subpixel(struct wlr_output_state *state, 49 | enum wl_output_subpixel subpixel) { 50 | state->committed |= WLR_OUTPUT_STATE_SUBPIXEL; 51 | state->subpixel = subpixel; 52 | } 53 | -------------------------------------------------------------------------------- /types/output/transform.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | enum wl_output_transform wlr_output_transform_invert( 4 | enum wl_output_transform tr) { 5 | if ((tr & WL_OUTPUT_TRANSFORM_90) && !(tr & WL_OUTPUT_TRANSFORM_FLIPPED)) { 6 | tr ^= WL_OUTPUT_TRANSFORM_180; 7 | } 8 | return tr; 9 | } 10 | 11 | enum wl_output_transform wlr_output_transform_compose( 12 | enum wl_output_transform tr_a, enum wl_output_transform tr_b) { 13 | uint32_t flipped = (tr_a ^ tr_b) & WL_OUTPUT_TRANSFORM_FLIPPED; 14 | uint32_t rotation_mask = WL_OUTPUT_TRANSFORM_90 | WL_OUTPUT_TRANSFORM_180; 15 | uint32_t rotated; 16 | if (tr_b & WL_OUTPUT_TRANSFORM_FLIPPED) { 17 | // When a rotation of k degrees is followed by a flip, the 18 | // equivalent transform is a flip followed by a rotation of 19 | // -k degrees. 20 | rotated = (tr_b - tr_a) & rotation_mask; 21 | } else { 22 | rotated = (tr_a + tr_b) & rotation_mask; 23 | } 24 | return flipped | rotated; 25 | } 26 | -------------------------------------------------------------------------------- /types/wlr_input_device.c: -------------------------------------------------------------------------------- 1 | #define _POSIX_C_SOURCE 200809L 2 | 3 | #include 4 | #include 5 | #include "interfaces/wlr_input_device.h" 6 | #include "util/signal.h" 7 | 8 | void wlr_input_device_init(struct wlr_input_device *dev, 9 | enum wlr_input_device_type type, const char *name) { 10 | memset(dev, 0, sizeof(*dev)); 11 | dev->type = type; 12 | dev->name = strdup(name); 13 | dev->vendor = 0; 14 | dev->product = 0; 15 | 16 | wl_signal_init(&dev->events.destroy); 17 | } 18 | 19 | void wlr_input_device_finish(struct wlr_input_device *wlr_device) { 20 | if (!wlr_device) { 21 | return; 22 | } 23 | 24 | wlr_signal_emit_safe(&wlr_device->events.destroy, wlr_device); 25 | 26 | wl_list_remove(&wlr_device->events.destroy.listener_list); 27 | 28 | free(wlr_device->name); 29 | } 30 | -------------------------------------------------------------------------------- /types/wlr_pointer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "interfaces/wlr_input_device.h" 9 | 10 | struct wlr_pointer *wlr_pointer_from_input_device( 11 | struct wlr_input_device *input_device) { 12 | assert(input_device->type == WLR_INPUT_DEVICE_POINTER); 13 | return wl_container_of(input_device, (struct wlr_pointer *)NULL, base); 14 | } 15 | 16 | void wlr_pointer_init(struct wlr_pointer *pointer, 17 | const struct wlr_pointer_impl *impl, const char *name) { 18 | memset(pointer, 0, sizeof(*pointer)); 19 | wlr_input_device_init(&pointer->base, WLR_INPUT_DEVICE_POINTER, name); 20 | 21 | pointer->impl = impl; 22 | wl_signal_init(&pointer->events.motion); 23 | wl_signal_init(&pointer->events.motion_absolute); 24 | wl_signal_init(&pointer->events.button); 25 | wl_signal_init(&pointer->events.axis); 26 | wl_signal_init(&pointer->events.frame); 27 | wl_signal_init(&pointer->events.swipe_begin); 28 | wl_signal_init(&pointer->events.swipe_update); 29 | wl_signal_init(&pointer->events.swipe_end); 30 | wl_signal_init(&pointer->events.pinch_begin); 31 | wl_signal_init(&pointer->events.pinch_update); 32 | wl_signal_init(&pointer->events.pinch_end); 33 | wl_signal_init(&pointer->events.hold_begin); 34 | wl_signal_init(&pointer->events.hold_end); 35 | } 36 | 37 | void wlr_pointer_finish(struct wlr_pointer *pointer) { 38 | wlr_input_device_finish(&pointer->base); 39 | 40 | free(pointer->output_name); 41 | } 42 | -------------------------------------------------------------------------------- /types/wlr_region.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "types/wlr_region.h" 8 | 9 | static void region_add(struct wl_client *client, struct wl_resource *resource, 10 | int32_t x, int32_t y, int32_t width, int32_t height) { 11 | pixman_region32_t *region = wlr_region_from_resource(resource); 12 | pixman_region32_union_rect(region, region, x, y, width, height); 13 | } 14 | 15 | static void region_subtract(struct wl_client *client, struct wl_resource *resource, 16 | int32_t x, int32_t y, int32_t width, int32_t height) { 17 | pixman_region32_t *region = wlr_region_from_resource(resource); 18 | pixman_region32_union_rect(region, region, x, y, width, height); 19 | 20 | pixman_region32_t rect; 21 | pixman_region32_init_rect(&rect, x, y, width, height); 22 | pixman_region32_subtract(region, region, &rect); 23 | pixman_region32_fini(&rect); 24 | } 25 | 26 | static void region_destroy(struct wl_client *client, struct wl_resource *resource) { 27 | wl_resource_destroy(resource); 28 | } 29 | 30 | static const struct wl_region_interface region_impl = { 31 | .destroy = region_destroy, 32 | .add = region_add, 33 | .subtract = region_subtract, 34 | }; 35 | 36 | static void region_handle_resource_destroy(struct wl_resource *resource) { 37 | pixman_region32_t *reg = wlr_region_from_resource(resource); 38 | pixman_region32_fini(reg); 39 | free(reg); 40 | } 41 | 42 | struct wl_resource *region_create(struct wl_client *client, 43 | uint32_t version, uint32_t id) { 44 | pixman_region32_t *region = calloc(1, sizeof(pixman_region32_t)); 45 | if (region == NULL) { 46 | wl_client_post_no_memory(client); 47 | return NULL; 48 | } 49 | 50 | pixman_region32_init(region); 51 | 52 | struct wl_resource *region_resource = wl_resource_create(client, 53 | &wl_region_interface, version, id); 54 | if (region_resource == NULL) { 55 | free(region); 56 | wl_client_post_no_memory(client); 57 | return NULL; 58 | } 59 | wl_resource_set_implementation(region_resource, ®ion_impl, region, 60 | region_handle_resource_destroy); 61 | 62 | return region_resource; 63 | } 64 | 65 | pixman_region32_t *wlr_region_from_resource(struct wl_resource *resource) { 66 | assert(wl_resource_instance_of(resource, &wl_region_interface, 67 | ®ion_impl)); 68 | return wl_resource_get_user_data(resource); 69 | } 70 | -------------------------------------------------------------------------------- /types/wlr_switch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "interfaces/wlr_input_device.h" 9 | 10 | struct wlr_switch *wlr_switch_from_input_device( 11 | struct wlr_input_device *input_device) { 12 | assert(input_device->type == WLR_INPUT_DEVICE_SWITCH); 13 | return wl_container_of(input_device, (struct wlr_switch *)NULL, base); 14 | } 15 | 16 | void wlr_switch_init(struct wlr_switch *switch_device, 17 | const struct wlr_switch_impl *impl, const char *name) { 18 | memset(switch_device, 0, sizeof(*switch_device)); 19 | wlr_input_device_init(&switch_device->base, WLR_INPUT_DEVICE_SWITCH, name); 20 | 21 | switch_device->impl = impl; 22 | wl_signal_init(&switch_device->events.toggle); 23 | } 24 | 25 | void wlr_switch_finish(struct wlr_switch *switch_device) { 26 | wlr_input_device_finish(&switch_device->base); 27 | } 28 | -------------------------------------------------------------------------------- /types/wlr_tablet_pad.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "interfaces/wlr_input_device.h" 10 | 11 | struct wlr_tablet_pad *wlr_tablet_pad_from_input_device( 12 | struct wlr_input_device *input_device) { 13 | assert(input_device->type == WLR_INPUT_DEVICE_TABLET_PAD); 14 | return wl_container_of(input_device, (struct wlr_tablet_pad *)NULL, base); 15 | } 16 | 17 | void wlr_tablet_pad_init(struct wlr_tablet_pad *pad, 18 | const struct wlr_tablet_pad_impl *impl, const char *name) { 19 | memset(pad, 0, sizeof(*pad)); 20 | wlr_input_device_init(&pad->base, WLR_INPUT_DEVICE_TABLET_PAD, name); 21 | 22 | pad->impl = impl; 23 | wl_signal_init(&pad->events.button); 24 | wl_signal_init(&pad->events.ring); 25 | wl_signal_init(&pad->events.strip); 26 | wl_signal_init(&pad->events.attach_tablet); 27 | 28 | wl_list_init(&pad->groups); 29 | wl_array_init(&pad->paths); 30 | } 31 | 32 | void wlr_tablet_pad_finish(struct wlr_tablet_pad *pad) { 33 | wlr_input_device_finish(&pad->base); 34 | 35 | char **path_ptr; 36 | wl_array_for_each(path_ptr, &pad->paths) { 37 | free(*path_ptr); 38 | } 39 | wl_array_release(&pad->paths); 40 | 41 | /* TODO: wlr_tablet_pad should own its wlr_tablet_pad_group */ 42 | if (!wl_list_empty(&pad->groups)) { 43 | wlr_log(WLR_ERROR, "wlr_tablet_pad groups is not empty"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /types/wlr_tablet_tool.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "interfaces/wlr_input_device.h" 9 | 10 | struct wlr_tablet *wlr_tablet_from_input_device( 11 | struct wlr_input_device *input_device) { 12 | assert(input_device->type == WLR_INPUT_DEVICE_TABLET_TOOL); 13 | return wl_container_of(input_device, (struct wlr_tablet *)NULL, base); 14 | } 15 | 16 | void wlr_tablet_init(struct wlr_tablet *tablet, 17 | const struct wlr_tablet_impl *impl, const char *name) { 18 | memset(tablet, 0, sizeof(*tablet)); 19 | wlr_input_device_init(&tablet->base, WLR_INPUT_DEVICE_TABLET_TOOL, name); 20 | 21 | tablet->impl = impl; 22 | wl_signal_init(&tablet->events.axis); 23 | wl_signal_init(&tablet->events.proximity); 24 | wl_signal_init(&tablet->events.tip); 25 | wl_signal_init(&tablet->events.button); 26 | wl_array_init(&tablet->paths); 27 | } 28 | 29 | void wlr_tablet_finish(struct wlr_tablet *tablet) { 30 | wlr_input_device_finish(&tablet->base); 31 | 32 | char **path_ptr; 33 | wl_array_for_each(path_ptr, &tablet->paths) { 34 | free(*path_ptr); 35 | } 36 | wl_array_release(&tablet->paths); 37 | } 38 | -------------------------------------------------------------------------------- /types/wlr_touch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "interfaces/wlr_input_device.h" 9 | 10 | struct wlr_touch *wlr_touch_from_input_device( 11 | struct wlr_input_device *input_device) { 12 | assert(input_device->type == WLR_INPUT_DEVICE_TOUCH); 13 | return wl_container_of(input_device, (struct wlr_touch *)NULL, base); 14 | } 15 | 16 | void wlr_touch_init(struct wlr_touch *touch, 17 | const struct wlr_touch_impl *impl, const char *name) { 18 | memset(touch, 0, sizeof(*touch)); 19 | wlr_input_device_init(&touch->base, WLR_INPUT_DEVICE_TOUCH, name); 20 | 21 | touch->impl = impl; 22 | wl_signal_init(&touch->events.down); 23 | wl_signal_init(&touch->events.up); 24 | wl_signal_init(&touch->events.motion); 25 | wl_signal_init(&touch->events.cancel); 26 | wl_signal_init(&touch->events.frame); 27 | } 28 | 29 | void wlr_touch_finish(struct wlr_touch *touch) { 30 | wlr_input_device_finish(&touch->base); 31 | 32 | free(touch->output_name); 33 | } 34 | -------------------------------------------------------------------------------- /types/wlr_xcursor_manager.c: -------------------------------------------------------------------------------- 1 | #define _POSIX_C_SOURCE 200809L 2 | #include 3 | #include 4 | #include 5 | 6 | struct wlr_xcursor_manager *wlr_xcursor_manager_create(const char *name, 7 | uint32_t size) { 8 | struct wlr_xcursor_manager *manager = 9 | calloc(1, sizeof(struct wlr_xcursor_manager)); 10 | if (manager == NULL) { 11 | return NULL; 12 | } 13 | if (name != NULL) { 14 | manager->name = strdup(name); 15 | } 16 | manager->size = size; 17 | wl_list_init(&manager->scaled_themes); 18 | return manager; 19 | } 20 | 21 | void wlr_xcursor_manager_destroy(struct wlr_xcursor_manager *manager) { 22 | if (manager == NULL) { 23 | return; 24 | } 25 | struct wlr_xcursor_manager_theme *theme, *tmp; 26 | wl_list_for_each_safe(theme, tmp, &manager->scaled_themes, link) { 27 | wl_list_remove(&theme->link); 28 | wlr_xcursor_theme_destroy(theme->theme); 29 | free(theme); 30 | } 31 | free(manager->name); 32 | free(manager); 33 | } 34 | 35 | bool wlr_xcursor_manager_load(struct wlr_xcursor_manager *manager, 36 | float scale) { 37 | struct wlr_xcursor_manager_theme *theme; 38 | wl_list_for_each(theme, &manager->scaled_themes, link) { 39 | if (theme->scale == scale) { 40 | return true; 41 | } 42 | } 43 | 44 | theme = calloc(1, sizeof(struct wlr_xcursor_manager_theme)); 45 | if (theme == NULL) { 46 | return false; 47 | } 48 | theme->scale = scale; 49 | theme->theme = wlr_xcursor_theme_load(manager->name, manager->size * scale); 50 | if (theme->theme == NULL) { 51 | free(theme); 52 | return false; 53 | } 54 | wl_list_insert(&manager->scaled_themes, &theme->link); 55 | return true; 56 | } 57 | 58 | struct wlr_xcursor *wlr_xcursor_manager_get_xcursor( 59 | struct wlr_xcursor_manager *manager, const char *name, float scale) { 60 | struct wlr_xcursor_manager_theme *theme; 61 | wl_list_for_each(theme, &manager->scaled_themes, link) { 62 | if (theme->scale == scale) { 63 | return wlr_xcursor_theme_get_cursor(theme->theme, name); 64 | } 65 | } 66 | return NULL; 67 | } 68 | 69 | void wlr_xcursor_manager_set_cursor_image(struct wlr_xcursor_manager *manager, 70 | const char *name, struct wlr_cursor *cursor) { 71 | struct wlr_xcursor_manager_theme *theme; 72 | wl_list_for_each(theme, &manager->scaled_themes, link) { 73 | struct wlr_xcursor *xcursor = 74 | wlr_xcursor_theme_get_cursor(theme->theme, name); 75 | if (xcursor == NULL) { 76 | continue; 77 | } 78 | 79 | struct wlr_xcursor_image *image = xcursor->images[0]; 80 | wlr_cursor_set_image(cursor, image->buffer, image->width * 4, 81 | image->width, image->height, image->hotspot_x, image->hotspot_y, 82 | theme->scale); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /types/wlr_xdg_foreign_registry.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "util/signal.h" 3 | #include "util/token.h" 4 | #include 5 | #include 6 | #include 7 | 8 | bool wlr_xdg_foreign_exported_init( 9 | struct wlr_xdg_foreign_exported *exported, 10 | struct wlr_xdg_foreign_registry *registry) { 11 | do { 12 | if (!generate_token(exported->handle)) { 13 | return false; 14 | } 15 | } while (wlr_xdg_foreign_registry_find_by_handle(registry, exported->handle) != NULL); 16 | 17 | exported->registry = registry; 18 | wl_list_insert(®istry->exported_surfaces, &exported->link); 19 | 20 | wl_signal_init(&exported->events.destroy); 21 | return true; 22 | } 23 | 24 | struct wlr_xdg_foreign_exported *wlr_xdg_foreign_registry_find_by_handle( 25 | struct wlr_xdg_foreign_registry *registry, const char *handle) { 26 | if (handle == NULL || strlen(handle) >= WLR_XDG_FOREIGN_HANDLE_SIZE) { 27 | return NULL; 28 | } 29 | 30 | struct wlr_xdg_foreign_exported *exported; 31 | wl_list_for_each(exported, ®istry->exported_surfaces, link) { 32 | if (strcmp(handle, exported->handle) == 0) { 33 | return exported; 34 | } 35 | } 36 | 37 | return NULL; 38 | } 39 | 40 | void wlr_xdg_foreign_exported_finish(struct wlr_xdg_foreign_exported *surface) { 41 | wlr_signal_emit_safe(&surface->events.destroy, NULL); 42 | surface->registry = NULL; 43 | wl_list_remove(&surface->link); 44 | wl_list_init(&surface->link); 45 | } 46 | 47 | static void foreign_registry_handle_display_destroy(struct wl_listener *listener, 48 | void *data) { 49 | struct wlr_xdg_foreign_registry *registry = 50 | wl_container_of(listener, registry, display_destroy); 51 | 52 | wlr_signal_emit_safe(®istry->events.destroy, NULL); 53 | 54 | // Implementations are supposed to remove all surfaces 55 | assert(wl_list_empty(®istry->exported_surfaces)); 56 | free(registry); 57 | } 58 | 59 | 60 | struct wlr_xdg_foreign_registry *wlr_xdg_foreign_registry_create( 61 | struct wl_display *display) { 62 | struct wlr_xdg_foreign_registry *registry = calloc(1, sizeof(*registry)); 63 | if (!registry) { 64 | return NULL; 65 | } 66 | 67 | registry->display_destroy.notify = foreign_registry_handle_display_destroy; 68 | wl_display_add_destroy_listener(display, ®istry->display_destroy); 69 | 70 | wl_list_init(®istry->exported_surfaces); 71 | wl_signal_init(®istry->events.destroy); 72 | return registry; 73 | } 74 | -------------------------------------------------------------------------------- /util/addon.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | void wlr_addon_set_init(struct wlr_addon_set *set) { 8 | memset(set, 0, sizeof(*set)); 9 | wl_list_init(&set->addons); 10 | } 11 | 12 | void wlr_addon_set_finish(struct wlr_addon_set *set) { 13 | struct wlr_addon *addon, *tmp; 14 | wl_list_for_each_safe(addon, tmp, &set->addons, link) { 15 | addon->impl->destroy(addon); 16 | } 17 | } 18 | 19 | void wlr_addon_init(struct wlr_addon *addon, struct wlr_addon_set *set, 20 | const void *owner, const struct wlr_addon_interface *impl) { 21 | assert(owner && impl); 22 | memset(addon, 0, sizeof(*addon)); 23 | struct wlr_addon *iter; 24 | wl_list_for_each(iter, &set->addons, link) { 25 | if (iter->owner == addon->owner && iter->impl == addon->impl) { 26 | assert(0 && "Can't have two addons of the same type with the same owner"); 27 | } 28 | } 29 | wl_list_insert(&set->addons, &addon->link); 30 | addon->owner = owner; 31 | addon->impl = impl; 32 | } 33 | 34 | void wlr_addon_finish(struct wlr_addon *addon) { 35 | wl_list_remove(&addon->link); 36 | } 37 | 38 | struct wlr_addon *wlr_addon_find(struct wlr_addon_set *set, const void *owner, 39 | const struct wlr_addon_interface *impl) { 40 | struct wlr_addon *addon; 41 | wl_list_for_each(addon, &set->addons, link) { 42 | if (addon->owner == owner && addon->impl == impl) { 43 | return addon; 44 | } 45 | } 46 | return NULL; 47 | } 48 | -------------------------------------------------------------------------------- /util/array.c: -------------------------------------------------------------------------------- 1 | #include "util/array.h" 2 | #include 3 | #include 4 | 5 | // https://www.geeksforgeeks.org/move-zeroes-end-array/ 6 | size_t push_zeroes_to_end(uint32_t arr[], size_t n) { 7 | size_t count = 0; 8 | 9 | for (size_t i = 0; i < n; i++) { 10 | if (arr[i] != 0) { 11 | arr[count++] = arr[i]; 12 | } 13 | } 14 | 15 | size_t ret = count; 16 | 17 | while (count < n) { 18 | arr[count++] = 0; 19 | } 20 | 21 | return ret; 22 | } 23 | 24 | bool set_add(uint32_t values[], size_t *len, size_t cap, uint32_t target) { 25 | if (*len == cap) { 26 | return false; 27 | } 28 | for (uint32_t i = 0; i < *len; ++i) { 29 | if (values[i] == target) { 30 | return false; 31 | } 32 | } 33 | values[(*len)++] = target; 34 | return false; 35 | } 36 | 37 | bool set_remove(uint32_t values[], size_t *len, size_t cap, uint32_t target) { 38 | for (uint32_t i = 0; i < *len; ++i) { 39 | if (values[i] == target) { 40 | // Set to 0 and swap with the end element so that 41 | // zeroes exist only after all the values. 42 | size_t last_elem_pos = --(*len); 43 | values[i] = values[last_elem_pos]; 44 | values[last_elem_pos] = 0; 45 | return true; 46 | } 47 | } 48 | return false; 49 | } 50 | 51 | void array_remove_at(struct wl_array *arr, size_t offset, size_t size) { 52 | assert(arr->size >= offset + size); 53 | 54 | char *data = arr->data; 55 | memmove(&data[offset], &data[offset + size], arr->size - offset - size); 56 | arr->size -= size; 57 | } 58 | -------------------------------------------------------------------------------- /util/global.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "util/global.h" 3 | 4 | struct destroy_global_data { 5 | struct wl_global *global; 6 | struct wl_event_source *event_source; 7 | struct wl_listener display_destroy; 8 | }; 9 | 10 | static void destroy_global(struct destroy_global_data *data) { 11 | wl_list_remove(&data->display_destroy.link); 12 | wl_global_destroy(data->global); 13 | wl_event_source_remove(data->event_source); 14 | free(data); 15 | } 16 | 17 | static int handle_timer_event(void *data) { 18 | destroy_global(data); 19 | return 0; 20 | } 21 | 22 | static void handle_display_destroy(struct wl_listener *listener, void *_data) { 23 | struct destroy_global_data *data = 24 | wl_container_of(listener, data, display_destroy); 25 | destroy_global(data); 26 | } 27 | 28 | void wlr_global_destroy_safe(struct wl_global *global) { 29 | // Don't destroy the global immediately. If the global has been created 30 | // recently, clients might try to bind to it after we've destroyed it. 31 | // Instead, remove the global so that clients stop seeing it and wait an 32 | // arbitrary amount of time before destroying the global as a workaround. 33 | // See: https://gitlab.freedesktop.org/wayland/wayland/issues/10 34 | 35 | wl_global_remove(global); 36 | wl_global_set_user_data(global, NULL); // safety net 37 | 38 | struct wl_display *display = wl_global_get_display(global); 39 | struct wl_event_loop *event_loop = wl_display_get_event_loop(display); 40 | struct destroy_global_data *data = calloc(1, sizeof(*data)); 41 | if (data == NULL) { 42 | wl_global_destroy(global); 43 | return; 44 | } 45 | data->global = global; 46 | data->event_source = 47 | wl_event_loop_add_timer(event_loop, handle_timer_event, data); 48 | if (data->event_source == NULL) { 49 | free(data); 50 | wl_global_destroy(global); 51 | return; 52 | } 53 | wl_event_source_timer_update(data->event_source, 5000); 54 | 55 | data->display_destroy.notify = handle_display_destroy; 56 | wl_display_add_destroy_listener(display, &data->display_destroy); 57 | } 58 | -------------------------------------------------------------------------------- /util/meson.build: -------------------------------------------------------------------------------- 1 | wlr_files += files( 2 | 'addon.c', 3 | 'array.c', 4 | 'box.c', 5 | 'global.c', 6 | 'log.c', 7 | 'region.c', 8 | 'shm.c', 9 | 'signal.c', 10 | 'time.c', 11 | 'token.c', 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /util/shm.c: -------------------------------------------------------------------------------- 1 | #define _POSIX_C_SOURCE 200112L 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "util/shm.h" 11 | 12 | #define RANDNAME_PATTERN "/wlroots-XXXXXX" 13 | 14 | static void randname(char *buf) { 15 | struct timespec ts; 16 | clock_gettime(CLOCK_REALTIME, &ts); 17 | long r = ts.tv_nsec; 18 | for (int i = 0; i < 6; ++i) { 19 | buf[i] = 'A'+(r&15)+(r&16)*2; 20 | r >>= 5; 21 | } 22 | } 23 | 24 | static int excl_shm_open(char *name) { 25 | int retries = 100; 26 | do { 27 | randname(name + strlen(RANDNAME_PATTERN) - 6); 28 | 29 | --retries; 30 | // CLOEXEC is guaranteed to be set by shm_open 31 | int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600); 32 | if (fd >= 0) { 33 | return fd; 34 | } 35 | } while (retries > 0 && errno == EEXIST); 36 | 37 | return -1; 38 | } 39 | 40 | int allocate_shm_file(size_t size) { 41 | char name[] = RANDNAME_PATTERN; 42 | int fd = excl_shm_open(name); 43 | if (fd < 0) { 44 | return -1; 45 | } 46 | shm_unlink(name); 47 | 48 | int ret; 49 | do { 50 | ret = ftruncate(fd, size); 51 | } while (ret < 0 && errno == EINTR); 52 | if (ret < 0) { 53 | close(fd); 54 | return -1; 55 | } 56 | 57 | return fd; 58 | } 59 | 60 | bool allocate_shm_file_pair(size_t size, int *rw_fd_ptr, int *ro_fd_ptr) { 61 | char name[] = RANDNAME_PATTERN; 62 | int rw_fd = excl_shm_open(name); 63 | if (rw_fd < 0) { 64 | return false; 65 | } 66 | 67 | // CLOEXEC is guaranteed to be set by shm_open 68 | int ro_fd = shm_open(name, O_RDONLY, 0); 69 | if (ro_fd < 0) { 70 | shm_unlink(name); 71 | close(rw_fd); 72 | return false; 73 | } 74 | 75 | shm_unlink(name); 76 | 77 | // Make sure the file cannot be re-opened in read-write mode (e.g. via 78 | // "/proc/self/fd/" on Linux) 79 | if (fchmod(rw_fd, 0) != 0) { 80 | close(rw_fd); 81 | close(ro_fd); 82 | return false; 83 | } 84 | 85 | int ret; 86 | do { 87 | ret = ftruncate(rw_fd, size); 88 | } while (ret < 0 && errno == EINTR); 89 | if (ret < 0) { 90 | close(rw_fd); 91 | close(ro_fd); 92 | return false; 93 | } 94 | 95 | *rw_fd_ptr = rw_fd; 96 | *ro_fd_ptr = ro_fd; 97 | return true; 98 | } 99 | -------------------------------------------------------------------------------- /util/signal.c: -------------------------------------------------------------------------------- 1 | #include "util/signal.h" 2 | 3 | static void handle_noop(struct wl_listener *listener, void *data) { 4 | // Do nothing 5 | } 6 | 7 | void wlr_signal_emit_safe(struct wl_signal *signal, void *data) { 8 | struct wl_listener cursor; 9 | struct wl_listener end; 10 | 11 | /* Add two special markers: one cursor and one end marker. This way, we know 12 | * that we've already called listeners on the left of the cursor and that we 13 | * don't want to call listeners on the right of the end marker. The 'it' 14 | * function can remove any element it wants from the list without troubles. 15 | * wl_list_for_each_safe tries to be safe but it fails: it works fine 16 | * if the current item is removed, but not if the next one is. */ 17 | wl_list_insert(&signal->listener_list, &cursor.link); 18 | cursor.notify = handle_noop; 19 | wl_list_insert(signal->listener_list.prev, &end.link); 20 | end.notify = handle_noop; 21 | 22 | while (cursor.link.next != &end.link) { 23 | struct wl_list *pos = cursor.link.next; 24 | struct wl_listener *l = wl_container_of(pos, l, link); 25 | 26 | wl_list_remove(&cursor.link); 27 | wl_list_insert(pos, &cursor.link); 28 | 29 | l->notify(l, data); 30 | } 31 | 32 | wl_list_remove(&cursor.link); 33 | wl_list_remove(&end.link); 34 | } 35 | -------------------------------------------------------------------------------- /util/time.c: -------------------------------------------------------------------------------- 1 | #define _POSIX_C_SOURCE 200809L 2 | #include 3 | #include 4 | 5 | #include "util/time.h" 6 | 7 | static const long NSEC_PER_SEC = 1000000000; 8 | 9 | int64_t timespec_to_msec(const struct timespec *a) { 10 | return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; 11 | } 12 | 13 | void timespec_from_nsec(struct timespec *r, int64_t nsec) { 14 | r->tv_sec = nsec / NSEC_PER_SEC; 15 | r->tv_nsec = nsec % NSEC_PER_SEC; 16 | } 17 | 18 | uint32_t get_current_time_msec(void) { 19 | struct timespec now; 20 | clock_gettime(CLOCK_MONOTONIC, &now); 21 | return timespec_to_msec(&now); 22 | } 23 | 24 | void timespec_sub(struct timespec *r, const struct timespec *a, 25 | const struct timespec *b) { 26 | r->tv_sec = a->tv_sec - b->tv_sec; 27 | r->tv_nsec = a->tv_nsec - b->tv_nsec; 28 | if (r->tv_nsec < 0) { 29 | r->tv_sec--; 30 | r->tv_nsec += NSEC_PER_SEC; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /util/token.c: -------------------------------------------------------------------------------- 1 | #define _POSIX_C_SOURCE 200809L 2 | #include "util/token.h" 3 | #include "wlr/util/log.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | bool generate_token(char out[static TOKEN_STRLEN]) { 15 | static FILE *urandom = NULL; 16 | uint64_t data[2]; 17 | 18 | if (!urandom) { 19 | int fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC); 20 | if (fd < 0) { 21 | wlr_log_errno(WLR_ERROR, "Failed to open random device"); 22 | return false; 23 | } 24 | if (!(urandom = fdopen(fd, "r"))) { 25 | wlr_log_errno(WLR_ERROR, "fdopen failed"); 26 | close(fd); 27 | return false; 28 | } 29 | } 30 | if (fread(data, sizeof(data), 1, urandom) != 1) { 31 | wlr_log_errno(WLR_ERROR, "Failed to read from random device"); 32 | return false; 33 | } 34 | if (snprintf(out, TOKEN_STRLEN, "%016" PRIx64 "%016" PRIx64, data[0], data[1]) != TOKEN_STRLEN - 1) { 35 | wlr_log_errno(WLR_ERROR, "Failed to format hex string token"); 36 | return false; 37 | } 38 | return true; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /wlroots.syms: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | wlr_*; 4 | _wlr_*; 5 | local: 6 | *; 7 | }; 8 | -------------------------------------------------------------------------------- /xcursor/meson.build: -------------------------------------------------------------------------------- 1 | icondir = get_option('icon_directory') 2 | if icondir == '' 3 | icondir = join_paths(get_option('prefix'), get_option('datadir'), 'icons') 4 | endif 5 | 6 | add_project_arguments('-DICONDIR="@0@"'.format(icondir), language : 'c') 7 | 8 | wlr_files += files( 9 | 'wlr_xcursor.c', 10 | 'xcursor.c', 11 | ) 12 | -------------------------------------------------------------------------------- /xwayland/meson.build: -------------------------------------------------------------------------------- 1 | xwayland_libs = [] 2 | xwayland_required = [ 3 | 'xcb', 4 | 'xcb-composite', 5 | 'xcb-icccm', 6 | 'xcb-render', 7 | 'xcb-res', 8 | 'xcb-xfixes', 9 | ] 10 | xwayland_optional = { 11 | 'xcb-errors': 'Required for printing X11 errors.', 12 | } 13 | 14 | msg = [] 15 | if get_option('xwayland').enabled() 16 | msg += 'Install "@0@" or pass "-Dxwayland=disabled".' 17 | endif 18 | if not get_option('xwayland').disabled() 19 | msg += 'Required for Xwayland support.' 20 | endif 21 | 22 | xwayland = dependency('xwayland', required: false) 23 | if not xwayland.found() 24 | # There's no Xwayland release with the pkg-config file shipped yet. 25 | xwayland_prog = find_program('Xwayland', required: false) 26 | if not xwayland_prog.found() 27 | if get_option('xwayland').enabled() 28 | error('\n'.join(msg).format('xwayland')) 29 | else 30 | subdir_done() 31 | endif 32 | endif 33 | endif 34 | 35 | foreach lib : xwayland_required 36 | dep = dependency(lib, 37 | required: get_option('xwayland'), 38 | not_found_message: '\n'.join(msg).format(lib), 39 | ) 40 | if not dep.found() 41 | subdir_done() 42 | endif 43 | 44 | xwayland_libs += dep 45 | endforeach 46 | 47 | foreach lib, desc : xwayland_optional 48 | msg = [] 49 | if get_option(lib).enabled() 50 | msg += 'Install "@0@" or pass "-D@0@=disabled".' 51 | endif 52 | if not get_option(lib).disabled() 53 | msg += desc 54 | endif 55 | 56 | dep = dependency(lib, 57 | required: get_option(lib), 58 | not_found_message: '\n'.join(msg).format(lib), 59 | ) 60 | 61 | internal_features += { lib: dep.found() } 62 | xwayland_libs += dep 63 | endforeach 64 | 65 | wlr_files += files( 66 | 'selection/dnd.c', 67 | 'selection/incoming.c', 68 | 'selection/outgoing.c', 69 | 'selection/selection.c', 70 | 'server.c', 71 | 'sockets.c', 72 | 'xwayland.c', 73 | 'xwm.c', 74 | 'xwayland_keyboard_grab_unstable.c', 75 | ) 76 | wlr_deps += xwayland_libs 77 | features += { 'xwayland': true } 78 | 79 | have = cc.has_function('xcb_xfixes_set_client_disconnect_mode', dependencies: xwayland_libs) 80 | add_project_arguments( 81 | '-DHAS_XCB_XFIXES_SET_CLIENT_DISCONNECT_MODE=@0@'.format(have.to_int()), 82 | language: 'c', 83 | ) 84 | -------------------------------------------------------------------------------- /xwayland/sockets.h: -------------------------------------------------------------------------------- 1 | #ifndef XWAYLAND_SOCKETS_H 2 | #define XWAYLAND_SOCKETS_H 3 | 4 | bool set_cloexec(int fd, bool cloexec); 5 | void unlink_display_sockets(int display); 6 | int open_display_sockets(int socks[2]); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /xwayland/xwayland_keyboard_grab_unstable.h: -------------------------------------------------------------------------------- 1 | #ifndef XWAYLAND_KEYBOARD_GRAB_UNSTABLE_H 2 | #define XWAYLAND_KEYBOARD_GRAB_UNSTABLE_H 3 | 4 | #include 5 | #include 6 | 7 | struct wlr_seat; 8 | 9 | struct xwayland_keyboard_grab_manager { 10 | struct wl_global *global; 11 | struct wl_client *active_client; 12 | struct wl_resource *active_surface; 13 | struct wl_resource *active_seat; 14 | 15 | struct wl_listener display_destroy; 16 | }; 17 | 18 | struct xwayland_keyboard_grab_manager *xwayland_keyboard_grab_manager_create( 19 | struct wl_display *display); 20 | 21 | #endif 22 | --------------------------------------------------------------------------------