darcs patch: Decoration: fix mouse dragging jump ...

I'm not so sure if I should push this patch. It works, but I don't
understand why.
If you do, please let me know.
Andrea
Fri Feb 8 21:41:20 CET 2008 Andrea Rossato

On Fri, Feb 08, 2008 at 09:47:02PM +0100, Andrea Rossato wrote:
Fri Feb 8 21:41:20 CET 2008 Andrea Rossato
* Decoration: fix mouse dragging jump ...
please forget this one. see below.
+ decoEventHook _ (DS dwrs@(((_,r),(dw, Just dr)):_) _) ButtonEvent { ev_window = ew + , ev_event_type = ty + , ev_x = ex } + | ty == buttonPress + , dw == ew = mouseDrag (\x y -> do + let rect = Rectangle (x - fi ex) (y - rect_y dr + rect_y r) + (rect_width r) (rect_height r) + sendMessage (SetGeometry rect)) (return ())
can you please check if the reasoning is fine? 1. I have 1 point (pointer even: px,py) relative to the (absolute) decoration window's origin (dx,dy) 2. the absolute coordinates of the pointer events are: (dx + px), (dy + py) 3. the distance of the pointer event from the decorated window's origin (wx,wy) is: (dx + px) - wx, (dy + py) -wy 4. when I start grabbing I get the absolute position of the pointer (ex,ey), and so I need to subtract the above distance to set the new decorated window's origin like this: ex - (dx + px - wx), ey - (dy + py - wy) This seems to be working fine (I'm going to push within a couple of hours, but if you find a mistake please drop me a line - here or on IRC). Sorry for this noise but I find this a quite subtle issue if you are not that used to this kind of stuff... high school memories here... ;) Andrea ps: I'm going to write a small DecorationMadness module for storing, well... you'll see!

On Feb 9, 2008, at 3:38 , Andrea Rossato wrote:
can you please check if the reasoning is fine?
Works for me, with a note and a nit:
2. the absolute coordinates of the pointer events are: (dx + px), (dy + py)
aka x_root and y_root in the ButtonEvent, if this saves you anything.
3. the distance of the pointer event from the decorated window's origin (wx,wy) is: (dx + px) - wx, (dy + py) -wy
I'd call this "offset", because "distance" is the length of the vector from (x_root,y_root) to (wx,wy). :) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Sat, Feb 09, 2008 at 10:37:32AM -0500, Brandon S. Allbery KF8NH wrote:
2. the absolute coordinates of the pointer events are: (dx + px), (dy + py)
aka x_root and y_root in the ButtonEvent, if this saves you anything.
Sure it does, and it makes the code clearer (which is not bad too)!
3. the distance of the pointer event from the decorated window's origin (wx,wy) is: (dx + px) - wx, (dy + py) -wy
I'd call this "offset", because "distance" is the length of the vector from (x_root,y_root) to (wx,wy). :)
Luckily I'm writing this in Haskell, and so no risk of terminology confusion whatsoever. :) Thank you very much. It was really worth waiting. Cheers Andrea
participants (2)
-
Andrea Rossato
-
Brandon S. Allbery KF8NH