# This file has been autogenerated by the pywayland scanner

# Copyright © 2014      Jonas Ådahl
# Copyright © 2015      Red Hat Inc.
#
# 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

import enum

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

from .wayland import WlPointer
from .wayland import WlPointerProxy
from .wayland import WlRegion
from .wayland import WlRegionProxy
from .wayland import WlSurface
from .wayland import WlSurfaceProxy


class ZwpConfinedPointerV1(Interface):
    """Confined pointer object

    The wp_confined_pointer interface represents a confined pointer state.

    This object will send the event 'confined' when the confinement is
    activated. Whenever the confinement is activated, it is guaranteed that the
    surface the pointer is confined to will already have received pointer focus
    and that the pointer will be within the region passed to the request
    creating this object. It is up to the compositor to decide whether this
    requires some user interaction and if the pointer will warp to within the
    passed region if outside.

    To unconfine the pointer, send the destroy request. This will also destroy
    the wp_confined_pointer object.

    If the compositor decides to unconfine the pointer the unconfined event is
    sent. The wp_confined_pointer object is at this point defunct and should be
    destroyed.
    """

    name = "zwp_confined_pointer_v1"
    version = 1


class ZwpLockedPointerV1(Interface):
    """Receive relative pointer motion events

    The wp_locked_pointer interface represents a locked pointer state.

    While the lock of this object is active, the
    :class:`~pywayland.protocol.wayland.WlPointer` objects of the associated
    seat will not emit any :func:`WlPointer.motion()
    <pywayland.protocol.wayland.WlPointer.motion>` events.

    This object will send the event 'locked' when the lock is activated.
    Whenever the lock is activated, it is guaranteed that the locked surface
    will already have received pointer focus and that the pointer will be
    within the region passed to the request creating this object.

    To unlock the pointer, send the destroy request. This will also destroy the
    wp_locked_pointer object.

    If the compositor decides to unlock the pointer the unlocked event is sent.
    See wp_locked_pointer.unlock for details.

    When unlocking, the compositor may warp the cursor position to the set
    cursor position hint. If it does, it will not result in any relative motion
    events emitted via wp_relative_pointer.

    If the surface the lock was requested on is destroyed and the lock is not
    yet activated, the wp_locked_pointer object is now defunct and must be
    destroyed.
    """

    name = "zwp_locked_pointer_v1"
    version = 1


class ZwpPointerConstraintsV1(Interface):
    """Constrain the movement of a pointer

    The global interface exposing pointer constraining functionality. It
    exposes two requests: lock_pointer for locking the pointer to its position,
    and confine_pointer for locking the pointer to a region.

    The lock_pointer and confine_pointer requests create the objects
    wp_locked_pointer and wp_confined_pointer respectively, and the client can
    use these objects to interact with the lock.

    For any surface, only one lock or confinement may be active across all
    :class:`~pywayland.protocol.wayland.WlPointer` objects of the same seat. If
    a lock or confinement is requested when another lock or confinement is
    active or requested on the same surface and with any of the
    :class:`~pywayland.protocol.wayland.WlPointer` objects of the same seat, an
    'already_constrained' error will be raised.
    """

    name = "zwp_pointer_constraints_v1"
    version = 1

    class error(enum.IntEnum):
        already_constrained = 1

    class lifetime(enum.IntEnum):
        oneshot = 1
        persistent = 2


class ZwpConfinedPointerV1Resource(Resource[ZwpConfinedPointerV1]):
    interface = ZwpConfinedPointerV1

    @ZwpConfinedPointerV1.event()
    def confined(self) -> None:
        """Pointer confined

        Notification that the pointer confinement of the seat's pointer is
        activated.
        """
        self._post_event(0)

    @ZwpConfinedPointerV1.event()
    def unconfined(self) -> None:
        """Pointer unconfined

        Notification that the pointer confinement of the seat's pointer is no
        longer active. If this is a oneshot pointer confinement (see
        wp_pointer_constraints.lifetime) this object is now defunct and should
        be destroyed. If this is a persistent pointer confinement (see
        wp_pointer_constraints.lifetime) this pointer confinement may again
        reactivate in the future.
        """
        self._post_event(1)


class ZwpLockedPointerV1Resource(Resource[ZwpLockedPointerV1]):
    interface = ZwpLockedPointerV1

    @ZwpLockedPointerV1.event()
    def locked(self) -> None:
        """Lock activation event

        Notification that the pointer lock of the seat's pointer is activated.
        """
        self._post_event(0)

    @ZwpLockedPointerV1.event()
    def unlocked(self) -> None:
        """Lock deactivation event

        Notification that the pointer lock of the seat's pointer is no longer
        active. If this is a oneshot pointer lock (see
        wp_pointer_constraints.lifetime) this object is now defunct and should
        be destroyed. If this is a persistent pointer lock (see
        wp_pointer_constraints.lifetime) this pointer lock may again reactivate
        in the future.
        """
        self._post_event(1)


class ZwpPointerConstraintsV1Resource(Resource[ZwpPointerConstraintsV1]):
    interface = ZwpPointerConstraintsV1


