Cloudef / wlc

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

Setting a cursor from compositor #193

Open kozec opened 7 years ago

kozec commented 7 years ago

Hello and sorry, it's me again :)

I'm wondering if there is any way how to set mouse cursor from compositor side.

I already found that there is suspiciously looking method wlc_pointer_set_surface, but this method doesn't seems to be available in any file in /include directory.

Cloudef commented 7 years ago

Right, setting pointer is sort of anti-pattern in wayland ecosystem. Normally compositors have root level shell that sets the pointer surface (e.g. clients control pointer). Wlc just provides hardcoded default when there is none, and because of this I haven't really exposed any mechanism for customizing it.

kozec commented 7 years ago

So, basically, preferred way to do anything where changing cursor makes sense (dock, statusbar, decorations...) is to run it as separate wayland client?

Cloudef commented 7 years ago

Yeah

kozec commented 7 years ago

That's gonna overcomplicate things in rather crazy way :(

ddevault commented 7 years ago

swaybar and swaybg are both surfaces from seperate clients, ftr.

kozec commented 7 years ago

But swaybar, AFAIK, doesn't really communicate with compositor, it just displays unrelated info.

Just to explain what I'm trying to do; I'm playing around with attempt to create more traditional WM for my "2 in 1" tablet. Traditional as in "draws borders and titlebar around window" sense. I already have that drawing part done, but I can't signalize when mouse is hovering over that border.

AFAIK, Wayland has no official way how create "decorator" as separate process, because there is no protocol to request info about foreign windows. And, of course, since every real application actually uses XWayland, no window has CSDs drawn by client.

ddevault commented 7 years ago

It does communicate with the compositor, using a combination of the i3 IPC protocol and wayland extensions.

kozec commented 7 years ago

Ok, long question before I close this.

I tried to read little in libweston, but if that thing is documented anywhere, I was not able to find that docs. What I'm trying to do is kind of quick and dirty work (without selling it to MS though), so libwlc looks like closer tool for my needs.

So I'm going to clone it and make some adjustments. Namely this, then option to implement and set custom rendered (as defined here, but apparently not accessible from outside) and, if possible, option to intercept and synthesize input events. I'm trying to run it on tablet and my main purpose right now is less painful screen rotation.

Question is, @Cloudef, would you accept some of that as PR? It may be little out of scope of libwlc, but I believe it may be useful for others as well.

Cloudef commented 7 years ago

It depends how cleanly you can get it implemented. Just saying this is not how pointers are intended to work with the wl_pointer protocol.

Enerccio commented 7 years ago

well what if you have your own render loop set up in on output post render where you throw garbage wlc has rendered and render all views as textures? Where can you get pointer texture from view, since you have to render that pointer separately?