Commit Graph

592 Commits

Author SHA1 Message Date
Neil Roberts 6c3b01f81e Apply the zoom transformation before the output transformation
The zoom translation is just a scale and a translate. The translation
is calculated based on the coordinates of the pointer which are in
global space. Previously the calculated translation was transformed by
the output transformation so that when the zoom transform is applied
after the output transform then it will be correct. However if we just
apply the zoom transformation first then we get the same result
without the zoom code having to be aware of the output transformation.

This also fixes weston_output_transform_coordinate which was applying
the output and zoom transforms in the wrong order.

https://bugs.freedesktop.org/show_bug.cgi?id=78211
2014-05-06 15:36:55 -07:00
Neil Roberts eb5a200807 Take into account the zoom when applying the output transform
When converting output-relative coordinates (such as from an input
event) to global coordinates it now takes into account the zoom
transform. Previously this would only work for the primary pointer
because the transform doesn't affect the primary pointer position due
to that way zoom follows the mouse. Touch events and multiple pointers
were not working correctly.

https://bugs.freedesktop.org/show_bug.cgi?id=68620
2014-05-01 09:07:51 -07:00
Neil Roberts 1e40a7ec7a Simply the matrix calculation for zooming
In order to apply the zoom transformation to the output matrix, Weston was
doing the following:

• Create a temporary matrix to hold the translation
• Invert the translation matrix using weston_matrix_invert into
  another temporary matrix
• Scale that matrix by the scale factor
• Multiply the current matrix with the temporary matrix

Using weston_matrix_invert to invert a translation matrix is over the top.
Instead we can just negate the values we pass to weston_matrix_translate.
Matrix multiplication is associative so creating a temporary matrix to hold the
scale and translation transform should be equivalent to just applying them
directly to the output matrix.
2014-04-25 15:18:37 -07:00
Jason Ekstrand d0cebc36fb Use the correct width/height when transforming surfaces with viewports.
Previously, because of the wrong width/height,
weston_surface_to_buffer_* would return the wrong values when
wl_viewport was used in combination with wl_surface.set_buffer_transform.

Reviewed-by: Pekka Paalanen <ppaalanen@gmail.com>
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-25 13:24:57 -07:00
Pekka Paalanen e931721aa1 compositor: wl_viewport destination 1x1 min
Ensure, that the resulting surface size is at least 1x1, even when
destination size is not set and source size is zero. Previously this
lead to zero surface size.

