stevee

My wayland statusbar
git clone git://gtms.dev/stevee
Log | Files | Refs | README | LICENSE

wayland_client_core.zig (5541B)


      1 pub const Object = common.Object;
      2 pub const Message = common.Message;
      3 pub const Interface = common.Interface;
      4 pub const list = common.list;
      5 pub const Array = common.Array;
      6 pub const Fixed = common.Fixed;
      7 pub const Argument = common.Argument;
      8 
      9 pub const Proxy = opaque {
     10     extern fn wl_proxy_create(factory: *Proxy, interface: *const Interface) ?*Proxy;
     11     pub fn create(factory: *Proxy, interface: *const Interface) error{OutOfMemory}!*Proxy {
     12         return wl_proxy_create(factory, interface) orelse error.OutOfMemory;
     13     }
     14 
     15     extern fn wl_proxy_destroy(proxy: *Proxy) void;
     16     pub const destroy = wl_proxy_destroy;
     17 
     18     extern fn wl_proxy_marshal_array(proxy: *Proxy, opcode: u32, args: ?[*]Argument) void;
     19     pub const marshal = wl_proxy_marshal_array;
     20 
     21     extern fn wl_proxy_marshal_array_constructor(
     22         proxy: *Proxy,
     23         opcode: u32,
     24         args: [*]Argument,
     25         interface: *const Interface,
     26     ) ?*Proxy;
     27     pub fn marshalConstructor(
     28         proxy: *Proxy,
     29         opcode: u32,
     30         args: [*]Argument,
     31         interface: *const Interface,
     32     ) error{OutOfMemory}!*Proxy {
     33         return wl_proxy_marshal_array_constructor(proxy, opcode, args, interface) orelse
     34             error.OutOfMemory;
     35     }
     36 
     37     extern fn wl_proxy_marshal_array_constructor_versioned(
     38         proxy: *Proxy,
     39         opcode: u32,
     40         args: [*]Argument,
     41         interface: *const Interface,
     42         version: u32,
     43     ) ?*Proxy;
     44     pub fn marshalConstructorVersioned(
     45         proxy: *Proxy,
     46         opcode: u32,
     47         args: [*]Argument,
     48         interface: *const Interface,
     49         version: u32,
     50     ) error{OutOfMemory}!*Proxy {
     51         return wl_proxy_marshal_array_constructor_versioned(proxy, opcode, args, interface, version) orelse
     52             error.OutOfMemory;
     53     }
     54 
     55     const DispatcherFn = fn (
     56         implementation: ?*const anyopaque,
     57         proxy: *Proxy,
     58         opcode: u32,
     59         message: *const Message,
     60         args: [*]Argument,
     61     ) callconv(.C) c_int;
     62     extern fn wl_proxy_add_dispatcher(
     63         proxy: *Proxy,
     64         dispatcher: *const DispatcherFn,
     65         implementation: ?*const anyopaque,
     66         data: ?*anyopaque,
     67     ) c_int;
     68     pub fn addDispatcher(
     69         proxy: *Proxy,
     70         dispatcher: *const DispatcherFn,
     71         implementation: ?*const anyopaque,
     72         data: ?*anyopaque,
     73     ) void {
     74         const ret = wl_proxy_add_dispatcher(proxy, dispatcher, implementation, data);
     75         // Since there is no way to remove listeners, adding a listener to
     76         // the same proxy twice is always a bug, so assert instead of returning
     77         // an error.
     78         assert(ret != -1); // If this fails, a listener was already added
     79     }
     80 
     81     extern fn wl_proxy_get_user_data(proxy: *Proxy) ?*anyopaque;
     82     pub const getUserData = wl_proxy_get_user_data;
     83 
     84     extern fn wl_proxy_get_version(proxy: *Proxy) u32;
     85     pub const getVersion = wl_proxy_get_version;
     86 
     87     extern fn wl_proxy_get_id(proxy: *Proxy) u32;
     88     pub const getId = wl_proxy_get_id;
     89 
     90     extern fn wl_proxy_set_queue(proxy: *Proxy, queue: *EventQueue) void;
     91     pub const setQueue = wl_proxy_set_queue;
     92 };
     93 
     94 pub const EventQueue = opaque {
     95     extern fn wl_event_queue_destroy(queue: *EventQueue) void;
     96     pub const destroy = wl_event_queue_destroy;
     97 };
     98 
     99 pub const EglWindow = opaque {
    100     extern fn wl_egl_window_create(surface: *client.wl.Surface, width: c_int, height: c_int) ?*EglWindow;
    101     pub fn create(surface: *client.wl.Surface, width: c_int, height: c_int) !*EglWindow {
    102         // Why do people use int when they require a positive number?
    103         assert(width > 0 and height > 0);
    104         return wl_egl_window_create(surface, width, height) orelse error.OutOfMemory;
    105     }
    106 
    107     extern fn wl_egl_window_destroy(egl_window: *EglWindow) void;
    108     pub const destroy = wl_egl_window_destroy;
    109 
    110     extern fn wl_egl_window_resize(egl_window: *EglWindow, width: c_int, height: c_int, dx: c_int, dy: c_int) void;
    111     pub const resize = wl_egl_window_resize;
    112 
    113     extern fn wl_egl_window_get_attached_size(egl_window: *EglWindow, width: *c_int, height: *c_int) void;
    114     pub const getAttachedSize = wl_egl_window_get_attached_size;
    115 };
    116 
    117 pub const CursorTheme = opaque {
    118     extern fn wl_cursor_theme_load(name: ?[*:0]const u8, size: c_int, shm: *client.wl.Shm) ?*CursorTheme;
    119     pub fn load(name: ?[*:0]const u8, size: i32, shm: *client.wl.Shm) error{LoadThemeFailed}!*CursorTheme {
    120         return wl_cursor_theme_load(name, @intCast(size), shm) orelse error.LoadThemeFailed;
    121     }
    122 
    123     extern fn wl_cursor_theme_destroy(wl_cursor_theme: *CursorTheme) void;
    124     pub const destroy = wl_cursor_theme_destroy;
    125 
    126     extern fn wl_cursor_theme_get_cursor(theme: *CursorTheme, name: [*:0]const u8) ?*Cursor;
    127     pub const getCursor = wl_cursor_theme_get_cursor;
    128 };
    129 
    130 pub const Cursor = extern struct {
    131     image_count: c_uint,
    132     images: [*]*CursorImage,
    133     name: [*:0]u8,
    134 
    135     extern fn wl_cursor_frame(cursor: *Cursor, time: u32) c_int;
    136     pub const frame = wl_cursor_frame;
    137 
    138     extern fn wl_cursor_frame_and_duration(cursor: *Cursor, time: u32, duration: *u32) c_int;
    139     pub const frameAndDuration = wl_cursor_frame_and_duration;
    140 };
    141 
    142 pub const CursorImage = extern struct {
    143     width: u32,
    144     height: u32,
    145     hotspot_x: u32,
    146     hotspot_y: u32,
    147     delay: u32,
    148 
    149     extern fn wl_cursor_image_get_buffer(image: *CursorImage) ?*client.wl.Buffer;
    150     pub fn getBuffer(image: *CursorImage) error{OutOfMemory}!*client.wl.Buffer {
    151         return wl_cursor_image_get_buffer(image) orelse error.OutOfMemory;
    152     }
    153 };