简体   繁体   English

韦兰窗饰

[英]Wayland window decorations

I am writing a Wayland client, using only the Wayland C library ( wayland-client.h ).我正在编写一个 Wayland 客户端,仅使用 Wayland C 库( wayland-client.h )。 I want to spend as less effort as needed to add window decorations for moving, resizing, minimising and closing the window.我想花费尽可能少的精力来添加用于移动、调整大小、最小化和关闭窗口的窗口装饰。

The options I see are: a) request the compositor to draw window decorations around my Wayland surface (server side decorations), or b) use a small library or code snipped to draw the decorations myself in the client (client side decorations).我看到的选项是:a)请求合成器在我的 Wayland 表面周围绘制窗口装饰(服务器端装饰),或 b)使用一个小型库或代码在客户端自己绘制装饰(客户端装饰)。

Which ways exist to achieve both of the options?有哪些方法可以实现这两种选择? Eg for the simple hello_wayland example, how do I request server side decorations (a) or how can I draw window decorations in the client (b)?例如,对于简单的hello_wayland示例,我如何请求服务器端装饰 (a) 或如何在客户端 (b) 中绘制窗口装饰? For the latter option, I am looking for something like the Rust library https://github.com/Smithay/wayland-window , but for C/C++.对于后一个选项,我正在寻找类似于 Rust 库https://github.com/Smithay/wayland-window 的东西,但适用于 C/C++。

Edit: For the client-side decoration option (b) I found the dedicated decoration library libdecoration .编辑:对于客户端装饰选项 (b),我找到了专用的装饰库libdecoration

UPDATE: In case you don't read comments, just want to highlight that the protocol outlined in the original answer as proposed has since been accepted into unstable.更新:如果您不阅读评论,只想强调最初提出的答案中概述的协议已被接受为不稳定。 https://github.com/wayland-project/wayland-protocols/commit/76d1ae8c65739eff3434ef219c58a913ad34e988 https://github.com/wayland-project/wayland-protocols/commit/76d1ae8c65739eff3434ef219c58a913ad34e988

ORIGINAL: Right now, there is no standard/stable way to do server-side decorations on Wayland.原文:目前,在 Wayland 上没有标准/稳定的方法来进行服务器端装饰。 The protocol itself doesn't disallow for server-side decorations, but it certainly did not seem to prioritize it.协议本身并没有禁止服务器端装饰,但它似乎没有优先考虑它。 (Though, the complaint is moot since the shell protocol is being redefined for desktops under the xdg-namespaced protocols anyways.) (不过,抱怨没有意义,因为无论如何,shell 协议都在 xdg-namespaced 协议下为桌面重新定义。)

KDE obviously was impacted by this, especially since server-side decorations are used for Plasma Shell to maintain consistent theming. KDE 显然受到了这种影响,特别是因为 Plasma Shell 使用了服务器端装饰来保持一致的主题。 The KDE folks have a protocol extension for their implementation called simply "server-decorations" KWayland server-decorations . KDE 人员为他们的实现提供了一个协议扩展,简称为“服务器装饰” KWayland 服务器装饰 You could test for this interface, and utilize it if it is present.您可以测试此接口,并在它存在时使用它。

The more long-term solution still hasn't landed yet.更长期的解决方案还没有落地。 This is something that the group of people working on Wayland protocols (likely the XDG ones) will have to agree upon.这是从事 Wayland 协议(可能是 XDG 协议)的团队必须同意的事情。 There was an attempt to roll this into the xdg-namespaced Wayland protocols under the name xdg-toplevel-decoration .有人试图将其纳入 xdg-namespaced Wayland 协议中,名称为xdg-toplevel-decoration The patch eventually being marked superseded.该补丁最终被标记为已被取代。 The latest attempt to patch this protocol in is still in the proposal state - xdg-decoration .修补此协议的最新尝试仍处于提案状态 - xdg-decoration

Without server-side decorations, you're stuck drawing your own decorations (as well as handling the key events to make the window functional).如果没有服务器端装饰,您将不得不绘制自己的装饰(以及处理关键事件以使窗口起作用)。 I feel like the a protocol will appear at some point for this - lack of one begs for a ton of extension protocols and code smell checking for each and every one of them.我觉得 a 协议会在某个时候出现 - 缺少一个请求大量扩展协议和代码异味检查的每个扩展协议。 Nonetheless, I am hopeful that the current lack of action is because the proposal phase for a new protocol is picky by nature.尽管如此,我希望目前缺乏行动是因为新协议的提案阶段本质上是挑剔的。 It's very difficult to change a protocol after its been issued as stable, so it will likely take time to see this even enter an unstable state.协议在稳定发布后很难更改,因此即使进入不稳定状态也可能需要时间。

My recommendation is to continue to show support for this kind of change, but exercise patience and don't assume it will come any time soon (we aren't even in possession of an unstable state of a protocol).我的建议是继续支持这种改变,但要有耐心,不要假设它会很快到来(我们甚至没有协议的不稳定状态)。 In the meantime, if you really want to get work done, check for KDE's server-decorations protocol extension, and use that if it is available.同时,如果您真的想完成工作,请检查 KDE 的服务器装饰协议扩展,并在可用时使用它。 And don't assume that it will be available.并且不要假设它将可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM