Commit Graph

154 Commits

Author SHA1 Message Date
Jon Cruz
35b2eaa989 Moved helper macro to a discrete include file.
To help reduce code duplication and also 'kitchen-sink' includes
the ARRAY_LENGTH macro was moved to a stand-alone file and
referenced from the sources consuming it. Other macros will be
added in subsequent passes.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-15 17:11:45 -07:00
Jon Cruz
4678bab13c Remove redundant #include path component.
Using the parent '../' path component in #include statements makes
the codebase more rigid and is redundant due to proper -I use.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-15 17:11:09 -07:00
Bryce Harrington
a0bbfea64b src: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00
Dima Ryazanov
b7e70af346 compositor-wayland: Code cleanup
Don't do multi-assignments.

Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-05-20 11:26:25 +03:00
Dima Ryazanov
01d5c02c04 compositor-wayland: Handle window close events more gracefully
When a compositor window is closed, remove the output instead of just exiting.

(The "if (!input->output)" checks are kind of ugly - but I couldn't find
a better way to handle the output going away.)

Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-05-19 16:42:53 -07:00
Derek Foreman
e76f185050 gl-renderer: Take a list of acceptable formats in create functions
Currently we pass either a single format or no formats to the gl renderer
create and output_create functions.  We extend this to any number of
formats so we can allow fallback formats if we don't get our first pick.

Reviewed-By: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-By: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
2015-05-18 11:51:45 +03:00
Giulio Camuffo
b114715dae compositor: send the output_created signal after inserting it in the list
The compositor's output_created signal used to be sent in weston_output_init()
which the backend call before putting the output in the output_list.
This caused problems when creating a new view in a listener to that signal,
because weston_view_assign_output() doesn't yet know the new output exists.
To fix this add a new weston_composito_add_output() func which adds the
output in the list and later sends the signal, and make the backends call
that.
2015-05-08 14:09:02 -07:00
Pekka Paalanen
04f8a9b3fa compositor-wayland: ignore frame callback's time
Weston running the Wayland backend is nested. The parent compositor uses
an unknown clock for the frame callback timestamps. This is quite likely
a different clock from what the nested Weston chose as its presentation
clock.

This means we cannot reasonably read the presentation clock and assume
it has any relation to the timestamp got from the frame callback. In
fact, this was seen to cause absurd repaint delays, trigger the insanity
check, reduce fraterate, etc. problems, because we assume we can read
the clock and compute the remaining repaint delay.

As we can't use the timestamp, ignore it, and read our own presentation
clock instead.

The X11 backend does not suffer from this, because there the parent
window system never provides us any timestamps, so we always read our
own clock.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Giulio Camuffo <giuliocamuffo@gmail.com>
2015-04-07 11:27:27 +03:00
Jonny Lamb
74eed31108 gl-renderer: call supports() automatically in create()
This means compositors don't need to call supports() manually and
create() will just return -1 in the failure case as before. This also
means we can deal with the case of eglGetProcAddress returning
non-NULL but not actually being available at runtime.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-26 09:54:49 +02:00
Jonny Lamb
ace6920912 compositor-{drm, wayland, x11}: remove useless tests for ->supports
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-26 09:54:48 +02:00
Jonny Lamb
a3e6a4a87a gl-renderer: move all EGL_PLATFORM_* defines here
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-26 09:54:48 +02:00
Jonny Lamb
62185f42ea compositor-{drm, x11, wayland}: stop including EGL headers here
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-26 09:54:48 +02:00
Jonny Lamb
671148f064 gl-renderer: use eglCreatePlatformWindowSurfaceEXT to get EGLSurfaces
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-03-20 13:57:14 -07:00
Jonny Lamb
70eba3fbde gl-renderer: use eglGetPlatformDisplayEXT to get an EGLDisplay
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-03-20 13:55:46 -07:00
Pekka Paalanen
363aa7bc76 compositor: set presentation.presented flags
Change weston_output_finish_frame() signature so that backends are
required to set the flags, that will be reported on the Presentation
'presented' event. This is meant for output-wide feedback flags. Flags
that vary per wl_surface are subject for the following patch.

