Commit Graph

3823 Commits

Author SHA1 Message Date
Neil Roberts
40c0c3f91e tests: Test whether a simple EGL main loop uses too many buffers
This adds a test that tries to simulate a simple game loop that would
be like this:

while (1) {
        draw_something();
        eglSwapBuffers();
}

In this case the test is relying on eglSwapBuffers to throttle to a
sensible frame rate.

The test then verifies that only 2 EGL buffers are used. This is done
via a new request and event in the wayland-test protocol.

Currently this causes 3 buffers to be created because the release
event generated by the swap buffers is not processed by Mesa until it
blocks for the frame complete event in the next swap buffers call, but
that is too late.

This can be fixed in Mesa by issuing a sync request after the swap
buffers and blocking on it before deciding whether to allocate a new
buffer.
2013-12-07 22:26:23 -08:00
Giulio Camuffo
65a07f8aef input: make sure the devices get the resource destruction signal
The device may not have a resource for the client yet, but install
the listeners nevertheless.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=65726
2013-12-06 11:19:38 -08:00
Kristian Høgsberg
c8f8dd894e desktop-shell: Drop next_type from shell_surface
The surface type now no longer changes and we track pending state changes in
next_state.  Instead of testing type != next_type to detect changes in
state, we just look at state_changed.
2013-12-05 23:20:44 -08:00
Kristian Høgsberg
4804a301db shell: Put xwayland surface at the top of the fullscreen layer
An xwayland surface corresponds to a override-redirect window under X,
which is typically a menu or a popup window.  They typically appear
with a keyboard and mouse grab and by nature of being override-redirect
these window can appear anywhere on screen and in the stack.

We need to resort to heuristics to decide where to place the
override-redirect in our surface stack, and for now we'll just put it on
top of everything.  That's going to be correct for almost all cases of
clicking to open a menu, but we can revisit and refine if we run into
a case that needs better handling.
2013-12-05 22:43:03 -08:00
Kristian Høgsberg
41fbf6f7fd desktop-shell: Make set_toplevel() clear surface states
This is used from wl_shell and xwayland and we need to make sure
xwayland also gets this behavior.
2013-12-05 22:31:25 -08:00
Kristian Høgsberg
e960b3f012 desktop-shell: Set fullscreen flags in common code path
Just as for set_maximized() we can move the setting of the fullscreen and
state_changed flags into the common set_fullscreen() function.  This
function is also used from the xwayland wm to set fullscreen windows, and
with this change that now works again.
2013-12-05 22:04:42 -08:00
Kristian Høgsberg
c2745b14f0 desktop-shell: Set maximized flags in common code path
We can set the maximized and state_changed flags in set_maximized(),
which is shared between shell_surface_set_maximized() and
xdg_surface_set_maximized().
2013-12-05 22:00:40 -08:00
Kristian Høgsberg
acdae2e641 stacking: Set a keyboard focus handler so we can repaint the frame
Yes, perhaps this should be more automatic...
2013-12-05 15:37:29 -08:00
Rafael Antognolli
5031cbe7b4 shell: Don't try to switch to a NULL shell surface.
Fixes the crash from alt+tab when there's a fullscreen surface.
2013-12-05 15:37:29 -08:00
Rafael Antognolli
db59f9a53f shell: Set a surface as TOPLEVEL instead of the old surface types.
Since internally there's no more SHELL_SURFACE_FULLSCREEN and
SHELL_SURFACE_MAXIMIZED, the surface must be set to
SHELL_SURFACE_TOPLEVEL on the respective functions.

This fixes the bug when clients start already in fullscreen mode. In
that case, they aren't set first to toplevel, and then change to
fullscreen. They are set as fullscreen directly, not receiving the
SHELL_SURFACE_TOPLEVEL type on the set_fullscreen function.
2013-12-05 15:15:11 -08:00
Kristian Høgsberg
a98c2e17fd compositor-x11: Damage output when we receive expose events for the window
The gl renderer typically repaints everything since we don't have
EGL_buffer_age under X, but the pixman renderer carefully only repaints
damaged regions.  So to actually repaint anything with the pixman
renderer, we need to damage the output.

https://bugs.freedesktop.org/show_bug.cgi?id=72351
2013-12-05 12:30:39 -08:00
Rafael Antognolli
44a3162eea shell: Add missing break to a case statement inside set_surface_type.
This should fix the surface not going back to its original position
after unsetting fullscreen or maximized states.