This can still happen due to wl_viewport.set(#, #, 0, 0, #, #) followed
by wl_viewport.set_destination(-1, -1).

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-04-06 22:38:24 -07:00
Pekka Paalanen 2c8b5f534b protocol: unify wl_viewport src and dst size rules
Let's make the source and destination size rules consistent: neither can
have zero, {-1, -1} disables it, and other negatives are not allowed.

The sanity of allowing zero sized source rectangle as debatable. Now the
minimum becomes 1/256x1/256, and with output_scale the actual samples
may be even smaller. That should be enough.

On not allowed values, raise a protocol error. This should help catch
bugs in clients that accidentally send garbage values.

The old wl_viewport.set request remains the same, and can still produce
zero sized source rectangle.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-04-06 22:38:15 -07:00
Kristian Høgsberg f03a04afac compositor: Add create_surface_signal
This signal is emitted when a client creates a surface, not for internal
surfaces.
2014-04-06 22:22:04 -07:00
Hardening f34cd2c676 compositor-rdp: Add an option to disable client initiated resizes
This patch adds an option to the RDP compositor to disable
desktop resizes initiated by RDP peer. The current behaviour
is that if an incoming RDP peer suggests a resolution that is
not the current one, a mode_switch() is done and the desktop is
resized to that new resolution. This new flag allows to disable
that behaviour. If the flag is set, the new behaviour is that the
RDP peer will be instructed to resize to the size of the desktop.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-02 21:27:49 -07:00
Jason Ekstrand 923bfe6f1f Add support for running with a primary client
On startup weston now detects the WAYLAND_SERVER_SOCKET environment
variable.  If found, weston does not create the display like normal, but
instead directly adds a client corresponding to the given fd.  This,
combined with the fullscreen shell, allows a process to spawn weston and
use it as a backend.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-02 21:27:30 -07:00
Jason Ekstrand cf40a13820 Automatically select the wayland backend if WAYLAND_SOCKET is set
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-02 21:27:06 -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
Giulio Camuffo c6ab3d52f5 compositor: let the shells create the screenshooter 2014-04-02 11:39:19 -07:00
Giulio Camuffo e058cd13e8 compositor: export weston_buffer_from_resource()
This is needed to allow shell plugins to implement their own
screenshooter.
2014-04-02 09:13:45 -07:00
Hardening fb24eaac03 Make RDP backend supports arbitrary modes
This patch removes the extra modes parameter for the RDP compositor. And
make it support any mode that is requested (be aware that RDP client may not
support all possible modes, especially odd resolution).

This new version fixes remarks done by Jason Ekstrand. It also fixes
some missing spaces between if and (.
2014-04-01 16:46:41 -07:00
Pekka Paalanen 0b4c535d73 protocol,compositor: split wl_viewport setters
Bump wl_scaler and wl_viewport versions to 2. Add new requests
wl_viewport.set_source and .set_destination, which are meant to replace
wl_viewport.set request.

Now a client can set and unset just one of source rectangle and
destination size. Define the semantics when one of these is unset.

Implement these semantics changes in compositor and pixman renderer.
GL-renderer does not need changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-04-01 16:46:40 -07:00
Pekka Paalanen f0cad4844c compositor: replace weston_buffer_viewport::viewport_set
Remove the explicit boolean variable, and use illegal width to denote
"not set".

Split the boolean into two, so we can later start having buffer.src_*
and surface.* set or not set independently. This may become useful when
the wl_viewport interface is changed to allow modifying them separately.

At the moment, both buffer.src_width and surface.width conditions are
always in sync.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-04-01 16:46:40 -07:00
Pekka Paalanen 952b6c8004 compositor: reorganize struct weston_buffer_viewport
Queueing in the Presentation extension requires splitting the viewport
state into buffer state and surface state. To conveniently allow
assigning only one, the other, or both, reorganize the
weston_buffer_viewport structure.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-04-01 16:46:40 -07:00
Pekka Paalanen 7ed251c119 compositor: use surface_set_size() in one more case
Fix one left-over case that directly assigned
weston_surface::width,height, and so missed view dirtying.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-04-01 16:46:40 -07:00
Pekka Paalanen 3c9b8024fa compositor: refactor code into weston_surface_reset_pending_buffer()
No functional changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-04-01 16:46:40 -07:00
Pekka Paalanen 260ba38fff compositor: buffer can be non-NULL only if newly_attached
There is no need for weston_subsurface_commit_to_cache() to leave the
pending.buffer set. Reset it to NULL.

This makes pending.buffer always NULL if pending.newly_attached == 0.
IOW, pending.buffer cannot be non-NULL unless
pending.newly_attached == 1.

Therefore no need to check pending.buffer nor cached.buffer_ref.buffer
for the weston_surface_attach() calls.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-04-01 16:46:40 -07:00
Pekka Paalanen bb2f3f2f91 compositor: refactor more into weston_surface_attach
Merge more code into a common function. No functional changes.

At every site where weston_surface_set_size_from_buffer() was called,
weston_surface_attach() was called first. Move all calls of
set_size_from_buffer into weston_surface_attach.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-04-01 16:46:40 -07:00
Quanxian Wang b2c86363b8 weston: Send done event with version 2 of wl_output
With protocol of wl_output version 2, after the output change,
it should send done event to all clients bound to it.

Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
2014-04-01 16:46:40 -07:00
Kristian Høgsberg e11ef64534 compositor: Drop core ping_handler callout
This was always a little iffy.  At least it could have been a signal,
but we now have focus signal, so lets just use that.  We lose
the ability to detect unresponsive clients at key event time, but we
could add that back by adding a key_signal.
2014-02-11 16:35:22 -08:00
Ander Conselvan de Oliveira c94d6229dc compositor: Move view repositioning logic into shell
Remove the listener for output destroy from weston_view and instead
iterate views owned by the shell in its own output destroy listener.

This simplifies the code a bit since keeping the view listening for the
destroy on the right output was a bit complicated. This also removes the
function pointer output_destroyed from weston_view. The only user for it
was desktop shell, but now this is all handled in shell.c.
2014-02-05 17:36:00 -08:00
Ander Conselvan de Oliveira a8a9baf873 compositor: Remove weston_output::move_signal
Since that signal is per output, it is necessary to track in which
output a view is in so that the signal is handled properly.

Instead, add a compositor wide output moved signal, that is handled by
the shell. The shell iterates over the layers it owns to move views
appropriately.
2014-02-05 17:32:35 -08:00
Ander Conselvan de Oliveira f84327aef2 input: Remove exported function weston_pointer_verify()
Instead, add a compositor signal that an output has been destroyed and
handle that case locally in input.c.
2014-02-01 01:36:05 -08:00
Guillem Jover 32b793cb7f compositor: Clarify XDG_RUNTIME_DIR misconfiguration message
If only the mode or the owner are wrong, do not say both are wrong.
Change the text to state that there's a problem and the current
values, and let the user figure it out.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2014-02-01 01:16:07 -08:00
U. Artie Eoff 2e2384aac5 compositor: free memory from str config sections after done using it
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-19 22:10:19 -08:00
Jason Ekstrand 81038fba86 Only update the surface size if a new buffer is attached
This fixes a regression caused by either 918f2dd4 or da75ee1d.  In
particular, if a client called commit without attaching a buffer and if the
compositor had already released its reference to the buffer, then a size of
0x0 would be set on the surface.  In particular, this affects the wayland
backend because it frequently sends only a frame request in order to cause
a refresh.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-01-13 15:59:08 -08:00
Kristian Høgsberg b0fb25dedc compositor: Init output listeners in weston_view if it's not on any output
If we don't add the listener back to a new output, we have to init the
list links so we can remove them unconditionally.

Closes: https://bugs.freedesktop.org/show_bug.cgi?id=73415
2014-01-09 22:42:28 -08:00
Pekka Paalanen b0420aeb3d protocol: rename wl_surface_scaler to wl_viewport
This seems like a better name, and will not conflict if someone later
extends wl_surface with a request scaler_set (yeah, unlikely).

This code was written by Jonny Lamb, I just diffed his branches and made
a patch for Weston.

Cc: Jonny Lamb <jonny.lamb@collabora.co.uk>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-01-08 21:33:19 -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
Ander Conselvan de Oliveira 24dff2b704 compositor: Clean up view output move and destroy listeners
Remove those listeners when the output is destroyed, otherwise they'll
point to invalid data that may lead to corruption when assigning a new
output for the view.

--
This is possibly related to bug 72845. I didn't have enough equipment
to try and reproduce it.

https://bugs.freedesktop.org/show_bug.cgi?id=72845
2013-12-19 21:52:09 -08:00
Kristian Høgsberg df42a80ea2 compositor: Initialize output listener links
Make sure the links are initialized so we can safely remove the listeners
in weston_view_unmap().

https://bugs.freedesktop.org/show_bug.cgi?id=72808
2013-12-17 14:58:19 -08:00
Jonny Lamb 7413076f82 compositor: transform surface coordinates if a surface scaler is used
Implements wl_surface_scaler.set by setting desired
src_{x,y,width,height} and dst_{width,height} values in the
weston_buffer_viewport struct, then altering coordinates in
weston_surface_to_buffer* functions if there is a scaler set for said
surface.
2013-12-16 22:38:07 -08:00
Jonny Lamb 8ae3590325 compositor: add stub scaler resources
This registers the wl_scaler global object and lets clients create
wl_surface_scaler objects for surfaces. wl_surface_scaler.set is not
implemented so this doesn't really do anything useful yet.
2013-12-16 22:36:11 -08:00
Jason Ekstrand 5c11a3340b Add a weston_surface_set_size function
Surfaces that are created by clients get their size automatically updated
by the attach/commit.  Surfaces created directly by shells (such as black
surfaces) sometimes need to be manually resized.  This function allows you
to do that while being somewhat less messy than messing with the internals
of weston_surface manually.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-12-16 17:23:09 -08:00
Zhang, Xiong Y 31236932a1 desktop-shell: Invalidate saved position when output is destroyed
If the saved position for a fullscreen or maximized output view is in an
output that has been unplugged, the coordinates don't make sense
anymore. In that case, invalidate them and use the initial position
algorithm when changing them back to the basic state.

Signed-off-by: Zhang, Xiong Y <xiong.y.zhang@intel.com>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2013-12-16 17:23:08 -08:00
Ander Conselvan de Oliveira 54e90c7e1e compositor: Make pointers visible when an output is unplugged
Previously, if a pointer was inside an output that was unplugged, it
could potentialy end up outside any valid output forever. With this
patch, the pointer is moved to the "closest" output to the pointer.
2013-12-16 17:23:08 -08:00
Ander Conselvan de Oliveira e1e2352dcc compositor: Don't repaint outputs being destroyed
Set a flag when an output is being destroyed and use that to avoid
repainting. This allows functions that schedule an output repaint to
be called when the output is being destroyed without causing the
compositor to crash.
2013-12-16 17:23:01 -08:00
Zhang, Xiong Y 010d0b1695 compositor: Ensure views are visible if their output was unplugged
Use the output destroy signal to move the views in the event the output
was unplugged.

Signed-off-by: Zhang, Xiong Y <xiong.y.zhang@intel.com>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2013-12-16 16:46:22 -08:00
Zhang, Xiong Y f301241d1a compositor: Move views when outputs are moved
Previously, when an output was moved due to another output being
unplugged, the views on the first output would remain in the same
position.

This patch adds an output_move signal that the views listen too in
order to repostion themselves in the event of an unplug.

Signed-off-by: Zhang, Xiong Y <xiong.y.zhang@intel.com>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2013-12-16 16:23:11 -08:00
Zhang, Xiong Y a4b54c0b79 compositor: Move the logic of moving outputs into the core
Instead of having the backends move the remaining outputs when one is
destroyed, let the core compositor deal with that.

Signed-off-by: Zhang, Xiong Y <xiong.y.zhang@intel.com>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2013-12-16 16:20:51 -08:00
Ander Conselvan de Oliveira f749fc3782 compositor: Remove output from list in weston_output_destroy()
When destroying ouputs, they would sometimes be removed before the call
to weston_output_destory() and sometimes after, depending on the
backend. Now the output is remove withing that function so the behavior
is standard across all backends.
2013-12-16 16:19:46 -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
Philip Withnall 83ffd9d17b shell: Remove weston_view_restack()
It’s tied too deeply into the shell’s window stacking and ordering code
to legitimately be split out into compositor.c. Inline it in the shell,
and refactor some code around it a little, tidying up the stacking
behaviour for fullscreen surfaces.
2013-12-02 11:44:51 -08:00
Tomeu Vizoso e4f7b92204 rpi: Support opaque regions
This is needed for XWayland surfaces with alpha channel, as X will be
sending crap in there that should be discarded.

This is currently done with a copy in the compositor, while we wait for
support in the VideoCore side.
2013-12-02 11:36:29 -08:00
Pekka Paalanen da75ee1de0 compositor: merge surface size from buffer size funcs
Replace the two functions getting the intended surface dimensions from
the surface's buffer and buffer transformation parameters by a single
function that just set the surface size according to all the buffer
state.

The old functions were always called in pairs, and always assigned to
the surface dimension variables.

This function also deals with a NULL buffer by setting the dimensions to
zero, just like the callers used to do.

The new function has no users outside this source file, so do not export
it. This basically unexports the old functions.
2013-11-28 14:14:10 -08:00
Pekka Paalanen 1fd9c0f81a compositor: gather buffer_transform and _scale into a struct
Gather the variables affecting the coordinate transformations between
buffer and local coordinates into a new struct weston_buffer_viewport.

This will be more useful later, when the crop & scale extension is
implemented.
2013-11-28 14:14:05 -08:00
Axel Davy 40ee921fff Do not set output->current_mode in compositor.c
The field is already set - correctly - in the backend switch_mode.
setting output->current_mode to mode in compositor.c leads to bugs,
since mode can be freed by the shell.
For example, the shell allocates it on the stack for
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2013-11-27 22:56:43 -08:00