[haiku-development] Re: Implement Begin- and EndRectTracking() in the app_server
- From: Stephan Aßmus <superstippi@xxxxxx>
- To: haiku-development@xxxxxxxxxxxxx
- Date: Tue, 28 Mar 2017 10:58:32 +0200
Hi Vivek,
thank you for your patch, I am going to comment below:
Am 27.03.2017 um 21:17 schrieb Vivek Roy:
AFAIR, the drawing engine always works on screen coordinates. I
don't remember if the rectangle is supposed to leave the view, though.
From what I could make sense of, the BPoint 'where' is also based on
screen coordinates. So I just added checks so that for
B_TRACK_RECT_CORNER, the rectangle does not go out of the window. But I
could make sure it remains inside the window frame inside which it
originated, not for some view. (I suppose, windows can have multiple views).
The tracking rectangle is not contrained to the window which initiated
the tracking.
I tried, but could not figure out how to implement the
ClearTrackingRect() function. If you could just point me to some code.
It needs to work completely differently from how you have done it in
your patch. You need to look at how the mouse cursor works. Think about
a window which plays a video. If you drag the tracking rect so it
overlaps with the window contents and hold your mouse still... think
about what needs to happen. The tracking rect needs to be an "overlay"
which is "composited" on top of the (changing) screen contents. Even
when the rect is implemented by XOR drawing, each drawing command that
app_server carries out at any time needs to be aware of the tracking
rect, so that the region of the rect which is damaged by the drawing
command can be restored.
This is exactly what is already implemented for the mouse cursor. If you
look at the implementations of the various methods in DrawingEngine, you
will see that they start by "removing" the mouse cursor before they
draw, then "restore" it after they are done. There are actually multiple
methods implemented of drawing the mouse cursor. If the app_server is in
a mode where the screen contents are stored in a separate buffer without
the mouse cursor, it doesn't actually need to be removed (which is not
the concern of DrawingEngine however). But when a drawing command is
complete, the updated contents are transfered to the on-screen visible
buffer, which is the moment when the mouse cursor is composited on top
to form the final visible image. And that is what needs to happen for
the tracking rect as well. (And that probably also answers your question
of how to clear the tracking rect.)
I intended to refactor the code so that instead of the mouse-cursor
being something special which is handled directly by the DrawingEngine,
there is instead an anonymous layer of "overlays" composited onto the
screen contents in the "transfer to visible buffer" stage. The code
would be changed to handle any number of "overlays" and the mouse cursor
and tracking rect would just be two examples.
With all that in mind, you can see that the implementation needs to be a
lot more involved. But you have the existing code for the mouse cursor
to go by. And you can look at the code with an understanding of the
above and why it is done that way. If you think this is just a bit too
much for a first contribution, that would be totally understandable, so
please don't feel overwhelmed! You can also pick something different.
It's up to you!
Best regards,
-Stephan
Other related posts: