# 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.

from __future__ import annotations

import enum

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

from .wayland import WlSurface
from .wayland import WlSurfaceProxy


class ZxdgExportedV2(Interface):
    """An exported surface handle

    An xdg_exported object represents an exported reference to a surface. The
    exported surface may be referenced as long as the xdg_exported object not
    destroyed. Destroying the xdg_exported invalidates any relationship the
    importer may have established using xdg_imported.
    """

    name = "zxdg_exported_v2"
    version = 1


class ZxdgExporterV2(Interface):
    """Interface for exporting surfaces

    A global interface used for exporting surfaces that can later be imported
    using xdg_importer.
    """

    name = "zxdg_exporter_v2"
    version = 1

    class error(enum.IntEnum):
        invalid_surface = 0


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 ZxdgImporterV2(Interface):
    """Interface for importing surfaces

    A global interface used for importing surfaces exported by xdg_exporter.
    With this interface, a client can create a reference to a surface of
    another client.
    """

    name = "zxdg_importer_v2"
    version = 1


class ZxdgExportedV2Resource(Resource[ZxdgExportedV2]):
    interface = ZxdgExportedV2

    @ZxdgExportedV2.event(
        Argument(ArgumentType.String),
    )
    def handle(self, handle: str) -> None:
        """The exported surface handle

        The handle event contains the unique handle of this exported surface
        reference. It may be shared with any client, which then can use it to
        import the surface by calling xdg_importer.import_toplevel. A handle
        may be used to import the surface multiple times.

        :param handle:
            the exported surface handle
        :type handle:
            `ArgumentType.String`
        """
        self._post_event(0, handle)


class ZxdgExporterV2Resource(Resource[ZxdgExporterV2]):
    interface = ZxdgExporterV2


class ZxdgImportedV2Resource(Resource[ZxdgImportedV2]):
    interface = ZxdgImportedV2

    @ZxdgImportedV2.event()
    def destroyed(self) -> None:
        """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 ZxdgImporterV2Resource(Resource[ZxdgImporterV2]):
    interface = ZxdgImporterV2


class ZxdgExportedV2Proxy(Proxy[ZxdgExportedV2]):
    interface = ZxdgExportedV2

    @ZxdgExportedV2.request()
    def destroy(self) -> None:
        """Unexport the exported surface

        Revoke the previously exported surface. This invalidates any
        relationship the importer may have set up using the xdg_imported
        created given the handle sent via xdg_exported.handle.
        """
        self._marshal(0)
        self._destroy()


class ZxdgExporterV2Proxy(Proxy[ZxdgExporterV2]):
    interface = ZxdgExporterV2

    @ZxdgExporterV2.request()
    def destroy(self) -> None:
        """Destroy the xdg_exporter object

        Notify the compositor that the xdg_exporter object will no longer be
        used.
        """
        self._marshal(0)
        self._destroy()

    @ZxdgExporterV2.request(
        Argument(ArgumentType.NewId, interface=ZxdgExportedV2),
        Argument(ArgumentType.Object, interface=WlSurface),
    )
    def export_toplevel(self, surface: WlSurfaceProxy) -> ZxdgExportedV2Proxy:
        """Export a toplevel surface

        The export_toplevel request exports the passed surface so that it can
        later be imported via xdg_importer. When called, a new xdg_exported
        object will be created and xdg_exported.handle will be sent
        immediately. See the corresponding interface and event for details.

        A surface may be exported multiple times, and each exported handle may
        be used to create an xdg_imported multiple times. Only
        :class:`~pywayland.protocol.xdg_shell.XdgToplevel` equivalent surfaces
        may be exported, otherwise an invalid_surface protocol error is sent.

        :param surface:
            the surface to export
        :type surface:
            :class:`~pywayland.protocol.wayland.WlSurface`
        :returns:
            :class:`~pywayland.protocol.xdg_foreign_unstable_v2.ZxdgExportedV2`
            -- the new xdg_exported object
        """
        id = self._marshal_constructor(1, ZxdgExportedV2, surface)
        return id


class ZxdgImportedV2Proxy(Proxy[ZxdgImportedV2]):
    interface = ZxdgImportedV2

    @ZxdgImportedV2.request()
    def destroy(self) -> None:
        """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: WlSurfaceProxy) -> None:
        """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 ZxdgImporterV2Proxy(Proxy[ZxdgImporterV2]):
    interface = ZxdgImporterV2

    @ZxdgImporterV2.request()
    def destroy(self) -> None:
        """Destroy the xdg_importer object

        Notify the compositor that the xdg_importer object will no longer be
        used.
        """
        self._marshal(0)
        self._destroy()

    @ZxdgImporterV2.request(
        Argument(ArgumentType.NewId, interface=ZxdgImportedV2),
        Argument(ArgumentType.String),
    )
    def import_toplevel(self, handle: str) -> ZxdgImportedV2Proxy:
        """Import a toplevel surface

        The import_toplevel request imports a surface from any client given a
        handle retrieved by exporting said surface using
        xdg_exporter.export_toplevel. When called, a new xdg_imported object
        will be created. This new object represents the imported surface, and
        the importing client can manipulate its relationship using it. See
        xdg_imported for details.

        :param handle:
            the exported surface handle
        :type handle:
            `ArgumentType.String`
        :returns:
            :class:`~pywayland.protocol.xdg_foreign_unstable_v2.ZxdgImportedV2`
            -- the new xdg_imported object
        """
        id = self._marshal_constructor(1, ZxdgImportedV2, handle)
        return id


class ZxdgExportedV2Global(Global[ZxdgExportedV2]):
    interface = ZxdgExportedV2


class ZxdgExporterV2Global(Global[ZxdgExporterV2]):
    interface = ZxdgExporterV2


class ZxdgImportedV2Global(Global[ZxdgImportedV2]):
    interface = ZxdgImportedV2


class ZxdgImporterV2Global(Global[ZxdgImporterV2]):
    interface = ZxdgImporterV2


ZxdgExportedV2._gen_c()
ZxdgExportedV2.proxy_class = ZxdgExportedV2Proxy
ZxdgExportedV2.resource_class = ZxdgExportedV2Resource
ZxdgExportedV2.global_class = ZxdgExportedV2Global


ZxdgExporterV2._gen_c()
ZxdgExporterV2.proxy_class = ZxdgExporterV2Proxy
ZxdgExporterV2.resource_class = ZxdgExporterV2Resource
ZxdgExporterV2.global_class = ZxdgExporterV2Global


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


ZxdgImporterV2._gen_c()
ZxdgImporterV2.proxy_class = ZxdgImporterV2Proxy
ZxdgImporterV2.resource_class = ZxdgImporterV2Resource
ZxdgImporterV2.global_class = ZxdgImporterV2Global
