# -*- 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 .wl_keyboard import WlKeyboard
from .wl_pointer import WlPointer
from .wl_touch import WlTouch

import enum


class WlSeat(Interface):
    """Group of input devices

    A seat is a group of keyboards, pointer and touch devices. This object is
    published as a global during start up, or when such a device is hot
    plugged.  A seat typically has a pointer and maintains a keyboard focus and
    a pointer focus.
    """
    name = "wl_seat"
    version = 7

    capability = enum.Enum("capability", {
        "pointer": 1,
        "keyboard": 2,
        "touch": 4,
    })


@WlSeat.request("n", [WlPointer])
def get_pointer(self):
    """Return pointer object

    The ID provided will be initialized to the
    :class:`~pywayland.protocol.wayland.WlPointer` interface for this seat.

    This request only takes effect if the seat has the pointer capability, or
    has had the pointer capability in the past. It is a protocol violation to
    issue this request on a seat that has never had the pointer capability.

    :returns:
        :class:`~pywayland.protocol.wayland.WlPointer` -- seat pointer
    """
    id = self._marshal_constructor(0, WlPointer)
    return id


@WlSeat.request("n", [WlKeyboard])
def get_keyboard(self):
    """Return keyboard object

    The ID provided will be initialized to the
    :class:`~pywayland.protocol.wayland.WlKeyboard` interface for this seat.

    This request only takes effect if the seat has the keyboard capability, or
    has had the keyboard capability in the past. It is a protocol violation to
    issue this request on a seat that has never had the keyboard capability.

    :returns:
        :class:`~pywayland.protocol.wayland.WlKeyboard` -- seat keyboard
    """
    id = self._marshal_constructor(1, WlKeyboard)
    return id


@WlSeat.request("n", [WlTouch])
def get_touch(self):
    """Return touch object

    The ID provided will be initialized to the
    :class:`~pywayland.protocol.wayland.WlTouch` interface for this seat.

    This request only takes effect if the seat has the touch capability, or has
    had the touch capability in the past. It is a protocol violation to issue
    this request on a seat that has never had the touch capability.

    :returns:
        :class:`~pywayland.protocol.wayland.WlTouch` -- seat touch interface
    """
    id = self._marshal_constructor(2, WlTouch)
    return id


@WlSeat.request("5", [])
def release(self):
    """Release the seat object

    Using this request a client can tell the server that it is not going to use
    the seat object anymore.
    """
    self._marshal(3)
    self._destroy()


@WlSeat.event("u", [None])
def capabilities(self, capabilities):
    """Seat capabilities changed

    This is emitted whenever a seat gains or loses the pointer, keyboard or
    touch capabilities.  The argument is a capability enum containing the
    complete set of capabilities this seat has.

    When the pointer capability is added, a client may create a
    :class:`~pywayland.protocol.wayland.WlPointer` object using the
    :func:`WlSeat.get_pointer()` request. This object will receive pointer
    events until the capability is removed in the future.

    When the pointer capability is removed, a client should destroy the
    :class:`~pywayland.protocol.wayland.WlPointer` objects associated with the
    seat where the capability was removed, using the :func:`WlPointer.release()
    <pywayland.protocol.wayland.WlPointer..release>` request. No further
    pointer events will be received on these objects.

    In some compositors, if a seat regains the pointer capability and a client
    has a previously obtained :class:`~pywayland.protocol.wayland.WlPointer`
    object of version 4 or less, that object may start sending pointer events
    again. This behavior is considered a misinterpretation of the intended
    behavior and must not be relied upon by the client.
    :class:`~pywayland.protocol.wayland.WlPointer` objects of version 5 or
    later must not send events if created before the most recent event
    notifying the client of an added pointer capability.

    The above behavior also applies to
    :class:`~pywayland.protocol.wayland.WlKeyboard` and
    :class:`~pywayland.protocol.wayland.WlTouch` with the keyboard and touch
    capabilities, respectively.

    :param capabilities:
        capabilities of the seat
    :type capabilities: `uint`
    """
    self._post_event(0, capabilities)


@WlSeat.event("2s", [None])
def name(self, name):
    """Unique identifier for this seat

    In a multiseat configuration this can be used by the client to help
    identify which physical devices the seat represents. Based on the seat
    configuration used by the compositor.

    :param name:
        seat identifier
    :type name: `string`
    """
    self._post_event(1, name)


WlSeat._gen_c()