All start_repaint_loop functions use the special private flag
PRESENTATION_FEEDBACK_INVALID to mark, that this call of
weston_output_finish_frame() cannot trigger the 'presented' event. If it
does, we now hit an assert, and should then investigate why a fake update
triggered Presentation feedback.

DRM:

Page flip is always vsync'd, and always gets the completion timestamp
from the kernel which should correspond well to hardware. Completion is
triggered by the kernel/hardware.

Vblank handler is only used with the broken planes path, therefore do
not report VSYNC, because we cannot guarantee all the planes updated at
the same time. We cannot set the INVALID, because it would abort the
compositor if the broken planes path was ever used.  This is a hack that
will get fixed with nuclear pageflip support in the future.

fbdev:

No vsync, update done by copy, no completion event from hardware, and
completion time is totally fake.

headless:

No real output to update.

RDP:

Guessing that maybe no vsync, fake time, and copy make sense (pixels
sent over network). Also no event that the pixels have been shown?

RPI:

Presumably Dispmanx updates are vsync'd. We get a completion event from
the driver, but need to read the clock ourselves, so the completion time
is somewhat unreliable. Zero-copy flag not implemented though it would
be theoretically possible with EGL clients (zero-copy is a per-surface
flag anyway, so in this patch).

Wayland:

No information how the host compositor is doing updates, so make a safe
guess without assuming vsync or hardware completion event. While we do
get some timestamp from the host compositor, it is not the completion
time. Would need to hook to the Presentation extension of the host
compositor to get more accurate flags.

X11:

No idea about vsync, completion event, or copying. Also the timestamp is
a fake.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Tested-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Acked-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2015-01-20 17:13:05 -08:00
Derek Foreman
64a3df086e backends: refactor transform string parsing
Most of the backends do their own parsing of transform strings, so let's
put that all in the same place (compositor.c/h)

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-19 16:46:56 +02:00
Pekka Paalanen
b5eedade36 compositor: set and use the presentation clock everywhere
Add presentation clock setters that verify the given clock actually
works. Offer an automatic choice of a software fallback clock, when a
backend has to always use clock_gettime() to approximate the
presentation time.

The DRM backend already queried the DRM about the clock id, just let the
DRM backend set the presentation clock from that.

For all other backends which do not get a timestamp from the driver,
call the software clock setter to choose a suitable clock.

Report the chosen clock via presentation.clock_id event to clients.

In finish_frame(), upgrade the argument from uint32_t milliseconds to
struct timespec which can accurately hold the presentation clock values.
This will be needed when weston_output_finish_frame() starts to send out
presentation_feedback.presented events.

While at it, replace gettimeofday() calls with clock_gettime() using the
chosen presentation clock, so we manufacture presentation timestamps
from the presentation clock when the gfx drivers cannot give us a proper
timestamp.

Rpi patch is more verbose due to not having the compositor pointer
available in rpi_flippipe_update_complete(). Explicitly carry the clock
id with flippipe so it is available in the thread.

Changes in v4:

* rpi debug build fix

v4 Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v3 Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2014-09-30 11:37:02 +03:00
Ran Benita
c9c74156cd Don't protect xkb_*_unref from NULL
Since xkbcommon-0.3.0, which is required by weston, a NULL argument
doesn't do anything.

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-08-20 01:05:16 -07:00
Ran Benita
2e1968fa1f Replace deprecated xkbcommon symbols with current names
These symbols (xkb_map_* and others) were replaced in xkbcommon with more
consistent names. See the header xkbcommon/xkbcommon-compat.h for how
the old names map to the new.

