On 2020-11-01 7:56 am, Jared Finder wrote: > On 2020-11-01 5:39 am, Stefan Monnier wrote: >> Hi Jared, >> >> I really like this new feature but have just one comment/question? >> >>> + previous_help_echo_string = help_echo_string; >>> + help_echo_string = Qnil; >>> + >>> + note_mouse_highlight(XFRAME(frame), XFIXNUM (mouse_x), XFIXNUM >>> (mouse_y)); >>> + >>> + if (!NILP (help_echo_string) >>> + || !NILP (previous_help_echo_string)) >>> + { >>> + gen_help_event (help_echo_string, frame, help_echo_window, >>> + help_echo_object, help_echo_pos); >>> + } >> >> I see this exact same code in other C files. >> Could we move it to a file where we can share it instead of having >> N copies? > > I completely agree, not just for this code but also for mouse handling > in general. I think there should be a shared mouse interface with > individual C functions for each type of mouse event: mouse move, mouse > click, etc. Translating OS-specific events to this shared > functionality would continue to be OS-specific, but the actual > handling of these events, such as this logic, would be fully shared. > For example, this would unify the different codepaths between TTY > menus for GPM, xterm-mouse, and NT Emacs. > > I would be happy to help with this next. However I need some help. I > can only locally build and test for Linux terminal with xterm-mouse or > GPM handling the mouse. Is there someone who can help for other > platforms? And should the GUI platforms be included as well? (I > suspect yes is the right answer.) Toward proving that the code could be shared, I refactored the GPM mouse logic so that it was clearly apparent how to share it with handle-lisp-mouse-motion. That patch is attached. I'd like to make sure this looks like an appropriate change to make. If so, I will finish up the patch. Two specific questions: 1. To enable sharing logic, I need to encode a handful of assumptions that I believe are true today (example: no need to handle quit-char in GPM handling). Do these assumptions look reasonable? 2. In what file should such a shared function go? My initial thought is a new file "mouse.c" as it would hold shared mouse logic. -- MJF