wayland_client.zig(1)

glfmn.io wayland_client.zig(1)
Name

wayland_client.zig

generated by zig-wayland via a build.zig file.

Description

This file gets generated using the zig-wayland Scanner at build time and placed in the zig-cache/o directory.

build.zig
const scanner = Scanner.create(b, .{});
const wayland = b.createModule(.{ .source_file = scanner.result });

scanner.generate("wl_compositor", 1);

exe.addModule("wayland", wayland);
exe.linkLibC();
exe.linkSystemLibrary("wayland-client");

Contents

// Generated by zig-wayland

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

const std = @import("std");
const os = std.os;
const client = @import("wayland.zig").client;
const common = @import("common.zig");
pub const Display = opaque {
    pub const generated_version = 1;
    pub const getInterface = common.wl.display.getInterface;
    pub const Error = common.wl.display.Error;
    pub fn setQueue(_display: *Display, _queue: *client.wl.EventQueue) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_display);
        _proxy.setQueue(_queue);
    }
    pub const Event = union(enum) {
        @"error": struct {
            object_id: ?*common.Object,
            code: u32,
            message: [*:0]const u8,
        },
        delete_id: struct {
            id: u32,
        },
    };
    pub inline fn setListener(
        _display: *Display,
        comptime T: type,
        _listener: *const fn (display: *Display, event: Event, data: T) void,
        _data: T,
    ) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_display);
        const _mut_data: ?*anyopaque = @ptrFromInt(@intFromPtr(_data));
        _proxy.addDispatcher(common.Dispatcher(Display, T).dispatcher, _listener, _mut_data);
    }
    pub fn sync(_display: *Display) !*client.wl.Callback {
        const _proxy: *client.wl.Proxy = @ptrCast(_display);
        var _args = [_]common.Argument{
            .{ .o = null },
        };
        return @ptrCast(try _proxy.marshalConstructor(0, &_args, client.wl.Callback.getInterface()));
    }
    pub fn getRegistry(_display: *Display) !*client.wl.Registry {
        const _proxy: *client.wl.Proxy = @ptrCast(_display);
        var _args = [_]common.Argument{
            .{ .o = null },
        };
        return @ptrCast(try _proxy.marshalConstructor(1, &_args, client.wl.Registry.getInterface()));
    }
    extern fn wl_display_connect(name: ?[*:0]const u8) ?*Display;
    pub inline fn connect(name: ?[*:0]const u8) error{ConnectFailed}!*Display {
        return wl_display_connect(name) orelse return error.ConnectFailed;
    }

    extern fn wl_display_connect_to_fd(fd: c_int) ?*Display;
    pub inline fn connectToFd(fd: c_int) error{ConnectFailed}!*Display {
        return wl_display_connect_to_fd(fd) orelse return error.ConnectFailed;
    }

    extern fn wl_display_disconnect(display: *Display) void;
    pub const disconnect = wl_display_disconnect;

    extern fn wl_display_get_fd(display: *Display) c_int;
    pub const getFd = wl_display_get_fd;

    extern fn wl_display_dispatch(display: *Display) c_int;
    pub inline fn dispatch(display: *Display) os.E {
        return os.errno(wl_display_dispatch(display));
    }

    extern fn wl_display_dispatch_queue(display: *Display, queue: *client.wl.EventQueue) c_int;
    pub inline fn dispatchQueue(display: *Display, queue: *client.wl.EventQueue) os.E {
        return os.errno(wl_display_dispatch_queue(display, queue));
    }

    extern fn wl_display_dispatch_pending(display: *Display) c_int;
    pub inline fn dispatchPending(display: *Display) os.E {
        return os.errno(wl_display_dispatch_pending(display));
    }

    extern fn wl_display_dispatch_queue_pending(display: *Display, queue: *client.wl.EventQueue) c_int;
    pub inline fn dispatchQueuePending(display: *Display, queue: *client.wl.EventQueue) os.E {
        return os.errno(wl_display_dispatch_queue_pending(display, queue));
    }

    extern fn wl_display_roundtrip(display: *Display) c_int;
    pub inline fn roundtrip(display: *Display) os.E {
        return os.errno(wl_display_roundtrip(display));
    }

    extern fn wl_display_roundtrip_queue(display: *Display, queue: *client.wl.EventQueue) c_int;
    pub inline fn roundtripQueue(display: *Display, queue: *client.wl.EventQueue) os.E {
        return os.errno(wl_display_roundtrip_queue(display, queue));
    }

    extern fn wl_display_flush(display: *Display) c_int;
    pub inline fn flush(display: *Display) os.E {
        return os.errno(wl_display_flush(display));
    }

    extern fn wl_display_create_queue(display: *Display) ?*client.wl.EventQueue;
    pub inline fn createQueue(display: *Display) error{OutOfMemory}!*client.wl.EventQueue {
        return wl_display_create_queue(display) orelse error.OutOfMemory;
    }

    extern fn wl_display_get_error(display: *Display) c_int;
    pub const getError = wl_display_get_error;

    extern fn wl_display_prepare_read_queue(display: *Display, queue: *client.wl.EventQueue) c_int;
    /// Succeeds if the queue is empty and returns true.
    /// Fails and returns false if the queue was not empty.
    pub inline fn prepareReadQueue(display: *Display, queue: *client.wl.EventQueue) bool {
        switch (wl_display_prepare_read_queue(display, queue)) {
            0 => return true,
            -1 => return false,
            else => unreachable,
        }
    }

    extern fn wl_display_prepare_read(display: *Display) c_int;
    /// Succeeds if the queue is empty and returns true.
    /// Fails and returns false if the queue was not empty.
    pub inline fn prepareRead(display: *Display) bool {
        switch (wl_display_prepare_read(display)) {
            0 => return true,
            -1 => return false,
            else => unreachable,
        }
    }

    extern fn wl_display_cancel_read(display: *Display) void;
    pub const cancelRead = wl_display_cancel_read;

    extern fn wl_display_read_events(display: *Display) c_int;
    pub inline fn readEvents(display: *Display) os.E {
        return os.errno(wl_display_read_events(display));
    }
};
pub const Registry = opaque {
    pub const generated_version = 1;
    pub const getInterface = common.wl.registry.getInterface;
    pub fn setQueue(_registry: *Registry, _queue: *client.wl.EventQueue) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_registry);
        _proxy.setQueue(_queue);
    }
    pub const Event = union(enum) {
        global: struct {
            name: u32,
            interface: [*:0]const u8,
            version: u32,
        },
        global_remove: struct {
            name: u32,
        },
    };
    pub inline fn setListener(
        _registry: *Registry,
        comptime T: type,
        _listener: *const fn (registry: *Registry, event: Event, data: T) void,
        _data: T,
    ) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_registry);
        const _mut_data: ?*anyopaque = @ptrFromInt(@intFromPtr(_data));
        _proxy.addDispatcher(common.Dispatcher(Registry, T).dispatcher, _listener, _mut_data);
    }
    pub fn bind(_registry: *Registry, _name: u32, comptime T: type, _version: u32) !*T {
        const version_to_construct = @min(T.generated_version, _version);
        const _proxy: *client.wl.Proxy = @ptrCast(_registry);
        var _args = [_]common.Argument{
            .{ .u = _name },                .{ .s = T.getInterface().name },
            .{ .u = version_to_construct }, .{ .o = null },
        };
        return @ptrCast(try _proxy.marshalConstructorVersioned(0, &_args, T.getInterface(), version_to_construct));
    }
    pub fn destroy(_registry: *Registry) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_registry);
        _proxy.destroy();
    }
};
pub const Callback = opaque {
    pub const generated_version = 1;
    pub const getInterface = common.wl.callback.getInterface;
    pub fn setQueue(_callback: *Callback, _queue: *client.wl.EventQueue) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_callback);
        _proxy.setQueue(_queue);
    }
    pub const Event = union(enum) {
        done: struct {
            callback_data: u32,
        },
    };
    pub inline fn setListener(
        _callback: *Callback,
        comptime T: type,
        _listener: *const fn (callback: *Callback, event: Event, data: T) void,
        _data: T,
    ) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_callback);
        const _mut_data: ?*anyopaque = @ptrFromInt(@intFromPtr(_data));
        _proxy.addDispatcher(common.Dispatcher(Callback, T).dispatcher, _listener, _mut_data);
    }
    pub fn destroy(_callback: *Callback) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_callback);
        _proxy.destroy();
    }
};
pub const Buffer = opaque {
    pub const generated_version = 1;
    pub const getInterface = common.wl.buffer.getInterface;
    pub fn setQueue(_buffer: *Buffer, _queue: *client.wl.EventQueue) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_buffer);
        _proxy.setQueue(_queue);
    }
    pub const Event = union(enum) {
        release: void,
    };
    pub inline fn setListener(
        _buffer: *Buffer,
        comptime T: type,
        _listener: *const fn (buffer: *Buffer, event: Event, data: T) void,
        _data: T,
    ) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_buffer);
        const _mut_data: ?*anyopaque = @ptrFromInt(@intFromPtr(_data));
        _proxy.addDispatcher(common.Dispatcher(Buffer, T).dispatcher, _listener, _mut_data);
    }
    pub fn destroy(_buffer: *Buffer) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_buffer);
        _proxy.marshal(0, null);
        _proxy.destroy();
    }
};
pub const Compositor = opaque {
    pub const generated_version = 1;
    pub const getInterface = common.wl.compositor.getInterface;
    pub fn setQueue(_compositor: *Compositor, _queue: *client.wl.EventQueue) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_compositor);
        _proxy.setQueue(_queue);
    }
    pub fn createSurface(_compositor: *Compositor) !*client.wl.Surface {
        const _proxy: *client.wl.Proxy = @ptrCast(_compositor);
        var _args = [_]common.Argument{
            .{ .o = null },
        };
        return @ptrCast(try _proxy.marshalConstructor(0, &_args, client.wl.Surface.getInterface()));
    }
    pub fn createRegion(_compositor: *Compositor) !*client.wl.Region {
        const _proxy: *client.wl.Proxy = @ptrCast(_compositor);
        var _args = [_]common.Argument{
            .{ .o = null },
        };
        return @ptrCast(try _proxy.marshalConstructor(1, &_args, client.wl.Region.getInterface()));
    }
    pub fn destroy(_compositor: *Compositor) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_compositor);
        _proxy.destroy();
    }
};
pub const Surface = opaque {
    pub const generated_version = 1;
    pub const getInterface = common.wl.surface.getInterface;
    pub const Error = common.wl.surface.Error;
    pub fn setQueue(_surface: *Surface, _queue: *client.wl.EventQueue) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_surface);
        _proxy.setQueue(_queue);
    }
    pub const Event = union(enum) {
        enter: struct {
            output: ?*client.wl.Output,
        },
        leave: struct {
            output: ?*client.wl.Output,
        },
    };
    pub inline fn setListener(
        _surface: *Surface,
        comptime T: type,
        _listener: *const fn (surface: *Surface, event: Event, data: T) void,
        _data: T,
    ) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_surface);
        const _mut_data: ?*anyopaque = @ptrFromInt(@intFromPtr(_data));
        _proxy.addDispatcher(common.Dispatcher(Surface, T).dispatcher, _listener, _mut_data);
    }
    pub fn destroy(_surface: *Surface) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_surface);
        _proxy.marshal(0, null);
        _proxy.destroy();
    }
    pub fn attach(_surface: *Surface, _buffer: ?*client.wl.Buffer, _x: i32, _y: i32) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_surface);
        var _args = [_]common.Argument{
            .{ .o = @ptrCast(_buffer) },
            .{ .i = _x },
            .{ .i = _y },
        };
        _proxy.marshal(1, &_args);
    }
    pub fn damage(_surface: *Surface, _x: i32, _y: i32, _width: i32, _height: i32) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_surface);
        var _args = [_]common.Argument{
            .{ .i = _x },
            .{ .i = _y },
            .{ .i = _width },
            .{ .i = _height },
        };
        _proxy.marshal(2, &_args);
    }
    pub fn frame(_surface: *Surface) !*client.wl.Callback {
        const _proxy: *client.wl.Proxy = @ptrCast(_surface);
        var _args = [_]common.Argument{
            .{ .o = null },
        };
        return @ptrCast(try _proxy.marshalConstructor(3, &_args, client.wl.Callback.getInterface()));
    }
    pub fn setOpaqueRegion(_surface: *Surface, _region: ?*client.wl.Region) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_surface);
        var _args = [_]common.Argument{
            .{ .o = @ptrCast(_region) },
        };
        _proxy.marshal(4, &_args);
    }
    pub fn setInputRegion(_surface: *Surface, _region: ?*client.wl.Region) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_surface);
        var _args = [_]common.Argument{
            .{ .o = @ptrCast(_region) },
        };
        _proxy.marshal(5, &_args);
    }
    pub fn commit(_surface: *Surface) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_surface);
        _proxy.marshal(6, null);
    }
};
pub const Region = opaque {
    pub const generated_version = 1;
    pub const getInterface = common.wl.region.getInterface;
    pub fn setQueue(_region: *Region, _queue: *client.wl.EventQueue) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_region);
        _proxy.setQueue(_queue);
    }
    pub fn destroy(_region: *Region) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_region);
        _proxy.marshal(0, null);
        _proxy.destroy();
    }
    pub fn add(_region: *Region, _x: i32, _y: i32, _width: i32, _height: i32) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_region);
        var _args = [_]common.Argument{
            .{ .i = _x },
            .{ .i = _y },
            .{ .i = _width },
            .{ .i = _height },
        };
        _proxy.marshal(1, &_args);
    }
    pub fn subtract(_region: *Region, _x: i32, _y: i32, _width: i32, _height: i32) void {
        const _proxy: *client.wl.Proxy = @ptrCast(_region);
        var _args = [_]common.Argument{
            .{ .i = _x },
            .{ .i = _y },
            .{ .i = _width },
            .{ .i = _height },
        };
        _proxy.marshal(2, &_args);
    }
};

References

This page is referenced by the following documents: