Skip to content
Commits on Source (236)
*.announce
*.deps
*.jpg
*.la
*.lo
*.log
*.o
*.pc
*.sig
*.so
*.swp
.*.sw?
.sw?
*.sublime-project
*.sublime-workspace
*.tar.xz
*.trs
*~
ctags
cscope.out
.libs
.dirstamp
/aclocal.m4
/autom4te.cache
/build-aux/
/config.guess
/config.h
/config.h.in
/config.log
/config.mk
/config.status
/config.sub
/configure
/depcomp
/doc/doxygen/*.doxygen
/docs/developer
/docs/tools
/install-sh
/libtool
/ltmain.sh
/logs
/missing
/stamp-h1
/test-driver
/weston.ini
Makefile
Makefile.in
TAGS
protocol/.*.valid
protocol/*.[ch]
00*.patch
weston-calibrator
weston-clickdot
weston-cliptest
weston-confine
weston-dnd
weston-editor
weston-eventdemo
weston-flower
weston-fullscreen
weston-gears
weston-image
weston-nested
weston-nested-client
weston-presentation-shm
weston-resizor
weston-scaler
weston-simple-dmabuf-drm
weston-simple-dmabuf-v4l
weston-simple-egl
weston-simple-shm
weston-simple-touch
weston-simple-damage
weston-smoke
weston-stacking
weston-subsurfaces
weston-touch-calibrator
weston-transformed
weston-view
weston-keyboard
libtoytoolkit.a
weston-desktop-shell
weston-ivi-shell-user-interface
weston-info
weston-screenshooter
weston-tablet-shell
weston-terminal
weston-multi-resource
weston-simple-im
weston
weston-launch
spring-tool
*.weston
*.test
*.ivi
wcap-decode
matrix-test
setbacklight
weston.1
weston-drm.7
weston.ini.5
/libweston/git-version.h
/libweston/version.h
/tests/weston-ivi.ini
internal-screenshot-00.png
/zuctest
image: debian:stretch
# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0:
variables:
UPSTREAM_REPO: wayland/weston
DEBIAN_VERSION: buster
DEBIAN_EXEC: 'bash .gitlab-ci/debian-install.sh'
DEBIAN_TAG: '2019-06-26.0'
DEBIAN_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/debian/$DEBIAN_VERSION:$DEBIAN_TAG
include:
- project: 'wayland/ci-templates'
ref: c73dae8b84697ef18e2dbbf4fed7386d9652b0cd
file: '/templates/debian.yml'
stages:
- container_prep
- build
- pages
before_script:
- echo 'path-exclude=/usr/share/doc/*' > /etc/dpkg/dpkg.cfg.d/99-exclude-cruft
- echo 'path-exclude=/usr/share/man/*' >> /etc/dpkg/dpkg.cfg.d/99-exclude-cruft
- echo '#!/bin/sh' > /usr/sbin/policy-rc.d
- echo 'exit 101' >> /usr/sbin/policy-rc.d
- chmod +x /usr/sbin/policy-rc.d
- echo 'deb http://deb.debian.org/debian stretch-backports main' >> /etc/apt/sources.list
- apt-get update
- apt-get -y --no-install-recommends install build-essential automake autoconf libtool pkg-config libexpat1-dev libffi-dev libxml2-dev libpixman-1-dev libpng-dev libjpeg-dev libcolord-dev mesa-common-dev libglu1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev libwayland-dev libxcb1-dev libxcb-composite0-dev libxcb-xfixes0-dev libxcb-xkb-dev libx11-xcb-dev libx11-dev libudev-dev libgbm-dev libxkbcommon-dev libcairo2-dev libpango1.0-dev libgdk-pixbuf2.0-dev libxcursor-dev libmtdev-dev libpam0g-dev libvpx-dev libsystemd-dev libevdev-dev libinput-dev libwebp-dev libjpeg-dev libva-dev liblcms2-dev git libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev freerdp2-dev curl python3-pip python3-setuptools ninja-build
- pip3 install --user git+https://github.com/mesonbuild/meson.git@0.49
- mkdir -p /tmp/.X11-unix
- chmod 777 /tmp/.X11-unix
build-native-autotools:
container_prep:
extends: .debian@container-ifnot-exists
stage: container_prep
.build-native:
stage: build
script:
- git clone --depth=1 git://anongit.freedesktop.org/git/wayland/wayland-protocols
image: $DEBIAN_CONTAINER_IMAGE
before_script:
- git clone --depth=1 https://gitlab.freedesktop.org/wayland/wayland-protocols
- export WAYLAND_PROTOCOLS_DIR="$(pwd)/prefix-wayland-protocols"
- export PKG_CONFIG_PATH="$WAYLAND_PROTOCOLS_DIR/share/pkgconfig:$PKG_CONFIG_PATH"
- export MAKEFLAGS="-j4"
......@@ -31,54 +42,38 @@ build-native-autotools:
- make install
- cd ../../
- export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
- export BUILD_ID="weston-$CI_JOB_NAME_$CI_COMMIT_SHA-$CI_JOB_ID"
- export BUILD_ID="weston-$CI_JOB_NAME"
- export PREFIX="$(pwd)/prefix-$BUILD_ID"
- export BUILDDIR="$(pwd)/build-$BUILD_ID"
- mkdir "$BUILDDIR" "$PREFIX"
- cd "$BUILDDIR"
- ../autogen.sh --prefix="$PREFIX" --disable-setuid-install --enable-xwayland --enable-x11-compositor --enable-drm-compositor --enable-wayland-compositor --enable-headless-compositor --enable-fbdev-compositor --enable-rdp-compositor --enable-screen-sharing --enable-vaapi-recorder --enable-simple-clients --enable-simple-egl-clients --enable-simple-dmabuf-drm-client --enable-simple-dmabuf-v4l-client --enable-clients --enable-resize-optimization --enable-weston-launch --enable-fullscreen-shell --enable-colord --enable-dbus --enable-systemd-login --enable-junit-xml --enable-ivi-shell --enable-wcap-tools --disable-libunwind --enable-demo-clients-install --enable-lcms --with-cairo=image --enable-remoting --enable-autotools
- make all
- make check
- make install
- make distcheck
artifacts:
name: weston-$CI_COMMIT_SHA-$CI_JOB_ID
when: always
paths:
- build-*/weston-*.tar.xz
- build-*/*.log
- build-*/logs
- prefix-*
build-native-meson:
stage: build
extends: .build-native
script:
- git clone --depth=1 git://anongit.freedesktop.org/git/wayland/wayland-protocols
- export WAYLAND_PROTOCOLS_DIR="$(pwd)/prefix-wayland-protocols"
- export PKG_CONFIG_PATH="$WAYLAND_PROTOCOLS_DIR/share/pkgconfig:$PKG_CONFIG_PATH"
- export MAKEFLAGS="-j4"
- cd wayland-protocols
- git show -s HEAD
- mkdir build
- cd build
- ../autogen.sh --prefix="$WAYLAND_PROTOCOLS_DIR"
- make install
- cd ../../
- export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
- export BUILD_ID="weston-$CI_JOB_NAME_$CI_COMMIT_SHA-$CI_JOB_ID"
- export PREFIX="$(pwd)/prefix-$BUILD_ID"
- export BUILDDIR="$(pwd)/build-$BUILD_ID"
- export PATH=~/.local/bin:$PATH
- mkdir "$BUILDDIR" "$PREFIX"
- cd "$BUILDDIR"
- meson --prefix="$PREFIX" -Dsimple-dmabuf-drm=intel ..
- meson --prefix="$PREFIX" -Dsimple-dmabuf-drm=intel -Dwerror=true -Ddoc=true ..
- ninja -k0
- ninja install
- ninja test
- ninja clean
artifacts:
name: weston-$CI_COMMIT_SHA-$CI_JOB_ID
name: weston-$CI_COMMIT_SHA
when: always
paths:
- build-*/meson-logs
- prefix-*
pages:
stage: pages
dependencies:
- build-native-meson
script:
- export PREFIX=$(pwd)/prefix-weston-build-native-meson
- mkdir public
- cp -R $PREFIX/share/doc/weston/* public/
artifacts:
paths:
- public
only:
- master
#!/bin/bash
set -o xtrace
echo 'deb http://deb.debian.org/debian buster-backports main' >> /etc/apt/sources.list
apt-get update
apt-get -y --no-install-recommends install build-essential automake autoconf libtool pkg-config libexpat1-dev libffi-dev libxml2-dev libpixman-1-dev libpng-dev libjpeg-dev libcolord-dev mesa-common-dev libglu1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev libwayland-dev libxcb1-dev libxcb-composite0-dev libxcb-xfixes0-dev libxcb-xkb-dev libx11-xcb-dev libx11-dev libudev-dev libgbm-dev libxkbcommon-dev libcairo2-dev libpango1.0-dev libgdk-pixbuf2.0-dev libxcursor-dev libmtdev-dev libpam0g-dev libvpx-dev libsystemd-dev libevdev-dev libinput-dev libwebp-dev libjpeg-dev libva-dev liblcms2-dev git libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev freerdp2-dev curl python3-pip python3-setuptools doxygen ninja-build libdbus-1-dev libpipewire-0.2-dev
pip3 install --user git+https://github.com/mesonbuild/meson.git@0.49
# for documentation
pip3 install sphinx==2.1.0 --user
pip3 install breathe==4.13.0.post0 --user
pip3 install sphinx_rtd_theme==0.4.3 --user
mkdir -p /tmp/.X11-unix
chmod 777 /tmp/.X11-unix
......@@ -37,7 +37,7 @@ fork the core Weston repository, push your changes to a branch in your new
repository, and then submit these patches for review through a merge request.
Weston formerly accepted patches via `git-send-email`, sent to
**wayland-devel@lists.freedesktop.org**; these were
**wayland-devel\@lists.freedesktop.org**; these were
[tracked using Patchwork](https://patchwork.freedesktop.org/projects/wayland/).
Some old patches continue to be sent this way, and we may accept small new
patches sent to the list, but please send all new patches through GitLab merge
......@@ -98,7 +98,9 @@ See [notes on commit messages] for a recommended reading on writing commit
messages.
Your patches should also include a Signed-off-by line with your name and
email address. If you're not the patch's original author, you should
email address which indicates that you agree to the
[Developer's Certificate of Origin 1.1](DCO-1.1.txt).
If you're not the patch's original author, you should
also gather S-o-b's by them (and/or whomever gave the patch to you.) The
significance of this is that it certifies that you created the patch,
that it was created under an appropriate open source license, or
......
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
This diff is collapsed.
......@@ -79,6 +79,8 @@ More [detailed documentation on building Weston](https://wayland.freedesktop.org
is available on the Wayland site. There are also more details on
[how to run and write tests](https://wayland.freedesktop.org/testing.html).
For building the documentation see [weston-doc](#weston-doc).
Running Weston
==============
......@@ -100,6 +102,41 @@ privileged access to input and output devices by running as root, then granting
access to the main Weston binary running as your user. Running Weston this way
is not recommended unless necessary.
Weston-doc
==========
For documenting weston we use [sphinx](http://www.sphinx-doc.org/en/master/)
together with [breathe](https://breathe.readthedocs.io/en/latest/) that
understands XMLs databases generated by doxygen. So far, this is a compromise
until better tools are available in order to remove the doxygen
dependency. You should be able to install both sphinx and breathe extension
using pip3 command, or your package manager.
Doxygen should be available using your distribution package manager.
Once those are set-up, run `meson` with `-Ddoc=true` option in order to enable
building the documentation. Installation will place the documentation in the
prefix's path under datadir (i.e., `share/doc`).
Adding and improving documentation
----------------------------------
For re-generating the documentation a special `docs` target has been added.
Although first time you build (and subsequently install) weston, you'll see the
documentation being built, updates to the spinx documentation files or to the
source files will only be updated when using `docs` target!
Example:
~~~~
$ ninja install # generates and installs the documentation
# time passes, hack hack, add doc in sources or rST files
$ ninja install # not sufficient, docs will not be updated
$ ninja docs && ninja install # run 'docs' then install
~~~~
Improving/adding documentation can be done by modifying rST files under
`doc/sphinx/` directory or by modifying the source code using doxygen
directives.
Libweston
=========
......@@ -165,14 +202,14 @@ The document provides the full details, with the gist summed below:
- Minor - new backward compatible features.
- Patch - internal (implementation specific) fixes.
Weston and libweston have separate version numbers in configure.ac. All
Weston and libweston have separate version numbers in meson.build. All
releases are made by the Weston version number. Libweston version number
matches the Weston version number in all releases except maybe pre-releases.
Pre-releases have the Weston micro version 91 or greater.
A pre-release is allowed to install a libweston version greater than the Weston
version in case libweston major was bumped. In that case, the libweston version
must be Weston major + 1 and with minor and patch versions zero.
must be Weston major + 1.
Pkg-config files are named after libweston major, but carry the Weston version
number. This means that Weston pre-release 2.1.91 may install libweston-3.pc
......@@ -205,18 +242,22 @@ user visible API changes, thus should be not considered part of the API version.
All new symbols should be guarded by the macro like the example given below:
~~~~
#if REQUIRE_LIBWESTON_API_VERSION >= 0x0101
bool
weston_ham_sandwich(void);
#endif
~~~~
In order to use the said symbol, the one will have a similar code in their
configure.ac:
~~~~
PKG_CHECK_MODULES(LIBWESTON, [libweston-1 >= 1.1])
AC_DEFINE(REQUIRE_LIBWESTON_API_VERSION, [0x0101])
~~~~
If the user is _not_ interested in forward compatibility, they can use 0xffff
or similar high value. Yet doing so is not recommended.
......
#! /bin/sh
test -n "$srcdir" || srcdir=`dirname "$0"`
test -n "$srcdir" || srcdir=.
(
cd "$srcdir" &&
autoreconf --force -v --install
) || exit
test -n "$NOCONFIGURE" || "$srcdir/configure" "$@"
......@@ -39,7 +39,7 @@
#include "window.h"
#include "shared/helpers.h"
#include "shared/matrix.h"
#include <libweston/matrix.h>
/* Our points for the calibration must be not be on a line */
static const struct {
......
/*
* Copyright © 2018 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "config.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <cairo.h>
#include <sys/time.h>
#include <linux/input.h>
#include <wayland-client.h>
#include "weston-content-protection-client-protocol.h"
#include "window.h"
#include <wayland-client-protocol.h>
#define WIDTH 500
#define HEIGHT 400
#define FRAME_H 18
#define FRAME_W 5
#define BUTTON_WIDTH 65
#define BUTTON_HEIGHT 20
enum protection_mode {
RELAXED,
ENFORCED
};
struct protected_content_player {
struct weston_content_protection *protection;
struct weston_protected_surface *psurface;
struct display *display;
struct window *window;
struct widget *widget;
struct button_t *b0, *b1, *off, *enforced, *relaxed;
int width, height, x, y;
enum weston_protected_surface_type protection_type;
enum protection_mode mode;
};
struct button_t {
struct window *window;
struct widget *widget;
struct protected_content_player *pc_player;
const char *name;
};
/**
* An event to tell the client that there is a change in protection status
*
* This event is sent whenever there is a change in content
* protection. The content protection status can be ON or OFF. ON
* in case of the desired protection type is accepted on all
* connectors, and Off in case of any of the connector
* content-protection property is changed from "enabled"
*/
static void
handle_status_changed(void *data, struct weston_protected_surface *psurface,
uint32_t status)
{
struct protected_content_player *pc_player = data;
enum weston_protected_surface_type event_status = status;
switch (event_status) {
case WESTON_PROTECTED_SURFACE_TYPE_HDCP_0:
pc_player->protection_type = WESTON_PROTECTED_SURFACE_TYPE_HDCP_0;
break;
case WESTON_PROTECTED_SURFACE_TYPE_HDCP_1:
pc_player->protection_type = WESTON_PROTECTED_SURFACE_TYPE_HDCP_1;
break;
case WESTON_PROTECTED_SURFACE_TYPE_UNPROTECTED:
default:
pc_player->protection_type = WESTON_PROTECTED_SURFACE_TYPE_UNPROTECTED;
}
window_schedule_redraw(pc_player->window);
}
static const struct weston_protected_surface_listener pc_player_listener = {
handle_status_changed,
};
static void
draw_content(cairo_surface_t *surface, int x, int y, int width, int height,
enum weston_protected_surface_type type, enum protection_mode mode)
{
cairo_t *cr;
cairo_text_extents_t extents;
const char *content_text;
const char *mode_text;
cr = cairo_create(surface);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_rectangle(cr, x, y, width, height);
if (type == WESTON_PROTECTED_SURFACE_TYPE_HDCP_0)
cairo_set_source_rgba(cr, 0, 1.0, 0, 1.0);
else if (type == WESTON_PROTECTED_SURFACE_TYPE_HDCP_1)
cairo_set_source_rgba(cr, 0, 0, 1.0, 1.0);
else
cairo_set_source_rgba(cr, 1.0, 0, 0, 1.0);
cairo_fill(cr);
cairo_set_source_rgba(cr, 0, 0, 0, 1.0);
cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, 15);
if (type == WESTON_PROTECTED_SURFACE_TYPE_HDCP_0)
content_text = "Content-Type : Type-0";
else if (type == WESTON_PROTECTED_SURFACE_TYPE_HDCP_1)
content_text = "Content-Type : Type-1";
else
content_text = "Content-Type : Unprotected";
cairo_text_extents(cr, content_text, &extents);
cairo_move_to(cr, width/2 - (extents.width/2),
height/2 - (extents.height/2));
cairo_show_text(cr, content_text);
if (mode == ENFORCED)
mode_text = "Mode : Enforced";
else
mode_text = "Mode : Relaxed";
cairo_text_extents(cr, mode_text, &extents);
cairo_move_to(cr, width / 2 - (extents.width / 2),
2 * height / 3 - (2 * extents.height / 3));
cairo_show_text(cr, mode_text);
cairo_fill(cr);
cairo_destroy(cr);
}
static void
redraw_handler(struct widget *widget, void *data)
{
struct protected_content_player *pc_player = data;
cairo_surface_t *surface;
struct rectangle rect;
widget_get_allocation(pc_player->widget, &rect);
surface = window_get_surface(pc_player->window);
if (surface == NULL ||
cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
fprintf(stderr, "failed to create cairo egl surface\n");
return;
}
draw_content(surface, rect.x, rect.y, rect.width, rect.height,
pc_player->protection_type, pc_player->mode);
cairo_surface_destroy(surface);
}
static void
resize_handler(struct widget *widget, int32_t width, int32_t height, void *data)
{
struct rectangle allocation;
struct protected_content_player *pc_player = data;
widget_get_allocation(pc_player->widget, &allocation);
widget_set_allocation(pc_player->b0->widget,
allocation.x + 20, allocation.y + 30,
BUTTON_WIDTH, BUTTON_HEIGHT);
widget_set_allocation(pc_player->b1->widget,
allocation.x + 20 + BUTTON_WIDTH + 5,
allocation.y + 30,
BUTTON_WIDTH, BUTTON_HEIGHT);
widget_set_allocation(pc_player->off->widget,
allocation.x + 20 + 2 * (BUTTON_WIDTH + 5),
allocation.y + 30,
BUTTON_WIDTH, BUTTON_HEIGHT);
widget_set_allocation(pc_player->enforced->widget,
allocation.x + 20 + 3 * (BUTTON_WIDTH + 5),
allocation.y + 30,
BUTTON_WIDTH, BUTTON_HEIGHT);
widget_set_allocation(pc_player->relaxed->widget,
allocation.x + 20 + 4 * (BUTTON_WIDTH + 5),
allocation.y + 30,
BUTTON_WIDTH, BUTTON_HEIGHT);
}
static void
buttons_handler(struct widget *widget, struct input *input, uint32_t time,
uint32_t button, enum wl_pointer_button_state state, void *data)
{
struct button_t *b = data;
struct protected_content_player *pc_player = b->pc_player;
struct wl_surface *surface;
if (strcmp(b->name, "ENFORCED") == 0) {
weston_protected_surface_enforce(pc_player->psurface);
pc_player->mode = ENFORCED;
window_schedule_redraw(pc_player->window);
}
else if (strcmp(b->name, "RELAXED") == 0) {
weston_protected_surface_relax(pc_player->psurface);
pc_player->mode = RELAXED;
window_schedule_redraw(pc_player->window);
}
else if (strcmp(b->name, "TYPE-0") == 0)
weston_protected_surface_set_type(pc_player->psurface,
WESTON_PROTECTED_SURFACE_TYPE_HDCP_0);
else if (strcmp(b->name, "TYPE-1") == 0)
weston_protected_surface_set_type(pc_player->psurface,
WESTON_PROTECTED_SURFACE_TYPE_HDCP_1);
else
weston_protected_surface_set_type(pc_player->psurface,
WESTON_PROTECTED_SURFACE_TYPE_UNPROTECTED);
surface = window_get_wl_surface(pc_player->window);
wl_surface_commit(surface);
}
static void
handle_global(struct display *display, uint32_t name, const char *interface,
uint32_t version, void *data)
{
struct protected_content_player *pc_player = data;
if (strcmp(interface, "weston_content_protection") == 0) {
pc_player->protection = display_bind(display, name,
&weston_content_protection_interface,
1);
}
}
static void
buttons_redraw_handler(struct widget *widget, void *data)
{
struct button_t *b = data;
cairo_surface_t *surface;
struct rectangle allocation;
cairo_t *cr;
surface = window_get_surface(b->window);
widget_get_allocation(b->widget, &allocation);
cr = cairo_create(surface);
cairo_rectangle(cr, allocation.x, allocation.y, allocation.width,
allocation.height);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba(cr, 1, 1, 1, 1);
cairo_fill(cr);
cairo_set_source_rgba(cr, 0, 0, 0, 1.0);
cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, 10);
cairo_move_to(cr, allocation.x + 5, allocation.y + 15);
cairo_show_text(cr, b->name);
cairo_fill(cr);
cairo_destroy(cr);
cairo_surface_destroy(surface);
}
static struct button_t*
create_button(struct protected_content_player *pc_player, const char *name)
{
struct button_t *b;
b = zalloc(sizeof(struct button_t));
if (b == NULL) {
fprintf(stderr, "Failed to allocate memory for button.\n");
exit(0);
}
b->widget = widget_add_widget(pc_player->widget, b);
b->window = pc_player->window;
b->pc_player = pc_player;
b->name = name;
widget_set_redraw_handler(b->widget, buttons_redraw_handler);
widget_set_button_handler(b->widget, buttons_handler);
return b;
}
static void
destroy_button(struct button_t *b)
{
if (!b)
return;
widget_destroy(b->widget);
free(b);
}
static void free_pc_player(struct protected_content_player *pc_player)
{
if (!pc_player)
return;
destroy_button(pc_player->b0);
destroy_button(pc_player->b1);
destroy_button(pc_player->off);
destroy_button(pc_player->enforced);
destroy_button(pc_player->relaxed);
widget_destroy(pc_player->widget);
window_destroy(pc_player->window);
free(pc_player);
}
int main(int argc, char *argv[])
{
struct protected_content_player *pc_player;
struct display *d;
static const char str_type_0[] = "TYPE-0";
static const char str_type_1[] = "TYPE-1";
static const char str_type_off[] = "OFF";
static const char str_type_enforced[] = "ENFORCED";
static const char str_type_relaxed[] = "RELAXED";
struct wl_surface *surface;
pc_player = zalloc(sizeof(struct protected_content_player));
if (pc_player == NULL) {
fprintf(stderr, "failed to allocate memory: %m\n");
return -1;
}
d = display_create(&argc, argv);
if (d == NULL) {
fprintf(stderr, "failed to create display: %m\n");
return -1;
}
pc_player->protection_type = WESTON_PROTECTED_SURFACE_TYPE_UNPROTECTED;
pc_player->mode = RELAXED;
pc_player->width = WIDTH * 2.0/4.0;
pc_player->height = HEIGHT * 2.0/4.0;
pc_player->x = WIDTH * 1.0/4.0;
pc_player->y = HEIGHT * 1.0/4.0;
pc_player->window = window_create(d);
pc_player->widget = window_frame_create(pc_player->window, pc_player);
pc_player->display = d;
display_set_user_data(d, pc_player);
display_set_global_handler(d, handle_global);
surface = window_get_wl_surface(pc_player->window);
if (pc_player->protection == NULL) {
printf("The content-protection object is NULL\n");
return -1;
}
pc_player->psurface = weston_content_protection_get_protection(pc_player->protection,
surface);
weston_protected_surface_add_listener(pc_player->psurface,
&pc_player_listener,
pc_player);
pc_player->b0 = create_button(pc_player, str_type_0);
pc_player->b1 = create_button(pc_player, str_type_1);
pc_player->off = create_button(pc_player, str_type_off);
pc_player->enforced = create_button(pc_player, str_type_enforced);
pc_player->relaxed = create_button(pc_player, str_type_relaxed);
window_set_title(pc_player->window, "Player");
widget_set_redraw_handler(pc_player->widget, redraw_handler);
widget_set_resize_handler(pc_player->widget, resize_handler);
window_schedule_resize(pc_player->window, WIDTH, HEIGHT);
widget_schedule_redraw(pc_player->b0->widget);
widget_schedule_redraw(pc_player->b1->widget);
widget_schedule_redraw(pc_player->off->widget);
display_run(d);
weston_protected_surface_destroy(pc_player->psurface);
weston_content_protection_destroy(pc_player->protection);
free_pc_player(pc_player);
display_destroy(d);
return 0;
}
......@@ -43,15 +43,16 @@
#include <wayland-client.h>
#include "window.h"
#include "shared/cairo-util.h"
#include "shared/config-parser.h"
#include <libweston/config-parser.h>
#include "shared/helpers.h"
#include "shared/xalloc.h"
#include "shared/zalloc.h"
#include <libweston/zalloc.h>
#include "shared/file-util.h"
#include "weston-desktop-shell-client-protocol.h"
#define DEFAULT_CLOCK_FORMAT CLOCK_FORMAT_MINUTES
#define DEFAULT_SPACING 10
extern char **environ; /* defined by libc */
......@@ -241,6 +242,14 @@ panel_launcher_redraw_handler(struct widget *widget, void *data)
cr = widget_cairo_create(launcher->panel->widget);
widget_get_allocation(widget, &allocation);
allocation.x += allocation.width / 2 -
cairo_image_surface_get_width(launcher->icon) / 2;
if (allocation.width > allocation.height)
allocation.x += allocation.width / 2 - allocation.height / 2;
allocation.y += allocation.height / 2 -
cairo_image_surface_get_height(launcher->icon) / 2;
if (allocation.height > allocation.width)
allocation.y += allocation.height / 2 - allocation.width / 2;
if (launcher->pressed) {
allocation.x++;
allocation.y++;
......@@ -377,7 +386,6 @@ panel_clock_redraw_handler(struct widget *widget, void *data)
cairo_t *cr;
struct rectangle allocation;
cairo_text_extents_t extents;
cairo_font_extents_t font_extents;
time_t rawtime;
struct tm * timeinfo;
char string[128];
......@@ -391,19 +399,20 @@ panel_clock_redraw_handler(struct widget *widget, void *data)
return;
cr = widget_cairo_create(clock->panel->widget);
cairo_select_font_face(cr, "sans",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, 14);
cairo_text_extents(cr, string, &extents);
cairo_font_extents (cr, &font_extents);
cairo_move_to(cr, allocation.x + 5,
allocation.y + 3 * (allocation.height >> 2) + 1);
cairo_set_source_rgb(cr, 0, 0, 0);
if (allocation.x > 0)
allocation.x +=
allocation.width - DEFAULT_SPACING * 1.5 - extents.width;
else
allocation.x +=
allocation.width / 2 - extents.width / 2;
allocation.y += allocation.height / 2 - 1 + extents.height / 2;
cairo_move_to(cr, allocation.x + 1, allocation.y + 1);
cairo_set_source_rgba(cr, 0, 0, 0, 0.85);
cairo_show_text(cr, string);
cairo_move_to(cr, allocation.x + 4,
allocation.y + 3 * (allocation.height >> 2));
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_move_to(cr, allocation.x, allocation.y);
cairo_set_source_rgba(cr, 1, 1, 1, 0.85);
cairo_show_text(cr, string);
cairo_destroy(cr);
}
......@@ -466,44 +475,33 @@ panel_resize_handler(struct widget *widget,
{
struct panel_launcher *launcher;
struct panel *panel = data;
int bx = width / 2;
int by = height / 2;
int spacing = 10;
int x = spacing;
int y = spacing;
int w, h;
int x = 0;
int y = 0;
int w = height > width ? width : height;
int h = w;
int horizontal = panel->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP || panel->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM;
int first_pad_h = horizontal ? 0 : DEFAULT_SPACING / 2;
int first_pad_w = horizontal ? DEFAULT_SPACING / 2 : 0;
wl_list_for_each(launcher, &panel->launcher_list, link) {
w = cairo_image_surface_get_width(launcher->icon);
h = cairo_image_surface_get_height(launcher->icon);
widget_set_allocation(launcher->widget, x, y,
w + first_pad_w + 1, h + first_pad_h + 1);
if (horizontal)
y = by - h / 2;
x += w + first_pad_w;
else
x = bx - w / 2;
widget_set_allocation(launcher->widget,
x, y, w + 1, h + 1);
if (horizontal)
x += w + spacing;
else
y += h + spacing;
y += h + first_pad_h;
first_pad_h = first_pad_w = 0;
}
h = 20;
if (panel->clock_format == CLOCK_FORMAT_SECONDS)
w = 190;
else /* CLOCK_FORMAT_MINUTES */
w = 170;
else /* CLOCK_FORMAT_MINUTES */
w = 150;
if (horizontal) {
x = width - w - spacing;
y = by - h / 2;
} else {
x = bx - w / 2;
y = height - h - spacing;
}
if (horizontal)
x = width - w;
else
y = height - (h = DEFAULT_SPACING * 3);
if (panel->clock)
widget_set_allocation(panel->clock->widget,
......@@ -544,10 +542,10 @@ panel_configure(void *data,
width = 32;
break;
case CLOCK_FORMAT_MINUTES:
width = 170;
width = 150;
break;
case CLOCK_FORMAT_SECONDS:
width = 190;
width = 170;
break;
}
break;
......
......@@ -38,7 +38,7 @@
#include <pango/pangocairo.h>
#include "shared/config-parser.h"
#include <libweston/config-parser.h>
#include "shared/helpers.h"
#include "shared/xalloc.h"
#include "window.h"
......
......@@ -193,10 +193,11 @@ keyboard_focus_handler(struct window *window,
/**
* \brief CALLBACK function, Wayland informs about key event
* \param window window
* \param input input
* \param time time
* \param key keycode
* \param unicode associated character
* \param state pressed or released
* \param modifiers modifiers: ctrl, alt, meta etc.
* \param data user data associated to the window
*/
static void
......@@ -351,8 +352,8 @@ axis_discrete_handler(struct widget *widget, struct input *input,
* \param time time the event happened
* \param x absolute x position
* \param y absolute y position
* \param sx x position relative to the window
* \param sy y position relative to the window
* \param x x position relative to the window
* \param y y position relative to the window
* \param data user data associated to the window
*
* Demonstrates the use of different cursors
......
......@@ -37,7 +37,7 @@
#include <wayland-client.h>
#include "window.h"
#include "fullscreen-shell-unstable-v1-client-protocol.h"
#include "shared/zalloc.h"
#include <libweston/zalloc.h>
struct fs_output {
struct wl_list link;
......
......@@ -39,11 +39,11 @@
#include <wayland-cursor.h>
#include <wayland-client-protocol.h>
#include "shared/cairo-util.h"
#include "shared/config-parser.h"
#include <libweston/config-parser.h>
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
#include "shared/xalloc.h"
#include "shared/zalloc.h"
#include <libweston/zalloc.h>
#include "shared/file-util.h"
#include "ivi-application-client-protocol.h"
#include "ivi-hmi-controller-client-protocol.h"
......
......@@ -132,7 +132,7 @@ foreach t : simple_clients
executable(
t_name, t.get('sources'),
include_directories: include_directories('..'),
include_directories: [ include_directories('..'), public_inc ],
dependencies: t_deps,
install: true
)
......@@ -215,7 +215,7 @@ foreach t : tools_list
executable(
'weston-@0@'.format(t.get('name')),
t.get('sources'),
include_directories: include_directories('..', '../shared'),
include_directories: [ include_directories('..', '../shared'), public_inc ],
dependencies: t.get('deps', []),
install: true
)
......@@ -226,9 +226,17 @@ demo_clients = [
{ 'basename': 'clickdot' },
{
'basename': 'cliptest',
'add_sources': [ '../libweston/vertex-clipping.c' ]
'dep_objs': dep_vertex_clipping
},
{ 'basename': 'confine' },
{
'basename': 'content_protection',
'add_sources': [
weston_content_protection_client_protocol_h,
weston_content_protection_protocol_c,
]
},
{ 'basename': 'dnd' },
{
'basename': 'editor',
......@@ -277,7 +285,7 @@ if get_option('demo-clients')
foreach t : demo_clients
t_name = 'weston-' + t.get('basename')
t_srcs = [ t.get('basename') + '.c' ] + t.get('add_sources', [])
t_deps = [ dep_toytoolkit ]
t_deps = [ dep_toytoolkit, t.get('dep_objs', []) ]
foreach depname : t.get('deps', [])
dep = dependency(depname, required: false)
if not dep.found()
......@@ -328,7 +336,7 @@ if simple_dmabuf_drm_deps.length() > 0
fullscreen_shell_unstable_v1_protocol_c,
linux_dmabuf_unstable_v1_client_protocol_h,
linux_dmabuf_unstable_v1_protocol_c,
include_directories: include_directories('..'),
include_directories: [ include_directories('..'), public_inc ],
dependencies: [
dep_wayland_client,
dep_libdrm,
......
......@@ -42,7 +42,7 @@
#include <wayland-client.h>
#include "shared/os-compatibility.h"
#include "shared/xalloc.h"
#include "shared/zalloc.h"
#include <libweston/zalloc.h>
struct device {
enum { KEYBOARD, POINTER } type;
......
......@@ -39,10 +39,11 @@
#include <wayland-client.h>
#include "shared/helpers.h"
#include "shared/zalloc.h"
#include <libweston/zalloc.h>
#include "shared/timespec-util.h"
#include "shared/os-compatibility.h"
#include "presentation-time-client-protocol.h"
#include "xdg-shell-client-protocol.h"
enum run_mode {
RUN_MODE_FEEDBACK,
......@@ -66,7 +67,7 @@ struct display {
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor;
struct wl_shell *shell;
struct xdg_wm_base *wm_base;
struct wl_shm *shm;
uint32_t formats;
......@@ -99,7 +100,9 @@ struct window {
int width, height;
enum run_mode mode;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
uint32_t configure_serial;
struct buffer *buffers;
int num_buffers;
......@@ -181,27 +184,48 @@ create_shm_buffers(struct display *display, struct buffer **buffers,
}
static void
handle_ping(void *data, struct wl_shell_surface *shell_surface,
xdg_wm_base_handle_ping(void *data, struct xdg_wm_base *xdg_wm_base,
uint32_t serial)
{
wl_shell_surface_pong(shell_surface, serial);
xdg_wm_base_pong(xdg_wm_base, serial);
}
static const struct xdg_wm_base_listener xdg_wm_base_listener = {
.ping = xdg_wm_base_handle_ping,
};
static void
handle_configure(void *data, struct wl_shell_surface *shell_surface,
uint32_t edges, int32_t width, int32_t height)
xdg_surface_handle_configure(void *data, struct xdg_surface *xdg_surface,
uint32_t serial)
{
struct window *window = data;
window->configure_serial = serial;
}
static const struct xdg_surface_listener xdg_surface_listener = {
.configure = xdg_surface_handle_configure,
};
static void
handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
xdg_toplevel_handle_configure(void *data, struct xdg_toplevel *xdg_toplevel,
int32_t width, int32_t height,
struct wl_array *states)
{
/* noop */
}
static const struct wl_shell_surface_listener shell_surface_listener = {
handle_ping,
handle_configure,
handle_popup_done
static void
xdg_toplevel_handle_close(void *data, struct xdg_toplevel *xdg_toplevel)
{
fprintf(stderr, "presentation-shm exiting\n");
exit(0);
}
static const struct xdg_toplevel_listener xdg_toplevel_listener = {
.configure = xdg_toplevel_handle_configure,
.close = xdg_toplevel_handle_close,
};
static struct window *
......@@ -228,16 +252,30 @@ create_window(struct display *display, int width, int height,
window->width = width;
window->height = height;
window->surface = wl_compositor_create_surface(display->compositor);
window->shell_surface = wl_shell_get_shell_surface(display->shell,
window->xdg_surface = xdg_wm_base_get_xdg_surface(display->wm_base,
window->surface);
if (window->shell_surface)
wl_shell_surface_add_listener(window->shell_surface,
&shell_surface_listener, window);
if (!window->xdg_surface)
return NULL;
window->xdg_toplevel = xdg_surface_get_toplevel(window->xdg_surface);
wl_shell_surface_set_title(window->shell_surface, title);
if (!window->xdg_toplevel)
return NULL;
wl_shell_surface_set_toplevel(window->shell_surface);
xdg_wm_base_add_listener(display->wm_base, &xdg_wm_base_listener,
NULL);
xdg_surface_add_listener(window->xdg_surface, &xdg_surface_listener,
window);
xdg_toplevel_add_listener(window->xdg_toplevel, &xdg_toplevel_listener,
window);
xdg_toplevel_set_title(window->xdg_toplevel, title);
xdg_toplevel_set_min_size(window->xdg_toplevel, width, height);
xdg_toplevel_set_max_size(window->xdg_toplevel, width, height);
wl_surface_commit(window->surface);
wl_display_roundtrip(window->display->display);
window->num_buffers = 60;
window->refresh_nsec = NSEC_PER_SEC / 60; /* 60 Hz guess */
......@@ -277,7 +315,7 @@ destroy_window(struct window *window)
if (window->callback)
wl_callback_destroy(window->callback);
wl_shell_surface_destroy(window->shell_surface);
xdg_surface_destroy(window->xdg_surface);
wl_surface_destroy(window->surface);
for (i = 0; i < window->num_buffers; i++)
......@@ -522,6 +560,12 @@ window_commit_next(struct window *window)
buffer = window_next_buffer(window);
assert(buffer);
if (window->configure_serial) {
xdg_surface_ack_configure(window->xdg_surface,
window->configure_serial);
window->configure_serial = 0;
}
wl_surface_attach(window->surface, buffer->buffer, 0, 0);
wl_surface_damage(window->surface, 0, 0, window->width, window->height);
wl_surface_commit(window->surface);
......@@ -718,9 +762,10 @@ registry_handle_global(void *data, struct wl_registry *registry,
d->compositor =
wl_registry_bind(registry,
name, &wl_compositor_interface, 1);
} else if (strcmp(interface, "wl_shell") == 0) {
d->shell = wl_registry_bind(registry,
name, &wl_shell_interface, 1);
} else if (strcmp(interface, "xdg_wm_base") == 0) {
d->wm_base =
wl_registry_bind(registry, name,
&xdg_wm_base_interface, version);
} else if (strcmp(interface, "wl_shm") == 0) {
d->shm = wl_registry_bind(registry,
name, &wl_shm_interface, 1);
......@@ -806,8 +851,8 @@ destroy_display(struct display *display)
if (display->shm)
wl_shm_destroy(display->shm);
if (display->shell)
wl_shell_destroy(display->shell);
if (display->wm_base)
xdg_wm_base_destroy(display->wm_base);
if (display->compositor)
wl_compositor_destroy(display->compositor);
......
......@@ -39,7 +39,7 @@
#include <wayland-client.h>
#include "shared/os-compatibility.h"
#include "shared/zalloc.h"
#include <libweston/zalloc.h>
#include "xdg-shell-client-protocol.h"
#include "fullscreen-shell-unstable-v1-client-protocol.h"
#include "viewporter-client-protocol.h"
......
......@@ -56,7 +56,7 @@
#include <drm_fourcc.h>
#include <wayland-client.h>
#include "shared/zalloc.h"
#include <libweston/zalloc.h>
#include "xdg-shell-client-protocol.h"
#include "fullscreen-shell-unstable-v1-client-protocol.h"
#include "linux-dmabuf-unstable-v1-client-protocol.h"
......