<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 19, 2014 at 11:20 AM, Jonas Ådahl <span dir="ltr"><<a href="mailto:jadahl@gmail.com" target="_blank">jadahl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Sep 19, 2014 at 11:00:21AM -0600, Jasper St. Pierre wrote:<br>
> On Fri, Sep 19, 2014 at 2:54 AM, Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com">ppaalanen@gmail.com</a>> wrote:<br>
><br>
> > On Fri, 19 Sep 2014 08:33:13 +0200<br>
> > Jonas Ådahl <<a href="mailto:jadahl@gmail.com">jadahl@gmail.com</a>> wrote:<br>
> ><br>
> > > On Thu, Sep 18, 2014 at 10:43:47AM -0700, Jason Ekstrand wrote:<br>
> > > > On Thu, Sep 18, 2014 at 2:26 AM, Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com">ppaalanen@gmail.com</a>><br>
> > wrote:<br>
> > > ><br>
> > > > > On Wed, 17 Sep 2014 22:35:40 +0200<br>
> > > > > Jonas Ådahl <<a href="mailto:jadahl@gmail.com">jadahl@gmail.com</a>> wrote:<br>
> > > > ><br>
> > > > > > On Wed, Sep 17, 2014 at 11:16:06PM +0300, Giulio Camuffo wrote:<br>
> > > > > > > 2014-09-17 23:11 GMT+03:00 Jonas Ådahl <<a href="mailto:jadahl@gmail.com">jadahl@gmail.com</a>>:<br>
> > > > > > > > On Wed, Sep 17, 2014 at 10:56:13PM +0300, Giulio Camuffo wrote:<br>
> > > > > > > >> I haven't looked at the implementation yet, just at the<br>
> > protocol,<br>
> > > > > but<br>
> > > > > > > >> isn't _wl_pointer_lock.lock_pointer() returning a new<br>
> > wl_pointer a<br>
> > > > > > > >> problem? Objects should have a unique factory interface, or<br>
> > else the<br>
> > > > > > > >> version of the interface can't be determined.<br>
> > > > > > > ><br>
> > > > > > > > Is it really? In the implementation below, the wl_pointer<br>
> > object gets<br>
> > > > > > > > the same version as the wl_pointer object that is locked. It<br>
> > is also<br>
> > > > > > > > specified in the last paragraph of<br>
> > _wl_pointer_lock.lock_pointer.<br>
> > > > > > ><br>
> > > > > > > Mmh, then maybe it is fine. I'm not convinced actually, but I'm<br>
> > too<br>
> > > > > > > tired now. :)<br>
> > > > ><br>
> > > > > No, it's not fine. You cannot define exceptions to the versioning<br>
> > rules<br>
> > > > > in a protocol spec. We have common code in libwayland handling all<br>
> > > > > runtime versioning, and you just cannot implement any exceptions.<br>
> > > > ><br>
> > > ><br>
> > > > Technically, those haven't been merged yet... So, technically, we could<br>
> > > > have it inherit the version from the wl_pointer.  That said, I think<br>
> > we'll<br>
> > > > regret if we do.  Even if we did do that, it would cause problems, not<br>
> > > > because we couldn't update wl_pointer, but because we really couldn't<br>
> > > > update wl_pointer_lock.  All in all, it's a bad plan.<br>
> > > ><br>
> > ><br>
> > > So, from what I've heard here now is it's clear we don't want to create<br>
> > > a new wl_pointer object. Other than the versioning issue, we'd have<br>
> ><br>
> > You could create a wl_pointer, if you do it from interface whose<br>
> > ancestor is wl_seat, or directly a request in wl_seat. But it does have<br>
> > downsides like not being able to let the extension mature in Weston<br>
> > before moving it to Wayland core.<br>
<br>
</div></div>I think its a good practice to have a isolateable kind of way of<br>
extending protocols (ala wl_relative_pointer, wl_scaler, etc) so that<br>
core protocol objects don't grow too large with non-removable request<br>
and events.<br>
<br>
Maybe we need to define "modes of operation" that would be similar to<br>
"roles" (e.g. xdg_surface), so that wl_relative_pointer changes the<br>
"mode" of wl_pointer to wl_relative_pointer. This would allow us to add<br>
a wl_pointer_lock.confine_pointer that doesn't make sense to enable at<br>
the same time as the pointer is in relative motion mode.<br></blockquote><div><br></div><div>Maybe, but that sounds like a problem to solve with the second extension of wl_pointer, not the first.  Right now, we don't have any other extensions flying around, so we don't know how it will interact with these other hypothetical extensions.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
> ><br>
> > > non-sensible requests (set_cursor) on the additional wl_pointer, and<br>
> > > potentially more as wl_pointer is extended. The alternatives that has<br>
> > > come up in IRC discussions and backlog reading are:<br>
> > ><br>
> > >  1) Create a wl_relative_pointer that would replace wl_pointer, i.e.<br>
> > >     have its own button, axis, etc events. This would solve all problems<br>
> > >     related to versioning and wl_pointer being extended, but brings a<br>
> > >     bunch of other problems for example we'd have to extend<br>
> > >     wl_relative_pointer each time wl_pointer is extended to keep up, as<br>
> > >     well as the issue where a wl_pointer is used in a interface or<br>
> > >     request.<br>
> ><br>
> > Either you use wl_pointer and get extensions automatically even if you<br>
> > don't want to, or you use a new interface that you have to extend<br>
> > explicitly if you want the same as in wl_pointer. Two sides of a coin.<br>
> ><br>
> > As concluded in IRC, wl_pointer is not used as argument in any messages.<br>
<br>
</span>But it is by wl_pointer_lock.lock_pointer, and who says it'll be the only<br>
place its used as an argument?<br>
<span class=""><br>
> ><br>
> > >  2) Add "begin" and "end" events to wl_pointer_lock that changes the<br>
> > >     state of an existing wl_pointer. After a wl_pointer_lock.begin is<br>
> > >     sent, wl_pointer.motion sends relative motion events. After<br>
> > >     wl_pointer_lock.end it'd revert back to sending absolute motion<br>
> > >     events.<br>
> ><br>
> > This might be confusing if a client creates several wl_pointer objects<br>
> > for the same seat underlying a wl_seat.<br>
> ><br>
> > Apart from being confusing just by changing the meaning of an event<br>
> > via a mode.<br>
> ><br>
> > >  3) Extend wl_pointer similar to how wl_viewport extends wl_surface with<br>
> > >     a wl_relative_pointer (different from in (1)). Such a<br>
> > >     wl_relative_pointer would, to begin with, only have one request<br>
> > >     (release) and one event (motion). It wouldn't change anything to the<br>
> > >     wl_pointer object, it'd still receive button, axis etc events, but<br>
> > >     motion events are turned into relative motion events via<br>
> > >     wl_relative_pointer, not affecting the position of the cursor, i.e.<br>
> > >     not resulting in wl_pointer.motion events.<br>
> ><br>
> > This is an interesting idea. I wonder how it works if the client has<br>
> > two parts (say, libraries or toolkits with their own input processing),<br>
> > therefore has multiple wl_pointer objects for the same thing, and only<br>
> > few of them have the pointer_lock interface associated.<br>
<br>
</span>Hmm. Maybe we need to lock pointer given a seat instead. It'd change the<br>
"mode" of the underlying pointer to be locked in its position, i.e. not<br>
send any wl_pointer.motion events. Locking could then be ref counted, so<br>
that as long as more than one wl_relative_pointer is alive, it's in<br>
relative mode. Maybe thats unnecessarily complex though.<br>
<span class=""><br>
> ><br>
> > Or what if an app manually starts pointer-lock because the toolkit does<br>
> > not support it? This is not a use case to design for at all, but if it<br>
> > happens to work, it might be a nice bonus.<br>
<br>
</span>If we make it so that locking simply locks the cursor at its position,<br>
it'd will just work, as the pointer cursor wouldn't move. No unexpected<br>
wierd wl_pointer.motion events.<br></blockquote><div><br></div><div>I don't see any problem with locking only one of the available pointers.  The absolute ones simply get no motion until it's unlocked.  If we add a set_position request to wl_relative_pointer, then I guess that would trigger motion on the absolute pointers.  I think it's probably fine.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
> ><br>
> > > To me, alternative (3) seems like the best choice. It'd give us<br>
> > > possibility to continue to control the pointer cursor via the original<br>
> > > wl_pointer object, as it will still have focus. It also allows us to make<br>
> ><br>
> > I don't think we ever want the compositor drawing the cursor in<br>
> > pointer-locked mode... do we? Would there be any use cases benefitting<br>
> > from it?<br>
> ><br>
><br>
> There's an additional problem here: where should the cursor be drawn? Will<br>
> wl_relative_pointer have a set_cursor_position argument while in relative<br>
> mode?<br>
><br>
> I could see arguments in favor of it (ability to reuse the cursor plane),<br>
> but we can leave this out for now. If we want to add it back, we say that<br>
> the cursor is always drawn in the center of the surface, unchanging, and if<br>
> apps want to remove it, they blank it.<br>
<br>
</span>I think that the best would be to simply not change the position or<br>
state of the cursor at all. Locking would mean that while locked, the<br>
wl_pointer has focus, meaning the client can change the cursor, or hide<br>
it. For example if pointer-locking would be used to click-drag to select<br>
items from a list (where dragging changes highlighted element), it would<br>
be bad if the cursor suddenly jumps to the middle of the surface when<br>
done.<br>
<br>
Staying where it was at the point of locking also works the same way as<br>
pointer locking does in GLFW. Haven't checked SDL yet.<br>
<br>
What would a set_cursor_position argument do? It sounds like that could<br>
be more or less used to implement actual warping by just locking, set<br>
position then unlocking. It'd probably be more useful to have a<br>
set_cursor_position request in wl_relative_pointer that can be used when<br>
implementing pointer warping in Xwayland and then possibly even SDL and<br>
GLFW. Hmm.<br></blockquote><div><br></div><div>I'm not 100% sure what you're getting at here.  However, I think we do want to have cases where the client is drawing a warped pointer and then the the pointer-lock breaks.  One example would be a VM that uses pointer_lock to give relative events to the client machine.  In that case, when the you move the pointer to the edge of the window, it sets the pointer position and breaks the lock.  This way it looks like the pointer is simply moving through the window.  RTS games will probably want to do similar things.  I don't think "just lock it where it is" is always going to work.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
><br>
><br>
> > Though, I don't see anything wrong with requiring the client to<br>
> > explicitly unset the cursor when pointer-lock activates. Or are there<br>
> > any room for races where the cursor might flicker?<br>
<br>
</span>Well, except for the buffer queue extension, is there any way for two<br>
surfaces to synchronize their rendering (assuming they are not not in a<br>
subsurface tree)?<br>
<span class=""><br>
> ><br>
> > > use of any future wl_pointer additions (problem being that they could<br>
> > > potentially conflict, but that wouldn't be unique for<br>
> > > wl_relative_pointer AFAIK). Alternative (2) would give us the same<br>
> > > benefits, but it feels rather awkward to temporarily change the meaning<br>
> > > of wl_pointer.motion.<br>
> ><br>
> > Agreed about 2).<br>
> ><br>
> > > Given that the three above choices are more or less semantically<br>
> > > equivalent it makes sense to try it out in a already used API. From what<br>
> > > I can see, the two common places it'd be used are SDL and GLFW, which<br>
> > > have different API's doing more or less the same thing, so it'd probably<br>
> > > be good to try it out in both of these.<br>
> ><br>
> > A very good idea. That is how we get some perspective to the design and<br>
> > find issues.<br>
> ><br>
> > There are at least to different basic use cases:<br>
> > - Quake, i.e. FPS-games with mouse-look<br>
> > - a strategy game, which still uses a cursor, but implements special<br>
> >   behaviour when running against window edges like scrolling the view,<br>
> >   likely with the pointer confined to the window<br>
> ><br>
<br>
</span>The second use case could potentially be implemented in the toolkit by<br>
moving around a subsurface over the parent surface given the relative<br>
motion events. It'd have the problem of the cursor jumping when<br>
unlocking, as the cursor have most likely ended up in a different place<br>
from where it started.<br>
<span class=""><br>
><br>
> A third use case. A less exciting one, but still an important one:<br>
> implement the W3C pointer-lock extension on top of the Wayland API.<br>
<br>
</span>Indeed, a pretty important use case.<br>
<span class=""><br>
><br>
><br>
> > A good question is, do we want to support the latter with<br>
> > pointer-lock, or should it be another extension?<br>
<br>
</span>I imagine we could have a wl_pointer_lock.confine_pointer, if we want to<br>
support such a use case directly in Wayland.<br>
<span class=""><br>
><br>
><br>
> Also, the latter probably wants the same motion acceleration algorithm<br>
> > as the desktop has, but the former probably not.<br>
> ><br>
<br>
</span>I can imagine that the second use case may very well be implemented both<br>
with confinement and relative pointer events and as such relative<br>
pointer events would need support both non-accelerated and accelerated<br>
modes.<br>
<span class=""><br>
><br>
> This is effectively an X server grab with "confine_to". I'd take a look at<br>
> some existing RTS games (FreeCiv? OpenTTD?) and see how they implement that<br>
> mode.<br>
<br>
</span>OpenRA and 0AD are two more examples.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
Jonas<br>
</font></span></blockquote></div><br></div></div>