https://bugs.freedesktop.org/show_bug.cgi?id=72321
2013-12-05 12:02:36 -08:00
Neil Roberts
a5059eb187 nested: Add an option to disable subsurfaces
This adds a -b option to force the nested compositor example to use
the old blit renderer even if the appropriate extensions are
available.
2013-12-04 16:34:08 -08:00
Neil Roberts
1f020a1fdb nested: Add a renderer using subsurfaces
Adds a second renderer implementation to the nested compositor example
that creates a subsurface for each of the client's surfaces. The
client buffers are directly attached to the subsurface using the
EGL_WL_create_wayland_buffer_from_image extension instead of blitting
them in the redraw_handler.

The new renderer is always used if the parent compositor supports the
wl_subcompositor protocol and the EGL extension is available.
Otherwise it will fall back to the blit renderer.
2013-12-04 16:34:07 -08:00
Neil Roberts
5e10a04481 clients: Add a widget_get_wl_subsurface
Adds a simple accessor for the wl_subsurface for widgets created with
window_add_subsurface.
2013-12-04 16:34:07 -08:00
Neil Roberts
47b87d5ec0 nested: Add a ‘renderer’ mechanism with a vtable
Eventually the nested compositor example will want to be able to cope
with either rendering as it does now with a blit to an intermediate
surface or by attaching the client buffers directly to a subsurface
without copying. This patch moves the code that is specific to the
blitting mechanism into a separate set of functions with a vtable to
make it easier to add the second way of rendering in a later patch.
2013-12-04 16:34:07 -08:00
Neil Roberts
f9b2541df1 nested: Move the frame callback list to the surface
Previously the frame callback list was tracked as part of the global
compositor state. This patch moves the list to be part of the surface
state like it is in Weston. The frame callback now iterates the list
of surfaces to flush all of the callbacks. This change will be useful
when the example is converted to use subsurfaces so that it can have a
separate frame callback for the subsurface and flush the list for an
individual client surface rather than flushing globally.
2013-12-04 16:34:07 -08:00
Neil Roberts
2855766333 nested: Add damage tracking to the nested compositor example
The nested compositor example now responds to damage requests and
tracks them in the pending buffer state. This isn't currently used for
anything and it is immediately discarded when the surface is commited
but it will be used later when the example is converted to use
subsurfaces.
2013-12-04 16:34:07 -08:00
Neil Roberts
15a8d340fd nested: Add double-buffered state semantics to the nested example
The buffer and frame callback state on the surfaces in the nested
compositor example are now double-buffered so that they only take
effect when the commit request is received. This doesn't really make
much difference for the current state that the example has but it will
be useful when more state is added in later patches.
2013-12-04 16:34:07 -08:00
Neil Roberts
6bf23879e9 nested: Add the buffer reference semantics from Weston
This copies the buffer reference busy count implementation from Weston
to the nested compositor example and adds an internal nested_buffer
struct that we could eventually use to attach data. This will be
useful to adapt the example to use subsurfaces so that we can attach
our compositor-side buffer to the resource.
2013-12-04 16:34:07 -08:00
Neil Roberts
8fbe3a68d4 nested: Remove the surface from the surface list when destroyed
Otherwise if the surface is destroyed then it will crash when it later
tries to render all of the surfaces. You can replicate this by doing
killall weston-nested-client while the example is running.
2013-12-04 16:34:07 -08:00
Kristian Høgsberg
b7fd89192f build: Fix out-of-tree build for desktop-shell 2013-12-04 12:57:02 -08:00
Rafael Antognolli
ba5d2d76af shell: Fix activate logic on surface map.
It should activate the newly mapped surface if not locked.
2013-12-04 11:55:03 -08:00
Pekka Paalanen
477333285e rpi: launcher must init before udev-seat
udev-seat will call weston_launcher_open(), so we better init launcher
first. Fixes a segfault.

Cc: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-12-04 11:38:40 -08:00
Pekka Paalanen
53b41c7890 rpi: seat quick fix
Fix the default seat name, so that we can find the input devices by
default.

This is just a quick fix. Further enhancement would be to make the
default seat on rpi taken from a command line option like the other
backends do. Furthermore, udev_input_init() should accept NULL as seat
to use the default seat, avoiding us hardcoding "seat0" all over.

Cc: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-12-04 11:38:26 -08:00
Pekka Paalanen
bc91e5120c rpi: compile in the common udev code
In a recent commit 37d38d932c, "rpi: Use
common udev_input for input device handling", the rpi-backend was made
to use the common udev code.

It just forgot to actually build the common udev code into the
rpi-backend.

