You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
ndg/wayland
alex 20ee2f8220 Squashed 'lib/lv_drivers/' changes from 718302577..0091dc612
0091dc612 fix(wayland): fix compile error wrt LV_WAYLAND_CLIENT_SIDE_DECORATIONS (#307)
451e659cf Add pkgconfig file (#301)
5a5b4a1a3 added x11 display driver port (#300)
4391dbf32 perf(drm): use wait_cb for direct double-buffered rendering (#299)
7e18481ce fix(drm): backport drm driver fixes from lvgl 9 (#298)
f5b58b947 feat(evdev): backport multi device support from lvgl 9 (#296)
ad66ff155 add return value to drm_init
c239cc465 Removed clamp from Calibrate section as it has map in it
e44e7f043 fix(build): Update xpt2046_read to match signature required by lv_indev_drv_t's read callback. (#290)
7b9dee11c Fix crash during startup in certain conditions (#286)
9d153fb65 Add USE_WAYLAND to smm.c (#285)
8669c6fc8 libInput: Add POINTER_MOTION_ABSOLUTE support (#284)
c71e5f84b drm: Default to XRGB8888 framebuffer (#282)
57494ff8e Add a way to set SDL window title from lv_drv_conf.h (#277)
b03c9dac9 fix(xkb): Fix memory leak by avoiding double reference (#276)
ec0ad8296 feature(libinput): Expose function for querying capability (#275)
0d5de84e2 feature(libinput): Add function to reset driver states (#274)
94dc4ce06 Use win32 singly linked list instead of LVGL linked list for fixing memory access conflict issues for win32drv. (#273)
1792ab20a feature(wayland): add a shared memory manager, allowing backing buffers to be allocated on demand. (#270)
f7935569f use SDL_RES instead of LV_RES for touch events (#268)
ba9c3cc4f Update README.md (#261)
f261225d9 follow lvgl changes
ab5e30ccb Add the multiple display support for win32drv. (#259)
820341ea1 Improve the keyboard support for win32drv. (#258)
b13361a1f fix: The mouse moves outside the screen area (#251)
829e0ffc3 chore(wayland) : accelerate damage updates, reduce unnecessary cycles (#249)
5523f9974 fix(wayland-protocols): minimum version (#246)
fe9de86e9 Wayland api fixes (#243)
59e698ce1 fix(wayland) : fix possible memory leak (#238)
2ed01feab fix(drm): Fix compiler warnings (#237)
cf4e6d75a make windows.h lower case (#236)
dc0d71a3a chore(sdl): fix warning (#232)
c68b59e42 fix(fbdev): Fix rendering for 24 bits per pixel (#231)
4f98fddd2 hide the SDL2 include from public LVGL functions (#227)
ff01834db fix(fbdev): Gracefully handle FBIOBLANK errors (#229)
73219786a bump version number to v9.0.0-dev

git-subtree-dir: lib/lv_drivers
git-subtree-split: 0091dc612facc94dce1061a9b78d641c77f1791a
9 months ago
..
.gitignore Squashed 'lib/lv_drivers/' content from commit 71830257 2 years ago
CMakeLists.txt Squashed 'lib/lv_drivers/' changes from 718302577..0091dc612 9 months ago
README.md Squashed 'lib/lv_drivers/' content from commit 71830257 2 years ago
smm.c Squashed 'lib/lv_drivers/' changes from 718302577..0091dc612 9 months ago
smm.h Squashed 'lib/lv_drivers/' changes from 718302577..0091dc612 9 months ago
wayland.c Squashed 'lib/lv_drivers/' changes from 718302577..0091dc612 9 months ago
wayland.h Squashed 'lib/lv_drivers/' changes from 718302577..0091dc612 9 months ago

README.md

Wayland display and input driver

Wayland display and input driver, with support for keyboard, pointer (i.e. mouse) and touchscreen. Keyboard support is based on libxkbcommon.

Following shell are supported:

  • wl_shell (deprecated)
  • xdg_shell

xdg_shell requires an extra build step; see section Generate protocols below.

Basic client-side window decorations (simple title bar, minimize and close buttons) are supported, while integration with desktop environments is not.

Install headers and libraries

Ubuntu

sudo apt-get install libwayland-dev libxkbcommon-dev libwayland-bin wayland-protocols

Fedora

sudo dnf install wayland-devel libxkbcommon-devel wayland-utils wayland-protocols-devel

Generate protocols

Support for non-basic shells (i.e. other than wl_shell) requires additional source files to be generated before the first build of the project. To do so, navigate to the wayland folder (the one which includes this file) and issue the following commands:

cmake .
make

Build configuration under Eclipse

In "Project properties > C/C++ Build > Settings" set the followings:

  • "Cross GCC Compiler > Command line pattern"

    • Add ${wayland-cflags} and ${xkbcommon-cflags} to the end (add a space between the last command and this)
  • "Cross GCC Linker > Command line pattern"

    • Add ${wayland-libs} and ${xkbcommon-libs} to the end (add a space between the last command and this)
  • In "C/C++ Build > Build variables"

    • Configuration: [All Configuration]

    • Add

      • Variable name: wayland-cflags
        • Type: String
        • Value: pkg-config --cflags wayland-client
      • Variable name: wayland-libs
        • Type: String
        • Value: pkg-config --libs wayland-client
      • Variable name: xkbcommon-cflags
        • Type: String
        • Value: pkg-config --cflags xkbcommon
      • Variable name: xkbcommon-libs
        • Type: String
        • Value: pkg-config --libs xkbcommon

Init Wayland in LVGL

  1. In main.c #incude "lv_drivers/wayland/wayland.h"
  2. Enable the Wayland driver in lv_drv_conf.h with USE_WAYLAND 1 and configure its features below, enabling at least support for one shell.
  3. LV_COLOR_DEPTH should be set either to 32 or 16 in lv_conf.h; support for 8 and 1 depends on target platform.
  4. After lv_init() call lv_wayland_init().
  5. Add a display (or more than one) using lv_wayland_create_window(), possibly with a close callback to track the status of each display:
  #define H_RES (800)
  #define V_RES (480)

  /* Create a display */
  lv_disp_t * disp = lv_wayland_create_window(H_RES, V_RES, "Window Title", close_cb);

As part of the above call, the Wayland driver will register four input devices for each display:

  • a KEYPAD connected to Wayland keyboard events
  • a POINTER connected to Wayland touch events
  • a POINTER connected to Wayland pointer events
  • a ENCODER connected to Wayland pointer axis events Handles for input devices of each display can be get using respectively lv_wayland_get_indev_keyboard(), lv_wayland_get_indev_touchscreen(), lv_wayland_get_indev_pointer() and lv_wayland_get_indev_pointeraxis(), using disp as argument.
  1. After lv_deinit() (if used), or in any case during de-initialization, call lv_wayland_deinit().

Fullscreen mode

In order to set one window as fullscreen or restore it as a normal one, call the lv_wayland_window_set_fullscreen() function respectively with true or false as fullscreen argument.

Disable window client-side decoration at runtime

Even when client-side decorations are enabled at compile time, they can be disabled at runtime setting the LV_WAYLAND_DISABLE_WINDOWDECORATION environment variable to 1.

Event-driven timer handler

Set LV_WAYLAND_TIMER_HANDLER in lv_drv_conf.h and call lv_wayland_timer_handler() in your timer loop (in place of lv_timer_handler()).

You can now sleep/wait until the next timer/event is ready, e.g.:

/* [After initialization and display creation] */
#include <limits.h>
#include <errno.h>
#include <poll.h>

struct pollfd pfd;
uint32_t time_till_next;
int sleep;

pfd.fd = lv_wayland_get_fd();
pfd.events = POLLIN;

while (1) {
    /* Handle any Wayland/LVGL timers/events */
    time_till_next = lv_wayland_timer_handler();

    /* Run until the last window closes */
    if (!lv_wayland_window_is_open(NULL)) {
        break;
    }

    /* Wait for something interesting to happen */
    if (time_till_next == LV_NO_TIMER_READY) {
        sleep = -1;
    } else if (time_till_next > INT_MAX) {
        sleep = INT_MAX;
    } else {
       sleep = time_till_next;
    }

    while ((poll(&pfd, 1, sleep) < 0) && (errno == EINTR));
}