# This file has been autogenerated by the pywayland scanner

# Copyright © 2015-2016 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.

import enum

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


class ZxdgImportedV2(Interface):
    """An imported surface handle

    An xdg_imported object represents an imported reference to surface exported
    by some client. A client can use this interface to manipulate relationships
    between its own surfaces and the imported surface.
    """

    name = "zxdg_imported_v2"
    version = 1

    class error(enum.IntEnum):
        invalid_surface = 0


class ZxdgImportedV2Proxy(Proxy):
    interface = ZxdgImportedV2

    @ZxdgImportedV2.request()
    def destroy(self):
        """Destroy the xdg_imported object

        Notify the compositor that it will no longer use the xdg_imported
        object. Any relationship that may have been set up will at this point
        be invalidated.
        """
        self._marshal(0)
        self._destroy()

    @ZxdgImportedV2.request(
        Argument(ArgumentType.Object, interface=WlSurface),
    )
    def set_parent_of(self, surface):
        """Set as the parent of some surface

        Set the imported surface as the parent of some surface of the client.
        The passed surface must be an
        :class:`~pywayland.protocol.xdg_shell.XdgToplevel` equivalent,
        otherwise an invalid_surface protocol error is sent. Calling this
        function sets up a surface to surface relation with the same stacking
        and positioning semantics as :func:`XdgToplevel.set_parent()
        <pywayland.protocol.xdg_shell.XdgToplevel.set_parent>`.

        :param surface:
            the child surface
        :type surface:
            :class:`~pywayland.protocol.wayland.WlSurface`
        """
        self._marshal(1, surface)


class ZxdgImportedV2Resource(Resource):
    interface = ZxdgImportedV2

    @ZxdgImportedV2.event()
    def destroyed(self):
        """The imported surface handle has been destroyed

        The imported surface handle has been destroyed and any relationship set
        up has been invalidated. This may happen for various reasons, for
        example if the exported surface or the exported surface handle has been
        destroyed, if the handle used for importing was invalid.
        """
        self._post_event(0)


class ZxdgImportedV2Global(Global):
    interface = ZxdgImportedV2


ZxdgImportedV2._gen_c()
ZxdgImportedV2.proxy_class = ZxdgImportedV2Proxy
ZxdgImportedV2.resource_class = ZxdgImportedV2Resource
ZxdgImportedV2.global_class = ZxdgImportedV2Global
