profile/ivi/weston-ivi-shell.git
11 years agocompositor-drm: Support output scaling
Alexander Larsson [Wed, 22 May 2013 12:41:39 +0000 (14:41 +0200)]
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.

11 years agocompositor-x11: Only repaint the damaged region
Alexander Larsson [Wed, 22 May 2013 12:41:38 +0000 (14:41 +0200)]
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.

11 years agocompositor: Support output/buffer scaling
Alexander Larsson [Wed, 22 May 2013 12:41:37 +0000 (14:41 +0200)]
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.

11 years agopixman-renderer: Fix up transform handling
Alexander Larsson [Wed, 22 May 2013 12:41:36 +0000 (14:41 +0200)]
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.

11 years agotransformed: Add keyboard shortcuts to change transform
Alexander Larsson [Wed, 22 May 2013 12:41:35 +0000 (14:41 +0200)]
transformed: Add keyboard shortcuts to change transform

This makes it easy to test buffer_transform and buffer_scale handling.
left-right: rotate
space: toggle inverse
z: toggle scale between 1 and 2

11 years agoterminal: Handle output transform
Alexander Larsson [Wed, 22 May 2013 12:41:34 +0000 (14:41 +0200)]
terminal: Handle output transform

We pick the highest scale of any output the terminal is on, and the
transform from the last one it entered.

11 years agowindow: Add window_get_output_scale()
Alexander Larsson [Wed, 22 May 2013 12:41:33 +0000 (14:41 +0200)]
window: Add window_get_output_scale()

This lets you find the maximal scale for all the outputs a window
is on, which is useful for picking a buffer_scale.

11 years agodesktop-shell: Respect output scale and translate
Alexander Larsson [Wed, 22 May 2013 12:41:32 +0000 (14:41 +0200)]
desktop-shell: Respect output scale and translate

We pick the window scale/tranform based on what the output uses, which means
we can avoid rotations in the compositor, and get sharper rendering
in scaled outputs.

11 years agowindow: Store server_allocation in surface size
Alexander Larsson [Wed, 22 May 2013 12:41:31 +0000 (14:41 +0200)]
window: Store server_allocation in surface size

We used to just store the buffer size here which is not right if the
surface has a buffer_transform or a buffer_scale. To fix this we pass
the transform and scale into the toysurface prepare and swap calls and
move both the surface to buffer and the buffer to surface size
conversion there.

Without this interactive resize on the top or left sides of a transformed
or scaled surface will not work correctly.

11 years agotransformed: Use the scale factor from the output
Alexander Larsson [Wed, 22 May 2013 12:41:30 +0000 (14:41 +0200)]
transformed: Use the scale factor from the output

11 years agowindow: Apply buffer_scale automatically in widget_cairo_create
Alexander Larsson [Wed, 22 May 2013 12:41:29 +0000 (14:41 +0200)]
window: Apply buffer_scale automatically in widget_cairo_create

11 years agowindow: allow setting a buffer scale on a window
Alexander Larsson [Wed, 22 May 2013 12:41:28 +0000 (14:41 +0200)]
window: allow setting a buffer scale on a window

11 years agowindow: Track output scales
Alexander Larsson [Wed, 22 May 2013 12:41:27 +0000 (14:41 +0200)]
window: Track output scales

11 years agotransformed: Rely on transformation in widget_cairo_create
Alexander Larsson [Wed, 22 May 2013 12:41:26 +0000 (14:41 +0200)]
transformed: Rely on transformation in widget_cairo_create

Rather than doing our own transformation handling when drawing we
just rely on the generic code in widget_cairo_create

11 years agowindow: Support transform in widget_cairo_create()
Alexander Larsson [Wed, 22 May 2013 12:41:25 +0000 (14:41 +0200)]
window: Support transform in widget_cairo_create()

If a buffer_transform it specified in the window we automatically
compensate for it in the cairo_t

11 years agowindow: avoid a gcc warning in buffer release handler
Pekka Paalanen [Wed, 22 May 2013 07:20:05 +0000 (10:20 +0300)]
window: avoid a gcc warning in buffer release handler

