Re: Patch for Mouse-wheel
Steven Tamm <[email protected]> Mon, 5 Aug 2002 14:02:46 -0700
| Newsgroups | gmane.emacs.macintosh.devel |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail-4-882042645
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
Here is the patch to macterm.c. The main part is to try to pass
non-command keyboard events to the system first and check to see if the
TSM intercepted it. If so, then it ignores the event, otherwise it
tries to post it to the screen. The "right thing" to do would be to
accept Unicode events, but that will probably have to wait for Jaguar
(but that is another email).
I also tried to test the input method floating window and ran into a lot
of crashes where emacs tries to treat it like another frame and
crashed. Most of the bulk of the patch is using is_emacs_window()
liberally and replacing FrontWindow() with FrontNonFloatingWindow().
--Apple-Mail-4-882042645
Content-Disposition: attachment;
filename=tsm.patch
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="tsm.patch"
Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.14
diff -c -r1.14 macterm.c
*** src/macterm.c 4 Aug 2002 19:29:06 -0000 1.14
--- src/macterm.c 5 Aug 2002 20:54:43 -0000
***************
*** 474,479 ****
--- 474,481 ----
static void activate_scroll_bars (FRAME_PTR);
static void deactivate_scroll_bars (FRAME_PTR);
+ static int is_emacs_window (WindowPtr);
+
extern int image_ascent (struct image *, struct face *);
void x_set_offset (struct frame *, int, int, int);
int x_bitmap_icon (struct frame *, Lisp_Object);
***************
*** 8250,8258 ****
Point mouse_pos;
int ignore1, ignore2;
WindowPtr wp = FrontWindow ();
! struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;
Lisp_Object frame, tail;
BLOCK_INPUT;
if (! NILP (last_mouse_scroll_bar) && insist == 0)
--- 8252,8263 ----
Point mouse_pos;
int ignore1, ignore2;
WindowPtr wp = FrontWindow ();
! struct frame *f;
Lisp_Object frame, tail;
+ if (is_emacs_window(wp))
+ f = ((mac_output *) GetWRefCon (wp))->mFP;
+
BLOCK_INPUT;
if (! NILP (last_mouse_scroll_bar) && insist == 0)
***************
*** 11839,11855 ****
do_mouse_moved (Point mouse_pos)
{
WindowPtr wp = FrontWindow ();
! struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;
#if TARGET_API_MAC_CARBON
SetPort (GetWindowPort (wp));
#else
SetPort (wp);
#endif
! GlobalToLocal (&mouse_pos);
!
! note_mouse_movement (f, &mouse_pos);
}
--- 11844,11865 ----
do_mouse_moved (Point mouse_pos)
{
WindowPtr wp = FrontWindow ();
! struct frame *f;
+ if (is_emacs_window (wp))
+ {
+ f = ((mac_output *) GetWRefCon (wp))->mFP;
+
#if TARGET_API_MAC_CARBON
SetPort (GetWindowPort (wp));
#else
SetPort (wp);
#endif
! GlobalToLocal (&mouse_pos);
!
! note_mouse_movement (f, &mouse_pos);
! }
}
***************
*** 12625,12631 ****
{
SInt32 delta;
Point point;
! WindowPtr window_ptr = FrontWindow ();
struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr);
GetEventParameter(eventRef, kEventParamMouseWheelDelta,
typeSInt32, NULL, sizeof (SInt32),
--- 12635,12641 ----
{
SInt32 delta;
Point point;
! WindowPtr window_ptr = FrontNonFloatingWindow ();
struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr);
GetEventParameter(eventRef, kEventParamMouseWheelDelta,
typeSInt32, NULL, sizeof (SInt32),
***************
*** 12665,12672 ****
SInt16 part_code;
#if USE_CARBON_EVENTS
! /* This is needed to correctly */
! SendEventToEventTarget (eventRef, GetEventDispatcherTarget ());
#endif
if (mouse_tracking_in_progress == mouse_tracking_scroll_bar
--- 12675,12688 ----
SInt16 part_code;
#if USE_CARBON_EVENTS
! /* This is needed to send mouse events like aqua window buttons
! to the correct handler. */
! if (eventNotHandledErr != SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) {
! break;
! }
!
! if (!is_emacs_window(window_ptr))
! break;
#endif
if (mouse_tracking_in_progress == mouse_tracking_scroll_bar
***************
*** 12860,12866 ****
case osEvt:
case activateEvt:
#if USE_CARBON_EVENTS
! SendEventToEventTarget (eventRef, GetEventDispatcherTarget ());
#endif
do_events (&er);
break;
--- 12876,12882 ----
case osEvt:
case activateEvt:
#if USE_CARBON_EVENTS
! if (eventNotHandledErr == SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()))
#endif
do_events (&er);
break;
***************
*** 12871,12876 ****
--- 12887,12905 ----
int keycode = (er.message & keyCodeMask) >> 8;
int xkeysym;
+ #if USE_CARBON_EVENTS
+ /* When using Carbon Events, we need to pass raw keyboard events
+ to the TSM ourselves. If TSM handles it, it will pass back
+ noErr, otherwise it will pass back "eventNotHandledErr" and
+ we can process it normally. */
+ if (!(er.modifiers & cmdKey)) {
+ OSStatus err;
+ err = SendEventToEventTarget(eventRef, GetEventDispatcherTarget());
+ if (err != eventNotHandledErr)
+ break;
+ }
+ #endif
+
if (!IsValidWindowPtr (FrontNonFloatingWindow ()))
{
SysBeep (1);
***************
*** 13010,13025 ****
constuct_drag_n_drop in w32term.c. */
if (!NILP (drag_and_drop_file_list))
{
! struct frame *f;
WindowPtr wp;
Lisp_Object frame;
! wp = FrontWindow ();
! if (!wp)
! f = NULL;
! else
! f = ((mac_output *) GetWRefCon (wp))->mFP;
!
bufp->kind = DRAG_N_DROP_EVENT;
bufp->code = 0;
bufp->timestamp = er.when * (1000 / 60);
--- 13039,13052 ----
constuct_drag_n_drop in w32term.c. */
if (!NILP (drag_and_drop_file_list))
{
! struct frame *f = NULL;
WindowPtr wp;
Lisp_Object frame;
! wp = FrontNonFloatingWindow ();
! if (wp && is_emacs_window(wp))
! f = ((mac_output *) GetWRefCon (wp))->mFP;
!
bufp->kind = DRAG_N_DROP_EVENT;
bufp->code = 0;
bufp->timestamp = er.when * (1000 / 60);
--Apple-Mail-4-882042645
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
-Steven
On Monday, August 5, 2002, at 10:46 AM, Steven Tamm wrote:
> I see the problem. The input method window isn't appearing when you
> type in text in CJKV. I'm currently pouring over the carbon docs
> regarding text input to see what I have to do to get the keyDown events
> to be intercepted by text services. Apple seems to be gearing more
> towards adoption of unicode input.
>
> I may try and look into getting Emacs to accept unicode and convert
> based on the current encoding, that way the Extended Roman keyboard
> would work.
>
> Thanks for trying it out.
--Apple-Mail-4-882042645--
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf