# -*- coding: utf-8 -*-
# This file has been autogenerated by the pywayland scanner

# Copyright © 2008-2011 Kristian Høgsberg
# Copyright © 2010-2011 Intel Corporation
# Copyright © 2012-2013 Collabora, Ltd.
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice (including the
# next paragraph) shall be included in all copies or substantial
# portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from pywayland.interface import Interface
from .surface import Surface


class Touch(Interface):
    """Touchscreen input device

    The :class:`Touch` interface represents a touchscreen associated with a
    seat.

    Touch interactions can consist of one or more contacts. For each contact, a
    series of events is generated, starting with a down event, followed by zero
    or more motion events, and ending with an up event. Events relating to the
    same contact point can be identified by the ID of the sequence.
    """
    name = "wl_touch"
    version = 3


@Touch.request("3", [])
def release(self):
    """Release the touch object
    """
    self._marshal(0)
    self._destroy()


@Touch.event("uuoiff", [None, None, Surface, None, None, None])
def down(self, serial, time, surface, id, x, y):
    """Touch down event and beginning of a touch sequence

    A new touch point has appeared on the surface. This touch point is assigned
    a unique @id. Future events from this touchpoint reference this ID. The ID
    ceases to be valid after a touch up event and may be re-used in the future.

    :param serial:
    :type serial: `uint`
    :param time: timestamp with millisecond granularity
    :type time: `uint`
    :param surface:
    :type surface: :class:`~pywayland.protocol.wayland.surface.Surface`
    :param id: the unique ID of this touch point
    :type id: `int`
    :param x: x coordinate in surface-relative coordinates
    :type x: `fixed`
    :param y: y coordinate in surface-relative coordinates
    :type y: `fixed`
    """
    self._post_event(0, serial, time, surface, id, x, y)


@Touch.event("uui", [None, None, None])
def up(self, serial, time, id):
    """End of a touch event sequence

    The touch point has disappeared. No further events will be sent for this
    touchpoint and the touch point's ID is released and may be re-used in a
    future touch down event.

    :param serial:
    :type serial: `uint`
    :param time: timestamp with millisecond granularity
    :type time: `uint`
    :param id: the unique ID of this touch point
    :type id: `int`
    """
    self._post_event(1, serial, time, id)


@Touch.event("uiff", [None, None, None, None])
def motion(self, time, id, x, y):
    """Update of touch point coordinates

    A touchpoint has changed coordinates.

    :param time: timestamp with millisecond granularity
    :type time: `uint`
    :param id: the unique ID of this touch point
    :type id: `int`
    :param x: x coordinate in surface-relative coordinates
    :type x: `fixed`
    :param y: y coordinate in surface-relative coordinates
    :type y: `fixed`
    """
    self._post_event(2, time, id, x, y)


@Touch.event("", [])
def frame(self):
    """End of touch frame event

    Indicates the end of a contact point list.
    """
    self._post_event(3)


@Touch.event("", [])
def cancel(self):
    """Touch session cancelled

    Sent if the compositor decides the touch stream is a global gesture. No
    further events are sent to the clients from that particular gesture. Touch
    cancellation applies to all touch points currently active on this client's
    surface. The client is responsible for finalizing the touch points, future
    touch points on this surface may re-use the touch point ID.
    """
    self._post_event(4)


Touch._gen_c()
