Commit Graph

1185 Commits

Author SHA1 Message Date
Alexander Larsson
d9a7bb75d0 compositor-drm: Support output scaling
If you specify e.g. scale=2 in an output section in weston.ini
we scale all modes by that factor.

We also correctly scale cursor positioning, but ATM there is no
scaling of the cursor sprite itself.
2013-05-22 16:19:59 -04:00
Alexander Larsson
80f9163ad6 compositor-x11: Only repaint the damaged region
Set a clip on the GC when painting the damaged region so that
we don't copy the entire shadow buffer each time.
2013-05-22 16:19:54 -04:00
Alexander Larsson
4ea9552d05 compositor: Support output/buffer scaling
If you specify e.g. scale=2 in weston.ini an output section for the
X11 backend we automatically upscale all normal surfaces by this
amount. Additionally we respect a buffer_scale set on the buffer to
mean that the buffer is already in a scaled form.

This works with both the gl and the pixman renderer. The non-X
backends compile and work, but don't support changing the output
scale (they do downscale as needed due to buffer_scale though).

This also sends the new "scale" and "done" events on wl_output,
making clients aware of the scale.
2013-05-22 16:19:42 -04:00
Alexander Larsson
1f206b4ce4 pixman-renderer: Fix up transform handling
Rather than storing the shadow_image in the untransformed space
and rotating on copy to hw_buffer we store both on the transformed
space. This means a copy between them is a straight copy, and that
apps supplying correctly transformed surface buffers need not
change them.

We also correctly handle all output transform including the previously
unhandled flipped ones, as well as client supplied buffer_transforms (which
were previously ignored).

We also simplify the actual rendering by just converting any damage
region to output coordinates and set it on a clip and composite
the whole buffer, letting pixman do the rectangle handling. This
means we always do all the transforms, including the surface positioning
as a pixman_image transform. This simplifies the code and sets us up
for handling scaling at a later stage.

The transform looks complicated, but in practice it ends up being
an integer translation almost always, so it will hit the pixman
fastpaths.
2013-05-22 16:19:36 -04:00
Kristian Høgsberg
d7ab5b8007 cms-static: Use the right wl_listener for the output hotplug listener 2013-05-22 14:20:42 -04:00
Rob Bradford
d33f2b065c weston-launch: Print explanation of why we failed to open the device 2013-05-20 16:55:12 -04:00
Rob Bradford
2f8d9aacfa shell: End grab if the grabbed shell surface has been destroyed
The shell_grab_start function sets up a destroy notification on the
shell surface such that when the shell surface is destroyed the pointer
on the grab to the shell surface is set to NULL.

We must therefore check whether the shell surface is NULL and end the
grab if it is.

https://bugs.freedesktop.org/show_bug.cgi?id=64689
2013-05-20 16:53:49 -04:00
Hardening
eb1e13044f Fix surface_pong when a seat doesn't have a pointer
This patch fixes a crash with the surface_pong when one of the
seats doesn't have a pointer. This was the case with the RDP compositor
that use a fake seat with no mouse or keyboard.
2013-05-17 16:30:39 -04:00
Quentin Glidic
ff3230952a weston-launch: Run weston in the user login shell
This patch brings back the user environment from the shell.
In the future, weston-launch could create the Wayland socket earlier, in
which case the user's shell could be used to run Wayland-specific tools
in the new Weston session.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2013-05-17 16:23:46 -04:00
Pekka Paalanen
86c8ca03b5 compositor: forbid sub-surface nesting loops
The only way to create a sub-surface loop by recursive nesting is to
make the main surface (which does not have a role) a sub-surface of any
of its sub-surfaces. All other cases should already be cought.

