[haiku] Re: Feature for Emacs

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku@xxxxxxxxxxxxx, Po Lu <dmarc-noreply@xxxxxxxxxxxxx>
  • Date: Sun, 03 Apr 2022 15:37:08 +0200

Le 3 avril 2022 13:50:19 GMT+02:00, Po Lu <dmarc-noreply@xxxxxxxxxxxxx> a écrit:

Emacs provides a Lisp function called `mouse-position', which returns
the window (in Emacs parlance, a frame) the mouse is currently under, if
it was created by Emacs.

Implementing this function correctly on Haiku requires a way to find the
window underneath the mouse pointer, but I don't see how to get that
information.

It would be nice if a function to obtain that window was added to the
interface kit.  Perhaps it would be named BApplication::GetWindowAtPoint
(BPoint), and return the BWindow underneath a given point (or the mouse
pointer location) if it was created by the calling application, or NULL
if it was not.

Thanks in advance.


Hello,

You have two options:
- Use get_mouse from interface kit that gives you the window position on 
screen. Then use BApplication::WindowAt(index) to iterate over your windows and 
find one intersecting that position. You will get events even if the window is 
currently obscured by something
- Subclass BView::MouseMoved to get events delivered directly to the root view 
of each of your windows. You only get events when the mouse is really in your 
window, unless you use SetMouseEventMask to get more.

-- 
Adrien.

Other related posts: