Search by Tags

Working with Weston on TorizonCore

 

Article updated at 02 Aug 2021
Subscribe for this article updates

Select the version of your OS from the tabs below. If you don't know the version you are using, run the command cat /etc/os-release or cat /etc/issue on the board.



Remember that you can always refer to the Torizon Documentation, there you can find a lot of relevant articles that might help you in the application development.

Torizon 5.4.0

Introduction

Linux systems with a graphical output need a graphics stack. There are two famous ones: X, also known as X11 or X.Org, and Wayland which aims at replacing X.

Wayland is a protocol and it requires a compositor implementation. The reference implementation, widely used, is the Weston compositor.

From our software releases 5.x onward, Toradex only supports Wayland/Weston. For Torizon, Toradex provides a Weston container, which is configured from its command line parameters, and a configuration file named weston.ini.

This article explains how to customize the default configuration. It does not replace the Wayland documentation.

This article complies to the Typographic Conventions for the Toradex Documentation.

Prerequisites

To have a better understanding of this article, the following prerequisites are recommended:

Configuration options

Weston uses a configuration file named weston.ini for its setup.

The Toradex container has a Weston startup script. While executing docker run, you can pass a --developer switch that allows either of the following files to be passed to Weston:

  • /etc/xdg/weston/weston.ini: used by default, if the --developer switch is not present.
  • /etc/xdg/weston-dev/weston.ini: used when you start the Weston container with the --developer switch.

An example of how to use the switch is available in the article Debian Containers for Torizon.

Before proceeding, create your own weston.ini, where you will store your custom configuration.

How to apply configuration options

There are two options to apply changes:

  • Bind mount a custom configuration file.
  • Rebuild a Weston container with the custom configuration file.

For evaluation and prototyping you can bind mount the weston.ini file. This will overwrite the existing configuration weston.ini file. To do it, add a volume flag to the docker run command:

-v <path_to_directory_containing_weston.ini_file>:/etc/xdg/weston/

For development and production rebuild the Weston Docker image using your weston.ini file.

You are encouraged to read the following articles for tips on how to do it:

Customization

In this section, customization that is often used by our customers is presented to you.

Screen rotation

The screen can be rotated or flipped by adding the following to the weston.ini file:

[output] 
name=HDMI-A-1
transform=rotate-90 

The name value can be found by executing weston-info from inside the running Weston container.

Additional transform values can be found in the weston.ini man page.

Switching between virtual terminals

Switching between virtual terminals can be enabled by changing these lines in weston.ini file:

[keyboard] 
vt-switching=true

Press Ctrl+Alt+F1 till F6 key combinations to switch between virtual terminals. To come back to the graphical session, press Ctrl+Alt+F7.

touch2pointer

With Wayland, it is possible to transfer touch events from the Wayland server to the client application. However, some applications are not aware of these events (e.g. QtWidgets). Therefore, they will not react to touch events and it is not possible to click buttons, etc.

touch2pointer is an application created by Toradex that operates directly on top of the touchscreen's evdev interface and creates a virtual pointer device. This makes it possible to use such applications. However, you will lose some of the capability of touchscreens (like multitouch).

How to use:

Calibrate the touchscreen with Weston touch calibrator if it is a resistive touch. Make sure you set the LIBINPUT_CALIBRATION_MATRIX variable to the calibration matrix.

Create a udev rule that makes Weston/libinput ignore the touch device ENV{LIBINPUT_IGNORE_DEVICE}="1". For example:

SUBSYSTEM=="input", KERNEL=="event0", ENV{ID_INPUT_TOUCHSCREEN}=="1", ENV{LIBINPUT_CALIBRATION_MATRIX}="1.034599 -0.008149 -0.013808 0.026801 -1.130055 1.058165"
SUBSYSTEM=="input", KERNEL=="event0", ENV{LIBINPUT_IGNORE_DEVICE}="1"

Start touch2pointer with touchscreen as an argument.

kiosk-shell

With version 9.0 Weston introduced the kiosk-shell.

Weston uses the desktop-shell by default. To use kiosk-shell, add the following to the core section in weston.ini file:

[core]
shell=kiosk-shell.so

Next Steps / Additional Resources

Additional configuration options can be found in the weston.ini man page.