weston 4: wayland协议衍生结构体分析
创始人
2025-05-30 20:20:19
0

以下为个人工作阶段性总结,如有错误概不负责。

wayland.xml 文件中核心协议接口(类)一共22个,全部被定义成结构体,位于编译后生成的文件wayland-client-protocol.h最上端。

struct wl_buffer;

struct wl_callback;

struct wl_compositor;

struct wl_data_device;

struct wl_data_device_manager;

struct wl_data_offer;

struct wl_data_source;

struct wl_display;

struct wl_keyboard;

struct wl_output;

struct wl_pointer;

struct wl_region;

struct wl_registry;

struct wl_seat;

struct wl_shell;

struct wl_shell_surface;

struct wl_shm;

struct wl_shm_pool;

struct wl_subcompositor;

struct wl_subsurface;

struct wl_surface;

struct wl_touch;

其中除wl_display,其余全部只是声明,没有实际结构。

除wl_display外其他结构体都是由wl_proxy转换生成,或者说都是wl_proxy。

以下为各个结构体来源介绍除wl_display外,其他结构体最终均定位到

wl_proxy_marshal_flags-->wl_proxy_marshal_array_flags如有兴趣,以下总结可以看下。

注:有3个暂未找到来源。

1.struct wl_display; 核心全局对象

wayland-client-core.h
struct wl_display {
    struct wl_proxy proxy;
    struct wl_connection *connection;
    int last_error;
    struct {

        uint32_t code;
        const struct wl_interface *interface;
        uint32_t id;
    } protocol_error;
    int fd;
    struct wl_map objects;
    struct wl_event_queue display_queue;
    struct wl_event_queue default_queue;
    pthread_mutex_t mutex;

    int reader_count;
    uint32_t read_serial;
    pthread_cond_t reader_cond;
};

2.struct wl_registry;     全局注册对象

生成方式:

(simple-shm.c 等所有客户端程序)

display->registry = wl_display_get_registry(display->display);

最终实现:

wl_display_get_registry  (wayland-client-protocol.h)

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

3.struct wl_callback;     回调对象 

生成方式:

callback = wl_display_sync(client->wl_display);

最终实现:

wl_display_sync

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

4.struct wl_compositor;    合成器单例

生成方式:

 d->compositor = wl_registry_bind(registry,id, &wl_compositor_interface, 1);

最终实现:

wl_registry_bind

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

5.struct wl_shm_pool;    共享内存池

生成方式:

(simple-shm.c 等所有客户端程序)

pool = wl_shm_create_pool(display->shm, fd, size);

最终实现:

wl_shm_create_pool

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

6. struct wl_shm;    共享内存支持

生成方式:

(simple-shm.c 等所有客户端程序)

d->shm = wl_registry_bind(registry,id, &wl_shm_interface, 1);

最终实现:

wl_registry_bind

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

7.struct wl_buffer;   wl_surface的内容

生成方式:

(window.c)

data->buffer = wl_shm_pool_create_buffer(pool->pool, offset,

rectangle->width,

rectangle->height,

stride, format);

最终实现:

wl_shm_pool_create_buffer

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

8.struct wl_data_offer;   提供传输数据

没找到

9.struct wl_data_source;  提供传输数据         

没找到

10.struct wl_data_device;   数据传输设备

生成方式:

(window.c)

input->data_device =

wl_data_device_manager_get_data_device(d->data_device_manager,

input->seat);

最终实现:

wl_data_device_manager_get_data_device

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

11.struct wl_data_device_manager;  数据传输接口

生成方式:

d->data_device_manager = wl_registry_bind(d->registry, id,

&wl_data_device_manager_interface,

d->data_device_manager_version);

最终实现:

wl_registry_bind

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

12.struct wl_shell;     创建桌面样式的surface

没找到

13.struct wl_shell_surface;    桌面样式元数据界面

生成方式:

static inline struct wl_shell_surface *
wl_shell_get_shell_surface(struct wl_shell *wl_shell, struct wl_surface *surface)
{
    struct wl_proxy *id;
    id = wl_proxy_marshal_flags((struct wl_proxy *) wl_shell,
             WL_SHELL_GET_SHELL_SURFACE, &wl_shell_surface_interface, 
             wl_proxy_get_version((struct wl_proxy *) wl_shell), 0, NULL, surface);
    return (struct wl_shell_surface *) id;
}

最终实现:

(暂未发现调用位置)

wl_shell_get_shell_surface

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

14.struct wl_surface;     屏幕surface

生成方式:

(simple-touch.c等)

window->surface = wl_compositor_create_surface(display->compositor);

最终实现:

wl_compositor_create_surface

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

15.struct wl_seat;    输入设备组

生成方式:

(simple-touch.c等)

seat->seat = wl_registry_bind(touch->registry, name,

&wl_seat_interface, 1);

最终实现:

wl_registry_bind

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

16.struct wl_pointer;     指针输入设备

生成方式:

(simple-egl.c等)

d->pointer = wl_seat_get_pointer(seat);

最终实现:

wl_seat_get_pointer

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

17.struct wl_keyboard;    键盘输入设备

生成方式:

(multi-resource.c)

device->p.keyboard = wl_seat_get_keyboard(display->seat);

最终实现:

wl_seat_get_keyboard

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

18.struct wl_touch;  触摸屏输入设备

生成方式:

(simple-touch.c等)

seat->wl_touch = wl_seat_get_touch(wl_seat);

最终实现:

wl_seat_get_touch

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

19.struct wl_output;    合成器输出区域

生成方式:

output->output = display_bind(desktop->display, id, &wl_output_interface, 2);

最终实现:

display_bind

-->wl_registry_bind

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

20.struct wl_region;    区域界面

生成方式:

region = wl_compositor_create_region(window->display->compositor);

最终实现:

wl_compositor_create_region

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

21.struct wl_subcompositor;    子表面合成

生成方式:

(window.c)

d->subcompositor =wl_registry_bind(registry, id,&wl_subcompositor_interface, 1);

最终实现:

wl_registry_bind

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

22.wl_subsurface    wl_surface的子表面

生成方式:

surface->subsurface = wl_subcompositor_get_subsurface(subcompo,surface->surface,parent);

最终实现:

wl_subcompositor_get_subsurface

-->wl_proxy_marshal_flags (wayland-client-core.h)

-->wl_proxy_marshal_array_flags (wayland-client-core.h)

相关内容

热门资讯

监控摄像头接入GB28181平... 流程简介将监控摄像头的视频在网站和APP中直播,要解决的几个问题是:1&...
Windows10添加群晖磁盘... 在使用群晖NAS时,我们需要通过本地映射的方式把NAS映射成本地的一块磁盘使用。 通过...
protocol buffer... 目录 目录 什么是protocol buffer 1.protobuf 1.1安装  1.2使用...
Fluent中创建监测点 1 概述某些仿真问题,需要创建监测点,用于获取空间定点的数据࿰...
educoder数据结构与算法...                                                   ...
MySQL下载和安装(Wind... 前言:刚换了一台电脑,里面所有东西都需要重新配置,习惯了所...
MFC文件操作  MFC提供了一个文件操作的基类CFile,这个类提供了一个没有缓存的二进制格式的磁盘...
在Word、WPS中插入AxM... 引言 我最近需要写一些文章,在排版时发现AxMath插入的公式竟然会导致行间距异常&#...
有效的括号 一、题目 给定一个只包括 '(',')','{','}'...
【Ctfer训练计划】——(三... 作者名:Demo不是emo  主页面链接:主页传送门 创作初心ÿ...