unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Third <alan@idiocy.org>
To: Keith David Bershatsky <esq@lawlist.com>
Cc: emacs-devel@gnu.org
Subject: Re: Whether a struct window *w is a live/valid window.
Date: Sat, 23 Mar 2019 10:49:55 +0000	[thread overview]
Message-ID: <20190323104955.GA48472@breton.holly.idiocy.org> (raw)
In-Reply-To: <m21s2yumpp.wl%esq@lawlist.com>

On Fri, Mar 22, 2019 at 11:30:26PM -0700, Keith David Bershatsky wrote:
> 
> When I stepped through the code, I observed that removal of the
> scroll bars is delayed on the NS and W32 platforms. update_window
> runs _before_ scroll bars are actually removed. Scroll bar removal
> occurs during read_char at approximately the location of
> read_decoded_event_from_main_queue.

OK, I think you have a slight misunderstanding of what ‘removing the
scrollbars’ does, on NS at lease.

When a scrollbar is removed it doesn’t ‘undraw’ the scrollbar from the
screen, it marks the area it was as needing to be redrawn, and that is
done from scratch. So the fact that the glyphs don’t appear to be
deleted means that they are *redrawn*. The multiple cursors appear to
be deleted, so that means that they are *not* redrawn.

The redrawing doesn’t happen synchronously either. It occurs when we
call [NSApp run], which is generally done when we’re handling input.

If you look in nsterm.m you’ll see a call in ns_read_socket and
ns_select. That’s where the screen will be redrawn.

You could try redrawing the cursors in [EmacsView drawRect:], but it
has no concept of Emacs windows, so you would have to step through
them and make sure you only updated the windows in the current frame,
and that they’re live.

It would be better if they were redrawn in expose_window, perhaps.

One thing to bear in mind is that drawRect: sets up clipping areas so
you can’t draw outside areas that have been marked for update. So the
usual drawing routine goes like

redisplay:
  mark area as dirty (setNeedsDisplayInRect:)
  
check for input:
  run the NS event loop ([NSApp run])
    drawRect:
      expose_frame
        expose_window
          do actual drawing somewhere in here

> The NS port uses `struct window *window`, and Emacs occasionally
> crashes when I have attempted to use XSETWINDOW (as described in the
> initial post of this thread). My workaround is to tentatively use:
> 
>    if (w != NULL && NILP (w->contents))

That looks reasonable to me.
-- 
Alan Third



  reply	other threads:[~2019-03-23 10:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-23  6:30 Whether a struct window *w is a live/valid window Keith David Bershatsky
2019-03-23 10:49 ` Alan Third [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-03-23 17:03 Keith David Bershatsky
2019-03-20 20:14 Keith David Bershatsky
2019-03-22 15:01 ` Alan Third

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190323104955.GA48472@breton.holly.idiocy.org \
    --to=alan@idiocy.org \
    --cc=emacs-devel@gnu.org \
    --cc=esq@lawlist.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).