The new names have been available since the first stable xkbcommon
release (0.2.0).

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-08-20 01:05:13 -07:00
Jonny Lamb
497994a459 compositor-wayland: listen to repeat_info and save values to pass on 2014-08-15 15:39:47 +03:00
Thierry Reding
6ac60c1791 compositor-wayland: Fix compiler warning
sizeof returns size_t, for which the correct printf specifier is %zu.
Fixes the following warning when building for ARMv7.

	src/compositor-wayland.c: In function 'wayland_output_get_shm_buffer':
	src/compositor-wayland.c:260:3: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'unsigned int' [-Wformat=]
	   weston_log("could not zalloc %ld memory for sb: %m\n", sizeof *sb);
	   ^

Signed-off-by: Thierry Reding <treding@nvidia.com>
2014-06-18 17:14:40 -07:00
U. Artie Eoff
a1e887bd46 comp-wayland: use safe foreach when destroying outputs
wl_list_for_each dereference's output to increment the
next iteration of the loop.  However, output is free'd
inside the loop resulting in a dereference to free'd
memory.

Use wl_list_for_each_safe instead, which is designed to
handle this kind of pattern.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
Reviewed-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-05-23 09:57:02 +03:00
U. Artie Eoff
d8d4701864 compositor-wayland: avoid possible NULL deref in handle_keymap
If data is NULL, then we jumped to error which attempts to
dereference data.  Instead, just close(fd) and return when
data is NULL.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-05-06 15:41:02 -07:00
U. Artie Eoff
67072d03d3 compositor-wayland: assign the correct mode
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-05-06 15:40:59 -07:00
U. Artie Eoff
8cbd8f3390 compositor-wayland: free output before returning
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-05-06 15:40:55 -07:00
Bryce W. Harrington
bfd74f40f3 Check zalloc return for out of memory situation
Most zalloc calls in weston are checked, this fixes a handful that were
being ignored.  As found by `grep -EIsr "[^x]zalloc\(" . -A1`

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
2014-04-25 13:19:51 -07:00
Jason Ekstrand
b7d9f2eb2f compositor-wayland: Properly handle running inside a compositor that does not provide keymaps
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-02 21:27:26 -07:00
Jason Ekstrand
e4ca8b0bdd compositor-wayland: Add a --sprawl option
This forces weston to create one output for every parent output.  This is
enabled by default if it detects a wl_fullscreen_shell.  The --sprawl
option is primarily to enable this on wl_shell.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-02 21:27:02 -07:00
Jason Ekstrand
53ee0dcca4 compositor-wayland: Add support for running on top of wl_fullscreen_shell
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-02 21:26:39 -07:00
Bryce W. Harrington
a093502891 compositor: Use weston_log rather than perror for error messages
weston_log() seems to be the standard elsewhere in the codebase for
errors.  These are the only two instances where perror() is used
instead, and their error messages aren't that informative anyway.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
2014-04-01 16:46:41 -07:00
Hardening
842a36ae4a Check return value of wl_cursor functions
This patch adds checks for themes and cursors returned by wl_cursor functions.

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
2014-04-01 16:46:41 -07:00
Neil Roberts
77c1a5b7dc Add support for having different GBM formats for different outputs
The gbm-format configuration option can now be specified per-output as
well as in the core config section. If it is not specified it will
default to the format specified in the core section. The
EGL_MESA_configless_context extension is required for this to work. If
this extension is available it will create a context without an
EGLConfig and then it will potentially use a different EGLConfig for
each output.