Apparently some compilers complain about set but not used variables
'available' and 'bufs', but I don't get the warning. Still, separate the
debugging code from shm_surface_buffer_release(), so that we only
compute 'bufs' when it is printed. This should fix the warnings.

The debugging code now prints the shm_surface buffer state before and
after, instead of just after.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
11 years agocms-static: Use the right wl_listener for the output hotplug listener
Kristian Høgsberg [Tue, 21 May 2013 15:44:22 +0000 (11:44 -0400)]
cms-static: Use the right wl_listener for the output hotplug listener

11 years agoconfigure.ac: colord version to 0.1.27
Mun Gwan-gyeong [Sat, 18 May 2013 12:43:10 +0000 (21:43 +0900)]
configure.ac: colord version to 0.1.27

11 years agoweston-launch: Print explanation of why we failed to open the device
Rob Bradford [Mon, 20 May 2013 15:55:10 +0000 (16:55 +0100)]
weston-launch: Print explanation of why we failed to open the device

11 years agoshell: End grab if the grabbed shell surface has been destroyed
Rob Bradford [Mon, 20 May 2013 11:09:20 +0000 (12:09 +0100)]
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

11 years agoprotocol: improve sub-surface spec wording
Pekka Paalanen [Fri, 17 May 2013 13:46:03 +0000 (16:46 +0300)]
protocol: improve sub-surface spec wording

Mention, that sub-surfaces are not clipped to the parent.
Be more accurate on surface commit vs. apply state.
Mention the initial stacking order.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
11 years agoFix surface_pong when a seat doesn't have a pointer
Hardening [Fri, 17 May 2013 16:07:41 +0000 (18:07 +0200)]
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.

11 years agoweston-launch: Run weston in the user login shell
Quentin Glidic [Fri, 17 May 2013 14:20:37 +0000 (16:20 +0200)]
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>
11 years agoprotocol: remove an unused sub-surface error code
Pekka Paalanen [Fri, 17 May 2013 13:46:08 +0000 (16:46 +0300)]
protocol: remove an unused sub-surface error code

This was left over from allowing nesting.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
11 years agocompositor: forbid sub-surface nesting loops
Pekka Paalanen [Fri, 17 May 2013 13:46:07 +0000 (16:46 +0300)]
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>
11 years agotests: add a sub-surface nesting loop test
Pekka Paalanen [Fri, 17 May 2013 13:46:06 +0000 (16:46 +0300)]
tests: add a sub-surface nesting loop test

It should not be possible to create a loop by nesting sub-surfaces.
Currently Weston fails this test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
11 years agoprotocol: set_desync should flush
Pekka Paalanen [Fri, 17 May 2013 13:46:05 +0000 (16:46 +0300)]
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>
11 years agotests: add sub-surface tree destruction permutations
Pekka Paalanen [Fri, 17 May 2013 13:46:04 +0000 (16:46 +0300)]
tests: add sub-surface tree destruction permutations

Add a test for varying the object destruction order in a complex
sub-surface tree.

This test attemps to fuzz the destruction of a sub-surface tree to make
sure the server does not crash on any wl_surface or wl_subsurface
destruction sequence.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
11 years agofix module_init signature in module tests
U. Artie Eoff [Fri, 17 May 2013 13:12:50 +0000 (06:12 -0700)]
fix module_init signature in module tests

surface-global-test and surface-test did not get updated to
the new module_init(...) signature when it changed in
a50e6e4c500e3080b8df7ec14c7e42741477a423.  Thus, they
failed to compile.  Simply running 'make check' shows the
problem. This patch fixes it.

fixes https://bugs.freedesktop.org/show_bug.cgi?id=64691

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
11 years agogl-renderer: Compile shaders only when needed
Ander Conselvan de Oliveira [Fri, 17 May 2013 11:00:40 +0000 (14:00 +0300)]
gl-renderer: Compile shaders only when needed

Saves some start up time by not compiling specific shaders until they
are needed.

11 years agoFix missing corner resize cursors in Kubuntu (oxy-white theme)
Dima Ryazanov [Tue, 14 May 2013 06:51:11 +0000 (23:51 -0700)]
Fix missing corner resize cursors in Kubuntu (oxy-white theme)