class ZwpConfinedPointerV1Proxy(Proxy[ZwpConfinedPointerV1]):
    interface = ZwpConfinedPointerV1

    @ZwpConfinedPointerV1.request()
    def destroy(self) -> None:
        """Destroy the confined pointer object

        Destroy the confined pointer object. If applicable, the compositor will
        unconfine the pointer.
        """
        self._marshal(0)
        self._destroy()

    @ZwpConfinedPointerV1.request(
        Argument(ArgumentType.Object, interface=WlRegion, nullable=True),
    )
    def set_region(self, region: WlRegionProxy | None) -> None:
        """Set a new confine region

        Set a new region used to confine the pointer.

        The new confine region is double-buffered, see
        :func:`WlSurface.commit()
        <pywayland.protocol.wayland.WlSurface.commit>`.

        If the confinement is active when the new confinement region is applied
        and the pointer ends up outside of newly applied region, the pointer
        may warped to a position within the new confinement region. If warped,
        a :func:`WlPointer.motion()
        <pywayland.protocol.wayland.WlPointer.motion>` event will be emitted,
        but no wp_relative_pointer.relative_motion event.

        The compositor may also, instead of using the new region, unconfine the
        pointer.

        For details about the confine region, see wp_confined_pointer.

        :param region:
            region of surface
        :type region:
            :class:`~pywayland.protocol.wayland.WlRegion` or `None`
        """
        self._marshal(1, region)


class ZwpLockedPointerV1Proxy(Proxy[ZwpLockedPointerV1]):
    interface = ZwpLockedPointerV1

    @ZwpLockedPointerV1.request()
    def destroy(self) -> None:
        """Destroy the locked pointer object

        Destroy the locked pointer object. If applicable, the compositor will
        unlock the pointer.
        """
        self._marshal(0)
        self._destroy()

    @ZwpLockedPointerV1.request(
        Argument(ArgumentType.Fixed),
        Argument(ArgumentType.Fixed),
    )
    def set_cursor_position_hint(self, surface_x: float, surface_y: float) -> None:
        """Set the pointer cursor position hint

        Set the cursor position hint relative to the top left corner of the
        surface.

        If the client is drawing its own cursor, it should update the position
        hint to the position of its own cursor. A compositor may use this
        information to warp the pointer upon unlock in order to avoid pointer
        jumps.

        The cursor position hint is double-buffered state, see
        :func:`WlSurface.commit()
        <pywayland.protocol.wayland.WlSurface.commit>`.

        :param surface_x:
            surface-local x coordinate
        :type surface_x:
            `ArgumentType.Fixed`
        :param surface_y:
            surface-local y coordinate
        :type surface_y:
            `ArgumentType.Fixed`
        """
        self._marshal(1, surface_x, surface_y)

    @ZwpLockedPointerV1.request(
        Argument(ArgumentType.Object, interface=WlRegion, nullable=True),
    )
    def set_region(self, region: WlRegionProxy | None) -> None:
        """Set a new lock region

        Set a new region used to lock the pointer.

        The new lock region is double-buffered, see :func:`WlSurface.commit()
        <pywayland.protocol.wayland.WlSurface.commit>`.

        For details about the lock region, see wp_locked_pointer.

        :param region:
            region of surface
        :type region:
            :class:`~pywayland.protocol.wayland.WlRegion` or `None`
        """
        self._marshal(2, region)