Cc: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-12-04 11:38:08 -08:00
Pekka Paalanen
e47d0d986c gl: fix fallback definition of EGL_DEFAULT_DISPLAY
Compiling fbdev backend on RaspberryPi caused the following warning:

compositor-fbdev.c: In function 'fbdev_compositor_create':
compositor-fbdev.c:929:6: warning: passing argument 2 of
'gl_renderer->create' makes integer from pointer without a cast [enabled
by default]
compositor-fbdev.c:929:6: note: expected 'EGLNativeDisplayType' but
argument is of type 'void *'

Fix the definition of EGL_DEFAULT_DISPLAY to match the definition in
EGL/egl.h (of Mesa).

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-12-04 11:37:57 -08:00
Kristian Høgsberg
677a5f5ac2 desktop-shell: Split out input-panel code 2013-12-04 11:03:24 -08:00
Kristian Høgsberg
1ef231377c desktop-shell: Split out exposay immplementation 2013-12-04 10:20:02 -08:00
Kristian Høgsberg
19d1e6b185 desktop-shell: Move to new desktop-shell subdirectory 2013-12-04 10:20:02 -08:00
Kristian Høgsberg
2ba10df300 Move xwayland up one directory level 2013-12-04 10:20:02 -08:00
Kristian Høgsberg
873b515aee tablet-shell: Remove
The tablet-shell is unmaintained and unused.  It is currently
dead-weight and a burden when we make changes to weston.  Let's
drop it for now, we can pull it out of git if we find a need for it later.
2013-12-04 10:18:29 -08:00
Dima Ryazanov
cae1f0ff2d Check if the frame exists before reading its size
This fixes crashes caused by popup windows that don't have override_redirect
(e.g., menus in VLC and KDE apps).

Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
2013-12-03 16:13:08 -08:00
Dima Ryazanov
b03b87fe63 Check for frame being NULL before setting/unsetting flags
Fixes a crash in Firefox when clicking an "install plugin" popup.

Signed-off-by: Dima Ryazanov <dima@gmail.com>
2013-12-03 16:12:54 -08:00
Dima Ryazanov
e5a3208373 Set the view to NULL when unmapping an X11 window
Fixes a crash caused by accessing a deleted view in weston_wm_window_schedule_repaint. It can be easily reproduced by switching between menus in Firefox.

Signed-off-by: Dima Ryazanov <dima@gmail.com>
2013-12-03 15:54:44 -08:00
Jonas Ådahl
767d891c35 data-device: Fix surface configure function type
The commit "Remove the weston_view.geometry.width/height fields" changed
the type of the surface configure callback function, but did not change
the callbacks in data-device.c. This commit fixes the type of the
functions left needed to be changed.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-03 15:16:21 -08:00
David Herrmann
aedc7732eb logind: delay wakeup until DRM-device is resumed
The logind API was designed to allow any kind of devices and any number of
devices. It has no idea of "main DRM device" or similar. However, the
weston DRM backend was designed with a single DRM device as master.
Therefore, we wake it up unconditionally on session-wakeup. But this may
fail with logind as a session may be awake, but not all devices have been
resumed, yet.

Therefore, we change the weston-logind backend to deal with this case
correctly. Instead of waking up the compositor on session-wakeup, we wait
for the main DRM device to wake up. Once we get the event, we notify the
compositor.

For sleep, we reverse this logic. On *any* of the following events we
tell the compositor to go to sleep:
 - Session gets inactive
 - DRM device gets inactive
 - DRM device is removed
This guarantees, that weston is only active if *both*, the session and the
main DRM device are awake/active.

Note that we could actually rely solely on the DRM-device Pause/Resume
events from logind and drop all the Active-Prop-Changed handling. logind
guarantees proper ordering of both. However, in case we ever change weston
to support multiple GPUs, we need the per-device notification. Thus, keep
the code. This also makes weston more fail-safe in case logind fails to
send the PauseDevice event (for whatever reason..).
2013-12-03 12:57:01 -08:00
Rafael Antognolli
ea997ac696 xdg-shell: Add key bindings for setting maximized and fullscreen. 2013-12-03 12:57:01 -08:00
Rafael Antognolli
65f98d8c2f xdg-shell: xdg_surface_set_output should only affect fullscreen. 2013-12-03 12:57:01 -08:00
Rafael Antognolli
3c4e3f7cc7 xdg-shell: Add surface size to configure.
Also emit configure on unset_maximized and unset_fullscreen.
2013-12-03 12:57:01 -08:00
Rafael Antognolli
e2a3455642 xdg-shell: Implement xdg-shell interface.
The whole xdg-shell interface is implement, except from the "focused_set"
and "focused_unset" events.
2013-12-03 12:57:01 -08:00
Rafael Antognolli
4b99a40bcb shell: Move shell_surface_set_parent to wl_shell calls.
The parent update on set_maximized and set_fullscreen is a behavior of
wl_shell.