The gl-renderer interface has been changed so that it takes the EGL
attributes and visual ID in the create_output function as well as in
the create function.
2014-03-12 14:44:02 -07:00
U. Artie Eoff
ff7550087e compositor-wayland: free 'theme' config option value
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-19 22:07:33 -08:00
U. Artie Eoff
1a08d1196a compositor-wayland: don't free unallocated memory
Assigning a string constant (i.e. memory that we didn't allocate)
to a char* pointer and then freeing that pointer is bad news.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-19 22:07:22 -08:00
Ander Conselvan de Oliveira
18536764b4 compositor: Destroy renderer in weston_compositor_shutdown()
Currently we destroy the renderer before the outputs are destroyed, but
that sometimes leads to an error since a reference to the renderer is
necessary in order to destroy a gl_renderer_output.

Since destroying the renderer is common among all backends, just move
that call into weston_compositor_shutdown() immediately after the
outputs being destroyed.
2013-12-22 13:45:29 -08:00
Jonas Ådahl
7395ea05c7 input: Move the xkb fields from weston_seat to weston_keyboard
XKB integration is a keyboard feature and should as such be kept track
of in the keyboard struct.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-03 08:38:25 -08:00
Axel Davy
dd8b88d102 Wayland backend: set the opaque region when starting fullscreen
The opaque region is not set when we start the nested
compositor fullscreen. This patch fixes this.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2013-11-19 11:44:51 -08:00
Jason Ekstrand
5ea048014d compositor-wayland: Add fullscreen support
This adds fullscreen support to the wayland backend.  You can make any
output fullscreen by the shortcut CTRL+ALT+F.  You can also run weston with
the --fullscreen option which causes it to create a single fullscreen
output.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-11 13:38:02 -08:00
Jason Ekstrand
12c6dd965b compositor-wayland: Add a --scale option
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-11 13:37:19 -08:00
Jason Ekstrand
0cf39351bb compositor-wayland: Move config parsing into backend_init
This cleans up the configuration and command parsing and separates it from
compositor/output initialization.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-11 13:37:08 -08:00
Jason Ekstrand
584fb62437 compositor-wayland: Fix cursor coordinate transforms so it works on translated outputs
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-11 13:36:45 -08:00
Jason Ekstrand
06ced80f93 compositor-wayland: rename wayland_compositor.inputs to input_list
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-11 13:36:32 -08:00
Jason Ekstrand
4d615a7aa1 compositor-wayland: Remove unused output handling code
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-11 13:36:22 -08:00
Jason Ekstrand
48ce42177f compositor-wayland: Parse [output] config sections and more options
This commit makes the wayland backend search through the config for
[output] sections with names starting with "WL" and create outputs
accordingly.  Outputs created due to the config file support mode, scale,
and transform parameters.  It also listens for the --output-count
command-line option.

This brings the wayland backend almost up to par, in terms of functionality
with the X11 backend.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-07 16:35:01 -08:00
Jason Ekstrand
00b842854b Remove the concept of a border from weston_output.
The only user for this was the wayland backend with the GL renderer.  It is
not needed in the Pixman renderer because you can easily create subimages.
All of the fancy output matrix calculations can be replaced by a single
glViewport call.  Also, it didn't work with outputs located anywhere but
(0, 0) and I'm pretty sure output transformed outputs would break it too.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-07 16:34:54 -08:00
Jason Ekstrand
ff2fd46e9c compositor-wayland: Add pixman/SHM fallback mode
This also adds a --use-pixman command-line option to enable the pixman
renderer explicitly.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-07 16:34:47 -08:00
Jason Ekstrand
7744f71550 compositor-wayland: Add an actual frame around the compositor window
This adds a window frame with a close button.  Similar to the X11 backend,
The window supports dragging but not resizing.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-07 16:34:10 -08:00
Jason Ekstrand
8f89fcb22b compositor-wayland: Rename structure members and make things more consistant
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-07 16:34:04 -08:00
Jason Ekstrand
286ff6817b compositor-wayland: Flush the display on commit
This fixes the problem where animations will wait to play until input is
received.  In general, it also makes the backend far more responsive.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>

https://bugs.freedesktop.org/show_bug.cgi?id=68221
2013-10-30 23:31:46 -07:00
Kristian Høgsberg
453de7a7e5 compositor-wayland: Handle HUP or ERR from event loop
Otherwise we end up in a busy loop instead of exiting nicely.
2013-10-30 23:15:44 -07:00