toytoolkit: Implement support for the workspace manager interface

Two buttons are added to the right-click menu of the window frame for
moving a surface either up or down.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
shell: Improve focus handling when moving surfaces between workspaces

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
workspaces: don't segfault on invalid move_surface_to_workspace request

Also fixes the off-by-one in toytoolkit that exposed the issue.
toytoolkit: supply correct widget in motion_handler callback
xwayland: replace opaque_rect, fix an alpha problem

Remove weston_surface::opaque_rect completely.

Instead, set the opaque region in xwayland.

Before this patch, black text in xterm was transparent. Now it is not.

However, this patch fixes only a part of the alpha problem. If you apply
full-surface alpha with super+alt+wheel, the problem reappears. This
problem is still due to bad alpha channel contents on xwayland windows.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
compositor: paint opaque regions with RGBX shader

weston_surface_draw() is restructured so that it will always use the
RGBX shader for opaque regions, if the surface is assigned the RGBA
shader.

Previously for opaque regions, we simply assumed, that the texture alpha
would be 1.0. If it was not (which really is an application bug), the
region would be misrendered. The RGBX shader forces the texture alpha to
1.0.

Xwayland surfaces may have bad alpha data in the opaque client area. If
blending was enabled, the bad alpha would be used with the RGBA shader.
This patch fixes rendering opaque xwayland windows with full-surface
alpha applied.

Test case: xterm, with full-surface alpha one step below 1.0. Before,
black text was fully transparent, now it is correctly only slightly
transparent.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
compositor: fix fan_debug mode

- make it respect output transforms by making sure the uniforms are
  up-to-date

- properly restore the current shader program, in case it was
  overridden

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
compositor: reduce the number of triangles

The intersection of two rectangles is guaranteed to be convex. Therefore
we do not need a center vertex for the triangle fan, we can simply use
the whatever first vertex the intersection polygon has. This reduces the
number of triangles, while still painting the exact same area.

While at it, emit_vertex() nested function is factored into the
for-loop, since that is the only calling site left.

Comments are updated to reflect the changes, and some unrelated comment
fixes are in repaint_region().

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Cc: Rob Clark <rob.clark@linaro.org>
compositor: do not duplicate ARRAY_SIZE

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
compositor: do not round a zero area to non-zero

surface_accumulate_damage() will call surface_compute_bbox() with the
extents of the surface damage region, for transformed surfaces only. If
there is no damage, surface_compute_bbox() will round up the empty
rectangle to a 1x1 rectangle. Triangles are produced for this 1x1
rectangle intersected with the surface.

The problem showed up with the triangle fan debug, where some seemingly
garbage pixels showed up relative to rotated surfaces.

Fix this by explicitly checking, that the area, for which a bounding box
is being computed for, is not zero.

Note, that the bbox will also be empty if only one of width and height
is zero. We do not paint things with zero thickness.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Cc: Rob Clark <rob.clark@linaro.org>
test-text-client: fix compile error

Pass surface to text_model_factory_create_text_model.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=54502

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
screensaver: fix decoding of transparency in xpm files

Use 0 as transparent pixel. This is needed when using premultiplied
alpha.
compositor: Consolidate output repaint logic

We move the EGL and GLES2 output repaint code into a new gles2-render.c
file.  The eglMakeCurrent, glViewPort, surface loop etc was duplicated
across all backends, but this patch moves it to a new file.
compositor: Move surface repaint code to gles2-renderer.c
compositor: Move non-GL initialization out of weston_compositor_init_gl()
compositor: Move gles2 initialization to gles2-renderer.h
compositor: Move update_shm_texture() to gles2-renderer.c

We rename it flush_damage() as it's the point where we update our rendering
API source (eg, the gles2 texture) according to the accumulated damage,
if necessary.
compositor: Move EGL/GLES2 parts of weston_surface_attach to gles2-renderer.c
compositor: Introduce a weston_renderer object

Move the gles2 render functions to vfuncs on the renderer object.
compositor: Create outputs before initializing GLES2 state

This way we can just use the first weston_output EGLSurface to make a
context current.