X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/c3f4c690b66558c159f98b9ab5d9164c2fa0bfb7..08f6668226c6c70e63c63e8962785dfe86cba70d:/src/macterm.c diff --git a/src/macterm.c b/src/macterm.c index 3616ac9567..f4f9235c84 100644 --- a/src/macterm.c +++ b/src/macterm.c @@ -228,6 +228,10 @@ extern int errno; extern int extra_keyboard_modifiers; +/* The keysyms to use for the various modifiers. */ + +static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value; + static Lisp_Object Qvendor_specific_keysyms; #if 0 @@ -275,7 +279,7 @@ static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int, enum text_cursor_kinds)); -static void x_clip_to_row P_ ((struct window *, struct glyph_row *, GC)); +static void x_clip_to_row P_ ((struct window *, struct glyph_row *, int, GC)); static void x_flush P_ ((struct frame *f)); static void x_update_begin P_ ((struct frame *)); static void x_update_window_begin P_ ((struct window *)); @@ -1450,12 +1454,12 @@ x_draw_fringe_bitmap (w, row, p) int oldVH = row->visible_height; row->visible_height = p->h; row->y -= rowY - p->y; - x_clip_to_row (w, row, gc); + x_clip_to_row (w, row, -1, gc); row->y = oldY; row->visible_height = oldVH; } else - x_clip_to_row (w, row, gc); + x_clip_to_row (w, row, -1, gc); if (p->bx >= 0 && !p->overlay_p) { @@ -4611,18 +4615,19 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) mode lines must be clipped to the whole window. */ static void -x_clip_to_row (w, row, gc) +x_clip_to_row (w, row, area, gc) struct window *w; struct glyph_row *row; + int area; GC gc; { struct frame *f = XFRAME (WINDOW_FRAME (w)); Rect clip_rect; - int window_y, window_width; + int window_x, window_y, window_width; - window_box (w, -1, 0, &window_y, &window_width, 0); + window_box (w, area, &window_x, &window_y, &window_width, 0); - clip_rect.left = WINDOW_TO_FRAME_PIXEL_X (w, 0); + clip_rect.left = window_x; clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); clip_rect.top = max (clip_rect.top, window_y); clip_rect.right = clip_rect.left + window_width; @@ -4688,7 +4693,7 @@ x_draw_hollow_cursor (w, row) gc = dpyinfo->scratch_cursor_gc; /* Set clipping, draw the rectangle, and reset clipping again. */ - x_clip_to_row (w, row, gc); + x_clip_to_row (w, row, TEXT_AREA, gc); mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h); mac_reset_clipping (dpy, FRAME_MAC_WINDOW (f)); } @@ -4759,7 +4764,7 @@ x_draw_bar_cursor (w, row, width, kind) width = min (cursor_glyph->pixel_width, width); w->phys_cursor_width = width; - x_clip_to_row (w, row, gc); + x_clip_to_row (w, row, TEXT_AREA, gc); if (kind == BAR_CURSOR) XFillRectangle (dpy, window, gc, @@ -6988,6 +6993,9 @@ Lisp_Object Qreverse; /* True if using command key as meta key. */ Lisp_Object Vmac_command_key_is_meta; +/* Modifier associated with the option key, or nil for normal behavior. */ +Lisp_Object Vmac_option_modifier; + /* True if the ctrl and meta keys should be reversed. */ Lisp_Object Vmac_reverse_ctrl_meta; @@ -7069,6 +7077,12 @@ mac_to_emacs_modifiers (EventModifiers mods) result |= meta_modifier; if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey)) result |= alt_modifier; + if (!NILP (Vmac_option_modifier) && (mods & optionKey)) { + Lisp_Object val = Fget(Vmac_option_modifier, Qmodifier_value); + if (!NILP(val)) + result |= XUINT(val); + } + return result; } @@ -8549,7 +8563,18 @@ XTread_socket (sd, expected, hold_quit) unsigned long some_state = 0; inev.code = KeyTranslate (kchr_ptr, new_keycode, &some_state) & 0xff; - } + } else if (!NILP(Vmac_option_modifier) && (er.modifiers & optionKey)) + { + /* When using the option key as an emacs modifier, convert + the pressed key code back to one without the Mac option + modifier applied. */ + int new_modifiers = er.modifiers & ~optionKey; + int new_keycode = keycode | new_modifiers; + Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); + unsigned long some_state = 0; + inev.code = KeyTranslate (kchr_ptr, new_keycode, + &some_state) & 0xff; + } else inev.code = er.message & charCodeMask; inev.kind = ASCII_KEYSTROKE_EVENT; @@ -9248,6 +9273,14 @@ syms_of_macterm () x_error_message_string = Qnil; #endif + Qmodifier_value = intern ("modifier-value"); + Qalt = intern ("alt"); + Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); + Qhyper = intern ("hyper"); + Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); + Qsuper = intern ("super"); + Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); + Fprovide (intern ("mac-carbon"), Qnil); staticpro (&Qreverse); @@ -9304,6 +9337,12 @@ to 4.1, set this to nil. */); Otherwise the option key is used. */); Vmac_command_key_is_meta = Qt; + DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier, + doc: /* Modifier to use for the Mac alt/option key. The value can +be alt, hyper, or super for the respective modifier. If the value is +nil then the key will act as the normal Mac option modifier. */); + Vmac_option_modifier = Qnil; + DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta, doc: /* Non-nil means that the control and meta keys are reversed. This is useful for non-standard keyboard layouts. */);