Hide surface

ferreiradaselva ferreiradaselva at protonmail.com
Mon Nov 27 19:59:53 UTC 2017


Hi, Matt

Thank you very much for the response! Removing the buffer (passing NULL with `wl_surface_attach`) worked. The function wl_shell_surface_minimize seems to not exist in the headers that I included (wayland-client.h and wayland-server.h), so I couldn't try that option.

I'm now trying to show the surface again. I think I found how in the documentation: attaching a new buffer created by a wl_shm_pool. So I'm going to try that.

Thanks for the help!
-- Felipe Ferreira

Sent with [ProtonMail](https://protonmail.com) Secure Email.

> -------- Original Message --------
> Subject: Re: Hide surface
> Local Time: November 27, 2017 3:48 PM
> UTC Time: November 27, 2017 6:48 PM
> From: matt.hoosier at gmail.com
> To: ferreiradaselva <ferreiradaselva at protonmail.com>
> wayland-devel at lists.freedesktop.org <wayland-devel at lists.freedesktop.org>
>
> On Sun, Nov 26, 2017 at 2:23 PM, ferreiradaselva
> ferreiradaselva at protonmail.com wrote:
>
>> Hi,
>> My first time posting here (sorry if I'm posting on the wrong place).
>>
>> You're in the right place. Welcome!
>> I'm working on this window creation framework
>> (https://github.com/ferreiradaselva/swfw), and for the Wayland backend I
>> need to implement a function to hide the "window".
>> I found that that is done by destroying the surface (I'm assuming the
>> wl_shell_surface). This is currently how I'm trying to do:
>> =============================
>> void swfw_hide_window_wl(struct swfw_window_wl *swfw_win_wl)
>> {
>> if (swfw_win_wl->shell_surface) {
>> wl_shell_surface_destroy(swfw_win_wl->shell_surface);
>> swfw_win_wl->shell_surface = NULL;
>> wl_surface_commit(swfw_win_wl->surface);
>> }
>> }
>>
>> void swfw_show_window_wl(struct swfw_window_wl *swfw_win_wl)
>> {
>> if (!swfw_win_wl->shell_surface) {
>> swfw_win_wl->shell_surface =
>> wl_shell_get_shell_surface(swfw_win_wl->swfw_ctx_wl->shell,
>> swfw_win_wl->surface);
>> wl_shell_surface_add_listener(swfw_win_wl->shell_surface,
>> &shell_surface_listener, swfw_win_wl);
>> wl_shell_surface_set_toplevel(swfw_win_wl->shell_surface);
>> wl_surface_commit(swfw_win_wl->surface);
>> }
>> }
>>
>> However, even after destroying the shell surface, the surface is still
>> rendered (testing on weston). Calling the function to show the surface again
>> will result in the surface being rendered twice on the screen. I'm also
>> using EGL, if that matters somehow.
>> I couldn't find any example on internet on how to properly hide the surface
>> (I couldn't get working with GLFW, and SDL doesn't seem to implement the
>> hide function on wayland).
>>
>> There are a couple levels of abstraction you might choose to approach
>> your need from. If you're always going to be using wl-shell, then you
>> can minimize the window. Have a look at wl_shell_surface::minimize.
>> Depending on the desktop environment, that may be the behavior you
>> were most closely seeking anyway.
>>
>> If you simply want the application-defined window content to
>> disappear, however, then just attach a null buffer to the wl_surface.
>> That is, wl_surface::attach( NULL ). Upon the next
>> wl_surface::commit(), the prior renderbuffers will no longer get
>> painted into the composited scene.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20171127/a685c887/attachment-0001.html>


More information about the wayland-devel mailing list