That does not happen on xdg-shell, so it can't be in the set_fullscreen
and set_maximized common code, but rather in the wl_shell_surface
interfaces.
2013-12-03 11:35:25 -08:00
Rafael Antognolli
ed207b4bd5 shell: Remove SHELL_SURFACE_TRANSIENT. 2013-12-03 11:35:25 -08:00
Rafael Antognolli
03b16597e0 shell: Remove SHELL_SURFACE_FULLSCREEN and SHELL_SURFACE_MAXIMIZED.
These surface types don't exist anymore inside weston desktop shell
implementation. They are just exposed as wl_shell surface types, but
internally the implementation is done with surface states.

The previous behavior (setting a surface type unsets another one) still
happens when using wl_shell. This change is mainly done as a refactory
to allow xdg-shell to use the same code.
2013-12-03 11:35:25 -08:00
Rafael Antognolli
3c4dc74ceb xdg_shell: Adding a new shell protocol.
xdg_shell is a protocol aimed to substitute wl_shell in the long term,
but will not be part of the wayland core protocol. It starts as a
non-stable API, aimed to be used as a development place at first, and
once features are defined as required by several desktop shells, we can
finally make it stable.

It provides mainly two new interfaces: xdg_surface and xdg_popup.

The xdg_surface interface implements a desktop-style window, that can be
moved, resized, maximized, etc. It provides a request for creating
child/parent relationship, called xdg_surface.set_transient_for.

The xdg_popup interface implements a desktop-style popup/menu. A
xdg_popup is always transient for another surface, and also has implicit
grab.
2013-12-03 11:35:24 -08:00
Jonas Ådahl
91fed5419c input: Reset keyboard state when releasing last seat keyboard
Don't rely on the input driver to properly send button-up events for
every pressed key.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-03 08:39:55 -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
Jason Ekstrand
918f2dd4cf Remove the weston_view.geometry.width/height fields
This has a couple of additional implications for the internal weston API:
 1) weston_view_configure no longer exists.  Use weston_view_set_position
    instead.
 2) The weston_surface.configure callback no longer takes a width and
    height.  If you need these, surface.width/height are set before
    configure is called.  If you need to know when the width/height
    changes, you must track that yourself.
2013-12-02 22:17:58 -08:00
Pekka Paalanen
fdca95c7db window: handle insufficient buffer space
It is quite possible for os_create_anonymous_file() to fail when trying
to allocate a new wl_shm buffer. Propagate this failure out from
shm_surface_prepare. Most parts of toytoolkit are already avoiding NULL
cairo surfaces.

If cairo surface allocation fails, do not try to call the widget redraw
functions, those are not prepared to deal with NULL. Also do not
schedule a frame callback, this allows us to retry drawing the next
time.

If redraw fails for the main_surface of a window, restore the widget
geometry to what the compositor currently is showing. This keeps the
window visual appearance in sync with application state, so interacting
with the application does not break too badly.

If the very first draw of any window fails, then forcefully exit the
program. E.g. if weston-desktop-shell fails to allocate buffers for the
unlock dialog, w-d-s exits, and weston unlocks the screen automatically.

This patch allows e.g. weston-terminal to stop from enlarging while
resizing, if new sized buffers can no longer the allocated. Even then,
the application stays usable, as it can often repaint in the last
successful size. It does not crash, and the user is able to resize it
smaller, too.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-12-02 16:20:58 -08:00
Pekka Paalanen
5b4ddbc11e os: use posix_fallocate in creating sharable buffers
If posix_fallocate is available, use it instead of ftruncate. Unlike
ftruncate, when posix_fallocate succeeds, it guarantees that you cannot
run out of disk space, when later writing to the mmap()'ed file.

With posix_fallocate, if os_create_anonymous_file() succeeds, the
program cannot get a SIGBUS later from accessing this file via mmap. If
there is insufficient disk space, the function fails and errno is set to
ENOSPC.

This is useful on systems, that limit the available buffer space by
having XDG_RUNTIME_DIR on a small tmpfs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-12-02 16:20:27 -08:00