# This file has been autogenerated by the pywayland scanner

# Copyright © 2017 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 __future__ import annotations

from pywayland.protocol_core import Argument, ArgumentType, Global, Interface, Proxy, Resource

from .wayland import WlKeyboard
from .wayland import WlKeyboardProxy
from .wayland import WlPointer
from .wayland import WlPointerProxy
from .wayland import WlTouch
from .wayland import WlTouchProxy


class ZwpInputTimestampsManagerV1(Interface):
    """Context object for high-resolution input timestamps

    A global interface used for requesting high-resolution timestamps for input
    events.
    """

    name = "zwp_input_timestamps_manager_v1"
    version = 1


class ZwpInputTimestampsV1(Interface):
    """Context object for input timestamps

    Provides high-resolution timestamp events for a set of subscribed input
    events. The set of subscribed input events is determined by the
    :class:`~pywayland.protocol.input_timestamps_unstable_v1.ZwpInputTimestampsManagerV1`
    request used to create this object.
    """

    name = "zwp_input_timestamps_v1"
    version = 1


class ZwpInputTimestampsManagerV1Resource(Resource[ZwpInputTimestampsManagerV1]):
    interface = ZwpInputTimestampsManagerV1


class ZwpInputTimestampsV1Resource(Resource[ZwpInputTimestampsV1]):
    interface = ZwpInputTimestampsV1

    @ZwpInputTimestampsV1.event(
        Argument(ArgumentType.Uint),
        Argument(ArgumentType.Uint),
        Argument(ArgumentType.Uint),
    )
    def timestamp(self, tv_sec_hi: int, tv_sec_lo: int, tv_nsec: int) -> None:
        """High-resolution timestamp event

        The timestamp event is associated with the first subsequent input event
        carrying a timestamp which belongs to the set of input events this
        object is subscribed to.

        The timestamp provided by this event is a high-resolution version of
        the timestamp argument of the associated input event. The provided
        timestamp is in the same clock domain and is at least as accurate as
        the associated input event timestamp.

        The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples,
        each component being an unsigned 32-bit value. Whole seconds are in
        tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo,
        and the additional fractional part in tv_nsec as nanoseconds. Hence,
        for valid timestamps tv_nsec must be in [0, 999999999].

        :param tv_sec_hi:
            high 32 bits of the seconds part of the timestamp
        :type tv_sec_hi:
            `ArgumentType.Uint`
        :param tv_sec_lo:
            low 32 bits of the seconds part of the timestamp
        :type tv_sec_lo:
            `ArgumentType.Uint`
        :param tv_nsec:
            nanoseconds part of the timestamp
        :type tv_nsec:
            `ArgumentType.Uint`
        """
        self._post_event(0, tv_sec_hi, tv_sec_lo, tv_nsec)


