compositor: Fix weston_subsurface_is_synchronized() return value.

Commit 280e7dd918f1717c7d677676384a9cd991097741 introduced a bug in the
return value of weston_subsurface_is_synchronized().

Signed-off-by: Carlos Olmedo Escobar <carlos.olmedo.e@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
compositor: Refactor weston_output_mode_switch()

This breaks weston_output_mode_switch() into 3 functions:
weston_output_mode_set_native()
weston_output_mode_switch_to_temporary()
weston_output_mode_switch_to_native()

Differences from previous behaviour:
SET_NATIVE didn't set current_scale (now it does)
SET_TEMPORARY could set mode and scale independently - now it can't.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Pekka Paalanen <pekka.paalanen@collabora.co.uk>
input: allow to destroy bindings in their handler

use wl_list_for_each_safe to iterate on the bindings list when
firing them, this way a binding can safely be destroyed in its
function handler.

Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
compositor: check version before calling wl_output_send_scale()

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
compositor: stop sending spurious events on mode switch

commit 6ae7bc982fa accidentally made weston_output_mode_switch_temporary
send done events when it shouldn't.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
compositor: make keep_buffer a bool

The comments already call it bool, so let's just make it one

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
input: fix access to invalid resource

the keyboard focus surface may not have a valid resource (server side
surface or a surface surviving its client), so check if it is valid
before using it.

Acked-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
smoke: Don't commit an xdg_surface with a NULL buffer

Committing to an xdg_surface with a NULL buffer is currently illegal in
the mutter implementation, so this simply causes the client to error and
exit.

It seems the reason the client did this was so it could add its own
frame callback, but toytoolkit actually provides accurate everything we
need. Just use its functions instead to get the time and schedule a
redraw.

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
smoke: fix valgrind invalid read errors

There are a number of invalid read errors reported by valgrind of the
form:
	==13428== Invalid read of size 4
        ==13428==    at 0x405656: advect (smoke.c:116)
        ==13428==    by 0x405E80: redraw_handler (smoke.c:228)
        ==13428==    by 0x40DE74: widget_redraw (window.c:3995)
        ==13428==    by 0x40E02D: surface_redraw (window.c:4053)
        ==13428==    by 0x40E0C9: idle_redraw (window.c:4082)
        ==13428==    by 0x410FC9: display_run (window.c:5561)
        ==13428==    by 0x406518: main (smoke.c:373)
        ==13428==  Address 0xb2c9b14 is 4 bytes after a block of size
                   160,000 alloc'd
        ==13428==    at 0x4C29DB4: calloc
        ==13428==    by 0x40646B: main (smoke.c:360)

This results in invalid rendering when running a debug version of the
application.

Fix the issue by limiting the maximum values of px and py to 1.5 less
than width and height. This prevents reading past the end of the source
buffer.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82287
Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
man: Fix some weston.ini.man typesetting macros

This patch fixes a couple of misuses around .TP 7 macros that wrongly
limited right margins and relative identation.

Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
compositor: (Whitespace-only) Indent with tabs

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
compositor: Fix tabbing of help output

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
compositor: Fix typos in help text

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
compositor: Display option help text only for enabled backends

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
compositor: List only available backends in help text

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
compositor: add missing newline to help text

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
input: don't send to clients key events eaten by bindings

weston key bindings are supposed to eat the key events, and not pass it
on to clients, and indeed the wl_keyboard.key event is not sent. But
we must also not put the key in the keys array to pass to client with
the wl_keyboard.enter event, or else we may send the 'eaten' one too.
In the case of a key binding hiding a surface having the keyboard focus,
the shell may decide to give the focus to another surface, but that will
happen before the key is released, so the new focus surface will receive
the code of the bound key in the wl_keyboard.enter array.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
input: use tmp var in pointer_unmap_sprite

Remove lots of repeated indirection.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
weston_surface: Add surface-to-buffer and buffer-to-surface matrices
gl-renderer: Call glViewport after the context is made current