Looks like that theme uses different names. Also, add the correspoding
horizontal and vertical resize cursors, just for consistency.

11 years agocms-colord: Warn if reading or writing to the FD failed
Richard Hughes [Wed, 15 May 2013 08:17:38 +0000 (09:17 +0100)]
cms-colord: Warn if reading or writing to the FD failed

This also fixes a compile warning when building the tarball.

11 years agocms-colord: Fix build after the API change 'Honor XDG_CONFIG_DIRS'
Richard Hughes [Wed, 15 May 2013 08:17:37 +0000 (09:17 +0100)]
cms-colord: Fix build after the API change 'Honor XDG_CONFIG_DIRS'

11 years agolock-surface: Set geometry width and height before centering
Kristian Høgsberg [Wed, 15 May 2013 00:59:02 +0000 (20:59 -0400)]
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.

11 years agotext: Respawn input method process if it exits
Eduardo Lima (Etrunko) [Tue, 14 May 2013 16:09:31 +0000 (13:09 -0300)]
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>
11 years agoconfig-parser: Honor XDG_CONFIG_DIRS
Ossama Othman [Tue, 14 May 2013 16:48:26 +0000 (09:48 -0700)]
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>
11 years agocompositor-drm: Don't page flip before a mode is set
Ander Conselvan de Oliveira [Tue, 7 May 2013 11:16:59 +0000 (14:16 +0300)]
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

11 years agoAdd a colord implementation of a CMS plugin for weston
Richard Hughes [Sat, 11 May 2013 08:48:22 +0000 (09:48 +0100)]
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.

11 years agomove subsurface-server-protocol.h include out of compositor.h
U. Artie Eoff [Mon, 13 May 2013 22:55:47 +0000 (15:55 -0700)]
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>
11 years agowindow: add DBG code for leaf management and redraws
Pekka Paalanen [Thu, 25 Apr 2013 10:57:53 +0000 (13:57 +0300)]
window: add DBG code for leaf management and redraws

Aids for debugging and inspecting the algorithms.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agowindow: throttle resizing to the main surface
Pekka Paalanen [Thu, 25 Apr 2013 10:57:52 +0000 (13:57 +0300)]
window: throttle resizing to the main surface

In case a toytoolkit application manages to schedule resizes constantly,
throttle them to the main surface display.

When resizing, all surfaces are updated synchronously, so it also makes
sense to synchronize on the main surface's frame callback particularly.
Rendering any faster will not make sense.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agowindow: prevent EGL sub-surface deadlock
Pekka Paalanen [Thu, 25 Apr 2013 10:57:51 +0000 (13:57 +0300)]
window: prevent EGL sub-surface deadlock

Mesa's eglSwapBuffers() waits for the frame event from the previous
swapBuffers, before it returns. Apparently eglSwapInterval(), which
should be able to disable the wait, is unimplemented for now.

When a sub-surface contains an EGL widget, and the commit mode is
synchronized, the frame events will not be delivered to EGL until the
parent surface gets committed. Therefore rendering the EGL widget twice
would lead to a deadlock.

When the window is being resized, we need to force a repaint of the EGL
widget, too, to make the whole window consistent. For that, we need to
make sure the frame event from the previous eglSwapBuffers() actually
arrives.

This patch adds an extra wl_surface.commit(parent), when the window is
being resized, which should guarantee, that the previous eglSwapBuffers
gets its event.

To properly handle an EGL widget in a sub-surface, running in its own
thread, the EGL widget's automatic updates should be paused before
sending the extra wl_surface.commit(parent). A natural place for the
pause would be in the widget's resize hook. However, wl_surface.commit
cannot be called right after resize hooks, because it would commit new,
incomplete surface state. Therefore this patch is not enough for
threaded toytoolkit applications.  Luckily those do not exist yet.

When eglSwapInterval() gets implemented, this patch should be reverted.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoclients: add subsurfaces demo
Pekka Paalanen [Thu, 25 Apr 2013 10:57:50 +0000 (13:57 +0300)]
clients: add subsurfaces demo

