├── .builds ├── alpine.yml ├── archlinux.yml └── freebsd.yml ├── .editorconfig ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── backend ├── backend.c ├── drm │ ├── atomic.c │ ├── backend.c │ ├── cvt.c │ ├── drm.c │ ├── legacy.c │ ├── meson.build │ ├── properties.c │ ├── renderer.c │ └── util.c ├── headless │ ├── backend.c │ ├── input_device.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 ├── noop │ ├── backend.c │ ├── meson.build │ └── output.c ├── session │ ├── meson.build │ └── session.c ├── wayland │ ├── backend.c │ ├── meson.build │ ├── output.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 │ │ ├── properties.h │ │ ├── renderer.h │ │ └── util.h │ ├── headless.h │ ├── libinput.h │ ├── multi.h │ ├── noop.h │ ├── session │ │ └── session.h │ ├── wayland.h │ └── x11.h ├── meson.build ├── render │ ├── allocator │ │ ├── allocator.h │ │ ├── drm_dumb.h │ │ ├── gbm.h │ │ └── shm.h │ ├── drm_format_set.h │ ├── egl.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_output.h │ ├── wlr_region.h │ ├── wlr_seat.h │ ├── wlr_surface.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 │ │ ├── noop.h │ │ ├── session.h │ │ ├── wayland.h │ │ └── x11.h │ ├── config.h.in │ ├── interfaces │ │ ├── wlr_input_device.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 │ │ ├── dmabuf.h │ │ ├── drm_format_set.h │ │ ├── egl.h │ │ ├── gles2.h │ │ ├── interface.h │ │ ├── pixman.h │ │ ├── vulkan.h │ │ ├── wlr_renderer.h │ │ └── wlr_texture.h │ ├── types │ │ ├── wlr_box.h │ │ ├── wlr_buffer.h │ │ ├── wlr_compositor.h │ │ ├── wlr_cursor.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_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 ├── 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 ├── render ├── allocator │ ├── allocator.c │ ├── drm_dumb.c │ ├── gbm.c │ ├── meson.build │ └── shm.c ├── dmabuf.c ├── drm_format_set.c ├── egl.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 └── 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 │ └── transform.c ├── scene │ ├── output_layout.c │ ├── subsurface_tree.c │ └── wlr_scene.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_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_surface.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 └── 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://github.com/swaywm/wlroots 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://github.com/swaywm/wlroots 23 | tasks: 24 | - setup: | 25 | cd wlroots 26 | CC=gcc meson build-gcc --fatal-meson-warnings --default-library=both -Dauto_features=enabled --prefix /usr 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 | 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://github.com/swaywm/wlroots 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 | 11 | [*.xml] 12 | indent_style = space 13 | indent_size = 2 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .clang_complete 2 | *.o 3 | *.a 4 | bin/ 5 | test/ 6 | build/ 7 | build-*/ 8 | wayland-*-protocol.* 9 | wlr-example.ini 10 | -------------------------------------------------------------------------------- /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 | 'properties.c', 8 | 'renderer.c', 9 | 'util.c', 10 | ) 11 | 12 | features += { 'drm-backend': true } 13 | -------------------------------------------------------------------------------- /backend/headless/meson.build: -------------------------------------------------------------------------------- 1 | wlr_files += files( 2 | 'backend.c', 3 | 'input_device.c', 4 | 'output.c', 5 | ) 6 | -------------------------------------------------------------------------------- /backend/libinput/keyboard.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "backend/libinput.h" 9 | 10 | struct wlr_libinput_keyboard { 11 | struct wlr_keyboard wlr_keyboard; 12 | struct libinput_device *libinput_dev; 13 | }; 14 | 15 | static const struct wlr_keyboard_impl impl; 16 | 17 | static struct wlr_libinput_keyboard *get_libinput_keyboard_from_keyboard( 18 | struct wlr_keyboard *wlr_kb) { 19 | assert(wlr_kb->impl == &impl); 20 | return (struct wlr_libinput_keyboard *)wlr_kb; 21 | } 22 | 23 | static void keyboard_set_leds(struct wlr_keyboard *wlr_kb, uint32_t leds) { 24 | struct wlr_libinput_keyboard *kb = 25 | get_libinput_keyboard_from_keyboard(wlr_kb); 26 | libinput_device_led_update(kb->libinput_dev, leds); 27 | } 28 | 29 | static void keyboard_destroy(struct wlr_keyboard *wlr_kb) { 30 | struct wlr_libinput_keyboard *kb = 31 | get_libinput_keyboard_from_keyboard(wlr_kb); 32 | libinput_device_unref(kb->libinput_dev); 33 | free(kb); 34 | } 35 | 36 | static const struct wlr_keyboard_impl impl = { 37 | .destroy = keyboard_destroy, 38 | .led_update = keyboard_set_leds 39 | }; 40 | 41 | struct wlr_keyboard *create_libinput_keyboard( 42 | struct libinput_device *libinput_dev) { 43 | struct wlr_libinput_keyboard *kb = 44 | calloc(1, sizeof(struct wlr_libinput_keyboard)); 45 | if (kb == NULL) { 46 | return NULL; 47 | } 48 | kb->libinput_dev = libinput_dev; 49 | libinput_device_ref(libinput_dev); 50 | libinput_device_led_update(libinput_dev, 0); 51 | struct wlr_keyboard *wlr_kb = &kb->wlr_keyboard; 52 | wlr_keyboard_init(wlr_kb, &impl); 53 | return wlr_kb; 54 | } 55 | 56 | void handle_keyboard_key(struct libinput_event *event, 57 | struct libinput_device *libinput_dev) { 58 | struct wlr_input_device *wlr_dev = 59 | get_appropriate_device(WLR_INPUT_DEVICE_KEYBOARD, libinput_dev); 60 | if (!wlr_dev) { 61 | wlr_log(WLR_DEBUG, 62 | "Got a keyboard event for a device with no keyboards?"); 63 | return; 64 | } 65 | struct libinput_event_keyboard *kbevent = 66 | libinput_event_get_keyboard_event(event); 67 | struct wlr_event_keyboard_key wlr_event = { 0 }; 68 | wlr_event.time_msec = 69 | usec_to_msec(libinput_event_keyboard_get_time_usec(kbevent)); 70 | wlr_event.keycode = libinput_event_keyboard_get_key(kbevent); 71 | enum libinput_key_state state = 72 | libinput_event_keyboard_get_key_state(kbevent); 73 | switch (state) { 74 | case LIBINPUT_KEY_STATE_RELEASED: 75 | wlr_event.state = WL_KEYBOARD_KEY_STATE_RELEASED; 76 | break; 77 | case LIBINPUT_KEY_STATE_PRESSED: 78 | wlr_event.state = WL_KEYBOARD_KEY_STATE_PRESSED; 79 | break; 80 | } 81 | wlr_event.update_state = true; 82 | wlr_keyboard_notify_key(wlr_dev->keyboard, &wlr_event); 83 | } 84 | -------------------------------------------------------------------------------- /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 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 | language: 'c', 35 | ) 36 | -------------------------------------------------------------------------------- /backend/libinput/switch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "backend/libinput.h" 9 | #include "util/signal.h" 10 | 11 | struct wlr_switch *create_libinput_switch( 12 | struct libinput_device *libinput_dev) { 13 | assert(libinput_dev); 14 | struct wlr_switch *wlr_switch = calloc(1, sizeof(struct wlr_switch)); 15 | if (!wlr_switch) { 16 | wlr_log(WLR_ERROR, "Unable to allocate wlr_switch"); 17 | return NULL; 18 | } 19 | wlr_switch_init(wlr_switch, NULL); 20 | wlr_log(WLR_DEBUG, "Created switch for device %s", libinput_device_get_name(libinput_dev)); 21 | return wlr_switch; 22 | } 23 | 24 | void handle_switch_toggle(struct libinput_event *event, 25 | struct libinput_device *libinput_dev) { 26 | struct wlr_input_device *wlr_dev = 27 | get_appropriate_device(WLR_INPUT_DEVICE_SWITCH, libinput_dev); 28 | if (!wlr_dev) { 29 | wlr_log(WLR_DEBUG, "Got a switch event for a device with no switch?"); 30 | return; 31 | } 32 | struct libinput_event_switch *sevent = 33 | libinput_event_get_switch_event (event); 34 | struct wlr_event_switch_toggle wlr_event = { 0 }; 35 | wlr_event.device = wlr_dev; 36 | switch (libinput_event_switch_get_switch(sevent)) { 37 | case LIBINPUT_SWITCH_LID: 38 | wlr_event.switch_type = WLR_SWITCH_TYPE_LID; 39 | break; 40 | case LIBINPUT_SWITCH_TABLET_MODE: 41 | wlr_event.switch_type = WLR_SWITCH_TYPE_TABLET_MODE; 42 | break; 43 | } 44 | switch (libinput_event_switch_get_switch_state(sevent)) { 45 | case LIBINPUT_SWITCH_STATE_OFF: 46 | wlr_event.switch_state = WLR_SWITCH_STATE_OFF; 47 | break; 48 | case LIBINPUT_SWITCH_STATE_ON: 49 | wlr_event.switch_state = WLR_SWITCH_STATE_ON; 50 | break; 51 | } 52 | wlr_event.time_msec = 53 | usec_to_msec(libinput_event_switch_get_time_usec(sevent)); 54 | wlr_signal_emit_safe(&wlr_dev->switch_device->events.toggle, &wlr_event); 55 | } 56 | -------------------------------------------------------------------------------- /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('noop') 20 | subdir('headless') 21 | 22 | subdir('session') 23 | -------------------------------------------------------------------------------- /backend/multi/meson.build: -------------------------------------------------------------------------------- 1 | wlr_files += files('backend.c') 2 | -------------------------------------------------------------------------------- /backend/noop/backend.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "backend/noop.h" 6 | #include "util/signal.h" 7 | 8 | struct wlr_noop_backend *noop_backend_from_backend( 9 | struct wlr_backend *wlr_backend) { 10 | assert(wlr_backend_is_noop(wlr_backend)); 11 | return (struct wlr_noop_backend *)wlr_backend; 12 | } 13 | 14 | static bool backend_start(struct wlr_backend *wlr_backend) { 15 | struct wlr_noop_backend *backend = noop_backend_from_backend(wlr_backend); 16 | wlr_log(WLR_INFO, "Starting noop backend"); 17 | 18 | struct wlr_noop_output *output; 19 | wl_list_for_each(output, &backend->outputs, link) { 20 | wlr_output_update_enabled(&output->wlr_output, true); 21 | wlr_signal_emit_safe(&backend->backend.events.new_output, 22 | &output->wlr_output); 23 | } 24 | 25 | backend->started = true; 26 | return true; 27 | } 28 | 29 | static void backend_destroy(struct wlr_backend *wlr_backend) { 30 | struct wlr_noop_backend *backend = noop_backend_from_backend(wlr_backend); 31 | if (!wlr_backend) { 32 | return; 33 | } 34 | 35 | struct wlr_noop_output *output, *output_tmp; 36 | wl_list_for_each_safe(output, output_tmp, &backend->outputs, link) { 37 | wlr_output_destroy(&output->wlr_output); 38 | } 39 | 40 | wlr_backend_finish(wlr_backend); 41 | 42 | wl_list_remove(&backend->display_destroy.link); 43 | 44 | free(backend); 45 | } 46 | 47 | static const struct wlr_backend_impl backend_impl = { 48 | .start = backend_start, 49 | .destroy = backend_destroy, 50 | }; 51 | 52 | static void handle_display_destroy(struct wl_listener *listener, void *data) { 53 | struct wlr_noop_backend *noop = 54 | wl_container_of(listener, noop, display_destroy); 55 | backend_destroy(&noop->backend); 56 | } 57 | 58 | struct wlr_backend *wlr_noop_backend_create(struct wl_display *display) { 59 | wlr_log(WLR_INFO, "Creating noop backend"); 60 | 61 | struct wlr_noop_backend *backend = 62 | calloc(1, sizeof(struct wlr_noop_backend)); 63 | if (!backend) { 64 | wlr_log(WLR_ERROR, "Failed to allocate wlr_noop_backend"); 65 | return NULL; 66 | } 67 | wlr_backend_init(&backend->backend, &backend_impl); 68 | backend->display = display; 69 | wl_list_init(&backend->outputs); 70 | 71 | backend->display_destroy.notify = handle_display_destroy; 72 | wl_display_add_destroy_listener(display, &backend->display_destroy); 73 | 74 | return &backend->backend; 75 | } 76 | 77 | bool wlr_backend_is_noop(struct wlr_backend *backend) { 78 | return backend->impl == &backend_impl; 79 | } 80 | -------------------------------------------------------------------------------- /backend/noop/meson.build: -------------------------------------------------------------------------------- 1 | wlr_files += files( 2 | 'backend.c', 3 | 'output.c', 4 | ) 5 | -------------------------------------------------------------------------------- /backend/noop/output.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "backend/noop.h" 7 | #include "util/signal.h" 8 | 9 | static const uint32_t SUPPORTED_OUTPUT_STATE = 10 | WLR_OUTPUT_STATE_BACKEND_OPTIONAL | 11 | WLR_OUTPUT_STATE_MODE; 12 | 13 | static struct wlr_noop_output *noop_output_from_output( 14 | struct wlr_output *wlr_output) { 15 | assert(wlr_output_is_noop(wlr_output)); 16 | return (struct wlr_noop_output *)wlr_output; 17 | } 18 | 19 | static bool output_commit(struct wlr_output *wlr_output) { 20 | uint32_t unsupported = 21 | wlr_output->pending.committed & ~SUPPORTED_OUTPUT_STATE; 22 | if (unsupported != 0) { 23 | wlr_log(WLR_DEBUG, "Unsupported output state fields: 0x%"PRIx32, 24 | unsupported); 25 | return false; 26 | } 27 | 28 | if (wlr_output->pending.committed & WLR_OUTPUT_STATE_MODE) { 29 | assert(wlr_output->pending.mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM); 30 | wlr_output_update_custom_mode(wlr_output, 31 | wlr_output->pending.custom_mode.width, 32 | wlr_output->pending.custom_mode.height, 33 | wlr_output->pending.custom_mode.refresh); 34 | } 35 | 36 | if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) { 37 | return false; 38 | } 39 | 40 | return true; 41 | } 42 | 43 | static void output_destroy(struct wlr_output *wlr_output) { 44 | struct wlr_noop_output *output = 45 | noop_output_from_output(wlr_output); 46 | 47 | wl_list_remove(&output->link); 48 | 49 | free(output); 50 | } 51 | 52 | static const struct wlr_output_impl output_impl = { 53 | .destroy = output_destroy, 54 | .commit = output_commit, 55 | }; 56 | 57 | bool wlr_output_is_noop(struct wlr_output *wlr_output) { 58 | return wlr_output->impl == &output_impl; 59 | } 60 | 61 | struct wlr_output *wlr_noop_add_output(struct wlr_backend *wlr_backend) { 62 | struct wlr_noop_backend *backend = noop_backend_from_backend(wlr_backend); 63 | 64 | struct wlr_noop_output *output = calloc(1, sizeof(struct wlr_noop_output)); 65 | if (output == NULL) { 66 | wlr_log(WLR_ERROR, "Failed to allocate wlr_noop_output"); 67 | return NULL; 68 | } 69 | output->backend = backend; 70 | wlr_output_init(&output->wlr_output, &backend->backend, &output_impl, 71 | backend->display); 72 | struct wlr_output *wlr_output = &output->wlr_output; 73 | 74 | strncpy(wlr_output->make, "noop", sizeof(wlr_output->make)); 75 | strncpy(wlr_output->model, "noop", sizeof(wlr_output->model)); 76 | snprintf(wlr_output->name, sizeof(wlr_output->name), "NOOP-%zd", 77 | ++backend->last_output_num); 78 | 79 | wl_list_insert(&backend->outputs, &output->link); 80 | 81 | if (backend->started) { 82 | wlr_output_update_enabled(wlr_output, true); 83 | wlr_signal_emit_safe(&backend->backend.events.new_output, wlr_output); 84 | } 85 | 86 | return wlr_output; 87 | } 88 | -------------------------------------------------------------------------------- /backend/session/meson.build: -------------------------------------------------------------------------------- 1 | libseat = dependency('libseat', 2 | version: '>=0.2.0', 3 | fallback: ['seatd', 'libseat'], 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 | wlr_files += files( 2 | 'backend.c', 3 | 'output.c', 4 | 'seat.c', 5 | 'tablet_v2.c', 6 | ) 7 | 8 | client_protos = [ 9 | 'drm', 10 | 'linux-dmabuf-unstable-v1', 11 | 'pointer-gestures-unstable-v1', 12 | 'presentation-time', 13 | 'relative-pointer-unstable-v1', 14 | 'tablet-unstable-v2', 15 | 'xdg-activation-v1', 16 | 'xdg-decoration-unstable-v1', 17 | 'xdg-shell', 18 | ] 19 | 20 | foreach proto : client_protos 21 | wlr_files += protocols_client_header[proto] 22 | endforeach 23 | -------------------------------------------------------------------------------- /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, noop) 7 | * *WLR_NO_HARDWARE_CURSORS*: set to 1 to use software cursors instead of 8 | hardware cursors 9 | * *WLR_DIRECT_TTY*: specifies the tty to be used (instead of using /dev/tty) 10 | * *WLR_XWAYLAND*: specifies the path to an Xwayland binary to be used (instead 11 | of following shell search semantics for "Xwayland") 12 | * *WLR_RENDERER*: forces the creation of a specified renderer (available 13 | renderers: gles2, pixman) 14 | 15 | ## DRM backend 16 | 17 | * *WLR_DRM_DEVICES*: specifies the DRM devices (as a colon separated list) 18 | instead of auto probing them. The first existing device in this list is 19 | considered the primary DRM device. 20 | * *WLR_DRM_NO_ATOMIC*: set to 1 to use legacy DRM interface instead of atomic 21 | mode setting 22 | * *WLR_DRM_NO_MODIFIERS*: set to 1 to always allocate planes without modifiers, 23 | this can fix certain modeset failures because of bandwidth restrictions. 24 | 25 | ## Headless backend 26 | 27 | * *WLR_HEADLESS_OUTPUTS*: when using the headless backend specifies the number 28 | of outputs 29 | 30 | ## libinput backend 31 | 32 | * *WLR_LIBINPUT_NO_DEVICES*: set to 1 to not fail without any input devices 33 | 34 | ## Wayland backend 35 | 36 | * *WLR_WL_OUTPUTS*: when using the wayland backend specifies the number of outputs 37 | 38 | ## X11 backend 39 | 40 | * *WLR_X11_OUTPUTS*: when using the X11 backend specifies the number of outputs 41 | 42 | ## gles2 renderer 43 | 44 | * *WLR_RENDERER_ALLOW_SOFTWARE*: allows the gles2 renderer to use software 45 | rendering 46 | 47 | # Generic 48 | 49 | * *DISPLAY*: if set probe X11 backend in `wlr_backend_autocreate` 50 | * *WAYLAND_DISPLAY*, *WAYLAND_SOCKET*: if set probe Wayland backend in 51 | `wlr_backend_autocreate` 52 | * *XCURSOR_PATH*: directory where xcursors are located 53 | * *XDG_SESSION_ID*: if set, session ID used by the logind session 54 | -------------------------------------------------------------------------------- /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 | /** 14 | * Get the backend's allocator. Automatically creates the allocator if 15 | * necessary. 16 | */ 17 | struct wlr_allocator *backend_get_allocator(struct wlr_backend *backend); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /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/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 | 24 | // atomic-modesetting only 25 | 26 | uint32_t crtc_id; 27 | }; 28 | uint32_t props[4]; 29 | }; 30 | 31 | union wlr_drm_crtc_props { 32 | struct { 33 | // Neither of these are guaranteed to exist 34 | uint32_t vrr_enabled; 35 | uint32_t gamma_lut; 36 | uint32_t gamma_lut_size; 37 | 38 | // atomic-modesetting only 39 | 40 | uint32_t active; 41 | uint32_t mode_id; 42 | }; 43 | uint32_t props[6]; 44 | }; 45 | 46 | union wlr_drm_plane_props { 47 | struct { 48 | uint32_t type; 49 | uint32_t rotation; // Not guaranteed to exist 50 | uint32_t in_formats; // Not guaranteed to exist 51 | 52 | // atomic-modesetting only 53 | 54 | uint32_t src_x; 55 | uint32_t src_y; 56 | uint32_t src_w; 57 | uint32_t src_h; 58 | uint32_t crtc_x; 59 | uint32_t crtc_y; 60 | uint32_t crtc_w; 61 | uint32_t crtc_h; 62 | uint32_t fb_id; 63 | uint32_t crtc_id; 64 | uint32_t fb_damage_clips; 65 | }; 66 | uint32_t props[14]; 67 | }; 68 | 69 | bool get_drm_connector_props(int fd, uint32_t id, 70 | union wlr_drm_connector_props *out); 71 | bool get_drm_crtc_props(int fd, uint32_t id, union wlr_drm_crtc_props *out); 72 | bool get_drm_plane_props(int fd, uint32_t id, union wlr_drm_plane_props *out); 73 | 74 | bool get_drm_prop(int fd, uint32_t obj, uint32_t prop, uint64_t *ret); 75 | void *get_drm_prop_blob(int fd, uint32_t obj, uint32_t prop, size_t *ret_len); 76 | char *get_drm_prop_enum(int fd, uint32_t obj, uint32_t prop); 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /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 | 9 | struct wlr_drm_backend; 10 | struct wlr_drm_plane; 11 | struct wlr_buffer; 12 | 13 | struct wlr_drm_renderer { 14 | struct wlr_drm_backend *backend; 15 | 16 | struct wlr_renderer *wlr_rend; 17 | struct wlr_allocator *allocator; 18 | }; 19 | 20 | struct wlr_drm_surface { 21 | struct wlr_drm_renderer *renderer; 22 | 23 | uint32_t width; 24 | uint32_t height; 25 | 26 | struct wlr_swapchain *swapchain; 27 | }; 28 | 29 | struct wlr_drm_fb { 30 | struct wlr_buffer *wlr_buf; 31 | struct wlr_addon addon; 32 | struct wlr_drm_backend *backend; 33 | struct wl_list link; // wlr_drm_backend.fbs 34 | 35 | uint32_t id; 36 | }; 37 | 38 | bool init_drm_renderer(struct wlr_drm_backend *drm, 39 | struct wlr_drm_renderer *renderer); 40 | void finish_drm_renderer(struct wlr_drm_renderer *renderer); 41 | 42 | bool init_drm_surface(struct wlr_drm_surface *surf, 43 | struct wlr_drm_renderer *renderer, uint32_t width, uint32_t height, 44 | const struct wlr_drm_format *drm_format); 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 | #include 8 | 9 | // Calculates a more accurate refresh rate (mHz) than what mode itself provides 10 | int32_t calculate_refresh_rate(const drmModeModeInfo *mode); 11 | // Populates the make/model/phys_{width,height} of output from the edid data 12 | void parse_edid(struct wlr_output *restrict output, size_t len, 13 | const uint8_t *data); 14 | // Returns the string representation of a DRM output type 15 | const char *conn_get_name(uint32_t type_id); 16 | 17 | // Part of match_obj 18 | enum { 19 | UNMATCHED = (uint32_t)-1, 20 | SKIP = (uint32_t)-2, 21 | }; 22 | 23 | /* 24 | * Tries to match some DRM objects with some other DRM resource. 25 | * e.g. Match CRTCs with Encoders, CRTCs with Planes. 26 | * 27 | * objs contains a bit array which resources it can be matched with. 28 | * e.g. Bit 0 set means can be matched with res[0] 29 | * 30 | * res contains an index of which objs it is matched with or UNMATCHED. 31 | * 32 | * This solution is left in out. 33 | * Returns the total number of matched solutions. 34 | */ 35 | size_t match_obj(size_t num_objs, const uint32_t objs[static restrict num_objs], 36 | size_t num_res, const uint32_t res[static restrict num_res], 37 | uint32_t out[static restrict num_res]); 38 | 39 | /** 40 | * Close a GEM buffer handle. 41 | * 42 | * TODO: replace with drmCloseBufferHandle. 43 | */ 44 | void close_bo_handle(int drm_fd, uint32_t handle); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /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 | int drm_fd; 12 | struct wl_display *display; 13 | struct wl_list outputs; 14 | size_t last_output_num; 15 | struct wl_list input_devices; 16 | struct wl_listener display_destroy; 17 | struct wlr_renderer *parent_renderer; 18 | struct wl_listener parent_renderer_destroy; 19 | bool started; 20 | }; 21 | 22 | struct wlr_headless_output { 23 | struct wlr_output wlr_output; 24 | 25 | struct wlr_headless_backend *backend; 26 | struct wl_list link; 27 | 28 | struct wl_event_source *frame_timer; 29 | int frame_delay; // ms 30 | }; 31 | 32 | struct wlr_headless_input_device { 33 | struct wlr_input_device wlr_input_device; 34 | 35 | struct wlr_headless_backend *backend; 36 | }; 37 | 38 | struct wlr_headless_backend *headless_backend_from_backend( 39 | struct wlr_backend *wlr_backend); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /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/noop.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKEND_NOOP_H 2 | #define BACKEND_NOOP_H 3 | 4 | #include 5 | #include 6 | 7 | struct wlr_noop_backend { 8 | struct wlr_backend backend; 9 | struct wl_display *display; 10 | struct wl_list outputs; 11 | size_t last_output_num; 12 | bool started; 13 | 14 | struct wl_listener display_destroy; 15 | }; 16 | 17 | struct wlr_noop_output { 18 | struct wlr_output wlr_output; 19 | 20 | struct wlr_noop_backend *backend; 21 | struct wl_list link; 22 | }; 23 | 24 | struct wlr_noop_backend *noop_backend_from_backend( 25 | struct wlr_backend *wlr_backend); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /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 | #endif 15 | -------------------------------------------------------------------------------- /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 | #include 6 | #include 7 | 8 | struct wlr_allocator; 9 | struct wlr_backend; 10 | struct wlr_renderer; 11 | 12 | struct wlr_allocator_interface { 13 | struct wlr_buffer *(*create_buffer)(struct wlr_allocator *alloc, 14 | int width, int height, const struct wlr_drm_format *format); 15 | void (*destroy)(struct wlr_allocator *alloc); 16 | }; 17 | 18 | struct wlr_allocator { 19 | const struct wlr_allocator_interface *impl; 20 | 21 | // Capabilities of the buffers created with this allocator 22 | uint32_t buffer_caps; 23 | 24 | struct { 25 | struct wl_signal destroy; 26 | } events; 27 | }; 28 | 29 | /** 30 | * Creates the adequate wlr_allocator given a backend and a renderer 31 | */ 32 | struct wlr_allocator *wlr_allocator_autocreate(struct wlr_backend *backend, 33 | struct wlr_renderer *renderer); 34 | /** 35 | * Destroy the allocator. 36 | */ 37 | void wlr_allocator_destroy(struct wlr_allocator *alloc); 38 | /** 39 | * Allocate a new buffer. 40 | * 41 | * When the caller is done with it, they must unreference it by calling 42 | * wlr_buffer_drop. 43 | */ 44 | struct wlr_buffer *wlr_allocator_create_buffer(struct wlr_allocator *alloc, 45 | int width, int height, const struct wlr_drm_format *format); 46 | 47 | // For wlr_allocator implementors 48 | void wlr_allocator_init(struct wlr_allocator *alloc, 49 | const struct wlr_allocator_interface *impl, uint32_t buffer_caps); 50 | 51 | struct wlr_allocator *allocator_autocreate_with_drm_fd( 52 | struct wlr_backend *backend, struct wlr_renderer *renderer, int drm_fd); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /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_add(struct wlr_drm_format **fmt_ptr, uint64_t modifier); 8 | struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format); 9 | /** 10 | * Intersect modifiers for two DRM formats. 11 | * 12 | * Both arguments must have the same format field. If the formats aren't 13 | * compatible, NULL is returned. If either format doesn't support any modifier, 14 | * a format that doesn't support any modifier is returned. 15 | */ 16 | struct wlr_drm_format *wlr_drm_format_intersect( 17 | const struct wlr_drm_format *a, const struct wlr_drm_format *b); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/render/egl.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDER_EGL_H 2 | #define RENDER_EGL_H 3 | 4 | #include 5 | 6 | struct wlr_egl_context { 7 | EGLDisplay display; 8 | EGLContext context; 9 | EGLSurface draw_surface; 10 | EGLSurface read_surface; 11 | }; 12 | 13 | /** 14 | * Initializes an EGL context for the given DRM FD. 15 | * 16 | * Will attempt to load all possibly required API functions. 17 | */ 18 | struct wlr_egl *wlr_egl_create_with_drm_fd(int drm_fd); 19 | 20 | /** 21 | * Frees all related EGL resources, makes the context not-current and 22 | * unbinds a bound wayland display. 23 | */ 24 | void wlr_egl_destroy(struct wlr_egl *egl); 25 | 26 | /** 27 | * Creates an EGL image from the given dmabuf attributes. Check usability 28 | * of the dmabuf with wlr_egl_check_import_dmabuf once first. 29 | */ 30 | EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl, 31 | struct wlr_dmabuf_attributes *attributes, bool *external_only); 32 | 33 | /** 34 | * Get DMA-BUF formats suitable for sampling usage. 35 | */ 36 | const struct wlr_drm_format_set *wlr_egl_get_dmabuf_texture_formats( 37 | struct wlr_egl *egl); 38 | /** 39 | * Get DMA-BUF formats suitable for rendering usage. 40 | */ 41 | const struct wlr_drm_format_set *wlr_egl_get_dmabuf_render_formats( 42 | struct wlr_egl *egl); 43 | 44 | /** 45 | * Destroys an EGL image created with the given wlr_egl. 46 | */ 47 | bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image); 48 | 49 | int wlr_egl_dup_drm_fd(struct wlr_egl *egl); 50 | 51 | /** 52 | * Save the current EGL context to the structure provided in the argument. 53 | * 54 | * This includes display, context, draw surface and read surface. 55 | */ 56 | void wlr_egl_save_context(struct wlr_egl_context *context); 57 | 58 | /** 59 | * Restore EGL context that was previously saved using wlr_egl_save_current(). 60 | */ 61 | bool wlr_egl_restore_context(struct wlr_egl_context *context); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /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 | 24 | struct wlr_swapchain_slot slots[WLR_SWAPCHAIN_CAP]; 25 | 26 | struct wl_listener allocator_destroy; 27 | }; 28 | 29 | struct wlr_swapchain *wlr_swapchain_create( 30 | struct wlr_allocator *alloc, int width, int height, 31 | const struct wlr_drm_format *format); 32 | void wlr_swapchain_destroy(struct wlr_swapchain *swapchain); 33 | /** 34 | * Acquire a buffer from the swap chain. 35 | * 36 | * The returned buffer is locked. When the caller is done with it, they must 37 | * unlock it by calling wlr_buffer_unlock. 38 | */ 39 | struct wlr_buffer *wlr_swapchain_acquire(struct wlr_swapchain *swapchain, 40 | int *age); 41 | /** 42 | * Mark the buffer as submitted for presentation. This needs to be called by 43 | * swap chain users on frame boundaries. 44 | * 45 | * If the buffer hasn't been created via the swap chain, the call is ignored. 46 | */ 47 | void wlr_swapchain_set_buffer_submitted(struct wlr_swapchain *swapchain, 48 | struct wlr_buffer *buffer); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /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 | #endif 73 | -------------------------------------------------------------------------------- /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_event_keyboard_key *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_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, int *width, 8 | int *height); 9 | 10 | struct wlr_drm_format *output_pick_format(struct wlr_output *output, 11 | const struct wlr_drm_format_set *display_formats); 12 | void output_clear_back_buffer(struct wlr_output *output); 13 | bool output_ensure_buffer(struct wlr_output *output); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /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_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_surface.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_WLR_SURFACE_H 2 | #define TYPES_WLR_SURFACE_H 3 | 4 | #include 5 | 6 | struct wlr_renderer; 7 | 8 | /** 9 | * Create a new surface resource with the provided new ID. 10 | */ 11 | struct wlr_surface *surface_create(struct wl_client *client, 12 | uint32_t version, uint32_t id, struct wlr_renderer *renderer); 13 | 14 | /** 15 | * Create a new subsurface resource with the provided new ID. 16 | */ 17 | struct wlr_subsurface *subsurface_create(struct wlr_surface *surface, 18 | struct wlr_surface *parent, uint32_t version, uint32_t id); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /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 | struct wlr_xdg_positioner_resource { 9 | struct wl_resource *resource; 10 | struct wlr_xdg_positioner attrs; 11 | }; 12 | 13 | extern const struct wlr_surface_role xdg_toplevel_surface_role; 14 | extern const struct wlr_surface_role xdg_popup_surface_role; 15 | 16 | struct wlr_xdg_surface *create_xdg_surface( 17 | struct wlr_xdg_client *client, struct wlr_surface *surface, 18 | uint32_t id); 19 | void unmap_xdg_surface(struct wlr_xdg_surface *surface); 20 | void reset_xdg_surface(struct wlr_xdg_surface *xdg_surface); 21 | void destroy_xdg_surface(struct wlr_xdg_surface *surface); 22 | void handle_xdg_surface_commit(struct wlr_surface *wlr_surface); 23 | void handle_xdg_surface_precommit(struct wlr_surface *wlr_surface); 24 | 25 | void create_xdg_positioner(struct wlr_xdg_client *client, uint32_t id); 26 | struct wlr_xdg_positioner_resource *get_xdg_positioner_from_resource( 27 | struct wl_resource *resource); 28 | 29 | void create_xdg_popup(struct wlr_xdg_surface *xdg_surface, 30 | struct wlr_xdg_surface *parent, 31 | struct wlr_xdg_positioner_resource *positioner, int32_t id); 32 | void handle_xdg_surface_popup_committed(struct wlr_xdg_surface *surface); 33 | struct wlr_xdg_popup_grab *get_xdg_shell_popup_grab_from_seat( 34 | struct wlr_xdg_shell *shell, struct wlr_seat *seat); 35 | 36 | void create_xdg_toplevel(struct wlr_xdg_surface *xdg_surface, 37 | uint32_t id); 38 | void handle_xdg_surface_toplevel_committed(struct wlr_xdg_surface *surface); 39 | void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface, 40 | struct wlr_xdg_surface_configure *configure); 41 | void handle_xdg_toplevel_ack_configure(struct wlr_xdg_surface *surface, 42 | struct wlr_xdg_surface_configure *configure); 43 | void destroy_xdg_toplevel(struct wlr_xdg_surface *surface); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /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 | struct wl_display *display); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /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 | struct wlr_backend { 18 | const struct wlr_backend_impl *impl; 19 | 20 | struct { 21 | /** Raised when destroyed, passed the wlr_backend reference */ 22 | struct wl_signal destroy; 23 | /** Raised when new inputs are added, passed the wlr_input_device */ 24 | struct wl_signal new_input; 25 | /** Raised when new outputs are added, passed the wlr_output */ 26 | struct wl_signal new_output; 27 | } events; 28 | 29 | // Private state 30 | 31 | bool has_own_renderer; 32 | struct wlr_renderer *renderer; 33 | struct wlr_allocator *allocator; 34 | }; 35 | 36 | /** 37 | * Automatically initializes the most suitable backend given the environment. 38 | * Will always return a multibackend. The backend is created but not started. 39 | * Returns NULL on failure. 40 | */ 41 | struct wlr_backend *wlr_backend_autocreate(struct wl_display *display); 42 | /** 43 | * Start the backend. This may signal new_input or new_output immediately, but 44 | * may also wait until the display's event loop begins. Returns false on 45 | * failure. 46 | */ 47 | bool wlr_backend_start(struct wlr_backend *backend); 48 | /** 49 | * Destroy the backend and clean up all of its resources. Normally called 50 | * automatically when the wl_display is destroyed. 51 | */ 52 | void wlr_backend_destroy(struct wlr_backend *backend); 53 | /** 54 | * Obtains the wlr_renderer reference this backend is using. 55 | */ 56 | struct wlr_renderer *wlr_backend_get_renderer(struct wlr_backend *backend); 57 | /** 58 | * Obtains the wlr_session reference from this backend if there is any. 59 | * Might return NULL for backends that don't use a session. 60 | */ 61 | struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend); 62 | /** 63 | * Returns the clock used by the backend for presentation feedback. 64 | */ 65 | clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend); 66 | /** 67 | * Returns the DRM node file descriptor used by the backend's underlying 68 | * platform. Can be used by consumers for additional rendering operations. 69 | * The consumer must not close the file descriptor since the backend continues 70 | * to have ownership of it. 71 | */ 72 | int wlr_backend_get_drm_fd(struct wlr_backend *backend); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /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 | /** 18 | * Creates a DRM backend using the specified GPU file descriptor (typically from 19 | * a device node in /dev/dri). 20 | * 21 | * To slave this to another DRM backend, pass it as the parent (which _must_ be 22 | * a DRM backend, other kinds of backends raise SIGABRT). 23 | */ 24 | struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, 25 | struct wlr_session *session, struct wlr_device *dev, 26 | struct wlr_backend *parent); 27 | 28 | bool wlr_backend_is_drm(struct wlr_backend *backend); 29 | bool wlr_output_is_drm(struct wlr_output *output); 30 | 31 | /** 32 | * Get the KMS connector object ID. 33 | */ 34 | uint32_t wlr_drm_connector_get_id(struct wlr_output *output); 35 | 36 | /** 37 | * Tries to open non-master DRM FD. The compositor must not call `drmSetMaster` 38 | * on the returned FD. 39 | * Returns a valid opened DRM FD, or -1 on error. 40 | */ 41 | int wlr_drm_backend_get_non_master_fd(struct wlr_backend *backend); 42 | 43 | /** 44 | * Leases a given output to the caller. The output must be from the associated 45 | * DRM backend. 46 | * Returns a valid opened DRM FD or -1 on error. 47 | */ 48 | int wlr_drm_create_lease(struct wlr_output **outputs, size_t n_outputs, 49 | uint32_t *lessee_id); 50 | 51 | /** 52 | * Terminates a given lease. The output will be owned again by the backend 53 | */ 54 | bool wlr_drm_backend_terminate_lease(struct wlr_backend *backend, 55 | uint32_t lessee_id); 56 | 57 | /** 58 | * Add mode to the list of available modes 59 | */ 60 | typedef struct _drmModeModeInfo drmModeModeInfo; 61 | struct wlr_output_mode *wlr_drm_connector_add_mode(struct wlr_output *output, 62 | const drmModeModeInfo *mode); 63 | 64 | /** 65 | * Get the connector's panel orientation. 66 | * 67 | * On some devices the panel is mounted in the casing in such a way that the 68 | * top side of the panel does not match with the top side of the device. This 69 | * function returns the output transform which needs to be applied to compensate 70 | * for this. 71 | */ 72 | enum wl_output_transform wlr_drm_connector_get_panel_orientation( 73 | struct wlr_output *output); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /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 | #include 15 | 16 | /** 17 | * Creates a headless backend. A headless backend has no outputs or inputs by 18 | * default. 19 | */ 20 | struct wlr_backend *wlr_headless_backend_create(struct wl_display *display); 21 | /** 22 | * Creates a headless backend with an existing renderer. 23 | */ 24 | struct wlr_backend *wlr_headless_backend_create_with_renderer( 25 | struct wl_display *display, struct wlr_renderer *renderer); 26 | /** 27 | * Create a new headless output backed by an in-memory EGL framebuffer. You can 28 | * read pixels from this framebuffer via wlr_renderer_read_pixels but it is 29 | * otherwise not displayed. 30 | */ 31 | struct wlr_output *wlr_headless_add_output(struct wlr_backend *backend, 32 | unsigned int width, unsigned int height); 33 | /** 34 | * Creates a new input device. The caller is responsible for manually raising 35 | * any event signals on the new input device if it wants to simulate input 36 | * events. 37 | */ 38 | struct wlr_input_device *wlr_headless_add_input_device( 39 | struct wlr_backend *backend, enum wlr_input_device_type type); 40 | bool wlr_backend_is_headless(struct wlr_backend *backend); 41 | bool wlr_input_device_is_headless(struct wlr_input_device *device); 42 | bool wlr_output_is_headless(struct wlr_output *output); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /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_renderer *(*get_renderer)(struct wlr_backend *backend); 20 | struct wlr_session *(*get_session)(struct wlr_backend *backend); 21 | clockid_t (*get_presentation_clock)(struct wlr_backend *backend); 22 | int (*get_drm_fd)(struct wlr_backend *backend); 23 | uint32_t (*get_buffer_caps)(struct wlr_backend *backend); 24 | }; 25 | 26 | /** 27 | * Initializes common state on a wlr_backend and sets the implementation to the 28 | * provided wlr_backend_impl reference. 29 | */ 30 | void wlr_backend_init(struct wlr_backend *backend, 31 | const struct wlr_backend_impl *impl); 32 | /** 33 | * Emit the destroy event and clean up common backend state. 34 | */ 35 | void wlr_backend_finish(struct wlr_backend *backend); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /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 | #include 17 | 18 | struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display, 19 | struct wlr_session *session); 20 | /** Gets the underlying libinput_device handle for the given wlr_input_device */ 21 | struct libinput_device *wlr_libinput_get_device_handle( 22 | struct wlr_input_device *dev); 23 | 24 | bool wlr_backend_is_libinput(struct wlr_backend *backend); 25 | bool wlr_input_device_is_libinput(struct wlr_input_device *device); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /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/noop.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_NOOP_H 10 | #define WLR_BACKEND_NOOP_H 11 | 12 | #include 13 | #include 14 | 15 | /** 16 | * Creates a noop backend. Noop backends do not have a framebuffer and are not 17 | * capable of rendering anything. They are useful for when there's no real 18 | * outputs connected; you can stash your views on a noop output until an output 19 | * is connected. 20 | */ 21 | struct wlr_backend *wlr_noop_backend_create(struct wl_display *display); 22 | 23 | /** 24 | * Create a new noop output. 25 | */ 26 | struct wlr_output *wlr_noop_add_output(struct wlr_backend *backend); 27 | 28 | bool wlr_backend_is_noop(struct wlr_backend *backend); 29 | bool wlr_output_is_noop(struct wlr_output *output); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /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 | #include 9 | 10 | /** 11 | * Creates a new wlr_wl_backend. This backend will be created with no outputs; 12 | * you must use wlr_wl_output_create to add them. 13 | * 14 | * The `remote` argument is the name of the host compositor wayland socket. Set 15 | * to NULL for the default behaviour (WAYLAND_DISPLAY env variable or wayland-0 16 | * default) 17 | */ 18 | struct wlr_backend *wlr_wl_backend_create(struct wl_display *display, 19 | const char *remote); 20 | 21 | /** 22 | * Returns the remote wl_display used by the Wayland backend. 23 | */ 24 | struct wl_display *wlr_wl_backend_get_remote_display(struct wlr_backend *backend); 25 | 26 | /** 27 | * Adds a new output to this backend. You may remove outputs by destroying them. 28 | * Note that if called before initializing the backend, this will return NULL 29 | * and your outputs will be created during initialization (and given to you via 30 | * the output_add signal). 31 | */ 32 | struct wlr_output *wlr_wl_output_create(struct wlr_backend *backend); 33 | 34 | /** 35 | * True if the given backend is a wlr_wl_backend. 36 | */ 37 | bool wlr_backend_is_wl(struct wlr_backend *backend); 38 | 39 | /** 40 | * True if the given input device is a wlr_wl_input_device. 41 | */ 42 | bool wlr_input_device_is_wl(struct wlr_input_device *device); 43 | 44 | /** 45 | * True if the given output is a wlr_wl_output. 46 | */ 47 | bool wlr_output_is_wl(struct wlr_output *output); 48 | 49 | /** 50 | * Sets the title of a wlr_output which is a Wayland window. 51 | */ 52 | void wlr_wl_output_set_title(struct wlr_output *output, const char *title); 53 | 54 | /** 55 | * Returns the remote wl_surface used by the Wayland output. 56 | */ 57 | struct wl_surface *wlr_wl_output_get_surface(struct wlr_output *output); 58 | 59 | /** 60 | * Returns the remote wl_seat for a Wayland input device. 61 | */ 62 | struct wl_seat *wlr_wl_input_device_get_seat(struct wlr_input_device *dev); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /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 | #include 11 | 12 | /** 13 | * Creates a new wlr_x11_backend. This backend will be created with no outputs; 14 | * you must use wlr_x11_output_create to add them. 15 | * 16 | * The `x11_display` argument is the name of the X Display socket. Set 17 | * to NULL for the default behaviour of XOpenDisplay. 18 | */ 19 | struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, 20 | const char *x11_display); 21 | 22 | /** 23 | * Adds a new output to this backend. You may remove outputs by destroying them. 24 | * Note that if called before initializing the backend, this will return NULL 25 | * and your outputs will be created during initialization (and given to you via 26 | * the output_add signal). 27 | */ 28 | struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend); 29 | 30 | /** 31 | * True if the given backend is a wlr_x11_backend. 32 | */ 33 | bool wlr_backend_is_x11(struct wlr_backend *backend); 34 | 35 | /** 36 | * True if the given input device is a wlr_x11_input_device. 37 | */ 38 | bool wlr_input_device_is_x11(struct wlr_input_device *device); 39 | 40 | /** 41 | * True if the given output is a wlr_x11_output. 42 | */ 43 | bool wlr_output_is_x11(struct wlr_output *output); 44 | 45 | /** 46 | * Sets the title of a wlr_output which is an X11 window. 47 | */ 48 | void wlr_x11_output_set_title(struct wlr_output *output, const char *title); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /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 | 10 | #mesondefine WLR_HAS_VULKAN_RENDERER 11 | 12 | #mesondefine WLR_HAS_XWAYLAND 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/wlr/interfaces/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_INTERFACES_WLR_INPUT_DEVICE_H 10 | #define WLR_INTERFACES_WLR_INPUT_DEVICE_H 11 | 12 | #include 13 | 14 | struct wlr_input_device_impl { 15 | void (*destroy)(struct wlr_input_device *wlr_device); 16 | }; 17 | 18 | void wlr_input_device_init( 19 | struct wlr_input_device *wlr_device, 20 | enum wlr_input_device_type type, 21 | const struct wlr_input_device_impl *impl, 22 | const char *name, int vendor, int product); 23 | void wlr_input_device_destroy(struct wlr_input_device *dev); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /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 | void (*destroy)(struct wlr_keyboard *keyboard); 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); 22 | void wlr_keyboard_destroy(struct wlr_keyboard *keyboard); 23 | void wlr_keyboard_notify_key(struct wlr_keyboard *keyboard, 24 | struct wlr_event_keyboard_key *event); 25 | void wlr_keyboard_notify_modifiers(struct wlr_keyboard *keyboard, 26 | uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, 27 | uint32_t group); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /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 | void (*destroy)(struct wlr_pointer *pointer); 16 | }; 17 | 18 | void wlr_pointer_init(struct wlr_pointer *pointer, 19 | const struct wlr_pointer_impl *impl); 20 | void wlr_pointer_destroy(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 | void (*destroy)(struct wlr_switch *switch_device); 16 | }; 17 | 18 | void wlr_switch_init(struct wlr_switch *switch_device, 19 | struct wlr_switch_impl *impl); 20 | void wlr_switch_destroy(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 | void (*destroy)(struct wlr_tablet_pad *pad); 16 | }; 17 | 18 | void wlr_tablet_pad_init(struct wlr_tablet_pad *pad, 19 | struct wlr_tablet_pad_impl *impl); 20 | void wlr_tablet_pad_destroy(struct wlr_tablet_pad *pad); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /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 | void (*destroy)(struct wlr_tablet *tablet); 16 | }; 17 | 18 | void wlr_tablet_init(struct wlr_tablet *tablet, 19 | const struct wlr_tablet_impl *impl); 20 | void wlr_tablet_destroy(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 | void (*destroy)(struct wlr_touch *touch); 16 | }; 17 | 18 | void wlr_touch_init(struct wlr_touch *touch, 19 | const struct wlr_touch_impl *impl); 20 | void wlr_touch_destroy(struct wlr_touch *touch); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/wlr/meson.build: -------------------------------------------------------------------------------- 1 | version_array = meson.project_version().split('.') 2 | version_data = configuration_data() 3 | version_data.set_quoted('WLR_VERSION_STR', meson.project_version()) 4 | version_data.set('WLR_VERSION_MAJOR', version_array[0]) 5 | version_data.set('WLR_VERSION_MINOR', version_array[1]) 6 | version_data.set('WLR_VERSION_MICRO', version_array[2]) 7 | 8 | conf_data = configuration_data() 9 | foreach name, have : features 10 | conf_data.set10('WLR_HAS_' + name.underscorify().to_upper(), have) 11 | endforeach 12 | 13 | conf_h = configure_file( 14 | input: 'config.h.in', 15 | output: 'config.h', 16 | configuration: conf_data, 17 | ) 18 | ver_h = configure_file( 19 | input: 'version.h.in', 20 | output: 'version.h', 21 | configuration: version_data, 22 | ) 23 | 24 | install_headers(conf_h, ver_h, subdir: 'wlr') 25 | -------------------------------------------------------------------------------- /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 | enum wlr_dmabuf_attributes_flags { 18 | WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT = 1 << 0, 19 | WLR_DMABUF_ATTRIBUTES_FLAGS_INTERLACED = 1 << 1, 20 | WLR_DMABUF_ATTRIBUTES_FLAGS_BOTTOM_FIRST = 1 << 2, 21 | }; 22 | 23 | struct wlr_dmabuf_attributes { 24 | int32_t width, height; 25 | uint32_t format; 26 | uint32_t flags; // enum wlr_dmabuf_attributes_flags 27 | uint64_t modifier; 28 | 29 | int n_planes; 30 | uint32_t offset[WLR_DMABUF_MAX_PLANES]; 31 | uint32_t stride[WLR_DMABUF_MAX_PLANES]; 32 | int fd[WLR_DMABUF_MAX_PLANES]; 33 | }; 34 | 35 | /** 36 | * Closes all file descriptors in the DMA-BUF attributes. 37 | */ 38 | void wlr_dmabuf_attributes_finish(struct wlr_dmabuf_attributes *attribs); 39 | /** 40 | * Clones the DMA-BUF attributes. 41 | */ 42 | bool wlr_dmabuf_attributes_copy(struct wlr_dmabuf_attributes *dst, 43 | const struct wlr_dmabuf_attributes *src); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /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 | struct wlr_drm_format { 9 | uint32_t format; 10 | size_t len, cap; 11 | uint64_t modifiers[]; 12 | }; 13 | 14 | struct wlr_drm_format_set { 15 | size_t len, cap; 16 | struct wlr_drm_format **formats; 17 | }; 18 | 19 | void wlr_drm_format_set_finish(struct wlr_drm_format_set *set); 20 | 21 | const struct wlr_drm_format *wlr_drm_format_set_get( 22 | const struct wlr_drm_format_set *set, uint32_t format); 23 | 24 | bool wlr_drm_format_set_has(const struct wlr_drm_format_set *set, 25 | uint32_t format, uint64_t modifier); 26 | 27 | bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format, 28 | uint64_t modifier); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /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 MESA_EGL_NO_X11_HEADERS 13 | #define MESA_EGL_NO_X11_HEADERS 14 | #endif 15 | #ifndef EGL_NO_X11 16 | #define EGL_NO_X11 17 | #endif 18 | #ifndef EGL_NO_PLATFORM_SPECIFIC_TYPES 19 | #define EGL_NO_PLATFORM_SPECIFIC_TYPES 20 | #endif 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | struct wlr_egl { 33 | EGLDisplay display; 34 | EGLContext context; 35 | EGLDeviceEXT device; // may be EGL_NO_DEVICE_EXT 36 | struct gbm_device *gbm_device; 37 | 38 | struct { 39 | // Display extensions 40 | bool KHR_image_base; 41 | bool EXT_image_dma_buf_import; 42 | bool EXT_image_dma_buf_import_modifiers; 43 | 44 | // Device extensions 45 | bool EXT_device_drm; 46 | bool EXT_device_drm_render_node; 47 | 48 | // Client extensions 49 | bool EXT_device_query; 50 | bool KHR_platform_gbm; 51 | bool EXT_platform_device; 52 | } exts; 53 | 54 | struct { 55 | PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT; 56 | PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; 57 | PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; 58 | PFNEGLQUERYWAYLANDBUFFERWL eglQueryWaylandBufferWL; 59 | PFNEGLQUERYDMABUFFORMATSEXTPROC eglQueryDmaBufFormatsEXT; 60 | PFNEGLQUERYDMABUFMODIFIERSEXTPROC eglQueryDmaBufModifiersEXT; 61 | PFNEGLDEBUGMESSAGECONTROLKHRPROC eglDebugMessageControlKHR; 62 | PFNEGLQUERYDISPLAYATTRIBEXTPROC eglQueryDisplayAttribEXT; 63 | PFNEGLQUERYDEVICESTRINGEXTPROC eglQueryDeviceStringEXT; 64 | PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT; 65 | } procs; 66 | 67 | struct wlr_drm_format_set dmabuf_texture_formats; 68 | struct wlr_drm_format_set dmabuf_render_formats; 69 | }; 70 | 71 | /** 72 | * Make the EGL context current. 73 | * 74 | * Callers are expected to clear the current context when they are done by 75 | * calling wlr_egl_unset_current. 76 | */ 77 | bool wlr_egl_make_current(struct wlr_egl *egl); 78 | 79 | bool wlr_egl_unset_current(struct wlr_egl *egl); 80 | 81 | bool wlr_egl_is_current(struct wlr_egl *egl); 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /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 inverted_y; 34 | bool has_alpha; 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/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_RENDER_INTERFACE_H 10 | #define WLR_RENDER_INTERFACE_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | struct wlr_box; 20 | struct wlr_fbox; 21 | 22 | struct wlr_renderer_impl { 23 | bool (*bind_buffer)(struct wlr_renderer *renderer, 24 | struct wlr_buffer *buffer); 25 | void (*begin)(struct wlr_renderer *renderer, uint32_t width, 26 | uint32_t height); 27 | void (*end)(struct wlr_renderer *renderer); 28 | void (*clear)(struct wlr_renderer *renderer, const float color[static 4]); 29 | void (*scissor)(struct wlr_renderer *renderer, struct wlr_box *box); 30 | bool (*render_subtexture_with_matrix)(struct wlr_renderer *renderer, 31 | struct wlr_texture *texture, const struct wlr_fbox *box, 32 | const float matrix[static 9], float alpha); 33 | void (*render_quad_with_matrix)(struct wlr_renderer *renderer, 34 | const float color[static 4], const float matrix[static 9]); 35 | const uint32_t *(*get_shm_texture_formats)( 36 | struct wlr_renderer *renderer, size_t *len); 37 | const struct wlr_drm_format_set *(*get_dmabuf_texture_formats)( 38 | struct wlr_renderer *renderer); 39 | const struct wlr_drm_format_set *(*get_render_formats)( 40 | struct wlr_renderer *renderer); 41 | uint32_t (*preferred_read_format)(struct wlr_renderer *renderer); 42 | bool (*read_pixels)(struct wlr_renderer *renderer, uint32_t fmt, 43 | uint32_t *flags, uint32_t stride, uint32_t width, uint32_t height, 44 | uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, 45 | void *data); 46 | void (*destroy)(struct wlr_renderer *renderer); 47 | int (*get_drm_fd)(struct wlr_renderer *renderer); 48 | uint32_t (*get_render_buffer_caps)(struct wlr_renderer *renderer); 49 | struct wlr_texture *(*texture_from_buffer)(struct wlr_renderer *renderer, 50 | struct wlr_buffer *buffer); 51 | }; 52 | 53 | void wlr_renderer_init(struct wlr_renderer *renderer, 54 | const struct wlr_renderer_impl *impl); 55 | 56 | struct wlr_texture_impl { 57 | bool (*is_opaque)(struct wlr_texture *texture); 58 | bool (*write_pixels)(struct wlr_texture *texture, 59 | uint32_t stride, uint32_t width, uint32_t height, 60 | uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, 61 | const void *data); 62 | void (*destroy)(struct wlr_texture *texture); 63 | }; 64 | 65 | void wlr_texture_init(struct wlr_texture *texture, 66 | const struct wlr_texture_impl *impl, uint32_t width, uint32_t height); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /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 | 16 | struct wlr_buffer; 17 | struct wlr_renderer; 18 | struct wlr_texture_impl; 19 | 20 | struct wlr_texture { 21 | const struct wlr_texture_impl *impl; 22 | uint32_t width, height; 23 | }; 24 | 25 | /** 26 | * Create a new texture from raw pixel data. `stride` is in bytes. The returned 27 | * texture is mutable. 28 | * 29 | * Should not be called in a rendering block like renderer_begin()/end() or 30 | * between attaching a renderer to an output and committing it. 31 | */ 32 | struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer, 33 | uint32_t fmt, uint32_t stride, uint32_t width, uint32_t height, 34 | const void *data); 35 | 36 | /** 37 | * Create a new texture from a wl_drm resource. The returned texture is 38 | * immutable. 39 | * 40 | * Should not be called in a rendering block like renderer_begin()/end() or 41 | * between attaching a renderer to an output and committing it. 42 | */ 43 | struct wlr_texture *wlr_texture_from_wl_drm(struct wlr_renderer *renderer, 44 | struct wl_resource *data); 45 | 46 | /** 47 | * Create a new texture from a DMA-BUF. The returned texture is immutable. 48 | * 49 | * Should not be called in a rendering block like renderer_begin()/end() or 50 | * between attaching a renderer to an output and committing it. 51 | */ 52 | struct wlr_texture *wlr_texture_from_dmabuf(struct wlr_renderer *renderer, 53 | struct wlr_dmabuf_attributes *attribs); 54 | 55 | /** 56 | * Returns true if this texture is using a fully opaque format. 57 | */ 58 | bool wlr_texture_is_opaque(struct wlr_texture *texture); 59 | 60 | /** 61 | * Update a texture with raw pixels. The texture must be mutable, and the input 62 | * data must have the same pixel format that the texture was created with. 63 | * 64 | * Should not be called in a rendering block like renderer_begin()/end() or 65 | * between attaching a renderer to an output and committing it. 66 | */ 67 | bool wlr_texture_write_pixels(struct wlr_texture *texture, 68 | uint32_t stride, uint32_t width, uint32_t height, 69 | uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, 70 | const void *data); 71 | 72 | /** 73 | * Destroys this wlr_texture. 74 | */ 75 | void wlr_texture_destroy(struct wlr_texture *texture); 76 | 77 | /** 78 | * Create a new texture from a buffer. 79 | * 80 | * Should not be called in a rendering block like renderer_begin()/end() or 81 | * between attaching a renderer to an output and committing it. 82 | */ 83 | struct wlr_texture *wlr_texture_from_buffer(struct wlr_renderer *renderer, 84 | struct wlr_buffer *buffer); 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_box.h: -------------------------------------------------------------------------------- 1 | #ifndef WLR_TYPES_WLR_BOX_H 2 | #define WLR_TYPES_WLR_BOX_H 3 | 4 | #warning "wlr_box has been moved to wlr/util/box.h" 5 | #include 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /include/wlr/types/wlr_compositor.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_COMPOSITOR_H 10 | #define WLR_TYPES_WLR_COMPOSITOR_H 11 | 12 | #include 13 | #include 14 | 15 | struct wlr_surface; 16 | 17 | struct wlr_subcompositor { 18 | struct wl_global *global; 19 | }; 20 | 21 | struct wlr_compositor { 22 | struct wl_global *global; 23 | struct wlr_renderer *renderer; 24 | 25 | struct wlr_subcompositor subcompositor; 26 | 27 | struct wl_listener display_destroy; 28 | 29 | struct { 30 | struct wl_signal new_surface; 31 | struct wl_signal destroy; 32 | } events; 33 | }; 34 | 35 | struct wlr_compositor *wlr_compositor_create(struct wl_display *display, 36 | struct wlr_renderer *renderer); 37 | 38 | bool wlr_surface_is_subsurface(struct wlr_surface *surface); 39 | 40 | /** 41 | * Get a subsurface from a surface. Can return NULL if the subsurface has been 42 | * destroyed. 43 | */ 44 | struct wlr_subsurface *wlr_subsurface_from_wlr_surface( 45 | struct wlr_surface *surface); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /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 | // 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_impl; 29 | 30 | struct wlr_input_device { 31 | const struct wlr_input_device_impl *impl; 32 | 33 | enum wlr_input_device_type type; 34 | unsigned int vendor, product; 35 | char *name; 36 | // Or 0 if not applicable to this device 37 | double width_mm, height_mm; 38 | char *output_name; 39 | 40 | /* wlr_input_device.type determines which of these is valid */ 41 | union { 42 | void *_device; 43 | struct wlr_keyboard *keyboard; 44 | struct wlr_pointer *pointer; 45 | struct wlr_switch *switch_device; 46 | struct wlr_touch *touch; 47 | struct wlr_tablet *tablet; 48 | struct wlr_tablet_pad *tablet_pad; 49 | }; 50 | 51 | struct { 52 | struct wl_signal destroy; 53 | } events; 54 | 55 | void *data; 56 | 57 | struct wl_list link; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /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 | #include 15 | 16 | struct wlr_keyboard_group { 17 | struct wlr_keyboard keyboard; 18 | struct wlr_input_device *input_device; 19 | struct wl_list devices; // keyboard_group_device::link 20 | struct wl_list keys; // keyboard_group_key::link 21 | 22 | struct { 23 | /* 24 | * Sent when a keyboard has entered the group with keys currently 25 | * pressed that are not pressed by any other keyboard in the group. The 26 | * data for this signal will be a wl_array containing the key codes. 27 | * This should be used to update the compositor's internal state. 28 | * Bindings should not be triggered based off of these key codes and 29 | * they should also not notify any surfaces of the key press. 30 | */ 31 | struct wl_signal enter; 32 | 33 | /* 34 | * Sent when a keyboard has left the group with keys currently pressed 35 | * that are not pressed by any other keyboard in the group. The data for 36 | * this signal will be a wl_array containing the key codes. This should 37 | * be used to update the compositor's internal state. Bindings should 38 | * not be triggered based off of these key codes. Additionally, surfaces 39 | * should only be notified if they received a corresponding key press 40 | * for the key code. 41 | */ 42 | struct wl_signal leave; 43 | } events; 44 | 45 | void *data; 46 | }; 47 | 48 | struct wlr_keyboard_group *wlr_keyboard_group_create(void); 49 | 50 | struct wlr_keyboard_group *wlr_keyboard_group_from_wlr_keyboard( 51 | struct wlr_keyboard *keyboard); 52 | 53 | bool wlr_keyboard_group_add_keyboard(struct wlr_keyboard_group *group, 54 | struct wlr_keyboard *keyboard); 55 | 56 | void wlr_keyboard_group_remove_keyboard(struct wlr_keyboard_group *group, 57 | struct wlr_keyboard *keyboard); 58 | 59 | void wlr_keyboard_group_destroy(struct wlr_keyboard_group *group); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /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 | 17 | struct wlr_dmabuf_v1_buffer { 18 | struct wlr_buffer base; 19 | 20 | struct wl_resource *resource; // can be NULL if the client destroyed it 21 | struct wlr_dmabuf_attributes attributes; 22 | 23 | struct wl_listener release; 24 | }; 25 | 26 | /** 27 | * Returns true if the given resource was created via the linux-dmabuf 28 | * buffer protocol, false otherwise 29 | */ 30 | bool wlr_dmabuf_v1_resource_is_buffer(struct wl_resource *buffer_resource); 31 | 32 | /** 33 | * Returns the wlr_dmabuf_buffer if the given resource was created 34 | * via the linux-dmabuf buffer protocol 35 | */ 36 | struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_from_buffer_resource( 37 | struct wl_resource *buffer_resource); 38 | 39 | struct wlr_linux_buffer_params_v1 { 40 | struct wl_resource *resource; 41 | struct wlr_linux_dmabuf_v1 *linux_dmabuf; 42 | struct wlr_dmabuf_attributes attributes; 43 | bool has_modifier; 44 | }; 45 | 46 | /* the protocol interface */ 47 | struct wlr_linux_dmabuf_v1 { 48 | struct wl_global *global; 49 | struct wlr_renderer *renderer; 50 | 51 | struct { 52 | struct wl_signal destroy; 53 | } events; 54 | 55 | struct wl_listener display_destroy; 56 | struct wl_listener renderer_destroy; 57 | }; 58 | 59 | /** 60 | * Create linux-dmabuf interface 61 | */ 62 | struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *display, 63 | struct wlr_renderer *renderer); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /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 | /** Writes a 2D orthographic projection matrix to mat of (width, height) with a 47 | * specified wl_output_transform. 48 | * 49 | * Deprecated: this function is deprecated and will be removed in a future 50 | * version of wlroots. */ 51 | void wlr_matrix_projection(float mat[static 9], int width, int height, 52 | enum wl_output_transform transform); 53 | 54 | /** Shortcut for the various matrix operations involved in projecting the 55 | * specified wlr_box onto a given orthographic projection with a given 56 | * rotation. The result is written to mat, which can be applied to each 57 | * coordinate of the box to get a new coordinate from [-1,1]. */ 58 | void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box, 59 | enum wl_output_transform transform, float rotation, 60 | const float projection[static 9]); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /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; // 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; 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 | #include 15 | 16 | struct wlr_pointer_gestures_v1 { 17 | struct wl_global *global; 18 | struct wl_list swipes; // wl_resource_get_link 19 | struct wl_list pinches; // wl_resource_get_link 20 | struct wl_list holds; // wl_resource_get_link 21 | 22 | struct wl_listener display_destroy; 23 | 24 | struct { 25 | struct wl_signal destroy; 26 | } events; 27 | 28 | void *data; 29 | }; 30 | 31 | struct wlr_pointer_gestures_v1 *wlr_pointer_gestures_v1_create( 32 | struct wl_display *display); 33 | 34 | void wlr_pointer_gestures_v1_send_swipe_begin( 35 | struct wlr_pointer_gestures_v1 *gestures, 36 | struct wlr_seat *seat, 37 | uint32_t time_msec, 38 | uint32_t fingers); 39 | void wlr_pointer_gestures_v1_send_swipe_update( 40 | struct wlr_pointer_gestures_v1 *gestures, 41 | struct wlr_seat *seat, 42 | uint32_t time_msec, 43 | double dx, 44 | double dy); 45 | void wlr_pointer_gestures_v1_send_swipe_end( 46 | struct wlr_pointer_gestures_v1 *gestures, 47 | struct wlr_seat *seat, 48 | uint32_t time_msec, 49 | bool cancelled); 50 | 51 | void wlr_pointer_gestures_v1_send_pinch_begin( 52 | struct wlr_pointer_gestures_v1 *gestures, 53 | struct wlr_seat *seat, 54 | uint32_t time_msec, 55 | uint32_t fingers); 56 | void wlr_pointer_gestures_v1_send_pinch_update( 57 | struct wlr_pointer_gestures_v1 *gestures, 58 | struct wlr_seat *seat, 59 | uint32_t time_msec, 60 | double dx, 61 | double dy, 62 | double scale, 63 | double rotation); 64 | void wlr_pointer_gestures_v1_send_pinch_end( 65 | struct wlr_pointer_gestures_v1 *gestures, 66 | struct wlr_seat *seat, 67 | uint32_t time_msec, 68 | bool cancelled); 69 | 70 | void wlr_pointer_gestures_v1_send_hold_begin( 71 | struct wlr_pointer_gestures_v1 *gestures, 72 | struct wlr_seat *seat, 73 | uint32_t time_msec, 74 | uint32_t fingers); 75 | void wlr_pointer_gestures_v1_send_hold_end( 76 | struct wlr_pointer_gestures_v1 *gestures, 77 | struct wlr_seat *seat, 78 | uint32_t time_msec, 79 | bool cancelled); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /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; // 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; 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_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_switch_impl *impl; 20 | 21 | struct { 22 | struct wl_signal toggle; 23 | } events; 24 | 25 | void *data; 26 | }; 27 | 28 | enum wlr_switch_type { 29 | WLR_SWITCH_TYPE_LID = 1, 30 | WLR_SWITCH_TYPE_TABLET_MODE, 31 | }; 32 | 33 | enum wlr_switch_state { 34 | WLR_SWITCH_STATE_OFF = 0, 35 | WLR_SWITCH_STATE_ON, 36 | WLR_SWITCH_STATE_TOGGLE 37 | }; 38 | 39 | struct wlr_event_switch_toggle { 40 | struct wlr_input_device *device; 41 | uint32_t time_msec; 42 | enum wlr_switch_type switch_type; 43 | enum wlr_switch_state switch_state; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /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_tablet_pad_impl *impl; 26 | 27 | struct { 28 | struct wl_signal button; 29 | struct wl_signal ring; 30 | struct wl_signal strip; 31 | struct wl_signal attach_tablet; //struct wlr_tablet_tool 32 | } events; 33 | 34 | size_t button_count; 35 | size_t ring_count; 36 | size_t strip_count; 37 | 38 | struct wl_list groups; // wlr_tablet_pad_group::link 39 | struct wl_array paths; // char * 40 | 41 | void *data; 42 | }; 43 | 44 | struct wlr_tablet_pad_group { 45 | struct wl_list link; 46 | 47 | size_t button_count; 48 | unsigned int *buttons; 49 | 50 | size_t strip_count; 51 | unsigned int *strips; 52 | 53 | size_t ring_count; 54 | unsigned int *rings; 55 | 56 | unsigned int mode_count; 57 | }; 58 | 59 | struct wlr_event_tablet_pad_button { 60 | uint32_t time_msec; 61 | uint32_t button; 62 | enum wlr_button_state state; 63 | unsigned int mode; 64 | unsigned int group; 65 | }; 66 | 67 | enum wlr_tablet_pad_ring_source { 68 | WLR_TABLET_PAD_RING_SOURCE_UNKNOWN, 69 | WLR_TABLET_PAD_RING_SOURCE_FINGER, 70 | }; 71 | 72 | struct wlr_event_tablet_pad_ring { 73 | uint32_t time_msec; 74 | enum wlr_tablet_pad_ring_source source; 75 | uint32_t ring; 76 | double position; 77 | unsigned int mode; 78 | }; 79 | 80 | enum wlr_tablet_pad_strip_source { 81 | WLR_TABLET_PAD_STRIP_SOURCE_UNKNOWN, 82 | WLR_TABLET_PAD_STRIP_SOURCE_FINGER, 83 | }; 84 | 85 | struct wlr_event_tablet_pad_strip { 86 | uint32_t time_msec; 87 | enum wlr_tablet_pad_strip_source source; 88 | uint32_t strip; 89 | double position; 90 | unsigned int mode; 91 | }; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /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 | 15 | struct wlr_touch_impl; 16 | 17 | struct wlr_touch { 18 | const struct wlr_touch_impl *impl; 19 | 20 | struct { 21 | struct wl_signal down; // struct wlr_event_touch_down 22 | struct wl_signal up; // struct wlr_event_touch_up 23 | struct wl_signal motion; // struct wlr_event_touch_motion 24 | struct wl_signal cancel; // struct wlr_event_touch_cancel 25 | struct wl_signal frame; 26 | } events; 27 | 28 | void *data; 29 | }; 30 | 31 | struct wlr_event_touch_down { 32 | struct wlr_input_device *device; 33 | uint32_t time_msec; 34 | int32_t touch_id; 35 | // From 0..1 36 | double x, y; 37 | }; 38 | 39 | struct wlr_event_touch_up { 40 | struct wlr_input_device *device; 41 | uint32_t time_msec; 42 | int32_t touch_id; 43 | }; 44 | 45 | struct wlr_event_touch_motion { 46 | struct wlr_input_device *device; 47 | uint32_t time_msec; 48 | int32_t touch_id; 49 | // From 0..1 50 | double x, y; 51 | }; 52 | 53 | struct wlr_event_touch_cancel { 54 | struct wlr_input_device *device; 55 | uint32_t time_msec; 56 | int32_t touch_id; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /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 | #include 15 | 16 | struct wlr_virtual_keyboard_manager_v1 { 17 | struct wl_global *global; 18 | struct wl_list virtual_keyboards; // struct wlr_virtual_keyboard_v1* 19 | 20 | struct wl_listener display_destroy; 21 | 22 | struct { 23 | struct wl_signal new_virtual_keyboard; // struct wlr_virtual_keyboard_v1* 24 | struct wl_signal destroy; 25 | } events; 26 | }; 27 | 28 | struct wlr_virtual_keyboard_v1 { 29 | struct wlr_input_device input_device; 30 | struct wl_resource *resource; 31 | struct wlr_seat *seat; 32 | bool has_keymap; 33 | 34 | struct wl_list link; 35 | 36 | struct { 37 | struct wl_signal destroy; // struct wlr_virtual_keyboard_v1* 38 | } events; 39 | }; 40 | 41 | struct wlr_virtual_keyboard_manager_v1* wlr_virtual_keyboard_manager_v1_create( 42 | struct wl_display *display); 43 | 44 | struct wlr_virtual_keyboard_v1 *wlr_input_device_get_virtual_keyboard( 45 | struct wlr_input_device *wlr_dev); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /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 | #include 17 | 18 | struct wlr_virtual_pointer_manager_v1 { 19 | struct wl_global *global; 20 | struct wl_list virtual_pointers; // struct wlr_virtual_pointer_v1* 21 | 22 | struct wl_listener display_destroy; 23 | 24 | struct { 25 | struct wl_signal new_virtual_pointer; // struct wlr_virtual_pointer_v1_new_pointer_event* 26 | struct wl_signal destroy; 27 | } events; 28 | }; 29 | 30 | struct wlr_virtual_pointer_v1 { 31 | struct wlr_input_device input_device; 32 | struct wl_resource *resource; 33 | /* Vertical and horizontal */ 34 | struct wlr_event_pointer_axis axis_event[2]; 35 | enum wl_pointer_axis axis; 36 | bool axis_valid[2]; 37 | 38 | struct wl_list link; 39 | 40 | struct { 41 | struct wl_signal destroy; // struct wlr_virtual_pointer_v1* 42 | } events; 43 | }; 44 | 45 | struct wlr_virtual_pointer_v1_new_pointer_event { 46 | struct wlr_virtual_pointer_v1 *new_pointer; 47 | /** Suggested by client; may be NULL. */ 48 | struct wlr_seat *suggested_seat; 49 | struct wlr_output *suggested_output; 50 | }; 51 | 52 | struct wlr_virtual_pointer_manager_v1* wlr_virtual_pointer_manager_v1_create( 53 | struct wl_display *display); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /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 | * wlr_xcursor_manager dynamically loads xcursor themes at sizes necessary for 27 | * 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 wlr_xcursor_manager has not loaded a cursor 55 | * 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 wlr_cursor's cursor image to the specified cursor name for all scale 62 | * factors. wlr_cursor will take over from this point and ensure the correct 63 | * cursor is used on each output, assuming a wlr_output_layout is attached to 64 | * 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_activation_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_ACTIVATION_V1 10 | #define WLR_TYPES_WLR_XDG_ACTIVATION_V1 11 | 12 | #include 13 | 14 | struct wlr_xdg_activation_token_v1 { 15 | struct wlr_xdg_activation_v1 *activation; 16 | // The source surface that created the token. 17 | struct wlr_surface *surface; // can be NULL 18 | struct wlr_seat *seat; // can be NULL 19 | // The serial for the input event that created the token. 20 | uint32_t serial; // invalid if seat is NULL 21 | // The application ID to be activated. This is just a hint. 22 | char *app_id; // can be NULL 23 | struct wl_list link; // wlr_xdg_activation_v1.tokens 24 | 25 | void *data; 26 | 27 | struct { 28 | struct wl_signal destroy; 29 | } events; 30 | 31 | // private state 32 | 33 | char *token; 34 | struct wl_resource *resource; // can be NULL 35 | struct wl_event_source *timeout; // can be NULL 36 | 37 | struct wl_listener seat_destroy; 38 | struct wl_listener surface_destroy; 39 | }; 40 | 41 | struct wlr_xdg_activation_v1 { 42 | uint32_t token_timeout_msec; // token timeout in milliseconds (0 to disable) 43 | 44 | struct wl_list tokens; // wlr_xdg_activation_token_v1.link 45 | 46 | struct { 47 | struct wl_signal destroy; 48 | struct wl_signal request_activate; // wlr_xdg_activation_v1_request_activate_event 49 | } events; 50 | 51 | // private state 52 | 53 | struct wl_display *display; 54 | 55 | struct wl_global *global; 56 | 57 | struct wl_listener display_destroy; 58 | }; 59 | 60 | struct wlr_xdg_activation_v1_request_activate_event { 61 | struct wlr_xdg_activation_v1 *activation; 62 | // The token used to request activation. 63 | struct wlr_xdg_activation_token_v1 *token; 64 | // The surface requesting for activation. 65 | struct wlr_surface *surface; 66 | }; 67 | 68 | struct wlr_xdg_activation_v1 *wlr_xdg_activation_v1_create( 69 | struct wl_display *display); 70 | 71 | struct wlr_xdg_activation_token_v1 *wlr_xdg_activation_token_v1_create( 72 | struct wlr_xdg_activation_v1 *activation); 73 | 74 | void wlr_xdg_activation_token_v1_destroy( 75 | struct wlr_xdg_activation_token_v1 *token); 76 | 77 | struct wlr_xdg_activation_token_v1 *wlr_xdg_activation_v1_find_token( 78 | struct wlr_xdg_activation_v1 *activation, const char *token_str); 79 | 80 | // Get a string suitable for exporting to launched clients 81 | const char *wlr_xdg_activation_token_v1_get_name( 82 | struct wlr_xdg_activation_token_v1 *token); 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /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 | * wlr_xdg_foreign_registry is used for storing a list of exported surfaces with 18 | * 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 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_destroy; 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_destroy; 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 | void (*destroy)(struct wlr_addon *addon); 24 | }; 25 | 26 | struct wlr_addon { 27 | const struct wlr_addon_interface *impl; 28 | // private state 29 | const void *owner; 30 | struct wl_list link; 31 | }; 32 | 33 | void wlr_addon_set_init(struct wlr_addon_set *set); 34 | void wlr_addon_set_finish(struct wlr_addon_set *set); 35 | 36 | void wlr_addon_init(struct wlr_addon *addon, struct wlr_addon_set *set, 37 | const void *owner, const struct wlr_addon_interface *impl); 38 | void wlr_addon_finish(struct wlr_addon *addon); 39 | 40 | struct wlr_addon *wlr_addon_find(struct wlr_addon_set *set, const void *owner, 41 | const struct wlr_addon_interface *impl); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/wlr/util/box.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 | #ifndef WLR_UTIL_BOX_H 16 | #define WLR_UTIL_BOX_H 17 | 18 | #include 19 | #include 20 | 21 | /** 22 | * A box representing a rectangle region in a 2D space. 23 | * 24 | * The x and y coordinates are inclusive, and the width and height lengths are 25 | * exclusive. In other words, the box starts from the coordinates (x, y), and 26 | * goes up to but not including (x + width, y + height) 27 | */ 28 | struct wlr_box { 29 | int x, y; 30 | int width, height; 31 | }; 32 | 33 | /** 34 | * A floating-point box representing a rectangle region in a 2D space. 35 | * 36 | * wlr_fbox has the same semantics as wlr_box 37 | */ 38 | struct wlr_fbox { 39 | double x, y; 40 | double width, height; 41 | }; 42 | 43 | /** 44 | * Finds the closest point within the box bounds 45 | * 46 | * Returns NAN if the box is empty 47 | */ 48 | void wlr_box_closest_point(const struct wlr_box *box, double x, double y, 49 | double *dest_x, double *dest_y); 50 | 51 | /** 52 | * Gives the intersecting box between two wlr_box. 53 | * 54 | * Returns an empty wlr_box if the provided wlr_box don't intersect. 55 | */ 56 | bool wlr_box_intersection(struct wlr_box *dest, const struct wlr_box *box_a, 57 | const struct wlr_box *box_b); 58 | 59 | /** 60 | * Verifies if a point is contained within the bounds of a given wlr_box. 61 | * 62 | * For example: 63 | * - A point at (100, 50) is not contained in the box (0, 0, 100, 50). 64 | * - A point at (10, 10) is contained in the box (10, 0, 50, 50). 65 | */ 66 | bool wlr_box_contains_point(const struct wlr_box *box, double x, double y); 67 | 68 | /** 69 | * Checks whether a box is empty or not. 70 | * 71 | * A wlr_box is considered empty if its width and/or height is zero or negative. 72 | */ 73 | bool wlr_box_empty(const struct wlr_box *box); 74 | 75 | /** 76 | * Transforms a box inside a (0, 0, width, height) box. 77 | */ 78 | void wlr_box_transform(struct wlr_box *dest, const struct wlr_box *box, 79 | enum wl_output_transform transform, int width, int height); 80 | 81 | /** 82 | * Checks whether a box is empty or not. 83 | * 84 | * A wlr_box is considered empty if its width and/or height is zero or negative. 85 | */ 86 | bool wlr_fbox_empty(const struct wlr_fbox *box); 87 | 88 | /** 89 | * Transforms a floating-point box inside a (0, 0, width, height) box. 90 | */ 91 | void wlr_fbox_transform(struct wlr_fbox *dest, const struct wlr_fbox *box, 92 | enum wl_output_transform transform, double width, double height); 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /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 | // Will log all messages less than or equal to `verbosity` 36 | // If `callback` is NULL, wlr will use its default logger. 37 | // The function can be called multiple times to update the verbosity or 38 | // callback function. 39 | void wlr_log_init(enum wlr_log_importance verbosity, wlr_log_func_t callback); 40 | 41 | // Returns the log verbosity provided to wlr_log_init 42 | enum wlr_log_importance wlr_log_get_verbosity(void); 43 | 44 | #ifdef __GNUC__ 45 | #define _WLR_ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end))) 46 | #else 47 | #define _WLR_ATTRIB_PRINTF(start, end) 48 | #endif 49 | 50 | void _wlr_log(enum wlr_log_importance verbosity, const char *format, ...) _WLR_ATTRIB_PRINTF(2, 3); 51 | void _wlr_vlog(enum wlr_log_importance verbosity, const char *format, va_list args) _WLR_ATTRIB_PRINTF(2, 0); 52 | 53 | #ifdef WLR_REL_SRC_DIR 54 | // strip prefix from __FILE__, leaving the path relative to the project root 55 | #define _WLR_FILENAME ((const char *)__FILE__ + sizeof(WLR_REL_SRC_DIR) - 1) 56 | #else 57 | #define _WLR_FILENAME __FILE__ 58 | #endif 59 | 60 | #define wlr_log(verb, fmt, ...) \ 61 | _wlr_log(verb, "[%s:%d] " fmt, _WLR_FILENAME, __LINE__, ##__VA_ARGS__) 62 | 63 | #define wlr_vlog(verb, fmt, args) \ 64 | _wlr_vlog(verb, "[%s:%d] " fmt, _WLR_FILENAME, __LINE__, args) 65 | 66 | #define wlr_log_errno(verb, fmt, ...) \ 67 | wlr_log(verb, fmt ": %s", ##__VA_ARGS__, strerror(errno)) 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /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 | XcursorImages * 58 | XcursorLibraryLoadImages (const char *file, const char *theme, int size); 59 | 60 | void 61 | XcursorImagesDestroy (XcursorImages *images); 62 | 63 | void 64 | xcursor_load_theme(const char *theme, int size, 65 | void (*load_callback)(XcursorImages *, void *), 66 | void *user_data); 67 | #endif 68 | -------------------------------------------------------------------------------- /include/xwayland/meson.build: -------------------------------------------------------------------------------- 1 | have_listenfd = false 2 | if xwayland.found() 3 | xwayland_path = xwayland.get_variable('xwayland') 4 | have_listenfd = xwayland.get_variable('have_listenfd') == 'true' 5 | else 6 | xwayland_path = xwayland_prog.full_path() 7 | endif 8 | 9 | xwayland_config_data = configuration_data() 10 | xwayland_config_data.set_quoted('XWAYLAND_PATH', xwayland_path) 11 | xwayland_config_data.set10('HAVE_XWAYLAND_LISTENFD', have_listenfd) 12 | configure_file( 13 | output: 'config.h', 14 | configuration: xwayland_config_data, 15 | ) 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | wlr_files += files( 2 | 'allocator.c', 3 | 'gbm.c', 4 | 'shm.c', 5 | 'drm_dumb.c', 6 | ) 7 | 8 | has = cc.has_function('gbm_bo_get_fd_for_plane', dependencies: [gbm]) 9 | add_project_arguments('-DHAS_GBM_BO_GET_FD_FOR_PLANE=@0@'.format(has.to_int()), language: 'c') 10 | -------------------------------------------------------------------------------- /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[i]); 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 egl.found()) 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 | "uniform bool invert_y;\n" 32 | "attribute vec2 pos;\n" 33 | "attribute vec2 texcoord;\n" 34 | "varying vec2 v_texcoord;\n" 35 | "\n" 36 | "void main() {\n" 37 | " gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n" 38 | " if (invert_y) {\n" 39 | " v_texcoord = vec2(texcoord.x, 1.0 - texcoord.y);\n" 40 | " } else {\n" 41 | " v_texcoord = texcoord;\n" 42 | " }\n" 43 | "}\n"; 44 | 45 | const GLchar tex_fragment_src_rgba[] = 46 | "precision mediump float;\n" 47 | "varying vec2 v_texcoord;\n" 48 | "uniform sampler2D tex;\n" 49 | "uniform float alpha;\n" 50 | "\n" 51 | "void main() {\n" 52 | " gl_FragColor = texture2D(tex, v_texcoord) * alpha;\n" 53 | "}\n"; 54 | 55 | const GLchar tex_fragment_src_rgbx[] = 56 | "precision mediump float;\n" 57 | "varying vec2 v_texcoord;\n" 58 | "uniform sampler2D tex;\n" 59 | "uniform float alpha;\n" 60 | "\n" 61 | "void main() {\n" 62 | " gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n" 63 | "}\n"; 64 | 65 | const GLchar tex_fragment_src_external[] = 66 | "#extension GL_OES_EGL_image_external : require\n\n" 67 | "precision mediump float;\n" 68 | "varying vec2 v_texcoord;\n" 69 | "uniform samplerExternalOES texture0;\n" 70 | "uniform float alpha;\n" 71 | "\n" 72 | "void main() {\n" 73 | " gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\n" 74 | "}\n"; 75 | -------------------------------------------------------------------------------- /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 | wlr_files += files( 9 | 'dmabuf.c', 10 | 'drm_format_set.c', 11 | 'pixel_format.c', 12 | 'swapchain.c', 13 | 'wlr_renderer.c', 14 | 'wlr_texture.c', 15 | ) 16 | 17 | egl = dependency('egl', required: 'gles2' in renderers) 18 | if egl.found() 19 | wlr_deps += egl 20 | wlr_files += files('egl.c') 21 | endif 22 | 23 | if 'gles2' in renderers or 'auto' in renderers 24 | subdir('gles2') 25 | endif 26 | 27 | if 'vulkan' in renderers or 'auto' in renderers 28 | subdir('vulkan') 29 | endif 30 | 31 | subdir('pixman') 32 | 33 | subdir('allocator') 34 | -------------------------------------------------------------------------------- /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 | wlr_files += files( 37 | 'renderer.c', 38 | 'texture.c', 39 | 'vulkan.c', 40 | 'util.c', 41 | 'pixel_format.c', 42 | ) 43 | 44 | wlr_deps += dep_vulkan 45 | features += { 'vulkan-renderer': true } 46 | 47 | subdir('shaders') 48 | -------------------------------------------------------------------------------- /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 | // 4 outlining points and uv coords 14 | const vec2[] values = { 15 | {0, 0}, 16 | {1, 0}, 17 | {1, 1}, 18 | {0, 1}, 19 | }; 20 | 21 | void main() { 22 | vec2 pos = values[gl_VertexIndex % 4]; 23 | uv = data.uv_offset + pos * data.uv_size; 24 | gl_Position = data.proj * vec4(pos, 0.0, 1.0); 25 | } 26 | -------------------------------------------------------------------------------- /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 | header = custom_target( 12 | shader + '_spv', 13 | output: shader + '.h', 14 | input: shader, 15 | command: args) 16 | 17 | vulkan_shaders += [header] 18 | endforeach 19 | 20 | wlr_files += vulkan_shaders 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /render/wlr_texture.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "types/wlr_buffer.h" 7 | 8 | void wlr_texture_init(struct wlr_texture *texture, 9 | const struct wlr_texture_impl *impl, uint32_t width, uint32_t height) { 10 | texture->impl = impl; 11 | texture->width = width; 12 | texture->height = height; 13 | } 14 | 15 | void wlr_texture_destroy(struct wlr_texture *texture) { 16 | if (texture && texture->impl && texture->impl->destroy) { 17 | texture->impl->destroy(texture); 18 | } else { 19 | free(texture); 20 | } 21 | } 22 | 23 | struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer, 24 | uint32_t fmt, uint32_t stride, uint32_t width, uint32_t height, 25 | const void *data) { 26 | assert(width > 0); 27 | assert(height > 0); 28 | assert(stride > 0); 29 | assert(data); 30 | 31 | struct wlr_readonly_data_buffer *buffer = 32 | readonly_data_buffer_create(fmt, stride, width, height, data); 33 | if (buffer == NULL) { 34 | return NULL; 35 | } 36 | 37 | struct wlr_texture *texture = 38 | wlr_texture_from_buffer(renderer, &buffer->base); 39 | 40 | // By this point, the renderer should have locked the buffer if it still 41 | // needs to access it in the future. 42 | readonly_data_buffer_drop(buffer); 43 | 44 | return texture; 45 | } 46 | 47 | struct wlr_texture *wlr_texture_from_dmabuf(struct wlr_renderer *renderer, 48 | struct wlr_dmabuf_attributes *attribs) { 49 | struct wlr_dmabuf_buffer *buffer = dmabuf_buffer_create(attribs); 50 | if (buffer == NULL) { 51 | return NULL; 52 | } 53 | 54 | struct wlr_texture *texture = 55 | wlr_texture_from_buffer(renderer, &buffer->base); 56 | 57 | // By this point, the renderer should have locked the buffer if it still 58 | // needs to access it in the future. 59 | dmabuf_buffer_drop(buffer); 60 | 61 | return texture; 62 | } 63 | 64 | struct wlr_texture *wlr_texture_from_buffer(struct wlr_renderer *renderer, 65 | struct wlr_buffer *buffer) { 66 | assert(!renderer->rendering); 67 | if (!renderer->impl->texture_from_buffer) { 68 | return NULL; 69 | } 70 | return renderer->impl->texture_from_buffer(renderer, buffer); 71 | } 72 | 73 | bool wlr_texture_is_opaque(struct wlr_texture *texture) { 74 | if (!texture->impl->is_opaque) { 75 | return false; 76 | } 77 | return texture->impl->is_opaque(texture); 78 | } 79 | 80 | bool wlr_texture_write_pixels(struct wlr_texture *texture, 81 | uint32_t stride, uint32_t width, uint32_t height, 82 | uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, 83 | const void *data) { 84 | if (!texture->impl->write_pixels) { 85 | return false; 86 | } 87 | return texture->impl->write_pixels(texture, stride, width, height, 88 | src_x, src_y, dst_x, dst_y, data); 89 | } 90 | -------------------------------------------------------------------------------- /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 | xdg-shell-protocol.c: xdg-shell-protocol.h 16 | $(WAYLAND_SCANNER) private-code \ 17 | $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ 18 | 19 | tinywl: tinywl.c xdg-shell-protocol.h xdg-shell-protocol.c 20 | $(CC) $(CFLAGS) \ 21 | -g -Werror -I. \ 22 | -DWLR_USE_UNSTABLE \ 23 | -o $@ $< \ 24 | $(LIBS) 25 | 26 | clean: 27 | rm -f tinywl xdg-shell-protocol.h xdg-shell-protocol.c 28 | 29 | .DEFAULT_GOAL=tinywl 30 | .PHONY: clean 31 | -------------------------------------------------------------------------------- /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 | - Damage tracking, which tracks which parts of the screen are changing and 47 | minimizes redraws accordingly. 48 | -------------------------------------------------------------------------------- /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/transform.c', 10 | 'scene/subsurface_tree.c', 11 | 'scene/wlr_scene.c', 12 | 'scene/output_layout.c', 13 | 'seat/wlr_seat_keyboard.c', 14 | 'seat/wlr_seat_pointer.c', 15 | 'seat/wlr_seat_touch.c', 16 | 'seat/wlr_seat.c', 17 | 'tablet_v2/wlr_tablet_v2_pad.c', 18 | 'tablet_v2/wlr_tablet_v2_tablet.c', 19 | 'tablet_v2/wlr_tablet_v2_tool.c', 20 | 'tablet_v2/wlr_tablet_v2.c', 21 | 'xdg_shell/wlr_xdg_popup.c', 22 | 'xdg_shell/wlr_xdg_positioner.c', 23 | 'xdg_shell/wlr_xdg_shell.c', 24 | 'xdg_shell/wlr_xdg_surface.c', 25 | 'xdg_shell/wlr_xdg_toplevel.c', 26 | 'wlr_buffer.c', 27 | 'wlr_compositor.c', 28 | 'wlr_cursor.c', 29 | 'wlr_data_control_v1.c', 30 | 'wlr_drm.c', 31 | 'wlr_export_dmabuf_v1.c', 32 | 'wlr_foreign_toplevel_management_v1.c', 33 | 'wlr_fullscreen_shell_v1.c', 34 | 'wlr_gamma_control_v1.c', 35 | 'wlr_idle_inhibit_v1.c', 36 | 'wlr_idle.c', 37 | 'wlr_input_device.c', 38 | 'wlr_input_inhibitor.c', 39 | 'wlr_input_method_v2.c', 40 | 'wlr_keyboard.c', 41 | 'wlr_keyboard_group.c', 42 | 'wlr_keyboard_shortcuts_inhibit_v1.c', 43 | 'wlr_layer_shell_v1.c', 44 | 'wlr_linux_dmabuf_v1.c', 45 | 'wlr_matrix.c', 46 | 'wlr_output_damage.c', 47 | 'wlr_output_layout.c', 48 | 'wlr_output_management_v1.c', 49 | 'wlr_output_power_management_v1.c', 50 | 'wlr_pointer_constraints_v1.c', 51 | 'wlr_pointer_gestures_v1.c', 52 | 'wlr_pointer.c', 53 | 'wlr_presentation_time.c', 54 | 'wlr_primary_selection_v1.c', 55 | 'wlr_primary_selection.c', 56 | 'wlr_region.c', 57 | 'wlr_relative_pointer_v1.c', 58 | 'wlr_screencopy_v1.c', 59 | 'wlr_server_decoration.c', 60 | 'wlr_surface.c', 61 | 'wlr_switch.c', 62 | 'wlr_tablet_pad.c', 63 | 'wlr_tablet_tool.c', 64 | 'wlr_text_input_v3.c', 65 | 'wlr_touch.c', 66 | 'wlr_viewporter.c', 67 | 'wlr_virtual_keyboard_v1.c', 68 | 'wlr_virtual_pointer_v1.c', 69 | 'wlr_xcursor_manager.c', 70 | 'wlr_xdg_activation_v1.c', 71 | 'wlr_xdg_decoration_v1.c', 72 | 'wlr_xdg_foreign_v1.c', 73 | 'wlr_xdg_foreign_v2.c', 74 | 'wlr_xdg_foreign_registry.c', 75 | 'wlr_xdg_output_v1.c', 76 | ) 77 | 78 | if features.get('drm-backend') 79 | wlr_files += files( 80 | 'wlr_drm_lease_v1.c', 81 | ) 82 | endif 83 | -------------------------------------------------------------------------------- /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 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "util/signal.h" 15 | 16 | void wlr_input_device_init(struct wlr_input_device *dev, 17 | enum wlr_input_device_type type, 18 | const struct wlr_input_device_impl *impl, 19 | const char *name, int vendor, int product) { 20 | dev->type = type; 21 | dev->impl = impl; 22 | dev->name = strdup(name); 23 | dev->vendor = vendor; 24 | dev->product = product; 25 | 26 | wl_signal_init(&dev->events.destroy); 27 | } 28 | 29 | void wlr_input_device_destroy(struct wlr_input_device *dev) { 30 | if (!dev) { 31 | return; 32 | } 33 | 34 | wlr_signal_emit_safe(&dev->events.destroy, dev); 35 | 36 | if (dev->_device) { 37 | switch (dev->type) { 38 | case WLR_INPUT_DEVICE_KEYBOARD: 39 | wlr_keyboard_destroy(dev->keyboard); 40 | break; 41 | case WLR_INPUT_DEVICE_POINTER: 42 | wlr_pointer_destroy(dev->pointer); 43 | break; 44 | case WLR_INPUT_DEVICE_SWITCH: 45 | wlr_switch_destroy(dev->switch_device); 46 | break; 47 | case WLR_INPUT_DEVICE_TOUCH: 48 | wlr_touch_destroy(dev->touch); 49 | break; 50 | case WLR_INPUT_DEVICE_TABLET_TOOL: 51 | wlr_tablet_destroy(dev->tablet); 52 | break; 53 | case WLR_INPUT_DEVICE_TABLET_PAD: 54 | wlr_tablet_pad_destroy(dev->tablet_pad); 55 | break; 56 | default: 57 | wlr_log(WLR_DEBUG, "Warning: leaking memory %p %p %d", 58 | dev->_device, dev, dev->type); 59 | break; 60 | } 61 | } 62 | free(dev->name); 63 | free(dev->output_name); 64 | if (dev->impl && dev->impl->destroy) { 65 | dev->impl->destroy(dev); 66 | } else { 67 | free(dev); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /types/wlr_pointer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | void wlr_pointer_init(struct wlr_pointer *pointer, 8 | const struct wlr_pointer_impl *impl) { 9 | pointer->impl = impl; 10 | wl_signal_init(&pointer->events.motion); 11 | wl_signal_init(&pointer->events.motion_absolute); 12 | wl_signal_init(&pointer->events.button); 13 | wl_signal_init(&pointer->events.axis); 14 | wl_signal_init(&pointer->events.frame); 15 | wl_signal_init(&pointer->events.swipe_begin); 16 | wl_signal_init(&pointer->events.swipe_update); 17 | wl_signal_init(&pointer->events.swipe_end); 18 | wl_signal_init(&pointer->events.pinch_begin); 19 | wl_signal_init(&pointer->events.pinch_update); 20 | wl_signal_init(&pointer->events.pinch_end); 21 | wl_signal_init(&pointer->events.hold_begin); 22 | wl_signal_init(&pointer->events.hold_end); 23 | } 24 | 25 | void wlr_pointer_destroy(struct wlr_pointer *pointer) { 26 | if (!pointer) { 27 | return; 28 | } 29 | if (pointer->impl && pointer->impl->destroy) { 30 | pointer->impl->destroy(pointer); 31 | } else { 32 | free(pointer); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /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 | 7 | void wlr_switch_init(struct wlr_switch *switch_device, 8 | struct wlr_switch_impl *impl) { 9 | switch_device->impl = impl; 10 | wl_signal_init(&switch_device->events.toggle); 11 | } 12 | 13 | void wlr_switch_destroy(struct wlr_switch *switch_device) { 14 | if (!switch_device) { 15 | return; 16 | } 17 | if (switch_device->impl && switch_device->impl->destroy) { 18 | switch_device->impl->destroy(switch_device); 19 | } else { 20 | free(switch_device); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /types/wlr_tablet_pad.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | void wlr_tablet_pad_init(struct wlr_tablet_pad *pad, 8 | struct wlr_tablet_pad_impl *impl) { 9 | pad->impl = impl; 10 | wl_signal_init(&pad->events.button); 11 | wl_signal_init(&pad->events.ring); 12 | wl_signal_init(&pad->events.strip); 13 | wl_signal_init(&pad->events.attach_tablet); 14 | 15 | wl_list_init(&pad->groups); 16 | wl_array_init(&pad->paths); 17 | } 18 | 19 | void wlr_tablet_pad_destroy(struct wlr_tablet_pad *pad) { 20 | if (!pad) { 21 | return; 22 | } 23 | 24 | char **path_ptr; 25 | wl_array_for_each(path_ptr, &pad->paths) { 26 | free(*path_ptr); 27 | } 28 | wl_array_release(&pad->paths); 29 | 30 | if (pad->impl && pad->impl->destroy) { 31 | pad->impl->destroy(pad); 32 | } else { 33 | free(pad); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /types/wlr_tablet_tool.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | void wlr_tablet_init(struct wlr_tablet *tablet, 8 | const struct wlr_tablet_impl *impl) { 9 | tablet->impl = impl; 10 | wl_signal_init(&tablet->events.axis); 11 | wl_signal_init(&tablet->events.proximity); 12 | wl_signal_init(&tablet->events.tip); 13 | wl_signal_init(&tablet->events.button); 14 | wl_array_init(&tablet->paths); 15 | } 16 | 17 | void wlr_tablet_destroy(struct wlr_tablet *tablet) { 18 | if (!tablet) { 19 | return; 20 | } 21 | 22 | char **path_ptr; 23 | wl_array_for_each(path_ptr, &tablet->paths) { 24 | free(*path_ptr); 25 | } 26 | wl_array_release(&tablet->paths); 27 | 28 | if (tablet->impl && tablet->impl->destroy) { 29 | tablet->impl->destroy(tablet); 30 | } else { 31 | free(tablet); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /types/wlr_touch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | void wlr_touch_init(struct wlr_touch *touch, 8 | const struct wlr_touch_impl *impl) { 9 | touch->impl = impl; 10 | wl_signal_init(&touch->events.down); 11 | wl_signal_init(&touch->events.up); 12 | wl_signal_init(&touch->events.motion); 13 | wl_signal_init(&touch->events.cancel); 14 | wl_signal_init(&touch->events.frame); 15 | } 16 | 17 | void wlr_touch_destroy(struct wlr_touch *touch) { 18 | if (touch && touch->impl && touch->impl->destroy) { 19 | touch->impl->destroy(touch); 20 | } else { 21 | free(touch); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /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 | 5 | #include "wlr/util/addon.h" 6 | 7 | void wlr_addon_set_init(struct wlr_addon_set *set) { 8 | wl_list_init(&set->addons); 9 | } 10 | 11 | void wlr_addon_set_finish(struct wlr_addon_set *set) { 12 | struct wlr_addon *addon, *tmp; 13 | wl_list_for_each_safe(addon, tmp, &set->addons, link) { 14 | wlr_addon_finish(addon); 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 | struct wlr_addon *iter; 23 | wl_list_for_each(iter, &set->addons, link) { 24 | if (iter->owner == addon->owner && iter->impl == addon->impl) { 25 | assert(0 && "Can't have two addons of the same type with the same owner"); 26 | } 27 | } 28 | wl_list_insert(&set->addons, &addon->link); 29 | addon->owner = owner; 30 | addon->impl = impl; 31 | } 32 | 33 | void wlr_addon_finish(struct wlr_addon *addon) { 34 | wl_list_remove(&addon->link); 35 | wl_list_init(&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 | }; 8 | 9 | static int destroy_global(void *_data) { 10 | struct destroy_global_data *data = _data; 11 | wl_global_destroy(data->global); 12 | wl_event_source_remove(data->event_source); 13 | free(data); 14 | return 0; 15 | } 16 | 17 | void wlr_global_destroy_safe(struct wl_global *global, 18 | struct wl_display *display) { 19 | // Don't destroy the global immediately. If the global has been created 20 | // recently, clients might try to bind to it after we've destroyed it. 21 | // Instead, remove the global so that clients stop seeing it and wait an 22 | // arbitrary amount of time before destroying the global as a workaround. 23 | // See: https://gitlab.freedesktop.org/wayland/wayland/issues/10 24 | 25 | wl_global_remove(global); 26 | wl_global_set_user_data(global, NULL); // safety net 27 | 28 | struct wl_event_loop *event_loop = wl_display_get_event_loop(display); 29 | struct destroy_global_data *data = calloc(1, sizeof(*data)); 30 | if (data == NULL) { 31 | wl_global_destroy(global); 32 | return; 33 | } 34 | data->global = global; 35 | data->event_source = 36 | wl_event_loop_add_timer(event_loop, destroy_global, data); 37 | if (data->event_source == NULL) { 38 | free(data); 39 | wl_global_destroy(global); 40 | return; 41 | } 42 | wl_event_source_timer_update(data->event_source, 5000); 43 | } 44 | -------------------------------------------------------------------------------- /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 "util/shm.h" 10 | 11 | #define RANDNAME_PATTERN "/wlroots-XXXXXX" 12 | 13 | static void randname(char *buf) { 14 | struct timespec ts; 15 | clock_gettime(CLOCK_REALTIME, &ts); 16 | long r = ts.tv_nsec; 17 | for (int i = 0; i < 6; ++i) { 18 | buf[i] = 'A'+(r&15)+(r&16)*2; 19 | r >>= 5; 20 | } 21 | } 22 | 23 | static int excl_shm_open(char *name) { 24 | int retries = 100; 25 | do { 26 | randname(name + strlen(RANDNAME_PATTERN) - 6); 27 | 28 | --retries; 29 | // CLOEXEC is guaranteed to be set by shm_open 30 | int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600); 31 | if (fd >= 0) { 32 | return fd; 33 | } 34 | } while (retries > 0 && errno == EEXIST); 35 | 36 | return -1; 37 | } 38 | 39 | int allocate_shm_file(size_t size) { 40 | char name[] = RANDNAME_PATTERN; 41 | int fd = excl_shm_open(name); 42 | if (fd < 0) { 43 | return -1; 44 | } 45 | shm_unlink(name); 46 | 47 | int ret; 48 | do { 49 | ret = ftruncate(fd, size); 50 | } while (ret < 0 && errno == EINTR); 51 | if (ret < 0) { 52 | close(fd); 53 | return -1; 54 | } 55 | 56 | return fd; 57 | } 58 | 59 | bool allocate_shm_file_pair(size_t size, int *rw_fd_ptr, int *ro_fd_ptr) { 60 | char name[] = RANDNAME_PATTERN; 61 | int rw_fd = excl_shm_open(name); 62 | if (rw_fd < 0) { 63 | return false; 64 | } 65 | 66 | // CLOEXEC is guaranteed to be set by shm_open 67 | int ro_fd = shm_open(name, O_RDONLY, 0); 68 | if (ro_fd < 0) { 69 | shm_unlink(name); 70 | close(rw_fd); 71 | return false; 72 | } 73 | 74 | shm_unlink(name); 75 | 76 | int ret; 77 | do { 78 | ret = ftruncate(rw_fd, size); 79 | } while (ret < 0 && errno == EINTR); 80 | if (ret < 0) { 81 | close(rw_fd); 82 | close(ro_fd); 83 | return false; 84 | } 85 | 86 | *rw_fd_ptr = rw_fd; 87 | *ro_fd_ptr = ro_fd; 88 | return true; 89 | } 90 | -------------------------------------------------------------------------------- /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 | #include "util/token.h" 2 | #include "wlr/util/log.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | bool generate_token(char out[static TOKEN_STRLEN]) { 10 | static FILE *urandom = NULL; 11 | uint64_t data[2]; 12 | 13 | if (!urandom) { 14 | if (!(urandom = fopen("/dev/urandom", "r"))) { 15 | wlr_log_errno(WLR_ERROR, "Failed to open random device"); 16 | return false; 17 | } 18 | } 19 | if (fread(data, sizeof(data), 1, urandom) != 1) { 20 | wlr_log_errno(WLR_ERROR, "Failed to read from random device"); 21 | return false; 22 | } 23 | if (snprintf(out, TOKEN_STRLEN, "%016" PRIx64 "%016" PRIx64, data[0], data[1]) != TOKEN_STRLEN - 1) { 24 | wlr_log_errno(WLR_ERROR, "Failed to format hex string token"); 25 | return false; 26 | } 27 | return true; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /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 | ) 75 | wlr_deps += xwayland_libs 76 | features += { 'xwayland': true } 77 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------