=== dandrader is now known as dandrader|afk === dandrader|afk is now known as dandrader === dandrader is now known as dandrader|afk [15:40] cnd, hey - i heard you might have some utility which allows me to experiment with MT touchscreen stuff without needing a touchscreen? [15:40] brendand: hmm? [15:40] cnd, something to record and play back touch events? [15:41] yeah, evemu [15:41] http://launchpad.net/evemu [15:41] you can use it to record input device events and play them back later === dandrader|afk is now known as dandrader [17:12] cnd, damn. I accidentally pushed directly to lp:frame when trying to update the merge request branch [17:13] dandrader: just back it out [17:13] yep [17:13] no worries [17:13] just try to be quick about it :) [17:15] cnd, done. and the merge request is now updated, by the way :) [17:16] cool, I'll take a look right now [17:16] awesome [17:28] dandrader: it's pretty good, though what happens if a backend borrows a touch but then doesn't give it back? [17:28] we're left in a bit of an errant state [17:28] cnd, yes. bad backend! [17:28] why can't we simply clone the touch, leaving it in the frame as it is [17:28] and then overwriting the frame's reference if the touch is given to it [17:29] this would always ensure invariance of the frame state [17:29] because that's inefficient [17:29] how? [17:29] by unnecessarily cloning a touch [17:31] actually, doesn't borrow_touch_by_id return the same touch, but wrapped in a new UFBackendTouch object? [17:31] if you change its values, doesn't it change the values of the touch for previous frames? [17:31] cnd, so you propose UFBackendTouch to hold a UFTouch instead of a UFSharedTouch ? [17:32] cnd, it depends [17:32] cnd, if the UFTouch has only one reference. it's just updated [17:32] cnd, if it has more than one reference, it's first cloned and then its clone is updated [17:33] ok, I remember that logic now [17:33] let me think a minute [17:33] it sounds like that's the main reason you have for the borrow semantics [17:34] that way the backend is the only one with a reference to the touch [17:34] thus it evaluates as unique [17:34] cnd, right [17:34] if we change the rules slightly, I think it could still work and leave frame invariant [17:34] say when you update the touch values, it checks if there are only two references [17:35] one for the only usage in its frame, and one for the backend reference [17:36] hmm.... sounds dangerous... making assumptions... [17:36] we can assert if the use_count is only 1, since that should never happen [17:36] and we are only using this check for the backend API [17:37] i.e. the built-in X11 backend shouldn't be interfered with [17:38] the only way I can see there being bad behavior is if: [17:38] the backend gets a reference to the touch [17:38] the ref count is now 2 [17:39] the backend deletes the touch, perhaps by giving it back to the frame [17:39] the ref count is now 1 [17:39] but then the backend reuses the touch, since it may still have a valid pointer value [17:39] but that's obviously very wrong :) [17:40] and besides, you delete the touch record altogether in frame_backend_frame_give_touch [17:40] so it shouldn't really be possible with explicit pointer shenanigans :) [17:40] s/with/without/ [17:40] not giving back a borrowed touch is also very wrong [17:41] so let me recap [17:41] of course, but it's merely a memory leak [17:41] you want to s/borrow_touch/get_touch [17:41] rather than something that could potentially cause bad behavior on the frontend client side [17:42] cnd, ^? [17:42] and keep the give_touch? [17:43] yeah, I want to be sure that I can't take a reference to the touch, hold on to it, and hence screw up the client who will be all confused when it can't find the touch in the frame [17:43] the client won't be confused [17:43] let's say there's a touch with ID of 5 [17:43] because you're editing a frame for a event that hasn't even been created yet [17:43] not alone sent to the client [17:43] s/not/let [17:44] oh, but what if you do send the event on before you gave the touch back? [17:44] because of a bug [17:44] some of my thoughts here are due to similar bugs I've made myself in things like the X input modules [17:45] if there's a possibility that a touch may be "lost" in the state somewhere, it gets really hard to figure out what's going on, and it often leads to crashes [17:45] however, a touch getting "stuck", but leaving the rest of the state intact, usually just leads to some gestures stopping from working [17:47] could you draft the API that you're proposing and pastebing it? [17:47] It's not very clear to me [17:48] how do you get a touch from a frame. and how do you get rid of that touch later on [17:48] touh backend, that is [17:48] and how you give a touch to a frame [18:03] the api is basically exactly what you've got [18:03] just that you don't "borrow" a touch by swapping references out [18:04] you simply give the backend a reference to the touch [18:04] then, when you change properties, you check if the use_count of the shared_ptr > 2, in which case you need to do a hard copy [18:07] I think that's all that needs to change [18:07] I guess in give_touch, you just need to add the touch to the frame, overwriting any touch that already is there for the same touch id [18:09] I think that would just serve to hide bogus situations [18:10] hmm [18:13] that's the point, really [18:13] making it less bad if you make a mistake in your backend code === dandrader is now known as dandrader|afk === dandrader|afk is now known as dandrader [18:40] cnd, what I don't like about your implementation is that it adds dependencies between seemingly independent implementations. Now the UFTouchBackend lazy-copy scheme will be twisted because it knows that if refcount==2 it's because one of the refs is being held by UFFrame while the touch is being borrowed etc so please ignore it and consider as if the refcount was just one instead [18:41] yeah, I agree that part is a bit messy [18:41] If you feel strongly about it, I'm ok with your approach [18:48] hmm, so it looks like we are coming to an agreement. Then could you please please finalize your review? :) [18:58] yeah [18:59] dandrader: I reviewed it [19:00] cnd, thanks! [19:01] np :)