The third arg to strtol() specifies the base to assume for the number.
When 0 is passed, as is currently done in option-parser.c, hexadecimal
and octal numbers are permitted and automatically detected and
converted.
This change is an expansion of f6051cbab8
to cover the remaining strtol() calls in Weston, where the routine is
being used to read fds and pids - which are always expressed in base-10.
It also changes the calls in config-parser, used by
weston_config_section_get_int(), which in turn is being used to read
scales, sizes, times, rates, and delays; these are all expressed in
base-10 numbers only.
The benefit of limiting this to base-10 is to eliminate surprises when
parsing numbers from the command line. Also, by making the code
consistent with other usages of strtol, it may make it possible to
factor out the common code in the future.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This patch makes use of new flags which were introduced
by previous patches to check if a surface/view is mapped
v2:
- Rebased to apply on git master
- Added comments with link to discussion about proposed
changes for weston_{surface,view}_is_mapped()
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Currently, weston assumes a surface/view is mapped if
it has an output assigned. In a zero outputs scenario,
this isn't really desirable.
This patch introduces a new flag to weston_surface and
weston_view, which has to be set manually to indicate
that a surface/view is mapped.
v2:
- Remove usage of new flags from
weston_{view,surface}_is_mapped at this point. They
will be added after all the implicit mappings have
been introduced
- Unmap a surface before unmapping a view so the input
foci is cleaned up properly
- Remove implicit view mapping from view_list_add
- Cosmetic fixes
v3:
- Rebased to apply on git master
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This patch follows a similar approach taken to detach the backends from
weston. But instead of passing a configuration struct when loading the
plugin, we use the plugin API registry to register an API, and to get it
in the compositor side. This API allows to spawn the Xwayland process
in the compositor side, and to deal with signal handling. A new
function is added in compositor.c to load and init the xwayland.so
plugin.
Also make sure to re-arm the SIGUSR1 when the X server quits.
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
[Pekka: moved xwayland/weston-xwayland.c -> compositor/xwayland.c]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Implement a simple register and lookup for function tables. This is
intended for plugins to expose APIs to other plugins.
It has been very hard to arrange a plugin to be able to call into
another plugin without modifying Weston core to explicitly support each
case. This patch fixes that.
The tests all pass.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
This clarifies what is supposed to be the libweston code.
v2: screen-share.c is already in compositor/ instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
Acked-by: Benoit Gschwind <gschwind@gnu-log.net>
[Pekka: rebased]
The revised wp_viewport spec requires that unset has to have all of x, y,
width and height -1 to be recognized.
Check for negative x and y and raise the required error. The error event
now mentions the wl_surface, too.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
wp_viewporter requires the destination size to be always in integers,
even when it is implicit from source rectangle. Emit appropriate
protocol errors.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
wp_viewporter spec requires protocol errors when the viewport is outside
the buffer area.
The viewport is checked in wl_surface.commit handler as the error needs
to be delivered as a reply to the commit, not at state apply time later
(e.g. with synchronized sub-surfaces, or at render time).
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
If a client destroyed the wl_surface before the wp_viewport, Weston core
would access freed memory, because the weston_surface pointer stored in
the wp_viewport wl_resource's user data was stale.
Fix this by setting the user data to NULL on wl_surface destruction. It
is specifically about wl_surface and not weston_surface destruction,
because this is about client-visible behaviour. Something internal might
keep weston_surface alive past the wl_surface.
Add checks to all wp_viewport request handlers.
At the same time, implement the new error conditions in wp_viewport:
calling any request except destroy must result in a protocol error.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Since the interface is now called wp_viewport, rename functions from
"scaler" to "viewporter" as well.
scaler_surface_to_buffer() is renamed to viewport_surface_to_buffer()
because it is more about viewport than viewporter.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Migrate from wl_scaler to wp_viewporter extension. The viewporter.xml
file is provided by wayland-protocols.
This stops Weston from advertising wl_scaler, and advertises
wp_viewporter instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
[Pekka: fix wayland-protocols requirement]
When an output permanently changes its resolution, the output on the right
should be moved accordingly. We also add an event for output resizing so that
plugins can react when an output is resized.
Signed-off-by: David Fort <contact@hardening-consulting.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Change weston_compositor_load_backend() to use an enum to choose the
backend.
The caller no longer needs to know what the backend DSO is called in the
file system. Custom backends cannot be laoded anymore, as the loading
path is now always either LIBWESTON_MODULEDIR, or formed from
$WESTON_BUILD_DIR.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Backends do not have access to command line elements nor weston_config
anymore. They use the backend-specific config APIs now.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Move load_backend_new() from main.c to weston_compositor_load_backend()
in compositor.c.
This makes libweston load its own backends without leaking the details
to the user.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
The backends are now installed in lib/libweston-0, and the include
files that will be used by libweston in include/libweston-0. The other
modules and weston-specific include files are kept in the old paths.
A new wet_load_module() is added to load plugins in the old path,
which is not part of libweston, but weston only and defined in main.c.
To allow that to be used by out of tree weston plugins, the function
is declared in a new weston.h, installed in include/weston.
The -0 in the paths is the abi version of libweston, and it will also
be used by the libweston .so. If the abi changes the number will need
to be increased.
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
They belong in the compositor rather than libweston since they
set signals handlers, and a library should not do that behind its
user's back. Besides, they were using functions in main.c already
so they were not usable by other compositors.
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Use SINCE macros instead of the hardcoded version value.
Signed-off-by: David Fort <contact@hardening-consulting.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
weston_surface::output and weston_view::output as used for different
purposes. Only the surface output is used for frame callbacks.
The uses of the view output are much more vague and hard to describe.
Also fix a comment mistake in weston_surface_assign_output().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
[Pekka: more verbose on the compositor.h comments]
There were two copies of code applying transform and scale to size.
Refactor the code to use just one copy in a new function.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Makes it easier to see that it does not change weston_surface state
implicitly.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Remove the input event loop.
After "compositor-x11: stop using input_loop", the input event loop is
completely unused.
The code was also broken because it did not account for multiple outputs
with independent repaint cycles.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
This patch is a further step in the wl_fixed_t internal sanitization.
It changes the notify_* functions to take doubles instead of wl_fixed_t
but does not change how these are stored in the various input structs
yet, except for weston_pointer_axis_event.
However this already allows to remove all wl_fixed_t usage in places
like the libinput or the x11 backend.
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Remove the unstable presentation_timing.xml file, and use
presentation-time.xml from wayland-protocols instead to generate all the
Presentation extension bindings.
The following renames are done according to the XML changes:
- generated header includes
- enum constants and macros prefixed with WP_
- interface symbol names prefixed with wp_
- protocol API calls prefixed with wp_
Clients use wp_presentation_interface.name rather than hardcoding the
global interface name: presentation-shm, weston-info, presentation-test.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
[Pekka: updated wayland-protocols dependency to 1.2]
output_id_pool is defined as a uint32_t, thus ffs() provides a range of
1-32 available id numbers. When the 33rd output is enabled, Weston will
set the ID to (unsigned)(-1) and thus lead to some unexpected
behaviors.
I'm not sure what the best way to handle this error would be since this
is in an initialization routine, but at least let's document the
potential error condition with an assert().
Add an implementation of wl_surface.damage_buffer, similar to
wl_surface.damage except it uses buffer co-ordinates.
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
The function 'weston_surface_to_buffer' is unused by compositor and
clients inside weston, so it should be safe to remove this function
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Rounding both corners of the rectangle down can result in a 0
width/height rectangle before passing to weston_transformed_rect.
This showed up as missing damage in weston-simple-damage (the
bouncing ball would leave green trails when --use-viewport was
used)
Reviewed-by: Daniel Stone <daniels@collabora.co.uk>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
libwayland-server protects us from invalid serial numbers by
posting an error already.
MIN() is for clients when selecting interface versions.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
commit 57388e44e5 accidentally changed the comment in
compositor.c::subsurface_commit_to_cache
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
If we pass negative height or width on to pixman we get error messages
in the log.
Also, if width or height is 0, there's no damage, so we can early return
for that too.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
We're going to use this to replace much of the other transform code so
it's no longer just relevant to pixman-renderer.c
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
[Pekka: add the warning about matrix restrictions]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Calling weston_compositor_destroy() on a pointer returned by
weston_compositor_create() should be always valid, even if the
compositor does not have yet a backend.
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
weston_compositor_create() should just create idle timer but not arm it,
because idle-time setting is not ready at this point.
Remove idle timer first update in weston_compositor_create() since
idle_time variable is not set at this point. Idle timer is armed
properly later in weston_compositor_wake().
Signed-off-by: Egor Starkov <egor.starkov@ge.com>
[Pekka: tweaked commit message]
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v2 changes:
- implement the revised protocol
- add basic sanity checks when creating buffer and check for support
- add way to attach user data to the dmabuf for renderer use
- bump max number of planes to 4 to follow DRM AddFb2 ioctl
- improve errors handling
- use separate linux_dmabuf_buffer fields for the different wl_resource
types
- as SERVER_ERROR code is no more, use a wl_display "generic" error for
emergency-disconneting a client we fail to process
- more documentation
- change y-invert from per-plane boolean to per-buffer flag
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
When the output can't be completely created in the backend (for example
lack of memory), weston_compositor_add_output() is never run. In such
a case output->link is not initialized. Letter, when
weston_output_destroy() is called, application crashes on
wl_list_remove(&output->link).
This problem happens when drm, fbdev, rdp, rpi or wayland backend is
used.
v2: Initialize output->link in weston_output_init() as suggested by
Derek Foreman.
Signed-off-by: Dawid Gajownik <gajownik@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Valgrind has shown that in at least one place (default_grab_pointer_focus)
we're testing uninitialized values coming out of weston_compositor_pick_view.
This is happening when default_grab_pointer_focus is called when there is
nothing on the view list, and during the first repaint when only the black
surface with no input region exists.
This patch adds a function to clear pointer focus and also set the sx,sy
co-ordinates to a sentinel value we shouldn't compute with.
Assertions are added to make sure any time pointer focus is set to NULL
these values are used.
weston_compositor_pick_view() now returns these values too.
Now the values are always initialized, even when no view exists, and
they're initialized in such a way that actually doing computation
with them should fail in an obvious way, but we can compare them
safely for equality.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
In weston_compositor_create, we initialize output_list.
After that we call weston_compositor_schedule_repaint which just calls
weston_output_schedule_repaint on all elements of output_list.
This call does nothing obviously. So we remove it.
Signed-off-by: Ryo Munakata <ryomnktml@gmail.com>
Reviewed-by: Guilio Camuffo <guiliocamuffo@gmail.com>
Keyboards and pointers aren't freed when devices are removed, so we should
really be testing keyboard_device_count and pointer_device_count in most
cases, not the actual pointers. Otherwise we end up with different
behaviour after removing a device than we had before it was inserted.
This commit renames the touch/keyboard/pointer pointers and adds helper
functions to get them that hide this complexity and return NULL when
*_device_count is 0.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
We were loading modules out of the system dirs unconditionally, so
tests that loaded modules would use the system ones, or fail if
they weren't installed.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-By: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Normally we need to check if a seat's [device_type]_count is > 0 before
we can use the associated pointer. However, in a binding you're
guaranteed that the seat has a device of that type. If we pass in
that type instead of the seat, it's obvious we don't have to test it.
The bindings can still get the seat pointer via whatever->seat if they
need it.
This is preparation for a follow up patch that prevents direct access
to seat->device_type pointers, and this will save us a few tests at
that point.
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>