class ZwpInputTimestampsManagerV1Proxy(Proxy[ZwpInputTimestampsManagerV1]):
    interface = ZwpInputTimestampsManagerV1

    @ZwpInputTimestampsManagerV1.request()
    def destroy(self) -> None:
        """Destroy the input timestamps manager object

        Informs the server that the client will no longer be using this
        protocol object. Existing objects created by this object are not
        affected.
        """
        self._marshal(0)
        self._destroy()

    @ZwpInputTimestampsManagerV1.request(
        Argument(ArgumentType.NewId, interface=ZwpInputTimestampsV1),
        Argument(ArgumentType.Object, interface=WlKeyboard),
    )
    def get_keyboard_timestamps(self, keyboard: WlKeyboardProxy) -> ZwpInputTimestampsV1Proxy:
        """Subscribe to high-resolution keyboard timestamp events

        Creates a new input timestamps object that represents a subscription to
        high-resolution timestamp events for all
        :class:`~pywayland.protocol.wayland.WlKeyboard` events that carry a
        timestamp.

        If the associated :class:`~pywayland.protocol.wayland.WlKeyboard`
        object is invalidated, either through client action (e.g. release) or
        server-side changes, the input timestamps object becomes inert and the
        client should destroy it by calling
        :func:`ZwpInputTimestampsV1.destroy()
        <pywayland.protocol.input_timestamps_unstable_v1.ZwpInputTimestampsV1.destroy>`.

        :param keyboard:
            the :class:`~pywayland.protocol.wayland.WlKeyboard` object for
            which to get timestamp events
        :type keyboard:
            :class:`~pywayland.protocol.wayland.WlKeyboard`
        :returns:
            :class:`~pywayland.protocol.input_timestamps_unstable_v1.ZwpInputTimestampsV1`
        """
        id = self._marshal_constructor(1, ZwpInputTimestampsV1, keyboard)
        return id

    @ZwpInputTimestampsManagerV1.request(
        Argument(ArgumentType.NewId, interface=ZwpInputTimestampsV1),
        Argument(ArgumentType.Object, interface=WlPointer),
    )
    def get_pointer_timestamps(self, pointer: WlPointerProxy) -> ZwpInputTimestampsV1Proxy:
        """Subscribe to high-resolution pointer timestamp events

        Creates a new input timestamps object that represents a subscription to
        high-resolution timestamp events for all
        :class:`~pywayland.protocol.wayland.WlPointer` events that carry a
        timestamp.

        If the associated :class:`~pywayland.protocol.wayland.WlPointer` object
        is invalidated, either through client action (e.g. release) or server-
        side changes, the input timestamps object becomes inert and the client
        should destroy it by calling :func:`ZwpInputTimestampsV1.destroy()
        <pywayland.protocol.input_timestamps_unstable_v1.ZwpInputTimestampsV1.destroy>`.

        :param pointer:
            the :class:`~pywayland.protocol.wayland.WlPointer` object for which
            to get timestamp events
        :type pointer:
            :class:`~pywayland.protocol.wayland.WlPointer`
        :returns:
            :class:`~pywayland.protocol.input_timestamps_unstable_v1.ZwpInputTimestampsV1`
        """
        id = self._marshal_constructor(2, ZwpInputTimestampsV1, pointer)
        return id

    @ZwpInputTimestampsManagerV1.request(
        Argument(ArgumentType.NewId, interface=ZwpInputTimestampsV1),
        Argument(ArgumentType.Object, interface=WlTouch),
    )
    def get_touch_timestamps(self, touch: WlTouchProxy) -> ZwpInputTimestampsV1Proxy:
        """Subscribe to high-resolution touch timestamp events

        Creates a new input timestamps object that represents a subscription to
        high-resolution timestamp events for all
        :class:`~pywayland.protocol.wayland.WlTouch` events that carry a
        timestamp.

        If the associated :class:`~pywayland.protocol.wayland.WlTouch` object
        becomes invalid, either through client action (e.g. release) or server-
        side changes, the input timestamps object becomes inert and the client
        should destroy it by calling :func:`ZwpInputTimestampsV1.destroy()
        <pywayland.protocol.input_timestamps_unstable_v1.ZwpInputTimestampsV1.destroy>`.

        :param touch:
            the :class:`~pywayland.protocol.wayland.WlTouch` object for which
            to get timestamp events
        :type touch:
            :class:`~pywayland.protocol.wayland.WlTouch`
        :returns:
            :class:`~pywayland.protocol.input_timestamps_unstable_v1.ZwpInputTimestampsV1`
        """
        id = self._marshal_constructor(3, ZwpInputTimestampsV1, touch)
        return id


class ZwpInputTimestampsV1Proxy(Proxy[ZwpInputTimestampsV1]):
    interface = ZwpInputTimestampsV1

    @ZwpInputTimestampsV1.request()
    def destroy(self) -> None:
        """Destroy the input timestamps object

        Informs the server that the client will no longer be using this
        protocol object. After the server processes the request, no more
        timestamp events will be emitted.
        """
        self._marshal(0)
        self._destroy()


class ZwpInputTimestampsManagerV1Global(Global[ZwpInputTimestampsManagerV1]):
    interface = ZwpInputTimestampsManagerV1


class ZwpInputTimestampsV1Global(Global[ZwpInputTimestampsV1]):
    interface = ZwpInputTimestampsV1


ZwpInputTimestampsManagerV1._gen_c()
ZwpInputTimestampsManagerV1.proxy_class = ZwpInputTimestampsManagerV1Proxy
ZwpInputTimestampsManagerV1.resource_class = ZwpInputTimestampsManagerV1Resource
ZwpInputTimestampsManagerV1.global_class = ZwpInputTimestampsManagerV1Global


ZwpInputTimestampsV1._gen_c()
ZwpInputTimestampsV1.proxy_class = ZwpInputTimestampsV1Proxy
ZwpInputTimestampsV1.resource_class = ZwpInputTimestampsV1Resource
ZwpInputTimestampsV1.global_class = ZwpInputTimestampsV1Global
