id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,blockedby,blocking,branch_state,votes 3571,High-level mouse API,mooffie,andrew_b,"We have about 20 widget classes and about 13 of them have mouse handlers. == The problem == There are two problems with our mouse handlers: - They are complicated to read (and write). - They are buggy. First, they all respond to events initiated inside other widgets. Second, each has its own peculiar bugs. == The cause == These two problems stem from the low-level nature of `Gpm_Event`, which is the structure around which our mouse handlers operate. This structure represents a mouse event occurring in the whole screen and is utterly oblivious to regions and to the concept of a region ""owning"" the mouse. To see the problem, simply drag the mouse over the whole screen: the panel will respond, then the command line, then the history button, then the buttons bar. A snafu. If you release the mouse over a WButton, the WButton will always execute its command --even if you didn't initiate the mouse press inside this WButton. Our mouse handlers are complex mainly because they try to work around this problem. == A solution == This simple patch solves this issue by introducing a higher level mouse API (or should I say protocol). Mouse handlers then become simpler (examples follow). The existing old-style handlers can still be used. The patch introduces `lib/widget/mouse.c` and `lib/widget/mouse.h`. There is **very little code** here: the reason for new files is just to keep things tidy. == ""But why bother?"" == You may ask, ""why bother? who's using mouse in console anyway?!"". Well, this proposal makes the handlers simpler, often shorter, so it makes our code more maintainable. ",task,closed,major,4.8.17,mc-core,master,fixed,,,,3559,merged,committed-master