Add a demo program with:
- a main surface (green)
- a Cairo-image sub-surface (red)
- a raw GLESv2 widget (triangle)

Sub-surface input region is set empty to avoid problems in toytoolkit.

If Cairo links to libGL, then we will end up with also libGLESv2 linked
to subsurfaces program, and both libs getting really used, which leads
to disaster.

Do not build subsurfaces demo, if Cairo links to libGL and cairo-egl is
usable.

The GL rendering loop is not tied to the toytoolkit or the widget, but
runs directly from its own frame callback. Therefore it runs
independent of the rest of the application. This also relies on one of
two things:
- eglSwapInterval(0) is implemented, and therefore eglSwapBuffers never
  blocks indefinitely, or
- toytoolkit has a workaround, that guarantees that eglSwapBuffers will
  return soon, when we force a repaint on resize.
Otherwise the demo will deadlock.

The code is separated into three sections:

1. The library component, using only EGL, GLESv2, and libwayland-client
   APIs, and not aware of any toolkit details of the parent application.
   This runs independently until the parent application tells otherwise.

2. The glue code: a toytoolkit application widget, who has its own
   rendering machinery.

3. The application written in toytoolkit.

This patch also adds new toytoolkit interfaces:
- widget_get_wl_surface()
- widget_get_last_time()
- widget_input_region_add()

Toytoolkit applications have not had a possibility to change the input
region. The frame widget (decorations) set the input region on its own
when used, otherwise the default input region of everything has been
used. If a window does not have a frame widget, it can now use
widget_input_region_add() to set a custom input region.

These are not window methods, because a widget may lie on a different
wl_surface (sub-surface) than the window.

Changes in v3:
- replace set_commit_mode with set_sync and set_desync

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agowindow: implement per-surface redraws
Pekka Paalanen [Thu, 25 Apr 2013 10:57:49 +0000 (13:57 +0300)]
window: implement per-surface redraws

Add redraw_needed flag to all surfaces, in addition to having one in
window. The window redraw_needed flag is changed to force a redraw of
the whole window, regardless of frame events.

widget_schedule_redraw() now schedules the redraw only for the surface,
where the widget is on. window_schedule_redraw() is equivalent to
scheduling a redraw for all (sub-)surfaces of the window.

We still use only one deferred task for all redraws.

surface_redraw() will skip the redraw, if the window does not force a
redraw and the surface does not need a redraw. It will also skip the
redraw, if the frame callback from the previous redraw has not triggered
yet. When the frame callback later arrives, the redraw task will be
scheduled, if the surface still needs a redraw.

If the window forces a redraw, the redraw is executed even if there is a
pending frame callback. This is for resizing: resizing should trigger a
window repaint, as it really wants to update all surfaces in one go, to
apply possible sub-surface size and position changes. Resizing is the
only thing that makes a window force a redraw.

With this change, subsurfaces demo can avoid repainting the cairo
sub-surface while still animating the GL sub-surface.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agowindow: create sub-surfaces
Pekka Paalanen [Thu, 25 Apr 2013 10:57:48 +0000 (13:57 +0300)]
window: create sub-surfaces

The new application API window_add_subsurface() will create a plain
widget that is on a new sub-surface.

The sub-surface position is taken from the surface's root widget
allocation. This way widget allocations are always in the main surface
(i.e. window) coordinates. However, Cairo drawing coordinates will now
be different to widget coordinates for sub-surfaces. Cairo coordinates
are fixed by applying a translation in widget_cairo_create(), so that
widget drawing code can simply use the widget allocation as before.

Sub-surfaces are hooked up into resize, window flush, redraw, and
find_widget. Window maintains a list of sub-surfaces in top-first order.

Add a client settable default commit mode, and toggle the mode when
resizing to guarantee in-sync updates of a window and its sub-surfaces.

Changes in v3:
- replaced set_commit_mode with set_sync and set_desync

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agowindow: implement shm triple-buffering
Pekka Paalanen [Thu, 25 Apr 2013 10:57:47 +0000 (13:57 +0300)]
window: implement shm triple-buffering

Increase the maximum number of shm "leaves" to three, and rewrite the
leaf release and pick algorithms. The new algorithms hopefully improve
on buffer re-use while freeing unused buffers.

The goal of the new release algorithm is to always leave one free leaf
with storage allocated, so that the next redraw could start straight on
it.

The new leaf picking algorithm will prefer a free leaf that already has
some storage allocated, instead of just picking the first free leaf that
may need to allocate a new buffer.

Triple-buffering is especially for sub-surfaces, where the compositor
may have one wl_buffer busy on screen, and another wl_buffer busy in the
sub-surface cached state due to the synchronized commit mode. To be
able to forcibly repaint at that situation for e.g. resize, we need a
third buffer.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoshell: account for the subsurfaces when going fullscreen or maximizing
Giulio Camuffo [Thu, 25 Apr 2013 10:57:46 +0000 (13:57 +0300)]
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>
11 years agoshell: enable moving and resizing of a surface when clicking on a subsurface
Giulio Camuffo [Thu, 25 Apr 2013 10:57:45 +0000 (13:57 +0300)]
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>
11 years agoshell: keyboard focus and restacking fixes for sub-surfaces
Pekka Paalanen [Thu, 25 Apr 2013 10:57:44 +0000 (13:57 +0300)]
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>
11 years agotests: add sub-surface protocol tests
Pekka Paalanen [Thu, 25 Apr 2013 10:57:43 +0000 (13:57 +0300)]
tests: add sub-surface protocol tests

For testing the protocol behaviour only:
- linking a surface to a parent does not fail
- position and placement requests do not fail
- bad linking and arguments do fail
- passing a surface as a sibling from a different set fails
- different destruction sequences do not crash
- setting a surface as its own parent fails
- nesting succeeds

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agocompositor: introduce sub-surfaces
Pekka Paalanen [Thu, 25 Apr 2013 10:57:42 +0000 (13:57 +0300)]
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>
11 years agoprotocol: add sub-surfaces
Pekka Paalanen [Thu, 25 Apr 2013 10:57:41 +0000 (13:57 +0300)]
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>
11 years agocompositor-drm: Destroy sprites before destroying the outputs
Kristian Høgsberg [Fri, 10 May 2013 16:36:04 +0000 (12:36 -0400)]
compositor-drm: Destroy sprites before destroying the outputs

11 years agoeditor: Removed unused utf8_characters() function
Kristian Høgsberg [Fri, 10 May 2013 15:04:08 +0000 (11:04 -0400)]
editor: Removed unused utf8_characters() function

I left this in when I merged Jans patches.

11 years agoAdd initial color management framework code
Richard Hughes [Thu, 9 May 2013 19:31:09 +0000 (20:31 +0100)]
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.

11 years agocompositor: Move gl-renderer vertex arrays into gl-renderer.c
Kristian Høgsberg [Thu, 9 May 2013 02:38:05 +0000 (22:38 -0400)]
compositor: Move gl-renderer vertex arrays into gl-renderer.c

They were still sitting in struct weston_compositor.

11 years agocompositor: Remove stale prototype
Kristian Høgsberg [Thu, 9 May 2013 02:31:03 +0000 (22:31 -0400)]
compositor: Remove stale prototype

We got rid of this function.

11 years agoinput: Remove unused focus and key fields from keyboard and focus grabs
Kristian Høgsberg [Thu, 9 May 2013 02:10:16 +0000 (22:10 -0400)]
input: Remove unused focus and key fields from keyboard and focus grabs

11 years agoinput: Move surface picking into the pointer grab focus callback
Kristian Høgsberg [Thu, 9 May 2013 02:02:59 +0000 (22:02 -0400)]
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.

11 years agoinput: Get rid of grab focus concept
Kristian Høgsberg [Thu, 9 May 2013 01:03:21 +0000 (21:03 -0400)]
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).

11 years agoinput: Remove 'current' and related fields from weston_pointer
Kristian Høgsberg [Wed, 8 May 2013 20:47:00 +0000 (16:47 -0400)]
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.

