aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdrian Robert2008-10-02 13:57:39 +0000
committerAdrian Robert2008-10-02 13:57:39 +0000
commitc8c057ded8e71ca6a1bb90c9c630f7313f803b8f (patch)
tree04cffeb366d33cfd0801e0789dc17746ad8e530f /src
parent2a7bb8823c0e36e9d093134bf49e2d9914641046 (diff)
downloademacs-c8c057ded8e71ca6a1bb90c9c630f7313f803b8f.tar.gz
emacs-c8c057ded8e71ca6a1bb90c9c630f7313f803b8f.zip
* nsterm.h (ns_cursor_types, ns_output.desired_cursor_color)(ns_output.current_cursor, ns_output.desired_cursor) (ns_output.last_inactive, FRAME_CURSOR, FRAME_NEW_CURSOR) (FRAME_NEW_CURSOR_COLOR,): Remove. * nsfns.m (ns_set_cursor_color): Use FRAME_CURSOR_COLOR. (ns_lisp_to_cursor_type, ns_cursor_type_to_lisp): Use core emacs enumeration (HOLLOW_BOX_CURSOR, etc.). * nsterm.m (ns_frame_rehighlight): Remove commented code. (draw_window_cursor): Simplify code. (EmacsView-windowDidBecomeKey:,-windowDidResignKey:): Don't change cursor type. In latter, call rehighlight instead of doing updates manually. (EmacsPrefsController-setPanelFromValues,-setValuesFromPanel): Use core emacs cursor types. * xdisp.c (draw_glyphs): Don't call notice_overwritten_cursor() under NS.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog22
-rw-r--r--src/nsfns.m29
-rw-r--r--src/nsterm.h24
-rw-r--r--src/nsterm.m273
-rw-r--r--src/xdisp.c4
5 files changed, 118 insertions, 234 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c7e4a9f87fb..9a7e6776394 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,25 @@
12008-10-02 Adrian Robert <Adrian.B.Robert@gmail.com>
2
3 * nsterm.h (ns_cursor_types, ns_output.desired_cursor_color)
4 (ns_output.current_cursor, ns_output.desired_cursor)
5 (ns_output.last_inactive, FRAME_CURSOR, FRAME_NEW_CURSOR)
6 (FRAME_NEW_CURSOR_COLOR): Remove.
7
8 * nsfns.m (ns_set_cursor_color): Use FRAME_CURSOR_COLOR.
9 (ns_lisp_to_cursor_type, ns_cursor_type_to_lisp): Use core emacs
10 enumeration (HOLLOW_BOX_CURSOR, etc.).
11
12 * nsterm.m (ns_frame_rehighlight): Remove commented code.
13 (draw_window_cursor): Simplify code.
14 (EmacsView-windowDidBecomeKey:,-windowDidResignKey:): Don't
15 change cursor type. In latter, call rehighlight instead of doing
16 updates manually.
17 (EmacsPrefsController-setPanelFromValues,-setValuesFromPanel): Use
18 core emacs cursor types.
19
20 * xdisp.c (draw_glyphs): Don't call notice_overwritten_cursor() under
21 NS.
22
12008-10-02 Martin Rudalics <rudalics@gmx.at> 232008-10-02 Martin Rudalics <rudalics@gmx.at>
2 24
3 * process.c (Faccept_process_output): Fix doc-string. 25 * process.c (Faccept_process_output): Fix doc-string.
diff --git a/src/nsfns.m b/src/nsfns.m
index e013809afc9..2c55f969c84 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -413,8 +413,6 @@ ns_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
413} 413}
414 414
415 415
416/* FIXME: adapt to generics */
417
418static void 416static void
419ns_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 417ns_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
420{ 418{
@@ -426,8 +424,8 @@ ns_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
426 error ("Unknown color"); 424 error ("Unknown color");
427 } 425 }
428 426
429 [f->output_data.ns->desired_cursor_color release]; 427 [FRAME_CURSOR_COLOR (f) release];
430 f->output_data.ns->desired_cursor_color = [col retain]; 428 FRAME_CURSOR_COLOR (f) = [col retain];
431 429
432 if (FRAME_VISIBLE_P (f)) 430 if (FRAME_VISIBLE_P (f))
433 { 431 {
@@ -437,6 +435,7 @@ ns_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
437 update_face_from_frame_parameter (f, Qcursor_color, arg); 435 update_face_from_frame_parameter (f, Qcursor_color, arg);
438} 436}
439 437
438
440static void 439static void
441ns_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 440ns_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
442{ 441{
@@ -906,11 +905,11 @@ ns_lisp_to_cursor_type (Lisp_Object arg)
906 else if (XTYPE (arg) == Lisp_Symbol) 905 else if (XTYPE (arg) == Lisp_Symbol)
907 str = SDATA (SYMBOL_NAME (arg)); 906 str = SDATA (SYMBOL_NAME (arg));
908 else return -1; 907 else return -1;
909 if (!strcmp (str, "box")) return filled_box; 908 if (!strcmp (str, "box")) return FILLED_BOX_CURSOR;
910 if (!strcmp (str, "hollow")) return hollow_box; 909 if (!strcmp (str, "hollow")) return HOLLOW_BOX_CURSOR;
911 if (!strcmp (str, "underscore")) return underscore; 910 if (!strcmp (str, "hbar")) return HBAR_CURSOR;
912 if (!strcmp (str, "bar")) return bar; 911 if (!strcmp (str, "bar")) return BAR_CURSOR;
913 if (!strcmp (str, "no")) return no_highlight; 912 if (!strcmp (str, "no")) return NO_CURSOR;
914 return -1; 913 return -1;
915} 914}
916 915
@@ -920,12 +919,12 @@ ns_cursor_type_to_lisp (int arg)
920{ 919{
921 switch (arg) 920 switch (arg)
922 { 921 {
923 case filled_box: return Qbox; 922 case FILLED_BOX_CURSOR: return Qbox;
924 case hollow_box: return intern ("hollow"); 923 case HOLLOW_BOX_CURSOR: return intern ("hollow");
925 case underscore: return intern ("underscore"); 924 case HBAR_CURSOR: return intern ("hbar");
926 case bar: return intern ("bar"); 925 case BAR_CURSOR: return intern ("bar");
927 case no_highlight: 926 case NO_CURSOR:
928 default: return intern ("no"); 927 default: return intern ("no");
929 } 928 }
930} 929}
931 930
diff --git a/src/nsterm.h b/src/nsterm.h
index e3a3478e713..30d39dc40ae 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -383,16 +383,6 @@ typedef unsigned long NSUInteger;
383 383
384 ========================================================================== */ 384 ========================================================================== */
385 385
386enum ns_cursor_types
387{
388 no_highlight =0,
389 filled_box,
390 hollow_box,
391 underscore,
392 bar
393};
394
395
396/* could use list to store these, but rest of emacs has a big infrastructure 386/* could use list to store these, but rest of emacs has a big infrastructure
397 for managing a table of bitmap "records" */ 387 for managing a table of bitmap "records" */
398struct ns_bitmap_record 388struct ns_bitmap_record
@@ -560,16 +550,14 @@ struct ns_output
560#ifdef __OBJC__ 550#ifdef __OBJC__
561 EmacsView *view; 551 EmacsView *view;
562 id miniimage; 552 id miniimage;
563 NSColor *current_cursor_color; 553 NSColor *cursor_color;
564 NSColor *desired_cursor_color;
565 NSColor *foreground_color; 554 NSColor *foreground_color;
566 NSColor *background_color; 555 NSColor *background_color;
567 EmacsToolbar *toolbar; 556 EmacsToolbar *toolbar;
568#else 557#else
569 void *view; 558 void *view;
570 void *miniimage; 559 void *miniimage;
571 void *current_cursor_color; 560 void *cursor_color;
572 void *desired_cursor_color;
573 void *foreground_color; 561 void *foreground_color;
574 void *background_color; 562 void *background_color;
575 void *toolbar; 563 void *toolbar;
@@ -599,8 +587,6 @@ struct ns_output
599 587
600 Lisp_Object icon_top; 588 Lisp_Object icon_top;
601 Lisp_Object icon_left; 589 Lisp_Object icon_left;
602 enum ns_cursor_types current_cursor, desired_cursor;
603 unsigned char last_inactive;
604 590
605 /* The size of the extra width currently allotted for vertical 591 /* The size of the extra width currently allotted for vertical
606 scroll bars, in pixels. */ 592 scroll bars, in pixels. */
@@ -656,12 +642,8 @@ struct x_output
656#define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID) 642#define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
657 643
658#define FRAME_NS_VIEW(f) ((f)->output_data.ns->view) 644#define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
659#define FRAME_CURSOR(f) ((f)->output_data.ns->current_cursor) 645#define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
660#define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->current_cursor_color)
661#define FRAME_NEW_CURSOR_COLOR(f) ((f)->output_data.ns->desired_cursor_color)
662#define FRAME_NEW_CURSOR(f) ((f)->output_data.ns->desired_cursor)
663#define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer) 646#define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
664#define FRAME_LAST_INACTIVE(f) ((f)->output_data.ns->last_inactive)
665 647
666#define FRAME_FONT(f) ((f)->output_data.ns->font) 648#define FRAME_FONT(f) ((f)->output_data.ns->font)
667 649
diff --git a/src/nsterm.m b/src/nsterm.m
index 202f4a2d306..78d0ba1dfbc 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -547,7 +547,6 @@ ns_update_begin (struct frame *f)
547{ 547{
548 NSView *view = FRAME_NS_VIEW (f); 548 NSView *view = FRAME_NS_VIEW (f);
549 NSTRACE (ns_update_begin); 549 NSTRACE (ns_update_begin);
550/*fprintf (stderr, "\\%p\n", f); */
551 550
552 ns_updating_frame = f; 551 ns_updating_frame = f;
553 [view lockFocus]; 552 [view lockFocus];
@@ -683,7 +682,7 @@ ns_focus (struct frame *f, NSRect *r, int n)
683 the entire window. 682 the entire window.
684 -------------------------------------------------------------------------- */ 683 -------------------------------------------------------------------------- */
685{ 684{
686 NSTRACE (ns_focus); 685// NSTRACE (ns_focus);
687#ifdef NS_IMPL_GNUSTEP 686#ifdef NS_IMPL_GNUSTEP
688 NSRect u; 687 NSRect u;
689 if (n == 2) 688 if (n == 2)
@@ -756,7 +755,7 @@ ns_unfocus (struct frame *f)
756 Internal: Remove focus on given frame 755 Internal: Remove focus on given frame
757 -------------------------------------------------------------------------- */ 756 -------------------------------------------------------------------------- */
758{ 757{
759 NSTRACE (ns_unfocus); 758// NSTRACE (ns_unfocus);
760 759
761 if (gsaved) 760 if (gsaved)
762 { 761 {
@@ -957,17 +956,10 @@ ns_frame_rehighlight (struct frame *frame)
957 if (dpyinfo->x_highlight_frame && 956 if (dpyinfo->x_highlight_frame &&
958 dpyinfo->x_highlight_frame != old_highlight) 957 dpyinfo->x_highlight_frame != old_highlight)
959 { 958 {
960 /* as of 20080602 the lower and raise are superfluous */
961 if (old_highlight) 959 if (old_highlight)
962 {
963 /*ns_lower_frame (old_highlight); */
964 x_update_cursor (old_highlight, 1); 960 x_update_cursor (old_highlight, 1);
965 }
966 if (dpyinfo->x_highlight_frame) 961 if (dpyinfo->x_highlight_frame)
967 {
968 /*ns_raise_frame (dpyinfo->x_highlight_frame); */
969 x_update_cursor (dpyinfo->x_highlight_frame, 1); 962 x_update_cursor (dpyinfo->x_highlight_frame, 1);
970 }
971 } 963 }
972} 964}
973 965
@@ -1227,12 +1219,14 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
1227} 1219}
1228 1220
1229 1221
1222
1230/* ========================================================================== 1223/* ==========================================================================
1231 1224
1232 Color management 1225 Color management
1233 1226
1234 ========================================================================== */ 1227 ========================================================================== */
1235 1228
1229
1236NSColor * 1230NSColor *
1237ns_lookup_indexed_color (unsigned long idx, struct frame *f) 1231ns_lookup_indexed_color (unsigned long idx, struct frame *f)
1238{ 1232{
@@ -1665,7 +1659,7 @@ note_mouse_movement (struct frame *frame, float x, float y)
1665 known as last_mouse_glyph. 1659 known as last_mouse_glyph.
1666 ------------------------------------------------------------------------ */ 1660 ------------------------------------------------------------------------ */
1667{ 1661{
1668 NSTRACE (note_mouse_movement); 1662// NSTRACE (note_mouse_movement);
1669 1663
1670 XSETFRAME (last_mouse_motion_frame, frame); 1664 XSETFRAME (last_mouse_motion_frame, frame);
1671 1665
@@ -1928,6 +1922,8 @@ ns_clear_frame_area (struct frame *f, int x, int y, int width, int height)
1928 if (!view || !face) 1922 if (!view || !face)
1929 return; 1923 return;
1930 1924
1925 NSTRACE (ns_clear_frame_area);
1926
1931 r = NSIntersectionRect (r, [view frame]); 1927 r = NSIntersectionRect (r, [view frame]);
1932 ns_focus (f, &r, 1); 1928 ns_focus (f, &r, 1);
1933 [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), f) set]; 1929 [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), f) set];
@@ -2262,31 +2258,22 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2262 int on_p, int active_p) 2258 int on_p, int active_p)
2263/* -------------------------------------------------------------------------- 2259/* --------------------------------------------------------------------------
2264 External call (RIF): draw cursor 2260 External call (RIF): draw cursor
2265 (modeled after x_draw_window_cursor and erase_phys_cursor. 2261 (modeled after x_draw_window_cursor
2266 FIXME: erase_phys_cursor is called from display_and_set_cursor, 2262 FIXME: cursor_width is effectively bogus -- it sometimes gets set
2267 called from update_window_cursor/x_update_window_end/... 2263 in xdisp.c set_frame_cursor_types, sometimes left uninitialized;
2268 Why do we have to duplicate this code? 2264 DON'T USE IT (no other terms do)
2269 -------------------------------------------------------------------------- */ 2265 -------------------------------------------------------------------------- */
2270{ 2266{
2271 NSRect r, s; 2267 NSRect r, s;
2272 int fx, fy, h; 2268 int fx, fy, h;
2273 struct frame *f = WINDOW_XFRAME (w); 2269 struct frame *f = WINDOW_XFRAME (w);
2274 struct glyph *phys_cursor_glyph; 2270 struct glyph *phys_cursor_glyph;
2275 int overspill; 2271 int overspill, cursorToDraw;
2276 char drawGlyph = 0, cursorType, oldCursorType;
2277 int new_cursor_type;
2278 int new_cursor_width;
2279 int active_cursor;
2280 enum draw_glyphs_face hl;
2281 struct glyph_matrix *active_glyphs = w->current_matrix;
2282 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
2283 int hpos = w->phys_cursor.hpos;
2284 int vpos = w->phys_cursor.vpos;
2285 struct glyph_row *cursor_row;
2286 2272
2287 NSTRACE (dumpcursor); 2273 NSTRACE (dumpcursor);
2274//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);
2288 2275
2289 if (!on_p) // check this? && !w->phys_cursor_on_p) 2276 if (!on_p)
2290 return; 2277 return;
2291 2278
2292 w->phys_cursor_type = cursor_type; 2279 w->phys_cursor_type = cursor_type;
@@ -2294,7 +2281,6 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2294 2281
2295 if (cursor_type == NO_CURSOR) 2282 if (cursor_type == NO_CURSOR)
2296 { 2283 {
2297 w->phys_cursor_on_p = 0;
2298 w->phys_cursor_width = 0; 2284 w->phys_cursor_width = 0;
2299 return; 2285 return;
2300 } 2286 }
@@ -2324,151 +2310,51 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2324 if (overspill > 0) 2310 if (overspill > 0)
2325 r.size.width -= overspill; 2311 r.size.width -= overspill;
2326 2312
2327 oldCursorType = FRAME_CURSOR (f);
2328 cursorType = FRAME_CURSOR (f) = FRAME_NEW_CURSOR (f);
2329 /* TODO: 23: use emacs stored cursor color instead of ns-specific */
2330 f->output_data.ns->current_cursor_color
2331 = f->output_data.ns->desired_cursor_color;
2332
2333 /* TODO: only needed in rare cases with last-resort font in HELLO.. 2313 /* TODO: only needed in rare cases with last-resort font in HELLO..
2334 should we do this more efficiently? */ 2314 should we do this more efficiently? */
2335 ns_clip_to_row (w, glyph_row, -1, NO); 2315 ns_clip_to_row (w, glyph_row, -1, NO); /* do ns_focus(f, &r, 1); if remove */
2336/* ns_focus (f, &r, 1); */ 2316 [FRAME_CURSOR_COLOR (f) set];
2337 2317
2338 /* Why would this be needed? 2318#ifdef NS_IMPL_COCOA
2339 if (FRAME_LAST_INACTIVE (f)) 2319 /* TODO: This makes drawing of cursor plus that of phys_cursor_glyph
2340 { 2320 atomic. Cleaner ways of doing this should be investigated.
2341 * previously hollow box; clear entire area * 2321 One way would be to set a global variable DRAWING_CURSOR
2342 [FRAME_BACKGROUND_COLOR (f) set]; 2322 when making the call to draw_phys..(), don't focus in that
2343 NSRectFill (r); 2323 case, then move the ns_unfocus() here after that call. */
2344 drawGlyph = 1; 2324 NSDisableScreenUpdates ();
2345 FRAME_LAST_INACTIVE (f) = NO; 2325#endif
2346 }
2347 */
2348 2326
2349 /* prepare to draw */ 2327 cursorToDraw = active_p ? cursor_type : HOLLOW_BOX_CURSOR;
2350 if (cursorType == no_highlight || cursor_type == NO_CURSOR) 2328 switch (cursorToDraw)
2351 { 2329 {
2352 /* clearing for blink: erase the cursor itself */ 2330 case NO_CURSOR:
2353 2331 break;
2354 /* No cursor displayed or row invalidated => nothing to do on the 2332 case FILLED_BOX_CURSOR:
2355 screen. */ 2333 NSRectFill (r);
2356 if (w->phys_cursor_type == NO_CURSOR) 2334 break;
2357 return; 2335 case HOLLOW_BOX_CURSOR:
2358 2336 NSRectFill (r);
2359 /* VPOS >= active_glyphs->nrows means that window has been resized.
2360 Don't bother to erase the cursor. */
2361 if (vpos >= active_glyphs->nrows)
2362 return;
2363
2364 /* If row containing cursor is marked invalid, there is nothing we
2365 can do. */
2366 cursor_row = MATRIX_ROW (active_glyphs, vpos);
2367 if (!cursor_row->enabled_p)
2368 return;
2369
2370 /* If line spacing is > 0, old cursor may only be partially visible in
2371 window after split-window. So adjust visible height. */
2372 cursor_row->visible_height = min (cursor_row->visible_height,
2373 window_text_bottom_y (w) - cursor_row->y);
2374
2375 /* If row is completely invisible, don't attempt to delete a cursor which
2376 isn't there. This can happen if cursor is at top of a window, and
2377 we switch to a buffer with a header line in that window. */
2378 if (cursor_row->visible_height <= 0)
2379 return;
2380
2381 /* If cursor is in the fringe, erase by drawing actual bitmap there. */
2382 if (cursor_row->cursor_in_fringe_p)
2383 {
2384 cursor_row->cursor_in_fringe_p = 0;
2385 draw_fringe_bitmap (w, cursor_row, 0);
2386 return;
2387 }
2388
2389 /* This can happen when the new row is shorter than the old one.
2390 In this case, either draw_glyphs or clear_end_of_line
2391 should have cleared the cursor. Note that we wouldn't be
2392 able to erase the cursor in this case because we don't have a
2393 cursor glyph at hand. */
2394 if (w->phys_cursor.hpos >= cursor_row->used[TEXT_AREA])
2395 return;
2396
2397 /* If the cursor is in the mouse face area, redisplay that when
2398 we clear the cursor. */
2399 if (! NILP (dpyinfo->mouse_face_window)
2400 && w == XWINDOW (dpyinfo->mouse_face_window)
2401 && (vpos > dpyinfo->mouse_face_beg_row
2402 || (vpos == dpyinfo->mouse_face_beg_row
2403 && hpos >= dpyinfo->mouse_face_beg_col))
2404 && (vpos < dpyinfo->mouse_face_end_row
2405 || (vpos == dpyinfo->mouse_face_end_row
2406 && hpos < dpyinfo->mouse_face_end_col))
2407 /* Don't redraw the cursor's spot in mouse face if it is at the
2408 end of a line (on a newline). The cursor appears there, but
2409 mouse highlighting does not. */
2410 && cursor_row->used[TEXT_AREA] > hpos)
2411 hl = DRAW_MOUSE_FACE;
2412 else
2413 hl = DRAW_NORMAL_TEXT;
2414 drawGlyph = 1; // just draw the Glyph
2415 [FRAME_BACKGROUND_COLOR (f) set]; 2337 [FRAME_BACKGROUND_COLOR (f) set];
2416 2338 NSRectFill (NSInsetRect (r, 1, 1));
2417#ifdef NS_IMPL_COCOA
2418 NSDisableScreenUpdates ();
2419#endif
2420 }
2421 else
2422 {
2423 cursorType = cursor_type;
2424 hl = DRAW_CURSOR;
2425 [FRAME_CURSOR_COLOR (f) set]; 2339 [FRAME_CURSOR_COLOR (f) set];
2426 2340 break;
2427 2341 case HBAR_CURSOR:
2428 if (!active_p) 2342 s = r;
2429 { 2343 s.origin.y += lrint (0.75 * s.size.height);
2430 /* inactive window: ignore what we just set and use a hollow box */ 2344 s.size.height = lrint (s.size.height * 0.25);
2431 cursorType = HOLLOW_BOX_CURSOR; 2345 NSRectFill (s);
2432 } 2346 break;
2433 2347 case BAR_CURSOR:
2434#ifdef NS_IMPL_COCOA 2348 s = r;
2435 NSDisableScreenUpdates (); 2349 s.size.width = min (cursor_width, 2); //FIXME(see above)
2436#endif 2350 NSRectFill (s);
2437 2351 break;
2438 switch (cursorType)
2439 {
2440 case NO_CURSOR: // no_highlight:
2441 break;
2442 case FILLED_BOX_CURSOR: //filled_box:
2443 NSRectFill (r);
2444 drawGlyph = 1;
2445 break;
2446 case HOLLOW_BOX_CURSOR: //hollow_box:
2447 NSRectFill (r);
2448 [FRAME_BACKGROUND_COLOR (f) set];
2449 NSRectFill (NSInsetRect (r, 1, 1));
2450 [FRAME_CURSOR_COLOR (f) set];
2451 drawGlyph = 1;
2452 break;
2453 case HBAR_CURSOR: // underscore:
2454 s = r;
2455 s.origin.y += lrint (0.75 * s.size.height);
2456 s.size.height = cursor_width; //lrint (s.size.height * 0.25);
2457 NSRectFill (s);
2458 break;
2459 case BAR_CURSOR: //bar:
2460 s = r;
2461 s.size.width = cursor_width;
2462 NSRectFill (s);
2463 drawGlyph = 1;
2464 break;
2465 }
2466 } 2352 }
2467 ns_unfocus (f); 2353 ns_unfocus (f);
2468 2354
2469 /* if needed, draw the character under the cursor */ 2355 /* draw the character under the cursor */
2470 if (drawGlyph) 2356 if (cursorToDraw != NO_CURSOR)
2471 draw_phys_cursor_glyph (w, glyph_row, hl); 2357 draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
2472 2358
2473#ifdef NS_IMPL_COCOA 2359#ifdef NS_IMPL_COCOA
2474 NSEnableScreenUpdates (); 2360 NSEnableScreenUpdates ();
@@ -2487,6 +2373,8 @@ ns_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
2487 struct face *face; 2373 struct face *face;
2488 NSRect r = NSMakeRect (x, y0, 2, y1-y0); 2374 NSRect r = NSMakeRect (x, y0, 2, y1-y0);
2489 2375
2376 NSTRACE (ns_draw_vertical_window_border);
2377
2490 face = FACE_FROM_ID (f, VERTICAL_BORDER_FACE_ID); 2378 face = FACE_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
2491 if (face) 2379 if (face)
2492 [ns_lookup_indexed_color(face->foreground, f) set]; 2380 [ns_lookup_indexed_color(face->foreground, f) set];
@@ -2935,7 +2823,7 @@ ns_draw_glyph_string (struct glyph_string *s)
2935 2823
2936 NSTRACE (ns_draw_glyph_string); 2824 NSTRACE (ns_draw_glyph_string);
2937 2825
2938 if (s->next && s->right_overhang && !s->for_overlaps/* && s->hl != DRAW_CURSOR*/) 2826 if (s->next && s->right_overhang && !s->for_overlaps/*&&s->hl!=DRAW_CURSOR*/)
2939 { 2827 {
2940 int width; 2828 int width;
2941 struct glyph_string *next; 2829 struct glyph_string *next;
@@ -4376,6 +4264,8 @@ extern void update_window_cursor (struct window *w, int on);
4376 if (newFont = [sender convertFont: 4264 if (newFont = [sender convertFont:
4377 ((struct nsfont_info *)face->font)->nsfont]) 4265 ((struct nsfont_info *)face->font)->nsfont])
4378 { 4266 {
4267 SET_FRAME_GARBAGED (emacsframe); /* now needed as of 2008/10 */
4268
4379 emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT; 4269 emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
4380 emacs_event->modifiers = 0; 4270 emacs_event->modifiers = 0;
4381 emacs_event->code = KEY_NS_CHANGE_FONT; 4271 emacs_event->code = KEY_NS_CHANGE_FONT;
@@ -4853,7 +4743,7 @@ if (NS_KEYLOG) NSLog (@"attributedSubstringFromRange request");
4853 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe); 4743 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe);
4854 Lisp_Object frame; 4744 Lisp_Object frame;
4855 4745
4856 NSTRACE (mouseMoved); 4746// NSTRACE (mouseMoved);
4857 4747
4858 last_mouse_movement_time = EV_TIMESTAMP (e); 4748 last_mouse_movement_time = EV_TIMESTAMP (e);
4859 last_mouse_motion_position 4749 last_mouse_motion_position
@@ -5031,8 +4921,8 @@ if (NS_KEYLOG) NSLog (@"attributedSubstringFromRange request");
5031 4921
5032 4922
5033- (void)windowDidBecomeKey: (NSNotification *)notification 4923- (void)windowDidBecomeKey: (NSNotification *)notification
4924/* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */
5034{ 4925{
5035 int val = ns_lisp_to_cursor_type (get_frame_param (emacsframe, Qcursor_type));
5036 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe); 4926 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe);
5037 struct frame *old_focus = dpyinfo->x_focus_frame; 4927 struct frame *old_focus = dpyinfo->x_focus_frame;
5038 4928
@@ -5041,14 +4931,6 @@ if (NS_KEYLOG) NSLog (@"attributedSubstringFromRange request");
5041 if (emacsframe != old_focus) 4931 if (emacsframe != old_focus)
5042 dpyinfo->x_focus_frame = emacsframe; 4932 dpyinfo->x_focus_frame = emacsframe;
5043 4933
5044 /*/last_mouse_frame = emacsframe;? */
5045
5046 if (val >= 0)
5047 {
5048 FRAME_NEW_CURSOR (emacsframe) = val;
5049/* x_update_cursor (emacsframe, 1); // will happen in ns_frame_rehighlight */
5050 }
5051
5052 ns_frame_rehighlight (emacsframe); 4934 ns_frame_rehighlight (emacsframe);
5053 4935
5054 if (emacs_event) 4936 if (emacs_event)
@@ -5060,27 +4942,20 @@ if (NS_KEYLOG) NSLog (@"attributedSubstringFromRange request");
5060 4942
5061 4943
5062- (void)windowDidResignKey: (NSNotification *)notification 4944- (void)windowDidResignKey: (NSNotification *)notification
4945/* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */
5063{ 4946{
5064 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe); 4947 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe);
5065 NSTRACE (windowDidResignKey); 4948 NSTRACE (windowDidResignKey);
5066 4949
5067 if (!windowClosing && [[self window] isVisible] == YES)
5068 {
5069 FRAME_NEW_CURSOR (emacsframe) = hollow_box;
5070 x_update_cursor (emacsframe, 1);
5071 FRAME_LAST_INACTIVE (emacsframe) = YES;
5072 }
5073
5074 if (dpyinfo->x_highlight_frame == emacsframe)
5075 dpyinfo->x_highlight_frame = 0;
5076 if (dpyinfo->x_focus_frame == emacsframe) 4950 if (dpyinfo->x_focus_frame == emacsframe)
5077 dpyinfo->x_focus_frame = 0; 4951 dpyinfo->x_focus_frame = 0;
5078 4952
5079 if (dpyinfo->mouse_face_mouse_frame == emacsframe) 4953 ns_frame_rehighlight (emacsframe);
5080 { 4954
5081 clear_mouse_face (dpyinfo); 4955 /* FIXME: for some reason needed on second and subsequent clicks away
5082 dpyinfo->mouse_face_mouse_frame = 0; 4956 from sole-frame Emacs to get hollow box to show */
5083 } 4957 if (!windowClosing && [[self window] isVisible] == YES)
4958 x_update_cursor (emacsframe, 1);
5084 4959
5085 if (emacs_event) 4960 if (emacs_event)
5086 { 4961 {
@@ -6084,9 +5959,9 @@ static void selectItemWithTag (NSPopUpButton *popup, int tag)
6084#endif 5959#endif
6085 5960
6086 [expandSpaceSlider setFloatValue: prevExpandSpace]; 5961 [expandSpaceSlider setFloatValue: prevExpandSpace];
6087 [cursorTypeMatrix selectCellWithTag: (cursorType == filled_box ? 1 : 5962 [cursorTypeMatrix selectCellWithTag: (cursorType == FILLED_BOX_CURSOR ? 1 :
6088 (cursorType == bar ? 2 : 5963 (cursorType == BAR_CURSOR ? 2 :
6089 (cursorType == underscore ? 3 : 4)))]; 5964 (cursorType == HBAR_CURSOR ? 3 : 4)))];
6090 selectItemWithTag (alternateModMenu, 5965 selectItemWithTag (alternateModMenu,
6091 parse_solitary_modifier (ns_alternate_modifier)); 5966 parse_solitary_modifier (ns_alternate_modifier));
6092 selectItemWithTag (commandModMenu, 5967 selectItemWithTag (commandModMenu,
@@ -6105,7 +5980,6 @@ static void selectItemWithTag (NSPopUpButton *popup, int tag)
6105 5980
6106- (void) setValuesFromPanel 5981- (void) setValuesFromPanel
6107{ 5982{
6108 int cursorTag = [[cursorTypeMatrix selectedCell] tag];
6109 int altTag = [[alternateModMenu selectedItem] tag]; 5983 int altTag = [[alternateModMenu selectedItem] tag];
6110 int cmdTag = [[commandModMenu selectedItem] tag]; 5984 int cmdTag = [[commandModMenu selectedItem] tag];
6111#ifdef NS_IMPL_COCOA 5985#ifdef NS_IMPL_COCOA
@@ -6113,6 +5987,11 @@ static void selectItemWithTag (NSPopUpButton *popup, int tag)
6113 int fnTag = [[functionModMenu selectedItem] tag]; 5987 int fnTag = [[functionModMenu selectedItem] tag];
6114#endif 5988#endif
6115 float expandSpace = [expandSpaceSlider floatValue]; 5989 float expandSpace = [expandSpaceSlider floatValue];
5990 int cursorTag = [[cursorTypeMatrix selectedCell] tag];
5991 Lisp_Object cursor_type = ns_cursor_type_to_lisp
5992 ( cursorTag == 1 ? FILLED_BOX_CURSOR
5993 : cursorTag == 2 ? BAR_CURSOR
5994 : cursorTag == 3 ? HBAR_CURSOR : HOLLOW_BOX_CURSOR);
6116 5995
6117 if (expandSpace != prevExpandSpace) 5996 if (expandSpace != prevExpandSpace)
6118 { 5997 {
@@ -6123,12 +6002,10 @@ static void selectItemWithTag (NSPopUpButton *popup, int tag)
6123 x_set_window_size (frame, 0, frame->text_cols, frame->text_lines); */ 6002 x_set_window_size (frame, 0, frame->text_cols, frame->text_lines); */
6124 prevExpandSpace = expandSpace; 6003 prevExpandSpace = expandSpace;
6125 } 6004 }
6126 FRAME_NEW_CURSOR (frame) 6005
6127 = (cursorTag == 1 ? filled_box 6006 store_frame_param (frame, Qcursor_type, cursor_type);
6128 : cursorTag == 2 ? bar 6007 ns_set_cursor_type(frame, cursor_type, Qnil); /* FIXME: do only if changed */
6129 : cursorTag == 3 ? underscore : hollow_box); 6008
6130 store_frame_param (frame, Qcursor_type,
6131 ns_cursor_type_to_lisp (FRAME_NEW_CURSOR (frame)));
6132 ns_alternate_modifier = ns_mod_to_lisp (altTag); 6009 ns_alternate_modifier = ns_mod_to_lisp (altTag);
6133 ns_command_modifier = ns_mod_to_lisp (cmdTag); 6010 ns_command_modifier = ns_mod_to_lisp (cmdTag);
6134#ifdef NS_IMPL_COCOA 6011#ifdef NS_IMPL_COCOA
diff --git a/src/xdisp.c b/src/xdisp.c
index 79988829ed7..32ad1fd1217 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -20503,6 +20503,9 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
20503 for (s = head; s; s = s->next) 20503 for (s = head; s; s = s->next)
20504 FRAME_RIF (f)->draw_glyph_string (s); 20504 FRAME_RIF (f)->draw_glyph_string (s);
20505 20505
20506#ifndef HAVE_NS
20507 /* When focus a sole frame and move horizontally, this sets on_p to 0
20508 causing a failure to erase prev cursor position. */
20506 if (area == TEXT_AREA 20509 if (area == TEXT_AREA
20507 && !row->full_width_p 20510 && !row->full_width_p
20508 /* When drawing overlapping rows, only the glyph strings' 20511 /* When drawing overlapping rows, only the glyph strings'
@@ -20519,6 +20522,7 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
20519 notice_overwritten_cursor (w, TEXT_AREA, x0, x1, 20522 notice_overwritten_cursor (w, TEXT_AREA, x0, x1,
20520 row->y, MATRIX_ROW_BOTTOM_Y (row)); 20523 row->y, MATRIX_ROW_BOTTOM_Y (row));
20521 } 20524 }
20525#endif
20522 20526
20523 /* Value is the x-position up to which drawn, relative to AREA of W. 20527 /* Value is the x-position up to which drawn, relative to AREA of W.
20524 This doesn't include parts drawn because of overhangs. */ 20528 This doesn't include parts drawn because of overhangs. */