This change checks for that exact case, and sends a protocol error.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-17 16:22:18 -04:00
Pekka Paalanen
16abf6a4d4 protocol: set_desync should flush
wl_subsurface.set_desync should apply the cached wl_surface state.
Otherwise, the sub-surface may be stuck: a commit on the parent surface,
if desynchronized, will not commit the sub-surface because it is
desynchronized, too. A commit on the sub-surface may not happen, if it
is waiting for the frame callback from the previous commit.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-17 16:21:50 -04:00
Ander Conselvan de Oliveira
1ed73246ed gl-renderer: Compile shaders only when needed
Saves some start up time by not compiling specific shaders until they
are needed.
2013-05-17 11:52:25 -04:00
Richard Hughes
d561687ec8 cms-colord: Warn if reading or writing to the FD failed
This also fixes a compile warning when building the tarball.
2013-05-15 11:40:10 -04:00
Richard Hughes
2379a65c9f cms-colord: Fix build after the API change 'Honor XDG_CONFIG_DIRS' 2013-05-15 11:40:10 -04:00
Kristian Høgsberg
b9f1c5248b lock-surface: Set geometry width and height before centering
The subsurface patches changed the center_on_output() behavior a bit.
Instead of using the buffer width and height, it now looks at surface
geometry.  In lock_surface_configure() we haven't set up the geometry
when we call center_on_output() so the lock surface would never show
up.
2013-05-14 20:59:07 -04:00
Eduardo Lima (Etrunko)
2733700bb4 text: Respawn input method process if it exits
Just the same as it is done in shell.c, if the input method process exits
for any reason, we relaunch it automatically, as it is not possible to
launch a standalone application outside of the weston process.

In v2:
 - Proper error message when giving up.

Signed-off-by: Eduardo Lima (Etrunko) <eduardo.lima@intel.com>
2013-05-14 14:55:39 -04:00
Ossama Othman
a50e6e4c50 config-parser: Honor XDG_CONFIG_DIRS
This set of changes adds support for searching for a given config file
in the directories listed in $XDG_CONFIG_DIRS if it wasn't found in
$XDG_CONFIG_HOME or ~/.config.  This allows packages to install custom
config files in /etc/xdg/weston, for example, thus allowing them to
avoid dealing with home directories.

To avoid a TOCTOU race the config file is actually open()ed during the
search.  Its file descriptor is returned and stored in the compositor
for later use when performing subsequent config file parses.

Signed-off-by: Ossama Othman <ossama.othman@intel.com>
2013-05-14 14:36:37 -04:00
Ander Conselvan de Oliveira
95eb3a2eb4 compositor-drm: Don't page flip before a mode is set
The function drm_output_start_repaint_loop() unconditionally issues a
page flip, even if the crtc for that output has not been enabled yet.
That causes the page flip to fail, and drm_output_repaint() is never
called.

Solve this by bypassing the initial page flip if the output needs a
mode set.

This has the caveat of affecting latency predictability for that first
frame and when a "driver" mode fullscreen surface causes a mode set.
However, on both cases the mode set would take an unpredictable amount
of time anyway.

https://bugs.freedesktop.org/show_bug.cgi?id=63812
https://bugs.freedesktop.org/show_bug.cgi?id=64183
2013-05-14 10:21:54 -04:00
Richard Hughes
be7c4dd2a0 Add a colord implementation of a CMS plugin for weston
This allows users to change the assigned display profile in GNOME (using
gnome-control-center) or KDE (using colord-kde) and also allows the profiling
tools to correctly inhibit the calibration state whilst measuring the native
screen response.
2013-05-14 10:15:39 -04:00
U. Artie Eoff
ec08f33482 move subsurface-server-protocol.h include out of compositor.h
The subsurface-server-protocol.h header should not be included
by any headers that are part of the SDK since it is not exported.
Otherwise, SDK consumers will break during compilation.

Move this include from compositor.h to compositor.c.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=64537

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2013-05-14 10:09:52 -04:00
Giulio Camuffo
b836664c42 shell: account for the subsurfaces when going fullscreen or maximizing
We must calculate the bounding box of the surface + subsurfaces set and use
that when maximizing the window or going fullscreen.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-10 14:35:33 -04:00
Giulio Camuffo
61da3fc948 shell: enable moving and resizing of a surface when clicking on a subsurface
[pq: changed to weston_surface_get_main_surface(), and used a temporary
variable to clean up the expressions.]

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-10 14:35:25 -04:00
Pekka Paalanen
01388e253e shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:

- Move, resize, and rotate bindings always target the parent surface.

- Opacity (full-surface alpha) binding targets the parent surface. This
  is broken, because it should change the opacity of the whole compound
  window, which is difficult to implement in the renderer.

- click_to_activate_binding() needs to check the shell surface type from
  the main surface, because sub-surface would produce SHELL_SURFACE_NONE
  and prevent activation.

- Also activate() needs to check the type from the main surface, and
  restack the main surface. Keyboard focus is assigned to the original
  (sub-)surface.

- focus_state_surface_destroy() needs to handle sub-surfaces: only the
  main surface will be in a layer list. If the destroyed surface is
  indeed a sub-surface, activate the main surface next. This way a
  client that destroys a focused sub-surface still retains focus in the
  same window.

- The workspace_manager.move_surface request can accept also
  sub-surfaces, and it will move the corresponding main surface.

Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
  sub-surfaces in shell, fix focus_state_surface_destroy()

Changes in v3:
- Renamed weston_surface_get_parent() to
  weston_surface_get_main_surface() to be more explicit that this is
  about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
  sub-surface.
- Used a temporary variable in several places to clarify code, instead
  of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-10 14:34:54 -04:00
Pekka Paalanen
e67858b9cf compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code

Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.

For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.

Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.

The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.

Features still lacking are:
- full-surface alpha support for compound windows

Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
  main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy

Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
  wl_subsurface protocol object inert, if one destroys the corresponding
  wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
  .place_below to be applied when the parent surface state is applied,
  instead of immediately. This conforms with the protocol specification
  now.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-10 14:32:51 -04:00
Pekka Paalanen
2396aec684 protocol: add sub-surfaces
Add protocol for sub-surfaces, wl_subcompositor as the global interface,
and wl_subsurface as the per-surface interface extension.

This patch is meant to be reverted, once sub-surfaces are moved into
Wayland core.

Changes in v2:

- Rewrite wl_subcompositor.get_subsurface description, and move mapping
  and commit details into wl_subsurface description. Check the wording
  in wl_subsurface.set_position description.

- Add wl_subsurface.set_commit_mode request, and document it, with the
  commit_mode enum. Add bad_value error code for wl_subsurface.

- Moved the protocol into Weston repository so we can land it upstream
  sooner for public exposure. It is to be moved into Wayland core later.

- Add destroy requests to both wl_subcompositor and wl_subsurface, and
  document them. Experience has showed, that interfaces should always
  have a destructor unless there is a good and future-proof reason to not
  have it.

Changes in v3:

- Specify, that wl_subsurface will become inert, if the corresponding
  wl_surface is destroyed, instead of requiring a certain destruction
  order.

- Replaced wl_subsurface.set_commit_mode with wl_subsurface.set_sync and
  wl_subsurface.set_desync. Parent-cached commit mode is now called
  synchronized, and independent mode is desynchronized. Removed
  commit_mode enum, and bad_value error.

- Added support for nested sub-surfaces.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-10 14:05:59 -04:00
Kristian Høgsberg
3d64a3e868 compositor-drm: Destroy sprites before destroying the outputs 2013-05-10 12:51:08 -04:00
Richard Hughes
b24e48e2ff Add initial color management framework code
ICC profiles can now be specified in weston.ini for each output, or a CMS
implementation can optionally loaded from a pluggable module.
2013-05-10 12:51:08 -04:00
Kristian Høgsberg
7b9195f9d6 compositor: Move gl-renderer vertex arrays into gl-renderer.c
They were still sitting in struct weston_compositor.
2013-05-08 22:38:05 -04:00
Kristian Høgsberg
659f2adacf compositor: Remove stale prototype
We got rid of this function.
2013-05-08 22:31:03 -04:00
Kristian Høgsberg
df54a60e67 input: Remove unused focus and key fields from keyboard and focus grabs 2013-05-08 22:11:11 -04:00
Kristian Høgsberg
6848c25677 input: Move surface picking into the pointer grab focus callback
Currently the core input code does surface picking before calling into
the focus callback of the current grab.  Not all grabs need to pick a
surface however, so we're doing work we don't have to in those cases.

For example, the shell move and resize grabs don't need to pick and the
default grab in implicit grab mode doesn't either.

With this change, the pointer grab mechanism is now very simple:
the focus callback is called whenever the pointer may have a new focus,
the motion callback is called whenever the pointer moves and
the button callback whenever a button is pressed or released.
2013-05-08 22:03:45 -04:00
Kristian Høgsberg
be6403ed5c input: Get rid of grab focus concept
This was another complication that we had to have to support the
split between libwayland-server and weston.  Different grabs want to send
events relative to different surfaces at different times.  The default
grab switches between sending coordinates relative to the 'current' surface,
that is the surface the pointer is currently above, or the 'clicked'
surface, in case of an implicit grab.

The grab focus was set by the grab implementation and the core input code
would transform the pointer position to surface relative coordinates for the
grab focus and store in grab->x/y.

