English | 简体中文 什么是QtWayland?QtWayland是封装了Wayland功能的Qt 5模块。QtWayland被分为一个客户端(client)和一个服务端(server)。客户端是wayland平台插件,提供了运行Wayland客户端Qt程序的方法。服务端是QtCompositor应用程序接口(API),允许用户编写自己的compositors。 什么是WaylandWayland是一个用C库实现的为了使Compositor和Client沟通的协议。要获得更多详细信息,请访问 Wayland项目主页 [wayland.] 从哪里找到QtWayland代码?Gitorious仓库 [qt.] 怎样构建QtWayland?桌面构建指令设置构建环境第一步,选择一个合适的新的Linux发行版。我使用Ubuntu 12.04,比这个新的更好。 下面的指南基于 http://wayland./building.html 上的提示 我做的第一件事是创建一个Wayland安装目录和一个设置环境的文件: ~/Apps/Wayland/wayland.sourceme
之后用这个文件设置您的工作环境: 编译依赖的库您需要的大部分依赖库都已经发布了。但是仍然没有包含在最新的Linux发行版中。所以您需要编译它们。这里是编译它们的指南: wayland
drm
mesa
libxkbcommon
weston(可选)
Qt 5.0.0依赖对于Qt,您可以使用于预编译的5.0.0二进制文件,或者从最新的Qt 5.0.0(stable分支)构建,这里不使用wayland.source环境。您至少需要的Qt 5.0.0模块有: 如果您遇到了关于libGL和undefined references链接错误,可能是需要编译Qt5并且链接自己编译的mesa库,可能是由于编译和安装mesa的方式,配置脚本需要明确的定义openGL的版本,使用: ./configure -opengl es2 构建QtWayland模块一旦您构建好了Qt 5,之后获取最新的QtWayland模块代码,使用qmake配置,这次是用wanyland.source环境。确定您使用的qmake是刚构建好的Qt 5中的。这将确定您使用了特别的OpenGL和Wayland版本来构建Wayland平台插件和QtCompositor API。
Raspberry Pi编译指南敬请期待。 怎样使用QtWayland?作为Wayland客户端运行Qt程序当您编译完QtWayland模块,您将得到一个新的wayland平台插件。要使用它,您首先需要有一个已经运行的Wayland compositor。这可以是一个Wayland项目提供的Weston reference compositor,或是QtWayland提供的Qt example compositor。不管怎样,作为一个应用程序开发者,您需要做的唯一一件事是把您的程序作为wayland客户端运行:
创建和运行您自己的Qt5 Wayland Compositor运行例子中的compositorQtWayland模块中提供了几个compositor样例,演示了QtCompositor是如何工作的。这些样例在QtWayland模块的example目录中,如果您使用qmake时添加了“wayland-compositor“到CONFIG变量。
这些例子示范了服务器端(server side)的Wayland,所以您不需要使用wayland平台插件,不管您是在那个平台运行。通常这些平台是eglfs、 kms或者您想运行于X11 xcb。 如果您想在X11中运行qml-compositor: 您需要按下面的方式运行:
现在,您的Wayland compositor运行了,您可以连接和显示Wayland客户端了。 创建您自己的compositor创建Wayland compositor和控制相关事件的应用程序接口在QtWayland类的WaylandCompositor中。它的构造函数需要QWindow对象指针作为主参数。这使实现compositor更加灵活。 由于这种设计,实现compositor有3中不同的方法:
WaylandCompositor是纯抽象虚类,它不能用来创建实例。实现compositor的通用方法是继承自WaylandCompositor并实现这个方法*void surfaceCreated(WaylandSurface *surface)*。 这个方法会在每次新客户端连接的时候执行(例如程序启动请求compositor服务时)。作为一个WaylandSurface对象。这里有一些这个对象生成的信号,被compositor处理,叫做:
工程文件需要使用compositor模块(即在.pro文件中添加QT += compositor)。有趣的是在写这篇文章的时候,需要注意的是有些QML相关的API只能在工程文件中添加宏定义(即DEFINES += QT_COMPOSITOR_QUICK)。 独立运行compositorTODO |
|
来自: dwlinux_gs > 《Wayland》