class ZwpPointerConstraintsV1Proxy(Proxy[ZwpPointerConstraintsV1]):
    interface = ZwpPointerConstraintsV1

    @ZwpPointerConstraintsV1.request()
    def destroy(self) -> None:
        """Destroy the pointer constraints manager object

        Used by the client to notify the server that it will no longer use this
        pointer constraints object.
        """
        self._marshal(0)
        self._destroy()

    @ZwpPointerConstraintsV1.request(
        Argument(ArgumentType.NewId, interface=ZwpLockedPointerV1),
        Argument(ArgumentType.Object, interface=WlSurface),
        Argument(ArgumentType.Object, interface=WlPointer),
        Argument(ArgumentType.Object, interface=WlRegion, nullable=True),
        Argument(ArgumentType.Uint),
    )
    def lock_pointer(self, surface: WlSurfaceProxy, pointer: WlPointerProxy, region: WlRegionProxy | None, lifetime: int) -> ZwpLockedPointerV1Proxy:
        """Lock pointer to a position

        The lock_pointer request lets the client request to disable movements
        of the virtual pointer (i.e. the cursor), effectively locking the
        pointer to a position. This request may not take effect immediately; in
        the future, when the compositor deems implementation-specific
        constraints are satisfied, the pointer lock will be activated and the
        compositor sends a locked event.

        The protocol provides no guarantee that the constraints are ever
        satisfied, and does not require the compositor to send an error if the
        constraints cannot ever be satisfied. It is thus possible to request a
        lock that will never activate.

        There may not be another pointer constraint of any kind requested or
        active on the surface for any of the
        :class:`~pywayland.protocol.wayland.WlPointer` objects of the seat of
        the passed pointer when requesting a lock. If there is, an error will
        be raised. See general pointer lock documentation for more details.

        The intersection of the region passed with this request and the input
        region of the surface is used to determine where the pointer must be in
        order for the lock to activate. It is up to the compositor whether to
        warp the pointer or require some kind of user interaction for the lock
        to activate. If the region is null the surface input region is used.

        A surface may receive pointer focus without the lock being activated.

        The request creates a new object wp_locked_pointer which is used to
        interact with the lock as well as receive updates about its state. See
        the the description of wp_locked_pointer for further information.

        Note that while a pointer is locked, the
        :class:`~pywayland.protocol.wayland.WlPointer` objects of the
        corresponding seat will not emit any :func:`WlPointer.motion()
        <pywayland.protocol.wayland.WlPointer.motion>` events, but relative
        motion events will still be emitted via wp_relative_pointer objects of
        the same seat. :func:`WlPointer.axis()
        <pywayland.protocol.wayland.WlPointer.axis>` and
        :func:`WlPointer.button()
        <pywayland.protocol.wayland.WlPointer.button>` events are unaffected.

        :param surface:
            surface to lock pointer to
        :type surface:
            :class:`~pywayland.protocol.wayland.WlSurface`
        :param pointer:
            the pointer that should be locked
        :type pointer:
            :class:`~pywayland.protocol.wayland.WlPointer`
        :param region:
            region of surface
        :type region:
            :class:`~pywayland.protocol.wayland.WlRegion` or `None`
        :param lifetime:
            lock lifetime
        :type lifetime:
            `ArgumentType.Uint`
        :returns:
            :class:`~pywayland.protocol.pointer_constraints_unstable_v1.ZwpLockedPointerV1`
        """
        id = self._marshal_constructor(1, ZwpLockedPointerV1, surface, pointer, region, lifetime)
        return id

    @ZwpPointerConstraintsV1.request(
        Argument(ArgumentType.NewId, interface=ZwpConfinedPointerV1),
        Argument(ArgumentType.Object, interface=WlSurface),
        Argument(ArgumentType.Object, interface=WlPointer),
        Argument(ArgumentType.Object, interface=WlRegion, nullable=True),
        Argument(ArgumentType.Uint),
    )
    def confine_pointer(self, surface: WlSurfaceProxy, pointer: WlPointerProxy, region: WlRegionProxy | None, lifetime: int) -> ZwpConfinedPointerV1Proxy:
        """Confine pointer to a region

        The confine_pointer request lets the client request to confine the
        pointer cursor to a given region. This request may not take effect
        immediately; in the future, when the compositor deems implementation-
        specific constraints are satisfied, the pointer confinement will be
        activated and the compositor sends a confined event.

        The intersection of the region passed with this request and the input
        region of the surface is used to determine where the pointer must be in
        order for the confinement to activate. It is up to the compositor
        whether to warp the pointer or require some kind of user interaction
        for the confinement to activate. If the region is null the surface
        input region is used.

        The request will create a new object wp_confined_pointer which is used
        to interact with the confinement as well as receive updates about its
        state. See the the description of wp_confined_pointer for further
        information.

        :param surface:
            surface to lock pointer to
        :type surface:
            :class:`~pywayland.protocol.wayland.WlSurface`
        :param pointer:
            the pointer that should be confined
        :type pointer:
            :class:`~pywayland.protocol.wayland.WlPointer`
        :param region:
            region of surface
        :type region:
            :class:`~pywayland.protocol.wayland.WlRegion` or `None`
        :param lifetime:
            confinement lifetime
        :type lifetime:
            `ArgumentType.Uint`
        :returns:
            :class:`~pywayland.protocol.pointer_constraints_unstable_v1.ZwpConfinedPointerV1`
        """
        id = self._marshal_constructor(2, ZwpConfinedPointerV1, surface, pointer, region, lifetime)
        return id


class ZwpConfinedPointerV1Global(Global[ZwpConfinedPointerV1]):
    interface = ZwpConfinedPointerV1


class ZwpLockedPointerV1Global(Global[ZwpLockedPointerV1]):
    interface = ZwpLockedPointerV1


class ZwpPointerConstraintsV1Global(Global[ZwpPointerConstraintsV1]):
    interface = ZwpPointerConstraintsV1


ZwpConfinedPointerV1._gen_c()
ZwpConfinedPointerV1.proxy_class = ZwpConfinedPointerV1Proxy
ZwpConfinedPointerV1.resource_class = ZwpConfinedPointerV1Resource
ZwpConfinedPointerV1.global_class = ZwpConfinedPointerV1Global


ZwpLockedPointerV1._gen_c()
ZwpLockedPointerV1.proxy_class = ZwpLockedPointerV1Proxy
ZwpLockedPointerV1.resource_class = ZwpLockedPointerV1Resource
ZwpLockedPointerV1.global_class = ZwpLockedPointerV1Global


ZwpPointerConstraintsV1._gen_c()
ZwpPointerConstraintsV1.proxy_class = ZwpPointerConstraintsV1Proxy
ZwpPointerConstraintsV1.resource_class = ZwpPointerConstraintsV1Resource
ZwpPointerConstraintsV1.global_class = ZwpPointerConstraintsV1Global
