We want to make sure that the matrix symbols are exported from weston and
that modules get them from there. To do that, we pull matrix.[ch] out of
libshared and back into weston. calibrator now also links to matrix.[ch]
and we add a IN_WESTON define to enable the WL_EXPORT macro when compiled
inside weston.
Trying to create a ARGB framebuffer for scanout results in EINVAL when
trying to queue the pageflip. This patch overrides the format we pass
to addfb2 in case of primary buffers like we do for sprites.
Since we always have to inspect and override the format, don't try to
look up the format in drm_fb_get_from_bo(). Instead return format from
drm_output_check_scanout_format().
Rename drm_surface_format_supported() to drm_output_check_sprite_format()
and make it follow the same convention.
We started scanning out ARGB surfaces in commit e920941032.
Since the call to drmModeSetPlane() fails with EINVAL if the supplied
fb has an unsupported format (which is the case of ARGB8888), the fb
format needs to be overridden.
This avoids calling weston_surface_set_position twice on the same surface. The
second call has no effect in many cases because sx and sy
are usually zero on this path.
This change now means that any sx/sy values passed into ::attach will be
ignored on the first attach for popup surfaces. This similar to the behaviour
for other surface types.
At this point path must point to an allocated string since otherwise the
asprintf that makes the allocation would have failed and we would have
returned earlier.
Make overlays work when the client uses a buffer with the same
transformation as the output.
In order to calculate the destination rectangle, the same logic in
weston_surface_to_buffer_float() is needed, but with the output
dimensions instead. For that reason, this patch generalizes this
function into weston_transformed_{coord,rect} and moves it to util.c.
The surface functions are then implemented using those.
After a client has been double-buffering, and then switches to
single-buffering, it should release the 2nd buffer. That never happens
in practice here, so just add a comment and a check in case it ever
occurs in the future.
If we implemented the releasing now, it would be difficult to test.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
A client can reliably avoid allocating a second buffer per surface, if
the compositor sends the wl_buffer.release event before the frame
callback. To enable clients' single-buffering, release the wl_buffer
early if possible. Otherwise clients will double-buffer.
Releasing early is not possible, if the backend needs the buffer for
migrating a surface to or from a non-primary weston_plane. In that case,
a new buffer must arrive, before the old can be released. Backends will
indicate this by setting weston_surface:keep_buffer to 1 in
assign_planes().
A proper buffer reference in the backends would be better than the
keep_buffer flag, but that would require a per-surface backend private.
The rpi and DRM backends are updated to set keep_buffer, other backends
do not support planes, so do not have to set it.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Instead of relying on the compositor core to keep the wl_buffer around
and unreleased, take a new reference to it in gl-renderer. This makes
sure in the future, that the gl-renderer always has the buffer at hand,
client misbehaviour excluded.
The reference is taken in the attach callback, and released in the
flush_damage callback after copy to texture, or when the next attach
callback with a different buffer occurs.
If the surface is not on the primary plane, the buffer is not released
in flush_damage. This ensures, that the buffer stays valid in case the
surface migrates to the primary plane later.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
The wl_buffer reference counting API has been inconsistent. You would
manually increment the refcount and register a destroy listener, as
opposed to calling weston_buffer_post_release(), which internally
decremented the refcount, and then removing a list item.
Replace both cases with a single function:
weston_buffer_reference(weston_buffer_reference *ref, wl_buffer *buffer)
Buffer is assigned to ref->buffer, while taking care of all the refcounting
and release posting. You take a reference by passing a non-NULL buffer, and
release a reference by passing NULL as buffer. The function uses an
internal wl_buffer destroy listener, so the pointer gets reset on
destruction automatically.
This is inspired by the pipe_resource_reference() of Mesa, and modified
by krh's suggestion to add struct weston_buffer_reference.
Additionally, when a surface gets destroyed, the associated wl_buffer
will send a release event. Often the buffer is already destroyed on
client side, so the event will be discarded by libwayland-client.
Compositor-drm.c is converted to use weston_buffer_reference.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
The protocol does not require us to flush_damage() on wl_buffer
destruction. In fact, by the time the server receives this request, the
client may have already clobbered the buffer's storage, so we could be
reading undefined data. Instead, just forget about the buffer. The
protocol already says, that a client must not destroy a buffer that is
being read by the server, or the window contents become undefined.
The practical reason for this change is that the following commit can
consolidate wl_buffer destruction listener handlers.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
If a client called wl_surface.attach with the same wl_buffer as
previously, the compositor would mistakenly send a release on that
buffer. This will cause problems only when clients start to properly use
the wl_buffer.release event.
Do not send wl_buffer.release if the same buffer is attached again.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Do not remove the input panel layer from the layer list when the
shell is locked in hide_input_panels().
https://bugs.freedesktop.org/show_bug.cgi?id=56543
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
This a basic calibration tool designed for "in factory" calibration of a touch
screen. The constants for the calibration functions:
x' = Ax + By + C and
y' = Dx + Ey + F
Are printed on stdout when the calibration is completed.
When redrawing surfaces, use_shader() checks if the desired shader is
already in use to avoid a call to glUseProgram(). However, once the
debug binding is activated, that same check would prevent the usage of
the recompiled shaders until something cause a different shader to be
passed to use_shader().
It's pure WM-related function, so use the same 'weston_wm_' prefix that others
in the same file are already using.
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
It was already being used in most of launcher.c and window-manager.c, so let's
make a standard everywhere now.
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
In a few cases, we set a motion handler just to be able to set a fixed
cursor. This adds a default cursor helper that can be used in those cases.
In case of the 'transformed' test case, we also avoid a brief flicker
of the pointer cursor, which is set on enter when the move grab is lifted.
Change the boolean parameter 'resize_hint' into a bitmask 'flags'.
Note, that this flags is very different to the other flags used in
creating the toysurface implementations. They do not make sense to mix
one way or the other. Prepare() cannot change the surface type, and
surface constructors do not care for dynamic hint flags.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
When a window's buffer transformation is set, its buffers are
reallocated with the appropriate size (i.e., with width and height
swapped in case of 90 or 270 degree rotation).
Since the opaque region was set in frame_resize_handler(), if a client
created a frameless window setting the toplevel widget as opaque would
have no effect.
This patch fixes this by moving the call wl_surface_set_opaque_region()
to idle_resize(), and changing the latter function to set the whole
window as opaque if its toplevel widget has the opaque flag set.
Fix the following build warnings, and the build failures due to the
warning fixes:
CC libshared_cairo_la-image-loader.lo
image-loader.c:369:1: warning: no previous prototype for 'load_image'
CC x11_backend_la-compositor-x11.lo
compositor-x11.c: In function 'x11_output_set_icon':
compositor-x11.c:396:2: warning: implicit declaration of function 'load_image'
compositor-x11.c:396:8: warning: assignment makes pointer from integer without a cast
CC wayland_backend_la-compositor-wayland.lo
compositor-wayland.c: In function 'create_border':
compositor-wayland.c:97:2: warning: implicit declaration of function 'load_image'
compositor-wayland.c:97:8: warning: assignment makes pointer from integer without a cast
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
The implementation of buffer transformation didn't handle transformed
shm buffers properly. The partial texture upload was broken since the
damage is in surface coordinates that don't necessarily match the
buffer's coordinates. It also wouldn't handle the buffer stride
properly, resulting in incorrect rendering if it didn't match the
buffer's width.
The logic used for converting texture coordinates was generalized and
moved out of the renderer, since this conversion may be useful in other
places, such as the backends.
To reproduce, launch the terminal, open a second window using Ctrl-Shift-N,
go back to the first window, and press Ctrl-D. The terminal's master FD gets
events even after being closed, causing terminal_destroy to be called twice
on the same object.
To fix this, I'm adding a function to stop watching an FD.
We were pulling in cairo and the image loading libraries through libshared.
Split out libshared into a core libshared and a libshared-cairo that
pulls in the extra libraries.
Since a6813d288, there is no longer a "type" key in the [shell] config section.
Instead the code accepts a [core] section with a modules key, containing a
comma separated list of modules to load. This patch removes the type keys
and adds a core section in the example weston.ini config file.
Since surface.commit was introduced, opqaue regions are stored in a pending
variable that isn't used until surface.commit. Xwayland uses the surface opaque
region as a way to tell weston what region of the surface should be opaque.
However when this pending opaque region was introduced, xwm was not updated
and so we have the 'black = transparent' problem again. This patch fixes the
problem by having xwm use the pending opaque regions.