Subject: Re: bug#51411: NS port cleanups

From: Alan Third <[email-masked]>
Date: Sun, 31 Oct 2021 10:59:40 +0000

On Sun, Oct 31, 2021 at 06:34:15PM +0800, Po Lu wrote:
> Alan Third <[email-masked]> writes:
> 
> > I think what you'll need to do is union the two rectangles and then
> > clip to that, rather than clipping them both separately. That will
> > then provide the same clipping as the NSClipRect code does.
> 
> I meant to say that DPSrectclip intersects (IOW, behaves just as
> NSClipRect does).  Unless that's incorrect, I think what I'm doing right
> now should work fine.

When there are two rectangles we use NSRectClipList, which behaves a
little differently. It uses the union of the two rectangles to
intersect with the existing clipping. So you'll have to do something
like

    u = NSUnionRect (r[0], r[1]);
    DPSrectclip (ctx, NSMinX (u), NSMinY (u),
		   NSWidth (u), NSHeight (u));

> > I must be failing to communicate well, we keep seeming to
> > misunderstand each other.
> 
> It could be my problem as well: my reading comprehension is nowhere near
> as good as I would rather it be.  Thanks a lot for tolerating it.

It turns out in this case I'm getting confused over what's changed in
each patch! Entirely my fault.

> > You still need to focus, however you don't have to clip when you
> > focus.
> 
> After I unfocus here:
> 
>   /* Draw box if not done already.  */
>   if (!s->for_overlaps && !box_drawn_p && s->face->box != FACE_NO_BOX)
>     ns_dumpglyphs_box_or_relief (s);
> 
> -> ns_unfocus (s->f);
> 
> I make sure to focus again if an overhang might be drawn again (inside
> if (s->prev) and if (s->next)), like so:
> 
>   /* Draw surrounding overhangs. */
>   if (s->prev)
>     {
> ->    ns_focus (s->f, NULL, 0);
>       struct glyph_string *prev;
> 
> There is, of course, a matching unfocus.  Is that not adequate, and if
> so, could you please explain how?

Sorry, I've got confused. What you're doing here now is good.

I noticed that you removed all calls to ns_focus in
ns_draw_window_cursor and thought you'd removed all calls to ns_focus,
but now I see that's an older change.

Is that a good idea? I think ns_draw_window_cursor is sometimes called
without matching ns_update_begin/end calls, so it needs to focus, or am I
misunderstanding the flow?

-- 
Alan Third