11 years agodata-device: Verify that the client has an implicit grab when starting a drag
Kristian Høgsberg [Wed, 8 May 2013 19:53:42 +0000 (15:53 -0400)]
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.

11 years agodata-device: Eliminate two small helper functions
Kristian Høgsberg [Wed, 8 May 2013 19:47:52 +0000 (15:47 -0400)]
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.

11 years agodata-device: Rename generic weston_drag 'surface' field to 'icon'
Kristian Høgsberg [Wed, 8 May 2013 19:30:42 +0000 (15:30 -0400)]
data-device: Rename generic weston_drag 'surface' field to 'icon'

11 years agodata-device: Move all drag-related fields out of weston_seat
Kristian Høgsberg [Wed, 8 May 2013 19:27:47 +0000 (15:27 -0400)]
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.

11 years agoinput: Move sprite fields into weston_pointer from weston_seat
Kristian Høgsberg [Wed, 8 May 2013 19:02:05 +0000 (15:02 -0400)]
input: Move sprite fields into weston_pointer from weston_seat

11 years agosimple-egl: Add support for EGL_EXT_swap_buffer_with_damage
Kristian Høgsberg [Wed, 8 May 2013 15:37:28 +0000 (11:37 -0400)]
simple-egl: Add support for EGL_EXT_swap_buffer_with_damage

This new EGL extension lets us communicate the damage area to the compositor
by using eglSwapBuffersWithDamge() instead of the regular eglSwapBuffer().

http://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_swap_buffers_with_damage.txt

11 years agocompositor: Adapt to wl_surface going away
Kristian Høgsberg [Wed, 8 May 2013 13:54:37 +0000 (09:54 -0400)]
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.

11 years agoinput: Allocate pointer/keyboard/touch structs
Kristian Høgsberg [Wed, 8 May 2013 03:52:07 +0000 (23:52 -0400)]
input: Allocate pointer/keyboard/touch structs

11 years agoinput: Eliminate weston_seat::has_pointer/keyboard/touch
Kristian Høgsberg [Wed, 8 May 2013 03:17:41 +0000 (23:17 -0400)]
input: Eliminate weston_seat::has_pointer/keyboard/touch

We can just look at weston_seat::pointer/keyboard/touch now.

11 years agodata-device: Update drag icon position from configure and motion handlers
Kristian Høgsberg [Wed, 8 May 2013 02:53:43 +0000 (22:53 -0400)]
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().

11 years agodata-device: Map drag icon in configure handler
Kristian Høgsberg [Wed, 8 May 2013 02:42:28 +0000 (22:42 -0400)]
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().

11 years agodata-device: Setup and release drag surface and beginning and end of drag
Kristian Høgsberg [Wed, 8 May 2013 01:06:38 +0000 (21:06 -0400)]
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.

11 years agodata-device: Fix dnd regression from weston_seat rewrite
Kristian Høgsberg [Wed, 8 May 2013 00:50:26 +0000 (20:50 -0400)]
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.

11 years agodata-device: Don't emit a signal for drag icon changes
Kristian Høgsberg [Tue, 7 May 2013 19:30:49 +0000 (15:30 -0400)]
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.

11 years agoinput: Move drag handling to data-device.c
Kristian Høgsberg [Tue, 7 May 2013 15:18:46 +0000 (11:18 -0400)]
input: Move drag handling to data-device.c

11 years agocompositor: Move fan_debug to gl-renderer
Kristian Høgsberg [Tue, 7 May 2013 14:50:09 +0000 (10:50 -0400)]
compositor: Move fan_debug to gl-renderer

With the debug binding infrastructure, we can do this all inside
gl-renderer.c.

11 years agoinput: Merge wl_seat into weston_seat
Kristian Høgsberg [Tue, 7 May 2013 03:19:49 +0000 (23:19 -0400)]
input: Merge wl_seat into weston_seat

11 years agoinput: Remove wl_seat destroy signal
Kristian Høgsberg [Tue, 7 May 2013 02:27:40 +0000 (22:27 -0400)]
input: Remove wl_seat destroy signal

We already have one on weston_seat.

11 years agoinput: Fold wl_seat init/release into weston_seat init/release
Kristian Høgsberg [Tue, 7 May 2013 02:24:50 +0000 (22:24 -0400)]
input: Fold wl_seat init/release into weston_seat init/release

11 years agoinput: Rename wl_touch to weston_touch
Kristian Høgsberg [Tue, 7 May 2013 02:19:57 +0000 (22:19 -0400)]
input: Rename wl_touch to weston_touch

This is now a weston object.

11 years agoinput: Rename wl_pointer to weston_pointer
Kristian Høgsberg [Tue, 7 May 2013 02:15:05 +0000 (22:15 -0400)]
input: Rename wl_pointer to weston_pointer

This is now a weston object.

11 years agoinput: Rename weston_device_repick() to weston_seat_repick()
Kristian Høgsberg [Tue, 7 May 2013 01:51:21 +0000 (21:51 -0400)]
input: Rename weston_device_repick() to weston_seat_repick()

Old left-over misnaming.

11 years agoinput: Drop find_resource_for_client()
Kristian Høgsberg [Tue, 7 May 2013 01:49:55 +0000 (21:49 -0400)]
input: Drop find_resource_for_client()

We can use find_resource_for_surface() instead now that it's all in the
same file.

11 years agomove input code from compositor.c into input.c
Kristian Høgsberg [Thu, 18 Apr 2013 19:40:10 +0000 (15:40 -0400)]
move input code from compositor.c into input.c

11 years agofold wl_keyboard into weston_keyboard
Kristian Høgsberg [Thu, 18 Apr 2013 19:25:39 +0000 (15:25 -0400)]
fold wl_keyboard into weston_keyboard

11 years agoImport input structs and helper functions from wayland
Kristian Høgsberg [Thu, 18 Apr 2013 19:07:39 +0000 (15:07 -0400)]
Import input structs and helper functions from wayland

11 years agoeditor: Fix some offsets for multi-byte characters
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:42 +0000 (16:47 +0200)]
editor: Fix some offsets for multi-byte characters

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agokeyboard: Fix offsets when deleting text
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:41 +0000 (16:47 +0200)]
keyboard: Fix offsets when deleting text

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agotext: Rename input_method to wl_input_method
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:39 +0000 (16:47 +0200)]
text: Rename input_method to wl_input_method

Also rename input_method_context to wl_input_method_context,
input_panel to wl_input_panel and input_panel_surface to
wl_input_panel_surface.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agotext: Improve protocol documentation.
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:38 +0000 (16:47 +0200)]
text: Improve protocol documentation.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agotext: Rename ::set_panel to ::set_overlay_panel
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:37 +0000 (16:47 +0200)]
text: Rename ::set_panel to ::set_overlay_panel

Also add documentation to input_panel_surface::set_overlay_panel.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agotext: Rename text_input to wl_text_input
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:36 +0000 (16:47 +0200)]
text: Rename text_input to wl_text_input

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agokeyboard: Remove unneded calls
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:35 +0000 (16:47 +0200)]
keyboard: Remove unneded calls

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agotext: delete text on commit_string
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:34 +0000 (16:47 +0200)]
text: delete text on commit_string

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agotext: Fix serial handling
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:33 +0000 (16:47 +0200)]
text: Fix serial handling

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agotext: Only allow input-method started by weston to bind
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:31 +0000 (16:47 +0200)]
text: Only allow input-method started by weston to bind

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agotext: Add output argument to set_toplevel
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:29 +0000 (16:47 +0200)]
text: Add output argument to set_toplevel

Allow to specify an output for a toplevel  input panel surface.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agotext: Add support for panels following the cursor
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:28 +0000 (16:47 +0200)]
text: Add support for panels following the cursor

Add input_panel_surface::set_panel to specify input panel surfaces which
are overlaying the application and are following the input cursor.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
11 years agoeditor: Send cursor position to the input method
Jan Arne Petersen [Thu, 18 Apr 2013 14:47:27 +0000 (16:47 +0200)]
editor: Send cursor position to the input method

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>