diff options
| author | Jan Djärv | 2010-12-30 12:30:55 +0100 |
|---|---|---|
| committer | Jan Djärv | 2010-12-30 12:30:55 +0100 |
| commit | 5bbb4727aa8adca6e1dac35dd7c1ed21ffd24e02 (patch) | |
| tree | 7dea21b2e4113414229b1be1d88debd640370f04 /src | |
| parent | b191c9d952321d72a39937847eabb8ff492cbde0 (diff) | |
| download | emacs-5bbb4727aa8adca6e1dac35dd7c1ed21ffd24e02.tar.gz emacs-5bbb4727aa8adca6e1dac35dd7c1ed21ffd24e02.zip | |
Encode frame title and icon name before setting.
* coding.h (ENCODE_UTF_8): Remove "Used by ..." comment.
* nsfns.m (ns_set_name_iconic): Remove.
(ns_set_name_internal): New function.
(Vicon_title_format): Extern declare.
(ns_set_name): Call ns_set_name_internal.
(x_explicitly_set_name): Remove call to ns_set_name_iconic.
(x_implicitly_set_name): Ditto.
(x_set_title): Remove commet about EXPLICIT. Call ns_set_name_internal.
(ns_set_name_as_filename): Encode name with ENCODE_UTF_8 (Bug#7517).
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/coding.h | 3 | ||||
| -rw-r--r-- | src/nsfns.m | 114 |
3 files changed, 63 insertions, 67 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 446a00c7f75..fca0b104f8c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2010-12-30 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * coding.h (ENCODE_UTF_8): Remove "Used by ..." comment. | ||
| 4 | |||
| 5 | * nsfns.m (ns_set_name_iconic): Remove. | ||
| 6 | (ns_set_name_internal): New function (Bug#7517). | ||
| 7 | (Vicon_title_format): Extern declare. | ||
| 8 | (ns_set_name): Call ns_set_name_internal. | ||
| 9 | (x_explicitly_set_name): Remove call to ns_set_name_iconic. | ||
| 10 | (x_implicitly_set_name): Ditto. | ||
| 11 | (x_set_title): Remove commet about EXPLICIT. Call ns_set_name_internal. | ||
| 12 | (ns_set_name_as_filename): Encode name with ENCODE_UTF_8 (Bug#7517). | ||
| 13 | |||
| 1 | 2010-12-29 Štěpán Němec <stepnem@gmail.com> (tiny change) | 14 | 2010-12-29 Štěpán Němec <stepnem@gmail.com> (tiny change) |
| 2 | 15 | ||
| 3 | * window.c (syms_of_window): Add missing defsubr for | 16 | * window.c (syms_of_window): Add missing defsubr for |
diff --git a/src/coding.h b/src/coding.h index 7233726a250..a69f3c938fb 100644 --- a/src/coding.h +++ b/src/coding.h | |||
| @@ -686,8 +686,7 @@ struct coding_system | |||
| 686 | ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \ | 686 | ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \ |
| 687 | : str) | 687 | : str) |
| 688 | 688 | ||
| 689 | /* Used by the gtk menu code. Note that this encodes utf-8, not | 689 | /* Note that this encodes utf-8, not utf-8-emacs, so it's not a no-op. */ |
| 690 | utf-8-emacs, so it's not a no-op. */ | ||
| 691 | #define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1) | 690 | #define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1) |
| 692 | 691 | ||
| 693 | /* Extern declarations. */ | 692 | /* Extern declarations. */ |
diff --git a/src/nsfns.m b/src/nsfns.m index 0b105ab6ff1..1b467297651 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -82,7 +82,7 @@ extern Lisp_Object Qunderline, Qundefined; | |||
| 82 | extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth; | 82 | extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth; |
| 83 | extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle; | 83 | extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle; |
| 84 | extern Lisp_Object Qnone; | 84 | extern Lisp_Object Qnone; |
| 85 | extern Lisp_Object Vframe_title_format; | 85 | extern Lisp_Object Vframe_title_format, Vicon_title_format; |
| 86 | 86 | ||
| 87 | /* The below are defined in frame.c. */ | 87 | /* The below are defined in frame.c. */ |
| 88 | 88 | ||
| @@ -473,55 +473,37 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 473 | [NSString stringWithUTF8String: SDATA (arg)]]; | 473 | [NSString stringWithUTF8String: SDATA (arg)]]; |
| 474 | } | 474 | } |
| 475 | 475 | ||
| 476 | |||
| 477 | static void | 476 | static void |
| 478 | ns_set_name_iconic (struct frame *f, Lisp_Object name, int explicit) | 477 | ns_set_name_internal (FRAME_PTR f, Lisp_Object name) |
| 479 | { | 478 | { |
| 479 | struct gcpro gcpro1; | ||
| 480 | Lisp_Object encoded_name, encoded_icon_name; | ||
| 481 | NSString *str; | ||
| 480 | NSView *view = FRAME_NS_VIEW (f); | 482 | NSView *view = FRAME_NS_VIEW (f); |
| 481 | NSTRACE (ns_set_name_iconic); | ||
| 482 | |||
| 483 | if (ns_in_resize) | ||
| 484 | return; | ||
| 485 | |||
| 486 | /* Make sure that requests from lisp code override requests from | ||
| 487 | Emacs redisplay code. */ | ||
| 488 | if (explicit) | ||
| 489 | { | ||
| 490 | /* If we're switching from explicit to implicit, we had better | ||
| 491 | update the mode lines and thereby update the title. */ | ||
| 492 | if (f->explicit_name && NILP (name)) | ||
| 493 | update_mode_lines = 1; | ||
| 494 | 483 | ||
| 495 | f->explicit_name = ! NILP (name); | 484 | GCPRO1 (name); |
| 496 | } | 485 | encoded_name = ENCODE_UTF_8 (name); |
| 497 | else if (f->explicit_name) | 486 | UNGCPRO; |
| 498 | name = f->name; | ||
| 499 | 487 | ||
| 500 | /* title overrides explicit name */ | 488 | str = [NSString stringWithUTF8String: SDATA (encoded_name)]; |
| 501 | if (! NILP (f->title)) | ||
| 502 | name = f->title; | ||
| 503 | 489 | ||
| 504 | /* icon_name overrides title and explicit name */ | 490 | /* Don't change the name if it's already NAME. */ |
| 505 | if (! NILP (f->icon_name)) | 491 | if (! [[[view window] title] isEqualToString: str]) |
| 506 | name = f->icon_name; | 492 | [[view window] setTitle: str]; |
| 507 | 493 | ||
| 508 | if (NILP (name)) | 494 | if (!STRINGP (f->icon_name)) |
| 509 | name = build_string([ns_app_name UTF8String]); | 495 | encoded_icon_name = encoded_name; |
| 510 | else | 496 | else |
| 511 | CHECK_STRING (name); | 497 | encoded_icon_name = ENCODE_UTF_8 (f->icon_name); |
| 498 | |||
| 499 | str = [NSString stringWithUTF8String: SDATA (encoded_icon_name)]; | ||
| 512 | 500 | ||
| 513 | /* Don't change the name if it's already NAME. */ | ||
| 514 | if ([[view window] miniwindowTitle] && | 501 | if ([[view window] miniwindowTitle] && |
| 515 | ([[[view window] miniwindowTitle] | 502 | ! [[[view window] miniwindowTitle] isEqualToString: str]) |
| 516 | isEqualToString: [NSString stringWithUTF8String: | 503 | [[view window] setMiniwindowTitle: str]; |
| 517 | SDATA (name)]])) | ||
| 518 | return; | ||
| 519 | 504 | ||
| 520 | [[view window] setMiniwindowTitle: | ||
| 521 | [NSString stringWithUTF8String: SDATA (name)]]; | ||
| 522 | } | 505 | } |
| 523 | 506 | ||
| 524 | |||
| 525 | static void | 507 | static void |
| 526 | ns_set_name (struct frame *f, Lisp_Object name, int explicit) | 508 | ns_set_name (struct frame *f, Lisp_Object name, int explicit) |
| 527 | { | 509 | { |
| @@ -547,6 +529,12 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit) | |||
| 547 | 529 | ||
| 548 | if (NILP (name)) | 530 | if (NILP (name)) |
| 549 | name = build_string([ns_app_name UTF8String]); | 531 | name = build_string([ns_app_name UTF8String]); |
| 532 | else | ||
| 533 | CHECK_STRING (name); | ||
| 534 | |||
| 535 | /* Don't change the name if it's already NAME. */ | ||
| 536 | if (! NILP (Fstring_equal (name, f->name))) | ||
| 537 | return; | ||
| 550 | 538 | ||
| 551 | f->name = name; | 539 | f->name = name; |
| 552 | 540 | ||
| @@ -554,17 +542,7 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit) | |||
| 554 | if (! NILP (f->title)) | 542 | if (! NILP (f->title)) |
| 555 | name = f->title; | 543 | name = f->title; |
| 556 | 544 | ||
| 557 | CHECK_STRING (name); | 545 | ns_set_name_internal (f, name); |
| 558 | |||
| 559 | view = FRAME_NS_VIEW (f); | ||
| 560 | |||
| 561 | /* Don't change the name if it's already NAME. */ | ||
| 562 | if ([[[view window] title] | ||
| 563 | isEqualToString: [NSString stringWithUTF8String: | ||
| 564 | SDATA (name)]]) | ||
| 565 | return; | ||
| 566 | [[view window] setTitle: [NSString stringWithUTF8String: | ||
| 567 | SDATA (name)]]; | ||
| 568 | } | 546 | } |
| 569 | 547 | ||
| 570 | 548 | ||
| @@ -575,7 +553,6 @@ static void | |||
| 575 | x_explicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) | 553 | x_explicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) |
| 576 | { | 554 | { |
| 577 | NSTRACE (x_explicitly_set_name); | 555 | NSTRACE (x_explicitly_set_name); |
| 578 | ns_set_name_iconic (f, arg, 1); | ||
| 579 | ns_set_name (f, arg, 1); | 556 | ns_set_name (f, arg, 1); |
| 580 | } | 557 | } |
| 581 | 558 | ||
| @@ -587,9 +564,10 @@ void | |||
| 587 | x_implicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) | 564 | x_implicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) |
| 588 | { | 565 | { |
| 589 | NSTRACE (x_implicitly_set_name); | 566 | NSTRACE (x_implicitly_set_name); |
| 590 | if (FRAME_ICONIFIED_P (f)) | 567 | |
| 591 | ns_set_name_iconic (f, arg, 0); | 568 | /* Deal with NS specific format t. */ |
| 592 | else if (FRAME_NS_P (f) && EQ (Vframe_title_format, Qt)) | 569 | if (FRAME_NS_P (f) && ((FRAME_ICONIFIED_P (f) && EQ (Vicon_title_format, Qt)) |
| 570 | || EQ (Vframe_title_format, Qt))) | ||
| 593 | ns_set_name_as_filename (f); | 571 | ns_set_name_as_filename (f); |
| 594 | else | 572 | else |
| 595 | ns_set_name (f, arg, 0); | 573 | ns_set_name (f, arg, 0); |
| @@ -597,15 +575,8 @@ x_implicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) | |||
| 597 | 575 | ||
| 598 | 576 | ||
| 599 | /* Change the title of frame F to NAME. | 577 | /* Change the title of frame F to NAME. |
| 600 | If NAME is nil, use the frame name as the title. | 578 | If NAME is nil, use the frame name as the title. */ |
| 601 | |||
| 602 | If EXPLICIT is non-zero, that indicates that lisp code is setting the | ||
| 603 | name; if NAME is a string, set F's name to NAME and set | ||
| 604 | F->explicit_name; if NAME is Qnil, then clear F->explicit_name. | ||
| 605 | 579 | ||
| 606 | If EXPLICIT is zero, that indicates that Emacs redisplay code is | ||
| 607 | suggesting a new name, which lisp code should override; if | ||
| 608 | F->explicit_name is set, ignore the new name; otherwise, set it. */ | ||
| 609 | static void | 580 | static void |
| 610 | x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) | 581 | x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) |
| 611 | { | 582 | { |
| @@ -617,6 +588,13 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) | |||
| 617 | update_mode_lines = 1; | 588 | update_mode_lines = 1; |
| 618 | 589 | ||
| 619 | f->title = name; | 590 | f->title = name; |
| 591 | |||
| 592 | if (NILP (name)) | ||
| 593 | name = f->name; | ||
| 594 | else | ||
| 595 | CHECK_STRING (name); | ||
| 596 | |||
| 597 | ns_set_name_internal (f, name); | ||
| 620 | } | 598 | } |
| 621 | 599 | ||
| 622 | 600 | ||
| @@ -628,6 +606,8 @@ ns_set_name_as_filename (struct frame *f) | |||
| 628 | Lisp_Object buf = XWINDOW (f->selected_window)->buffer; | 606 | Lisp_Object buf = XWINDOW (f->selected_window)->buffer; |
| 629 | const char *title; | 607 | const char *title; |
| 630 | NSAutoreleasePool *pool; | 608 | NSAutoreleasePool *pool; |
| 609 | struct gcpro gcpro1; | ||
| 610 | Lisp_Object encoded_name; | ||
| 631 | NSTRACE (ns_set_name_as_filename); | 611 | NSTRACE (ns_set_name_as_filename); |
| 632 | 612 | ||
| 633 | if (f->explicit_name || ! NILP (f->title) || ns_in_resize) | 613 | if (f->explicit_name || ! NILP (f->title) || ns_in_resize) |
| @@ -636,7 +616,7 @@ ns_set_name_as_filename (struct frame *f) | |||
| 636 | BLOCK_INPUT; | 616 | BLOCK_INPUT; |
| 637 | pool = [[NSAutoreleasePool alloc] init]; | 617 | pool = [[NSAutoreleasePool alloc] init]; |
| 638 | name = XBUFFER (buf)->filename; | 618 | name = XBUFFER (buf)->filename; |
| 639 | if (NILP (name) || FRAME_ICONIFIED_P (f)) name =XBUFFER (buf)->name; | 619 | if (NILP (name) || FRAME_ICONIFIED_P (f)) name = XBUFFER (buf)->name; |
| 640 | 620 | ||
| 641 | if (FRAME_ICONIFIED_P (f) && !NILP (f->icon_name)) | 621 | if (FRAME_ICONIFIED_P (f) && !NILP (f->icon_name)) |
| 642 | name = f->icon_name; | 622 | name = f->icon_name; |
| @@ -646,12 +626,16 @@ ns_set_name_as_filename (struct frame *f) | |||
| 646 | else | 626 | else |
| 647 | CHECK_STRING (name); | 627 | CHECK_STRING (name); |
| 648 | 628 | ||
| 629 | GCPRO1 (name); | ||
| 630 | encoded_name = ENCODE_UTF_8 (name); | ||
| 631 | UNGCPRO; | ||
| 632 | |||
| 649 | view = FRAME_NS_VIEW (f); | 633 | view = FRAME_NS_VIEW (f); |
| 650 | 634 | ||
| 651 | title = FRAME_ICONIFIED_P (f) ? [[[view window] miniwindowTitle] UTF8String] | 635 | title = FRAME_ICONIFIED_P (f) ? [[[view window] miniwindowTitle] UTF8String] |
| 652 | : [[[view window] title] UTF8String]; | 636 | : [[[view window] title] UTF8String]; |
| 653 | 637 | ||
| 654 | if (title && (! strcmp (title, SDATA (name)))) | 638 | if (title && (! strcmp (title, SDATA (encoded_name)))) |
| 655 | { | 639 | { |
| 656 | [pool release]; | 640 | [pool release]; |
| 657 | UNBLOCK_INPUT; | 641 | UNBLOCK_INPUT; |
| @@ -664,7 +648,7 @@ ns_set_name_as_filename (struct frame *f) | |||
| 664 | /* work around a bug observed on 10.3 where | 648 | /* work around a bug observed on 10.3 where |
| 665 | setTitleWithRepresentedFilename does not clear out previous state | 649 | setTitleWithRepresentedFilename does not clear out previous state |
| 666 | if given filename does not exist */ | 650 | if given filename does not exist */ |
| 667 | NSString *str = [NSString stringWithUTF8String: SDATA (name)]; | 651 | NSString *str = [NSString stringWithUTF8String: SDATA (encoded_name)]; |
| 668 | if (![[NSFileManager defaultManager] fileExistsAtPath: str]) | 652 | if (![[NSFileManager defaultManager] fileExistsAtPath: str]) |
| 669 | { | 653 | { |
| 670 | [[view window] setTitleWithRepresentedFilename: @""]; | 654 | [[view window] setTitleWithRepresentedFilename: @""]; |
| @@ -676,14 +660,14 @@ ns_set_name_as_filename (struct frame *f) | |||
| 676 | } | 660 | } |
| 677 | #else | 661 | #else |
| 678 | [[view window] setTitleWithRepresentedFilename: | 662 | [[view window] setTitleWithRepresentedFilename: |
| 679 | [NSString stringWithUTF8String: SDATA (name)]]; | 663 | [NSString stringWithUTF8String: SDATA (encoded_name)]]; |
| 680 | #endif | 664 | #endif |
| 681 | f->name = name; | 665 | f->name = name; |
| 682 | } | 666 | } |
| 683 | else | 667 | else |
| 684 | { | 668 | { |
| 685 | [[view window] setMiniwindowTitle: | 669 | [[view window] setMiniwindowTitle: |
| 686 | [NSString stringWithUTF8String: SDATA (name)]]; | 670 | [NSString stringWithUTF8String: SDATA (encoded_name)]]; |
| 687 | } | 671 | } |
| 688 | [pool release]; | 672 | [pool release]; |
| 689 | UNBLOCK_INPUT; | 673 | UNBLOCK_INPUT; |