From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.devel Subject: Re: Emacs Mac port Date: Mon, 06 Oct 2014 17:21:22 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <20141006.132110.314513310844070813.kazu@iij.ad.jp> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=ISO-2022-JP X-Trace: ger.gmane.org 1412583710 26930 80.91.229.3 (6 Oct 2014 08:21:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 6 Oct 2014 08:21:50 +0000 (UTC) Cc: emacs-devel@gnu.org To: Kazu Yamamoto (=?ISO-2022-JP?B?GyRCOzNLXE9CSScbKEI=?=) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 06 10:21:43 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xb3Y6-0002ig-TE for ged-emacs-devel@m.gmane.org; Mon, 06 Oct 2014 10:21:43 +0200 Original-Received: from localhost ([::1]:50691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xb3Y6-000425-GZ for ged-emacs-devel@m.gmane.org; Mon, 06 Oct 2014 04:21:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xb3Xz-00041v-AP for emacs-devel@gnu.org; Mon, 06 Oct 2014 04:21:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xb3Xt-0002xz-PX for emacs-devel@gnu.org; Mon, 06 Oct 2014 04:21:35 -0400 Original-Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]:55413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xb3Xt-0002nk-8W for emacs-devel@gnu.org; Mon, 06 Oct 2014 04:21:29 -0400 Original-Received: from fermat.math.s.chiba-u.ac.jp (fermat [133.82.132.10]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 65154C0560; Mon, 6 Oct 2014 17:21:22 +0900 (JST) In-Reply-To: <20141006.132110.314513310844070813.kazu@iij.ad.jp> User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 133.82.132.2 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:175007 Archived-At: >>>>> On Mon, 06 Oct 2014 13:21:10 +0900 (JST), Kazu Yamamoto (山本和彦) said: > However, I noticed two bugs so far. I would like to report one of > them here. I'm using two Mavericks. emacs-24.3.94-mac-4.94 gets a > segfault if it is operated through Mac's *screen share*. > I can reproduce this bug 100%. And I confirmed that this bug does > not exist in pure emacs-24.3.94. I could reproduce the bug, and it is a regression introduced in emacs-24.3.91-mac-4.91 . Please try the patch below. Thanks for reporting this. Next time, please report Mac port specific bugs to mituharu+bug-gnu-emacs-mac@math.s.chiba-u.ac.jp as guided with M-x report-emacs-bug RET. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp === modified file 'src/macappkit.h' *** src/macappkit.h 2014-10-02 03:58:26 +0000 --- src/macappkit.h 2014-10-06 08:14:09 +0000 *************** *** 975,980 **** --- 975,981 ---- #if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 @interface NSEvent (AvailableOn1050AndLater) - (CGEventRef)CGEvent; + - (const void * /* EventRef */)eventRef; @end #endif === modified file 'src/macappkit.m' *** src/macappkit.m 2014-10-02 03:58:26 +0000 --- src/macappkit.m 2014-10-06 08:14:09 +0000 *************** *** 318,323 **** --- 318,342 ---- pressure:[self pressure]]; } + static void + mac_cgevent_set_unicode_string_from_event_ref (CGEventRef cgevent, + EventRef eventRef) + { + ByteCount size; + + if (GetEventParameter (eventRef, kEventParamKeyUnicodes, + typeUnicodeText, NULL, 0, &size, NULL) == noErr) + { + UniChar *text = alloca (size); + + if (GetEventParameter (eventRef, kEventParamKeyUnicodes, + typeUnicodeText, NULL, size, NULL, + text) == noErr) + CGEventKeyboardSetUnicodeString (cgevent, size / sizeof (UniChar), + text); + } + } + - (CGEventRef)coreGraphicsEvent { CGEventRef event; *************** *** 328,334 **** { event = [self CGEvent]; if (event) ! return event; } /* Workaround for a bug on Mac OS X 10.4. */ --- 347,370 ---- { event = [self CGEvent]; if (event) ! { ! /* Unicode string is not set if the keyboard event comes ! from Screen Sharing on Mac OS X 10.6 and later. */ ! if (NSEventMaskFromType ([self type]) & (NSKeyDownMask | NSKeyUpMask)) ! { ! UniCharCount length; ! ! CGEventKeyboardGetUnicodeString (event, 0, &length, NULL); ! if (length == 0) ! { ! EventRef eventRef = (EventRef) [self eventRef]; ! ! mac_cgevent_set_unicode_string_from_event_ref (event, ! eventRef); ! } ! } ! return event; ! } } /* Workaround for a bug on Mac OS X 10.4. */ *************** *** 369,389 **** #if __LP64__ /* This seems to be unnecessary for 32-bit executables. */ { - ByteCount size; UInt32 keyboard_type; EventRef eventRef = (EventRef) [self eventRef]; ! if (GetEventParameter (eventRef, kEventParamKeyUnicodes, ! typeUnicodeText, NULL, 0, &size, NULL) == noErr) ! { ! UniChar *text = alloca (size); ! ! if (GetEventParameter (eventRef, kEventParamKeyUnicodes, ! typeUnicodeText, NULL, size, NULL, ! text) == noErr) ! CGEventKeyboardSetUnicodeString (event, size / sizeof (UniChar), ! text); ! } if (GetEventParameter (eventRef, kEventParamKeyboardType, typeUInt32, NULL, sizeof (UInt32), NULL, &keyboard_type) == noErr) --- 405,414 ---- #if __LP64__ /* This seems to be unnecessary for 32-bit executables. */ { UInt32 keyboard_type; EventRef eventRef = (EventRef) [self eventRef]; ! mac_cgevent_set_unicode_string_from_event_ref (event, eventRef); if (GetEventParameter (eventRef, kEventParamKeyboardType, typeUInt32, NULL, sizeof (UInt32), NULL, &keyboard_type) == noErr)