Now we can just let the grab implementation transform the pointer
coordinates itself, leaving the implementation free to transform
according to whichever surface it wants.  Or not transform at all if
it doesn't need surface relative coordinates (like the shell move and resize
grabs).
2013-05-08 21:03:23 -04:00
Kristian Høgsberg
e122b7ba58 input: Remove 'current' and related fields from weston_pointer
The current surface field was used to track the surface the pointer was
currently over along with pointer position relative to that surface,
regardless of implicit or explicit grabs.  The main purpose was to restore
the default grab when another grab terminated.  We can now just repick in
that case and avoid keeping that state around, with the destroy listener
overhead that involves.

There was one other use case - we used to optimize out calls to
weston_pointer_set_focus() if the focus didn't actually change.  We can
still do that, but we have to do that in the default_grab_focus() handler
and compare against weston_pointer->focus instead.
2013-05-08 16:47:06 -04:00
Kristian Høgsberg
dba25868bc data-device: Verify that the client has an implicit grab when starting a drag
Make sure that the implicit is valid and still in effect as we start
the drag.  Fixes a long standing FIXME.
2013-05-08 15:58:49 -04:00
Kristian Høgsberg
5a9fb35c89 data-device: Eliminate two small helper functions
device_setup_new_drag_surface() and device_release_drag_surface() are both
now fairly small and only called from data_device_start_drag() and
data_device_end_grab() respectively.  Folding the two functions in where
they're called from simplifies the code flow a bit.
2013-05-08 15:58:49 -04:00
Kristian Høgsberg
c43aad1ab4 data-device: Rename generic weston_drag 'surface' field to 'icon' 2013-05-08 15:58:49 -04:00
Kristian Høgsberg
054c50a6de data-device: Move all drag-related fields out of weston_seat
We can now allocate a temporary weston_drag structure that we keep all
this drag-and-drop related state in.
2013-05-08 15:58:49 -04:00
Kristian Høgsberg
195b869f0e input: Move sprite fields into weston_pointer from weston_seat 2013-05-08 15:58:49 -04:00
Kristian Høgsberg
fe7aa90ed4 compositor: Adapt to wl_surface going away
struct weston_surface is now the only surface type we have (in core, shell.c
has shell_surface, of course).  A lot of code gets simpler and we never
have to try to guess whether an API takes a wl_surface or a weston_surface.
2013-05-08 09:54:37 -04:00
Kristian Høgsberg
a4036bbd23 input: Allocate pointer/keyboard/touch structs 2013-05-07 23:52:07 -04:00
Kristian Høgsberg
2bf876282f input: Eliminate weston_seat::has_pointer/keyboard/touch
We can just look at weston_seat::pointer/keyboard/touch now.
2013-05-07 23:40:26 -04:00
Kristian Høgsberg
aad8099c2f data-device: Update drag icon position from configure and motion handlers
We can now update the drag icon position directly from the configure
handler or the grab motion handler, and no longer need
weston_seat_update_drag_surface().
2013-05-07 22:57:15 -04:00
Kristian Høgsberg
415f30cc08 data-device: Map drag icon in configure handler
This how we usually do it, and we avoid 'polling' for mapping in
weston_seat_update_drag_surface().
2013-05-07 22:42:31 -04:00
Kristian Høgsberg
5f95557631 data-device: Setup and release drag surface and beginning and end of drag
Previously we just got the drag_icon signal and had to figure out what
changed.  Now we can directly setup or release the drag icon when the
drag starts and stops.
2013-05-07 21:06:38 -04:00
Kristian Høgsberg
40e44ab18d data-device: Fix dnd regression from weston_seat rewrite
We had a drag_surface in wl_seat and weston_seat which confused me during
the rewrite.
2013-05-07 20:50:26 -04:00
Kristian Høgsberg
624d8f2293 data-device: Don't emit a signal for drag icon changes
The signal used to be in libwayland-server and the listener in weston, but
now they're both in the same file, so lets stop using signal.
2013-05-07 20:46:04 -04:00
Kristian Høgsberg
7848bb687c input: Move drag handling to data-device.c 2013-05-07 11:18:46 -04:00
Kristian Høgsberg
8799d41b1e compositor: Move fan_debug to gl-renderer
With the debug binding infrastructure, we can do this all inside
gl-renderer.c.
2013-05-07 10:50:09 -04:00
Kristian Høgsberg
e314875d00 input: Merge wl_seat into weston_seat 2013-05-07 09:07:43 -04:00
Kristian Høgsberg
4912454ba4 input: Remove wl_seat destroy signal
We already have one on weston_seat.
2013-05-06 22:27:40 -04:00