compositor: remove unused signal

The move_signal in weston_output isn't used, and not even initialized,
so anything trying to listen to it will crash on wl_signal_add().
Instead of it, the 'output_moved_signal' in weston_compositor is
used, so remove it.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
compositor: extract choose_default_backend and create_listening_socket

Extract these two new functions from main() to improve readability.
Refactoring only, no functioncal changes.

[Pekka Paalanen: commit message]

Signed-off-by: Ryo Munakata <ryomnktml@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
main: don't leak option strings

[Pekka Paalanen: fix a long line]

Signed-off-by: Ryo Munakata <ryomnktml@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
compositor: fix memory corruption when removing an output

The destructor set on the wl_output resources needs the weston_output
to be allocated, because it removes the resource from its list.
So unset the destructor on all the resources when destroying an
output.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
input: Schedule pointer sprite repaint when cursor is set

If a cursor was set with wl_pointer.set_cursor but not in combination
with an action that has the side effect of damaging the region where the
cursor is positioned, it would not be drawn. This patch explicitly
schedules a repaint of the pointer sprite when it is set.

clickdot is updated to illustrate the bug; when moving the pointer over
clickdot, the pointer is hidden. When not having moved the pointer for
500 ms it is made visible using wl_pointer.set_pointer.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
xdg-shell: update shsurf->output when maximizing

shsurf->output is the output that user expects the shell surface
is on. When maximizing, we don't have any explicit setting of the output
like in the case of fullscreening, so set the output to the one that
the surface is currently on. In the case that the surface is not mapped yet,
(if it ever happens) use the same heuristics as for fullscreening.

This fixes the size sent with configure event, when maximizing a window.
The size is now picked up by the correct output, but the maximized
window position is still wrong. [Pekka Paalanen]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82967
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
xdg-shell: fix maximizing in multi-head setup

Set the right position of maximized window. Up until now we ignored
output's "position" and were using only the working area
of output which is in output-relative coordinates. This led to
showing the maximized window always on the first output.

This, along with the previous patch, fixes
https://bugs.freedesktop.org/show_bug.cgi?id=82967

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Partially revert "xdg-shell: Add show_window_menu request"

This reverts the parts of commit 81ff075bf48c55cd07e37784e20c310fa52ed926
that touch window.c.

This brings the toytoolkit window context menus back, until someone
implements the xdg-shell equivalent in the compositor.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82972
Acked-by: Jasper St. Pierre <jstpierre@mecheye.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
cosmetic: update comments that refer to weston_surface_update_transform()

weston_surface_update_transform() no longer exists, except in comments.

Fix that.

[Pekka Paalanen: don't lose the full comment in compositor-drm.c.]

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
parse_options: fail on more malformed options

Fail on trailing text after numbers, such as --width=100mm

Fail on any text after booleans, such as --flag=false

Also fixed reading of memory after the null terminator of a long
option with no = sign in it.

[Pekka Paalanen: some whitespace style fixes.]

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
load_image: always print a message on failure if filename is not empty

It was rather inconsistent before. This may help users figure out why
backgrounds and icons don't show up. A better api where the error can
be queried might be nice, but this seems sufficient for current Weston use.

[Pekka Paalanen: removed one stray space.]

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
image: don't print redundant error

This error is printed by load_image() now

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
compositor: Don't free an uninitialised pointer.

When backend_init returns NULL, we goto out_signals, which wants to
free(modules), but in this particular code path, modules hasn't been
initialised leading to a "Double-free or corruption" error message.
Initialising modules to NULL makes the free a no-op in this scenario.

Signed-off-by: Ondřej Majerech <majerech.o@gmail.com>
Reviewed-by: Ryo Munakata <ryomnktml@gmail.com>
libinput: normalize WL_CALIBRATION before passing it to libinput

WL_CALIBRATION, introduced in weston-1.1, requires the translation component
of the calibration matrix to be in screen coordinates. libinput does not have
access to this and it's not a very generic way to do this anyway. So with
the libinput backend, WL_CALIBRATION support is currently broken (#82742).
This cannot be fixed in libinput without changing its API for this specific
use-case.

This patch lets weston take care of WL_CALIBRATION. It takes the original
format and normalizes it before passing it to libinput. This way libinput
still does the coordinate transformation, weston just needs to provide the
initial configuration.

Note that this needs an updated libinput, otherwise libinput will try to
transform coordinates as well.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82742
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
libinput-device: Don't get initial key states

Initial key state is no pressed keys, and the libinput_device_get_keys
function was deprecated in libinput 0.6.0.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
libinput: default to INFO log level

Set the default logging level from libinput to INFO. This matches better
the behaviour of the old input backend, and prints the found input
devices into Weston's log.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Jonas Ådahl <jadahl@gmail.com>
configure.ac: bump version 1.5.93 for rc2

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
window: Don't needlessly sync parent and geometry

When a toytoolkit client redraws, the toolkit syncs the parent and
geometry. If a client redraws often (such as the terminal drawing a huge
amount of output), this can spam the compositor with requests and may
result in the client's eventual being killed.

We don't need to send requests for changing the geometry or parent if
these haven't changed. So remember the last geometry and parent, and
update them only if needed.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83297
Signed-off-by: Ondřej Majerech <majerech.o@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
compositor-x11: Rename the output make to "weston-X11"

Previously all outputs in the X11 backend had the make "xwayland" which is
confusing.  Now they have something that makes a little more sense.
keyboard: do not crash when input panel is not available

[Pekka Paalanen: whitespace fix]

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>