aboutsummaryrefslogtreecommitdiffstats
path: root/src/nsfns.m
diff options
context:
space:
mode:
authorAlan Third2018-06-23 15:26:26 +0100
committerAlan Third2020-03-22 15:31:45 +0000
commit3316e78c120f69aa3ac12ff7345a79dd09654c9a (patch)
tree95dab41336265e82d71bc45c621733bfdbe06a74 /src/nsfns.m
parent41f54289058ec42829cd19f7c469b2e4e325b830 (diff)
downloademacs-scratch/ns/next.tar.gz
emacs-scratch/ns/next.zip
Run NSApp loop in its own threadscratch/ns/next
* src/emacs.c (main) [HAVE_NS]: Rename to emacs_main. * src/lisp.h (emacs_main) [HAVE_NS]: Define function. * src/nsfns.m (Fns_do_applescript): Remove runloop. (Fx_create_frame): Initialize the frame on the main thread. * src/nsterm.h ([EmacsApp initLispThread:withArgv:]): New method. ([EmacsApp fd_handler:]): ([EmacsApp timeout_handler:]): ([EmacsApp sendFromMainThread:]): Remove function definitions. ([EmacsApp initLispThread:]): New function. ([EmacsThread initWithArgc:Argv:]): ([EmacsThread sendEmacsEvent:NSEvent:frameOrWindow:]): New functions. * src/nsterm.m (EV_TRAILER): Reduce to a single function. (EV_TRAILER2): Remove. (ns_init_events): (ns_finish_events): (hold_event): (ns_send_appdefined): (ns_run_loop_break): ([EmacsApp timeout_handler:]): ([EmacsApp sendFromMainThread:]): ([EmacsApp fd_handler:]): Remove functions. (ns_check_menu_open): ([EmacsApp newFrame:]): ([EmacsApp openFile:]): ([EmacsApp terminate:]): ([EmacsApp fulfillService:withArg:]): ([EmacsView changeFont:]): ([EmacsView keyDown:]): ([EmacsView insertText:]): ([EmacsView setmarkedtext:selectedRange:]): ([EmacsView deleteWorkingText:]): ([EmacsView doCommandBySelector:]): ([EmacsView mouseDown:]): ([EmacsView mouseMoved:]): ([EmacsView windowShouldClose:]): ([EmacsView windowDidResize:]): ([EmacsView windowDidBecomeKey]): ([EmacsView windowDidResignKey:]): ([EmacsView windowDidMove:]): ([EmacsView windowDidDeminiaturize:]): ([EmacsView windowDidExpose:]): ([EmacsView windowDidMiniaturize:]): ([EmacsView menuDown:]): ([EmacsView toolbarClicked:]): ([EmacsView toggleToolbar:]): ([EmacsView performDragOperation:]): ([EmacsScroller sendScrollEventAtLoc:fromEvent:]): Change event handling. ([EmacsApp applicationDidFinishLaunching:]): ([EmacsApp applicationDidResignActive:]): Remove call to ns_send_appdefined. (ns_read_socket): Change event handling, use thread local runloop. (ns_select): Remove unused fd_handler and runloop related code. (ns_term_init): Move some NS initialisation code to new main function and remove fd_handler related code. ([EmacsApp sendEvent:]): Stop run loop from exiting. ([EmacsApp initLispThread:withArgv:]): New method. ([EmacsThread initWithArgc:Argv:]): ([EmacsThread processEmacsEvent:]): ([EmacsThread sendEmacsEvent:NSEvent:frameOrWindow:]): New functions. (main): New function to initialise NS stuff and run emacs_main in its own thread. * src/systhread.c (sys_cond_broadcast): Remove NS runloop related code.
Diffstat (limited to 'src/nsfns.m')
-rw-r--r--src/nsfns.m13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/nsfns.m b/src/nsfns.m
index dea51bdba00..d693873d422 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1310,7 +1310,10 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
1310 1310
1311 f->output_data.ns->in_animation = NO; 1311 f->output_data.ns->in_animation = NO;
1312 1312
1313 f->output_data.ns->frame = [[EmacsFrame alloc] initWithEmacsframe:f]; 1313 f->output_data.ns->frame =
1314 [(EmacsFrame *)[[[MainThreadProxy alloc] initWithObject:[EmacsFrame alloc]
1315 waitUntilDone:YES] autorelease]
1316 initWithEmacsframe:f];
1314 1317
1315 ns_icon (f, parms); 1318 ns_icon (f, parms);
1316 1319
@@ -2141,7 +2144,6 @@ In case the execution fails, an error is signaled. */)
2141 Lisp_Object result; 2144 Lisp_Object result;
2142 int status; 2145 int status;
2143 NSEvent *nxev; 2146 NSEvent *nxev;
2144 struct input_event ev;
2145 2147
2146 CHECK_STRING (script); 2148 CHECK_STRING (script);
2147 check_window_system (NULL); 2149 check_window_system (NULL);
@@ -2167,13 +2169,6 @@ In case the execution fails, an error is signaled. */)
2167 2169
2168 [NSApp postEvent: nxev atStart: NO]; 2170 [NSApp postEvent: nxev atStart: NO];
2169 2171
2170 /* If there are other events, the event loop may exit. Keep running
2171 until the script has been handled. */
2172 ns_init_events (&ev);
2173 while (! NILP (as_script))
2174 [NSApp run];
2175 ns_finish_events ();
2176
2177 status = as_status; 2172 status = as_status;
2178 as_status = 0; 2173 as_status = 0;
2179 as_result = 0; 2174 as_result = 0;