Destroy all wl objects and call EGL cleanup functions. Reduces leaks
reported by Valgrind considerably, though not to zero.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Implement proper destructors that call the wayland destroy functions.
With this and the "client: fix a strdup memory leak" patch in Wayland
core, simple-shm now runs Valgrind-clean (memcheck).
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Add signal handler for SIGINT to simple-egl and simple-shm, so they can
be exited voluntarily, without killing them. Later we can add clean-up
code and destructors, and check with valgrind for leaks and errors.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
fade_output() is strange in that it manufactures a wlsc_surface object
by hand, and then calls wlsc_surface_draw() on it.
Valgrind complained, that wlsc_surface_draw() accesses uninitialised
data: wlsc_surface::alpha. fade_output() forgets to set it.
Initialise surface.alpha in fade_output(). Specifically, set it to
compositor->current_alpha to deliberatly avoid the gluniform1f() call in
wlsc_surface_draw().
fade_output() binds a different GL shader program than
wlsc_surface_draw() expects. This program does not have a uniform called
"alpha", and the uniform location given in glUniform1f() is not for
this program anyway. A hint of that is the runtime error:
Mesa: User error: GL_INVALID_OPERATION in glUniform(type mismatch)
Fixing this seems to get rid of half a thousand of Valgrind errors, and
of course the Mesa user error.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Not sure why we get these, but it happens for Alt-click to move a window
(metacity binding) and messes up the idle inhibit counter.
FocusOut event as a result of ungrabbing doesn't really make sense and
fortunately we can safely ignore them.
The Cairo documentation tells us to always call cairo_device_flush()
before using other rendering APIs on the cairo surface, especially where
the Cairo device shares state with us (that is, EGL and GL state in this
case).
Add a call to cairo_device_flush() into display_acquire_window_surface(),
which the toytoolkit offers for switching to native (GL) rendering.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Besides the new header file, there's also a change in the main evdev creation
procedure for a more suggestive name (evdev_input_add_devices ->
evdev_input_create). There's no real functional changes in this commit.
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
I caught this when an evdev device fd was trying to trigger the main event
loop, which was already free'd and causing an invalid read.
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
Was causing an invalid read when the output is in fact destroyed. That's only
visible (segfault on my machine) on drm compositor because it's the only
backend trying to finish correct the compositor.
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
Activate the toplevel, fullscrren and menu surfaces during mapping,
so that the launched applications can get the keyboard focus without
clicking on that window.
Move idle_time variable to struct wlsc_compositor, so that a shell
plugin can change it. Also store the original value from the command
line.
Add "duration" option to the desktop-shell screensaver config. This is
the time the screensaver will be visible, after idle timeout triggers
another time and blanks the screen.
Now you can have different delays to lock the screen, and switch off the
screen while a screensaver is running.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Read the same configuration file in the shell plugin (desktop-shell) as
the desktop-shell client does.
Add a new section "screensaver", where "path" defines the path of the
idle animation client to be executed. Not defining "path" disables the
animation.
Idle animations are not in use by default. It must be configured in
wayland-desktop-shell.ini or launched manually.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Add WLSC_COMPOSITOR_IDLE state to the possible compositor internal
states, and fix the drm backend to restore the previous state instead of
forcing ACTIVE.
Normally, the compositor only uses the ACTIVE and SLEEPING states. The
IDLE state is another active state, reserved for the shell, when the
shell wants to have unlock() calls on activity, but the compositor cannot
be SLEEPING.
Use the IDLE state to fix exposing the unlock dialog while a screensaver
is animating. Without this fix, is it impossible to activate the unlock
dialog without waiting for a second idle timeout that really puts the
compositor into SLEEPING.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Reorder code in fade_frame() to that if shell->lock() calls
wlsc_compositor_wake(), the fade animation will run again.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Screensavers become visible the first time only after the compositor has
gone to sleep state. Therefore, to see screensaver in the start, wake up
the compositor. After a second idle timeout, the compositor will stay
sleeping.
We could also not apply this patch. It would mean the screensavers would
be visible only with the unlock dialog, and not become visible
automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Implement the basics of screensaver surface management. Exec'ing and
killing the screensaver client is punted for later.
When a surface registered as a screensaver is mapped, it stays hidden
if the screen is not locked, or it is added to the compositor visible
surfaces list if the screen is locked.
The map() is restructured to set initial position first, and stacking
next. This allows SHELL_SURFACE_SCREENSAVER share positioning with
SHELL_SURFACE_FULLSCREEN, while show_screensaver() does its own
wlsc_surface_configure() call.
Also fix centering to the given fullscreen output, not the first output.
Another bug fix: previously configure() would call
wlsc_surface_configure() unconditionally, which assigns an output to
the surface. While the compositor is locked, if an application resizes
its window, we hit configure() and assign an output while the surface is
not in compositor->surface_list. This leads to invalid memory access on
the next call to wlsc_surface_damage_below(). Fix this by not calling
wlsc_surface_configure() for surfaces that are not visible.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
So far nothing prevented a client for registering a surface as one type
and then as another type. With some special types, this would lead to
corrupted wl_lists.
Add a function, that either resets the surface type or posts an error to
the client. In case of an error, the set type operation must be aborted.
Change the type name SHELL_SURFACE_NORMAL to SHELL_SURFACE_NONE, as
there is nothing normal in the "none" type which just means uninitialised.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Create instances from outputs, and register the surfaces as
screensavers. Support multiple "Mode" instances.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Add output_configure_handler as a display property. This exposes only
configured outputs, that is the current mode info is already received,
to applications.
The handler is also called for mode changes on an existing output. This
simplifies the implementation in toytoolkit as we can defer the handler
calls from wl_output binding time to when we receive the current mode.
We do not need separate handlers for "new output" and "mode changed". A
plain "new output" handler would be problematic as the current mode is
not known yet.
Also add delete_handler hook for outputs, but that will never be called
for now, as the protocol lacks a way to signal output disconnections.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
when a motion is being performed on ts device, only one axis can be sent
through the evdev bytestream whereas the other could be omitted. For instance:
-------------- SYN_REPORT ------------
type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 22208
type 3 (EV_ABS), code 58 (ABS_MT_PRESSURE), value 631
type 3 (EV_ABS), code 0 (ABS_X), value 22208
-------------- SYN_REPORT ------------
on such case we'd have to send the compositor the old value of Y. Commit
f547bd36 introduced this bug cause it was sending zeroed coordinate and not
the old one.
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
We do not handle errors of gbm-buffer-creation and drm-mode-setting in
create_output_for_connectors. Correctly catch these now and free memory on error
to avoid memory leaks.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We currently simply return -1 on error in create_output_for_connector. This
correctly frees the output and all modes when we fail to avoid memory leaks.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We need to correctly free every connector we retrieve. We currently loose them
if they are not connected.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
In the wl_shell_surface migration, I forgot to correct one cast in
shell_surface_set_transient(). 'parent_resource' is not a (struct
wlsc_surface *) but (struct shell_surface *).
This bug corrupts a wlsc_surface::output field, which later (in my
experiments) leads to a segmentation fault in surface_frame().
Fix the casts.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Eventually we will want more functionality in the shared library and we
will rename it at that point. Perhaps we'll name it libnih, but for now
let's stick with libconfig-parser.
One less syscall and error path to check, and feels like a cleaner approach.
The commit adds two lines, but that's because we actually handle the
potential error now.
The signal mask is inherited over fork() and exec(), we need to
explicitly reset it.
This allows the children to receive the signals the compositor itself
has blocked, for example SIGINT and SIGTERM.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
shell.c and tablet-shell.c had almost the same code for forking their
special shell client. Generalise this code and put it into
wlsc_client_launch() in compositor.c.
Improve error cleanup and reporting in wlsc_client_launch().
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Add an option to the desktop-shell ini file that defines whether screen
locking is used or not.
Useful for testing screensaver interactions without a lock surface.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>