Fix handling of bar cursors in NS terminal.

* nsterm.m (ns_draw_window_cursor): Obey the cursor_width argument
directly, for bar cursors.

* xdisp.c (set_frame_cursor_types): Don't write an undefined value
into the frame's cursor_width.
This commit is contained in:
Ben Key 2011-02-23 15:41:43 -05:00 committed by Chong Yidong
parent 53cfe624fc
commit 2c6584e817
3 changed files with 41 additions and 23 deletions

View file

@ -1,3 +1,13 @@
2011-02-23 Ben Key <bkey76@gmail.com> (tiny change)
* nsterm.m (ns_draw_window_cursor): Obey the cursor_width argument
directly, for bar cursors.
2011-02-23 Chong Yidong <cyd@stupidchicken.com>
* xdisp.c (set_frame_cursor_types): Don't write an undefined value
into the frame's cursor_width.
2011-02-23 Stefan Monnier <monnier@iro.umontreal.ca>
* print.c (print_object): Never print old-style backquotes.

View file

@ -1072,7 +1072,7 @@ Free a pool and temporary objects it refers to (callable from C)
: f->left_pos;
/* We use visibleFrame here to take menu bar into account.
Ideally we should also adjust left/top with visibleFrame.origin. */
f->top_pos = f->size_hint_flags & YNegative
? ([screen visibleFrame].size.height + f->top_pos
- FRAME_PIXEL_HEIGHT (f) - FRAME_NS_TITLEBAR_HEIGHT (f)
@ -1154,7 +1154,7 @@ Free a pool and temporary objects it refers to (callable from C)
FRAME_TOOLBAR_HEIGHT (f) = 0;
wr.size.width = pixelwidth + f->border_width;
wr.size.height = pixelheight + FRAME_NS_TITLEBAR_HEIGHT (f)
wr.size.height = pixelheight + FRAME_NS_TITLEBAR_HEIGHT (f)
+ FRAME_TOOLBAR_HEIGHT (f);
/* Do not try to constrain to this screen. We may have multiple
@ -2230,11 +2230,8 @@ Free a pool and temporary objects it refers to (callable from C)
int x, int y, int cursor_type, int cursor_width,
int on_p, int active_p)
/* --------------------------------------------------------------------------
External call (RIF): draw cursor
(modeled after x_draw_window_cursor
FIXME: cursor_width is effectively bogus -- it sometimes gets set
in xdisp.c set_frame_cursor_types, sometimes left uninitialized;
DON'T USE IT (no other terms do)
External call (RIF): draw cursor.
Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
-------------------------------------------------------------------------- */
{
NSRect r, s;
@ -2251,7 +2248,6 @@ External call (RIF): draw cursor
and mini-buffer. */
NSTRACE (dumpcursor);
//fprintf(stderr, "drawcursor (%d,%d) activep = %d\tonp = %d\tc_type = %d\twidth = %d\n",x,y, active_p,on_p,cursor_type,cursor_width);
if (!on_p)
return;
@ -2276,8 +2272,22 @@ External call (RIF): draw cursor
return;
}
/* We draw the cursor (with NSRectFill), then draw the glyph on top
(other terminals do it the other way round). We must set
w->phys_cursor_width to the cursor width. For bar cursors, that
is CURSOR_WIDTH; for box cursors, it is the glyph width. */
get_phys_cursor_geometry (w, glyph_row, phys_cursor_glyph, &fx, &fy, &h);
/* The above get_phys_cursor_geometry call set w->phys_cursor_width
to the glyph width; replace with CURSOR_WIDTH for bar cursors. */
if (cursor_type == BAR_CURSOR || cursor_type == HBAR_CURSOR)
{
if (cursor_width < 0)
cursor_width = FRAME_CURSOR_WIDTH (f);
cursor_width = min (cursor_width, 1);
w->phys_cursor_width = cursor_width;
}
r.origin.x = fx, r.origin.y = fy;
r.size.height = h;
r.size.width = w->phys_cursor_width;
@ -2285,7 +2295,7 @@ External call (RIF): draw cursor
/* FIXME: if we overwrite the internal border area, it does not get erased;
fix by truncating cursor, but better would be to erase properly */
overspill = r.origin.x + r.size.width -
WINDOW_TEXT_TO_FRAME_PIXEL_X (w, WINDOW_BOX_RIGHT_EDGE_X (w)
WINDOW_TEXT_TO_FRAME_PIXEL_X (w, WINDOW_BOX_RIGHT_EDGE_X (w)
- WINDOW_TOTAL_FRINGE_WIDTH (w) - FRAME_INTERNAL_BORDER_WIDTH (f));
if (overspill > 0)
r.size.width -= overspill;
@ -2335,8 +2345,6 @@ External call (RIF): draw cursor
break;
case BAR_CURSOR:
s = r;
s.size.width = min (cursor_width, 2); //FIXME(see above)
/* If the character under cursor is R2L, draw the bar cursor
on the right of its glyph, rather than on the left. */
cursor_glyph = get_phys_cursor_glyph (w);
@ -2984,7 +2992,7 @@ overwriting cursor (usually when cursor on a tab) */
NS_FACE_BACKGROUND (s->face) = NS_FACE_FOREGROUND (s->face);
NS_FACE_FOREGROUND (s->face) = tmp;
}
ns_tmp_font->font.driver->draw
(s, 0, s->nchars, s->x, s->y,
(ns_tmp_flags == NS_DUMPGLYPH_NORMAL && !s->background_filled_p)
@ -3010,9 +3018,9 @@ overwriting cursor (usually when cursor on a tab) */
else
ns_maybe_dumpglyphs_background
(s, s->first_glyph->type == COMPOSITE_GLYPH);
/* ... */
/* ... */
/* Not yet implemented. */
/* ... */
/* ... */
ns_unfocus (s->f);
break;
@ -3785,7 +3793,7 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes.
strncpy (terminal->name, SDATA (display_name), SBYTES (display_name));
terminal->name[SBYTES (display_name)] = 0;
UNBLOCK_INPUT;
UNBLOCK_INPUT;
if (!inhibit_x_resources)
{
@ -3802,7 +3810,7 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes.
stringForKey: @"AppleHighlightColor"];
if (ns_selection_color == nil)
ns_selection_color = NS_SELECTION_COLOR_DEFAULT;
{
NSColorList *cl = [NSColorList colorListNamed: @"Emacs"];
@ -3898,7 +3906,7 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes.
keyEquivalent: @"q"
atIndex: 9];
item = [mainMenu insertItemWithTitle: ns_app_name
item = [mainMenu insertItemWithTitle: ns_app_name
action: @selector (menuDown:)
keyEquivalent: @""
atIndex: 0];
@ -4103,7 +4111,7 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification
-appShouldTerminate
Cancel -> Nothing else
Accept ->
-terminate
KEY_NS_POWER_OFF, (save-buffers-kill-emacs)
ns_term_shutdown()
@ -4113,10 +4121,10 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification
- (void) terminate: (id)sender
{
struct frame *emacsframe = SELECTED_FRAME ();
if (!emacs_event)
return;
emacs_event->kind = NS_NONKEY_EVENT;
emacs_event->code = KEY_NS_POWER_OFF;
emacs_event->arg = Qt; /* mark as non-key event */
@ -4418,7 +4426,7 @@ most recently updated (I guess), which is not the correct one. */
code = ([[theEvent charactersIgnoringModifiers] length] == 0) ?
0 : [[theEvent charactersIgnoringModifiers] characterAtIndex: 0];
/* (Carbon way: [theEvent keyCode]) */
/* is it a "function key"? */
fnKeysym = ns_convert_key (code);
if (fnKeysym)
@ -5446,7 +5454,7 @@ - (void)drawRect: (NSRect)rect
/*
drawRect: may be called (at least in OS X 10.5) for invisible
views as well for some reason. Thus, do not infer visibility
views as well for some reason. Thus, do not infer visibility
here.
emacsframe->async_visible = 1;

View file

@ -23252,7 +23252,7 @@ get_specified_cursor_type (Lisp_Object arg, int *width)
void
set_frame_cursor_types (struct frame *f, Lisp_Object arg)
{
int width;
int width = 1;
Lisp_Object tem;
FRAME_DESIRED_CURSOR (f) = get_specified_cursor_type (arg, &width);