From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
To: Lloyd Zusman <ljz@asfast.com>
Cc: emacs-devel@gnu.org
Subject: Re: Asynchronous events in Carbon or Cocoa Emacs (macosx)
Date: Sat, 11 Oct 2008 12:05:12 +0900 [thread overview]
Message-ID: <wld4i7zv9z.wl%mituharu@math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <loom.20081010T233433-351@post.gmane.org>
>>>>> On Fri, 10 Oct 2008 23:51:22 +0000 (UTC), Lloyd Zusman <ljz@asfast.com> said:
> However, if I run Carbon or Cocoa Emacs without the `-nw' flag so
> that it creates and manages its own window outside of Terminal,
> these `special-event-map' events don't get invoked in near-real time
> any more, but rather, they only get processed the next time I
> interact directly with the Emacs window with either the mouse or a
> keystroke.
> In other words, if I am trapping [sigusr1] as described above and
> send a USR1 signal to the process, nothing happens until after I
> click in the Emacs window with the mouse or perform some sort of
> keyboard interaction with it, at which time the [sigusr1] events
> that have accumulated all get processed, one after the other.
I'm not sure about the Cocoa/GNUstep port, but I can say something
about Carbon Emacs 22.
That's a known limitation in the `select' emulation of the Carbon
port, and I mentioned that when I updated the platform-independent
part of user-signal handling code to the current form:
http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg00443.html
I have some experimental code to remedy this limitation, but it's not
tested that much.
YAMAMOTO Mitsuharu
mituharu@math.s.chiba-u.ac.jp
Index: src/keyboard.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v
retrieving revision 1.899.2.11
diff -c -p -r1.899.2.11 keyboard.c
*** src/keyboard.c 25 Feb 2008 16:04:54 -0000 1.899.2.11
--- src/keyboard.c 11 Oct 2008 02:48:28 -0000
*************** struct user_signal_info
*** 7087,7092 ****
--- 7087,7094 ----
/* List of user signals. */
static struct user_signal_info *user_signals = NULL;
+ void (*handle_user_signal_hook) P_ ((int));
+
void
add_user_signal (sig, name)
int sig;
*************** handle_user_signal (sig)
*** 7128,7133 ****
--- 7130,7137 ----
if (p->sig == sig)
{
p->npending++;
+ if (handle_user_signal_hook)
+ (*handle_user_signal_hook) (sig);
#ifdef SIGIO
if (interrupt_input)
kill (getpid (), SIGIO);
Index: src/keyboard.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keyboard.h,v
retrieving revision 1.75.2.4
diff -c -p -r1.75.2.4 keyboard.h
*** src/keyboard.h 8 Jan 2008 04:30:01 -0000 1.75.2.4
--- src/keyboard.h 11 Oct 2008 02:48:28 -0000
*************** extern Lisp_Object Qscroll_bar_movement;
*** 297,302 ****
--- 297,304 ----
/* Symbols to use for non-text mouse positions. */
extern Lisp_Object Qmode_line, Qvertical_line, Qheader_line;
+ extern void (*handle_user_signal_hook) P_ ((int));
+
/* Forward declaration for prototypes. */
struct input_event;
Index: src/mac.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/Attic/mac.c,v
retrieving revision 1.77.2.10
diff -c -p -r1.77.2.10 mac.c
*** src/mac.c 29 Aug 2008 08:18:07 -0000 1.77.2.10
--- src/mac.c 11 Oct 2008 02:48:28 -0000
*************** static CFMutableDictionaryRef cfsockets_
*** 4958,4963 ****
--- 4958,5018 ----
/* Process ID of Emacs. */
static pid_t mac_emacs_pid;
+ static int wakeup_fds[2];
+
+ static void
+ wakeup_callback (s, type, address, data, info)
+ CFSocketRef s;
+ CFSocketCallBackType type;
+ CFDataRef address;
+ const void *data;
+ void *info;
+ {
+ char buf[64];
+
+ while (emacs_read (CFSocketGetNative (s), buf, sizeof (buf)) > 0)
+ ;
+ }
+
+ int
+ init_wakeup_fds ()
+ {
+ int result, i;
+ int flags;
+ CFSocketRef socket;
+ CFRunLoopSourceRef source;
+
+ result = pipe (wakeup_fds);
+ if (result < 0)
+ return result;
+ for (i = 0; i < 2; i++)
+ {
+ flags = fcntl (wakeup_fds[i], F_GETFL, 0);
+ result = fcntl (wakeup_fds[i], F_SETFL, flags | O_NONBLOCK);
+ if (result < 0)
+ return result;
+ }
+ socket = CFSocketCreateWithNative (NULL, wakeup_fds[0],
+ kCFSocketReadCallBack,
+ wakeup_callback, NULL);
+ if (socket == NULL)
+ return -1;
+ source = CFSocketCreateRunLoopSource (NULL, socket, 0);
+ CFRelease (socket);
+ if (source == NULL)
+ return -1;
+ CFRunLoopAddSource ((CFRunLoopRef)
+ GetCFRunLoopFromEventLoop (GetCurrentEventLoop ()),
+ source, kCFRunLoopDefaultMode);
+ CFRelease (source);
+ return 0;
+ }
+
+ void mac_wakeup_from_run_loop_run_once ()
+ {
+ emacs_write (wakeup_fds[1], "", 1);
+ }
+
static void
socket_callback (s, type, address, data, info)
CFSocketRef s;
Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/Attic/macterm.c,v
retrieving revision 1.214.2.31
diff -c -p -r1.214.2.31 macterm.c
*** src/macterm.c 2 Sep 2008 08:19:06 -0000 1.214.2.31
--- src/macterm.c 11 Oct 2008 02:48:28 -0000
*************** x_delete_display (dpyinfo)
*** 9436,9441 ****
--- 9436,9452 ----
}
\f
+ #ifdef MAC_OSX
+ void
+ mac_handle_user_signal (sig)
+ int sig;
+ {
+ extern void mac_wakeup_from_run_loop_run_once P_ ((void));
+
+ mac_wakeup_from_run_loop_run_once ();
+ }
+ #endif /* MAC_OSX */
+
/* Set up use of X before we make the first connection. */
extern frame_parm_handler mac_frame_parm_handlers[];
*************** mac_initialize ()
*** 9522,9527 ****
--- 9533,9543 ----
#if TARGET_API_MAC_CARBON
#ifdef MAC_OSX
+ if (init_wakeup_fds () < 0)
+ abort ();
+
+ handle_user_signal_hook = mac_handle_user_signal;
+
init_coercion_handler ();
init_dm_notification_handler ();
next prev parent reply other threads:[~2008-10-11 3:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-10 23:51 Asynchronous events in Carbon or Cocoa Emacs (macosx) Lloyd Zusman
2008-10-11 3:05 ` YAMAMOTO Mitsuharu [this message]
2008-10-11 4:04 ` Lloyd Zusman
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=wld4i7zv9z.wl%mituharu@math.s.chiba-u.ac.jp \
--to=mituharu@math.s.chiba-u.ac.jp \
--cc=emacs-devel@gnu.org \
--cc=ljz@asfast.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).