comparison src/macterm.c @ 83037:03a73693678e

Merged in changes from CVS HEAD Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-71 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-72 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-73 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-74 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-75 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-76 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-77 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-78 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-79 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-80 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-81 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-82 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-83 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-84 Add lisp/emacs-lisp/macroexp.el * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-85 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-86 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-87 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-88 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-89 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-90 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-91 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-92 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-93 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-94 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-95 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-96 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-97 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-77
author Karoly Lorentey <lorentey@elte.hu>
date Tue, 17 Feb 2004 01:52:25 +0000
parents 1d2f73785d9d 922b1cbf208b
children 887bb2eb4a89
comparison
equal deleted inserted replaced
83036:fc638739c70f 83037:03a73693678e
465 465
466 466
467 /* Mac replacement for XCopyArea. */ 467 /* Mac replacement for XCopyArea. */
468 468
469 static void 469 static void
470 mac_draw_bitmap (display, w, gc, x, y, bitmap) 470 mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
471 Display *display; 471 Display *display;
472 WindowPtr w; 472 WindowPtr w;
473 GC gc; 473 GC gc;
474 int x, y; 474 int x, y, width, height;
475 BitMap *bitmap; 475 unsigned short *bits;
476 { 476 int overlay_p;
477 {
478 BitMap bitmap;
477 Rect r; 479 Rect r;
480
481 bitmap.rowBytes = sizeof(unsigned short);
482 bitmap.baseAddr = bits;
483 SetRect (&(bitmap.bounds), 0, 0, width, height);
478 484
479 #if TARGET_API_MAC_CARBON 485 #if TARGET_API_MAC_CARBON
480 SetPort (GetWindowPort (w)); 486 SetPort (GetWindowPort (w));
481 #else 487 #else
482 SetPort (w); 488 SetPort (w);
483 #endif 489 #endif
484 490
485 mac_set_colors (gc); 491 mac_set_colors (gc);
486 SetRect (&r, x, y, x + bitmap->bounds.right, y + bitmap->bounds.bottom); 492 SetRect (&r, x, y, x + bitmap.bounds.right, y + bitmap.bounds.bottom);
487 493
488 #if TARGET_API_MAC_CARBON 494 #if TARGET_API_MAC_CARBON
489 { 495 {
490 PixMapHandle pmh; 496 PixMapHandle pmh;
491 497
492 LockPortBits (GetWindowPort (w)); 498 LockPortBits (GetWindowPort (w));
493 pmh = GetPortPixMap (GetWindowPort (w)); 499 pmh = GetPortPixMap (GetWindowPort (w));
494 CopyBits (bitmap, (BitMap *) *pmh, &(bitmap->bounds), &r, srcCopy, 0); 500 CopyBits (&bitmap, (BitMap *) *pmh, &(bitmap.bounds), &r,
501 overlay_p ? srcOr : srcCopy, 0);
495 UnlockPortBits (GetWindowPort (w)); 502 UnlockPortBits (GetWindowPort (w));
496 } 503 }
497 #else /* not TARGET_API_MAC_CARBON */ 504 #else /* not TARGET_API_MAC_CARBON */
498 CopyBits (bitmap, &(w->portBits), &(bitmap->bounds), &r, srcCopy, 0); 505 CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r,
506 overlay_p ? srcOr : srcCopy, 0);
499 #endif /* not TARGET_API_MAC_CARBON */ 507 #endif /* not TARGET_API_MAC_CARBON */
500 } 508 }
501 509
502 510
503 /* Mac replacement for XSetClipRectangles. */ 511 /* Mac replacement for XSetClipRectangles. */
1311 row->visible_height = oldVH; 1319 row->visible_height = oldVH;
1312 } 1320 }
1313 else 1321 else
1314 x_clip_to_row (w, row, gc); 1322 x_clip_to_row (w, row, gc);
1315 1323
1316 if (p->bx >= 0) 1324 if (p->bx >= 0 && !p->overlay_p)
1317 { 1325 {
1318 XGCValues gcv; 1326 XGCValues gcv;
1319 gcv.foreground = face->background; 1327 gcv.foreground = face->background;
1320 1328
1321 #if 0 /* MAC_TODO: stipple */ 1329 #if 0 /* MAC_TODO: stipple */
1337 if (!face->stipple) 1345 if (!face->stipple)
1338 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->foreground); 1346 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->foreground);
1339 #endif 1347 #endif
1340 } 1348 }
1341 1349
1342 if (p->which != NO_FRINGE_BITMAP) 1350 if (p->which)
1343 { 1351 {
1344 unsigned char *bits = fringe_bitmaps[p->which].bits + p->dh; 1352 unsigned short *bits = p->bits + p->dh;
1345 BitMap bitmap; 1353
1346 1354 gcv.foreground = (p->cursor_p
1347 mac_create_bitmap_from_bitmap_data (&bitmap, bits, p->wd, p->h); 1355 ? (p->overlay_p ? face->background
1348 gcv.foreground = face->foreground; 1356 : f->output_data.mac->cursor_pixel)
1357 : face->foreground);
1349 gcv.background = face->background; 1358 gcv.background = face->background;
1350 1359
1351 mac_draw_bitmap (display, window, &gcv, p->x, p->y, &bitmap); 1360 mac_draw_bitmap (display, window, &gcv, p->x, p->y,
1352 1361 p->wd, p->h, bits, p->overlay_p);
1353 mac_free_bitmap (&bitmap);
1354 } 1362 }
1355 1363
1356 mac_reset_clipping (display, window); 1364 mac_reset_clipping (display, window);
1357 } 1365 }
1358 1366
6453 #define ABOUT_ALERT_ID 128 6461 #define ABOUT_ALERT_ID 128
6454 #define RAM_TOO_LARGE_ALERT_ID 129 6462 #define RAM_TOO_LARGE_ALERT_ID 129
6455 6463
6456 Boolean terminate_flag = false; 6464 Boolean terminate_flag = false;
6457 6465
6466 /* Contains the string "reverse", which is a constant for mouse button emu.*/
6467 Lisp_Object Qreverse;
6468
6458 /* True if using command key as meta key. */ 6469 /* True if using command key as meta key. */
6459 Lisp_Object Vmac_command_key_is_meta; 6470 Lisp_Object Vmac_command_key_is_meta;
6460 6471
6461 /* True if the ctrl and meta keys should be reversed. */ 6472 /* True if the ctrl and meta keys should be reversed. */
6462 Lisp_Object Vmac_reverse_ctrl_meta; 6473 Lisp_Object Vmac_reverse_ctrl_meta;
6474
6475 /* True if the option and command modifiers should be used to emulate
6476 a three button mouse */
6477 Lisp_Object Vmac_emulate_three_button_mouse;
6463 6478
6464 #if USE_CARBON_EVENTS 6479 #if USE_CARBON_EVENTS
6465 /* True if the mouse wheel button (i.e. button 4) should map to 6480 /* True if the mouse wheel button (i.e. button 4) should map to
6466 mouse-2, instead of mouse-3. */ 6481 mouse-2, instead of mouse-3. */
6467 Lisp_Object Vmac_wheel_button_is_mouse_2; 6482 Lisp_Object Vmac_wheel_button_is_mouse_2;
6531 if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey)) 6546 if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey))
6532 result |= alt_modifier; 6547 result |= alt_modifier;
6533 return result; 6548 return result;
6534 } 6549 }
6535 6550
6551 static int
6552 mac_get_emulated_btn ( UInt32 modifiers )
6553 {
6554 int result = 0;
6555 if (Vmac_emulate_three_button_mouse != Qnil) {
6556 int cmdIs3 = (Vmac_emulate_three_button_mouse != Qreverse);
6557 if (modifiers & controlKey)
6558 result = cmdIs3 ? 2 : 1;
6559 else if (modifiers & optionKey)
6560 result = cmdIs3 ? 1 : 2;
6561 }
6562 return result;
6563 }
6564
6536 #if USE_CARBON_EVENTS 6565 #if USE_CARBON_EVENTS
6537 /* Obtains the event modifiers from the event ref and then calls 6566 /* Obtains the event modifiers from the event ref and then calls
6538 mac_to_emacs_modifiers. */ 6567 mac_to_emacs_modifiers. */
6539 static int 6568 static int
6540 mac_event_to_emacs_modifiers (EventRef eventRef) 6569 mac_event_to_emacs_modifiers (EventRef eventRef)
6541 { 6570 {
6542 UInt32 mods = 0; 6571 UInt32 mods = 0;
6543 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL, 6572 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
6544 sizeof (UInt32), NULL, &mods); 6573 sizeof (UInt32), NULL, &mods);
6574 if (Vmac_emulate_three_button_mouse != Qnil &&
6575 GetEventClass(eventRef) == kEventClassMouse)
6576 {
6577 mods &= ~(optionKey & cmdKey);
6578 }
6545 return mac_to_emacs_modifiers (mods); 6579 return mac_to_emacs_modifiers (mods);
6546 } 6580 }
6547 6581
6548 /* Given an event ref, return the code to use for the mouse button 6582 /* Given an event ref, return the code to use for the mouse button
6549 code in the emacs input_event. */ 6583 code in the emacs input_event. */
6554 GetEventParameter (ref, kEventParamMouseButton, typeMouseButton, NULL, 6588 GetEventParameter (ref, kEventParamMouseButton, typeMouseButton, NULL,
6555 sizeof (EventMouseButton), NULL, &result); 6589 sizeof (EventMouseButton), NULL, &result);
6556 switch (result) 6590 switch (result)
6557 { 6591 {
6558 case kEventMouseButtonPrimary: 6592 case kEventMouseButtonPrimary:
6559 return 0; 6593 if (Vmac_emulate_three_button_mouse == Qnil)
6594 return 0;
6595 else {
6596 UInt32 mods = 0;
6597 GetEventParameter (ref, kEventParamKeyModifiers, typeUInt32, NULL,
6598 sizeof (UInt32), NULL, &mods);
6599 return mac_get_emulated_btn(mods);
6600 }
6560 case kEventMouseButtonSecondary: 6601 case kEventMouseButtonSecondary:
6561 return NILP (Vmac_wheel_button_is_mouse_2) ? 1 : 2; 6602 return NILP (Vmac_wheel_button_is_mouse_2) ? 1 : 2;
6562 case kEventMouseButtonTertiary: 6603 case kEventMouseButtonTertiary:
6563 case 4: /* 4 is the number for the mouse wheel button */ 6604 case 4: /* 4 is the number for the mouse wheel button */
6564 return NILP (Vmac_wheel_button_is_mouse_2) ? 2 : 1; 6605 return NILP (Vmac_wheel_button_is_mouse_2) ? 2 : 1;
7690 GlobalToLocal (&mouse_loc); 7731 GlobalToLocal (&mouse_loc);
7691 7732
7692 #if USE_CARBON_EVENTS 7733 #if USE_CARBON_EVENTS
7693 bufp->code = mac_get_mouse_btn (eventRef); 7734 bufp->code = mac_get_mouse_btn (eventRef);
7694 #else 7735 #else
7695 bufp->code = 0; /* only one mouse button */ 7736 bufp_.code = mac_get_emulate_btn (er.modifiers);
7696 #endif 7737 #endif
7697 bufp->kind = SCROLL_BAR_CLICK_EVENT; 7738 bufp->kind = SCROLL_BAR_CLICK_EVENT;
7698 bufp->frame_or_window = tracked_scroll_bar->window; 7739 bufp->frame_or_window = tracked_scroll_bar->window;
7699 bufp->part = scroll_bar_handle; 7740 bufp->part = scroll_bar_handle;
7700 #if USE_CARBON_EVENTS 7741 #if USE_CARBON_EVENTS
7758 #endif 7799 #endif
7759 7800
7760 #if USE_CARBON_EVENTS 7801 #if USE_CARBON_EVENTS
7761 bufp->code = mac_get_mouse_btn (eventRef); 7802 bufp->code = mac_get_mouse_btn (eventRef);
7762 #else 7803 #else
7763 bufp->code = 0; /* only one mouse button */ 7804 bufp_.code = mac_get_emulate_btn (er.modifiers);
7764 #endif 7805 #endif
7765 XSETINT (bufp->x, mouse_loc.h); 7806 XSETINT (bufp->x, mouse_loc.h);
7766 XSETINT (bufp->y, mouse_loc.v); 7807 XSETINT (bufp->y, mouse_loc.v);
7767 bufp->timestamp = er.when * (1000 / 60); 7808 bufp->timestamp = er.when * (1000 / 60);
7768 /* ticks to milliseconds */ 7809 /* ticks to milliseconds */
8515 x_flush, 8556 x_flush,
8516 x_clear_window_mouse_face, 8557 x_clear_window_mouse_face,
8517 x_get_glyph_overhangs, 8558 x_get_glyph_overhangs,
8518 x_fix_overlapping_area, 8559 x_fix_overlapping_area,
8519 x_draw_fringe_bitmap, 8560 x_draw_fringe_bitmap,
8561 0, /* define_fringe_bitmap */
8562 0, /* destroy_fringe_bitmap */
8520 mac_per_char_metric, 8563 mac_per_char_metric,
8521 mac_encode_char, 8564 mac_encode_char,
8522 NULL, /* mac_compute_glyph_string_overhangs */ 8565 NULL, /* mac_compute_glyph_string_overhangs */
8523 x_draw_glyph_string, 8566 x_draw_glyph_string,
8524 mac_define_frame_cursor, 8567 mac_define_frame_cursor,
8634 x_error_message_string = Qnil; 8677 x_error_message_string = Qnil;
8635 #endif 8678 #endif
8636 8679
8637 Fprovide (intern ("mac-carbon"), Qnil); 8680 Fprovide (intern ("mac-carbon"), Qnil);
8638 8681
8682 staticpro (&Qreverse);
8683 Qreverse = intern ("reverse");
8684
8639 staticpro (&x_display_name_list); 8685 staticpro (&x_display_name_list);
8640 x_display_name_list = Qnil; 8686 x_display_name_list = Qnil;
8641 8687
8642 staticpro (&last_mouse_scroll_bar); 8688 staticpro (&last_mouse_scroll_bar);
8643 last_mouse_scroll_bar = Qnil; 8689 last_mouse_scroll_bar = Qnil;
8677 8723
8678 DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta, 8724 DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta,
8679 doc: /* Non-nil means that the control and meta keys are reversed. This is 8725 doc: /* Non-nil means that the control and meta keys are reversed. This is
8680 useful for non-standard keyboard layouts. */); 8726 useful for non-standard keyboard layouts. */);
8681 Vmac_reverse_ctrl_meta = Qnil; 8727 Vmac_reverse_ctrl_meta = Qnil;
8728
8729 DEFVAR_LISP ("mac-emulate-three-button-mouse",
8730 &Vmac_emulate_three_button_mouse,
8731 doc: /* t means that when the option-key is held down while pressing the
8732 mouse button, the click will register as mouse-2 and while the
8733 command-key is held down, the click will register as mouse-3.
8734 'reverse means that the the option-key will register for mouse-3
8735 and the command-key will register for mouse-2. nil means that
8736 not emulation should be done and the modifiers should be placed
8737 on the mouse-1 event. */);
8738 Vmac_emulate_three_button_mouse = Qnil;
8682 8739
8683 #if USE_CARBON_EVENTS 8740 #if USE_CARBON_EVENTS
8684 DEFVAR_LISP ("mac-wheel-button-is-mouse-2", &Vmac_wheel_button_is_mouse_2, 8741 DEFVAR_LISP ("mac-wheel-button-is-mouse-2", &Vmac_wheel_button_is_mouse_2,
8685 doc: /* Non-nil means that the wheel button will be treated as mouse-2 and 8742 doc: /* Non-nil means that the wheel button will be treated as mouse-2 and
8686 the right click will be mouse-3. 8743 the right click will be mouse-3.