Cloudef / wlc

High-level Wayland compositor library
MIT License
331 stars 58 forks source link

How does the wlc_view get created? #238

Closed xeechou closed 7 years ago

xeechou commented 7 years ago

Hi all, I want to know how/when does wlc generated wlc_view for a a wl_surface Because I want to write a custom interface for a background and other things. Is a wlc_view created at some where like wl_surface_attach callback? I checked the code in src/resources/types/surface.c, but it seems that wlc_view is not create there.

Can anybody help?

Cloudef commented 7 years ago

wlc_view is created when role is assigned to surface. Wlc only creates views for roles it supports by default and that is xdg_surface and wl_surface. If you want custom roles you need to extend wlc, see wlc-wayland.h. You can also turn surfaces into views without roles using https://github.com/Cloudef/wlc/blob/master/include/wlc/wlc-wayland.h#L40

xeechou commented 7 years ago

So are wl_shell_surface or xdg_surface are sufficient choices for stuff like background?

Cloudef commented 7 years ago

No, those are supposed to be used by GUI programs. https://github.com/Cloudef/wlc/blob/master/tests/wl-extension.c this can give you idea how to do background.

xeechou commented 7 years ago

okay, thanks, I tried, output_pre_render_callback is efficient, it didn't take much cpu resources as I expected, thanks