aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2004-09-06 07:53:44 +0000
committerKaroly Lorentey2004-09-06 07:53:44 +0000
commitd8d26438090eae0b8f518ad740ab4b821efdf540 (patch)
tree69762433ae6aac2547c033567707527a16045bf9 /src
parent5232b240359a0ee6b267e261607b80b6dc26859a (diff)
parentc28e534b74e2d25cb71cbb0bd33f7cc677300903 (diff)
downloademacs-d8d26438090eae0b8f518ad740ab4b821efdf540.tar.gz
emacs-d8d26438090eae0b8f518ad740ab4b821efdf540.zip
Merged in changes from CVS trunk.
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-521 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-522 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523 Merge from emacs--gnus--5.10, gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-524 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-525 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-526 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-527 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-528 Update from CVS * miles@gnu.org--gnu-2004/emacs--gnus--5.10--base-0 tag of miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-464 * miles@gnu.org--gnu-2004/emacs--gnus--5.10--patch-1 Import from CVS branch gnus-5_10-branch * miles@gnu.org--gnu-2004/emacs--gnus--5.10--patch-2 Merge from lorentey@elte.hu--2004/emacs--multi-tty--0, emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/emacs--gnus--5.10--patch-3 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--gnus--5.10--patch-4 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-18 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-19 Remove autoconf-generated files from archive * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-20 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-241
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog51
-rw-r--r--src/macfns.c49
-rw-r--r--src/macmenu.c6
-rw-r--r--src/macterm.c10
-rw-r--r--src/s/darwin.h17
-rw-r--r--src/w32menu.c198
-rw-r--r--src/xdisp.c77
-rw-r--r--src/xfns.c187
8 files changed, 388 insertions, 207 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 77a331a7802..8fd72a29c29 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,54 @@
12004-09-03 Jason Rumney <jasonr@gnu.org>
2
3 * w32menu.c (_widget_value): Added lname and lkey.
4 (digest_single_submenu): Set lname and lkey in widget_value
5 instead of name and key.
6 (update_submenu_strings): New function.
7 (set_frame_menubar): Remove call to inhibit_garbage_collection,
8 call update_submenu_strings.
9
10 * w32menu.c (globals_of_w32menu): Check for Unicode API.
11 (digest_single_submenu, w32_menu_show): Encode menu strings as
12 UTF-8 if Unicode API is available.
13 (utf8to16): New function.
14 (add_menu_item): Use it when calling Unicode API.
15
162004-09-03 Kim F. Storm <storm@cua.dk>
17
18 * xdisp.c (set_cursor_from_row): Look for non-nil `cursor' property
19 in overlay or text-property strings; set cursor on corresponding
20 glyph rather than at end of the string.
21
222004-09-02 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
23
24 * macfns.c (x_real_positions): Save the current window port and
25 set a new one before obtaining the global coordinate. Use
26 FRAME_MAC_WINDOW.
27 (x_set_name, x_set_title): Encode title to UTF8. Use
28 SetWindowTitleWithCFString.
29 (Fx_server_version): Get correct OS version.
30
31 * macmenu.c (add_menu_item): Remove unused variable `i'. Don't
32 let separator items destroy refence constants of other menu items.
33
34 * macterm.c (x_update_end): Move SetPortWindowPort to inside
35 BLOCK_INPUT.
36 (x_set_offset): Use FRAME_MAC_WINDOW.
37
38 * xdisp.c (note_mouse_highlight): Set the mouse pointer shape to
39 nontext_cursor if it is on a scroll bar.
40
41 * s/darwin.h (LIBS_CARBON): New define to specify libraries for
42 Carbon support.
43 (LD_SWITCH_SYSTEM_TEMACS): Don't link with unused libstdc++. Use
44 LIBS_CARBON.
45
462004-09-02 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
47
48 * xfns.c (x_set_name_internal): New function. Check if we shall call
49 xfree before ENCODE_UTF_8.
50 (x_set_name, x_set_title): Call x_set_name_internal.
51
12004-08-31 NAKAMURA Toshikazu <nr-tkz@nifty.com> (tiny change) 522004-08-31 NAKAMURA Toshikazu <nr-tkz@nifty.com> (tiny change)
2 53
3 * w32fns.c (w32_load_font): If a BDF font is already loaded, do not 54 * w32fns.c (w32_load_font): If a BDF font is already loaded, do not
diff --git a/src/macfns.c b/src/macfns.c
index fbade05ea17..3b09b344a55 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -324,19 +324,21 @@ x_real_positions (f, xptr, yptr)
324 Point pt; 324 Point pt;
325 GrafPtr oldport; 325 GrafPtr oldport;
326 326
327#ifdef TARGET_API_MAC_CARBON 327 GetPort (&oldport);
328 SetPortWindowPort (FRAME_MAC_WINDOW (f));
329
330#if TARGET_API_MAC_CARBON
328 { 331 {
329 Rect r; 332 Rect r;
330 333
331 GetWindowPortBounds (f->output_data.mac->mWP, &r); 334 GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);
332 SetPt (&pt, r.left, r.top); 335 SetPt (&pt, r.left, r.top);
333 } 336 }
334#else /* not TARGET_API_MAC_CARBON */ 337#else /* not TARGET_API_MAC_CARBON */
335 SetPt (&pt, 338 SetPt (&pt,
336 f->output_data.mac->mWP->portRect.left, 339 FRAME_MAC_WINDOW (f)->portRect.left,
337 f->output_data.mac->mWP->portRect.top); 340 FRAME_MAC_WINDOW (f)->portRect.top);
338#endif /* not TARGET_API_MAC_CARBON */ 341#endif /* not TARGET_API_MAC_CARBON */
339 GetPort (&oldport);
340 LocalToGlobal (&pt); 342 LocalToGlobal (&pt);
341 SetPort (oldport); 343 SetPort (oldport);
342 344
@@ -1934,8 +1936,8 @@ x_set_name (f, name, explicit)
1934 if (FRAME_MAC_WINDOW (f)) 1936 if (FRAME_MAC_WINDOW (f))
1935 { 1937 {
1936 if (STRING_MULTIBYTE (name)) 1938 if (STRING_MULTIBYTE (name))
1937#if 0 /* MAC_TODO: encoding title string */ 1939#if TARGET_API_MAC_CARBON
1938 name = ENCODE_SYSTEM (name); 1940 name = ENCODE_UTF_8 (name);
1939#else 1941#else
1940 return; 1942 return;
1941#endif 1943#endif
@@ -1943,6 +1945,14 @@ x_set_name (f, name, explicit)
1943 BLOCK_INPUT; 1945 BLOCK_INPUT;
1944 1946
1945 { 1947 {
1948#if TARGET_API_MAC_CARBON
1949 CFStringRef windowTitle =
1950 CFStringCreateWithCString (NULL, SDATA (name),
1951 kCFStringEncodingUTF8);
1952
1953 SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
1954 CFRelease (windowTitle);
1955#else
1946 Str255 windowTitle; 1956 Str255 windowTitle;
1947 if (strlen (SDATA (name)) < 255) 1957 if (strlen (SDATA (name)) < 255)
1948 { 1958 {
@@ -1950,6 +1960,7 @@ x_set_name (f, name, explicit)
1950 c2pstr (windowTitle); 1960 c2pstr (windowTitle);
1951 SetWTitle (FRAME_MAC_WINDOW (f), windowTitle); 1961 SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
1952 } 1962 }
1963#endif
1953 } 1964 }
1954 1965
1955 UNBLOCK_INPUT; 1966 UNBLOCK_INPUT;
@@ -2008,8 +2019,8 @@ x_set_title (f, name, old_name)
2008 if (FRAME_MAC_WINDOW (f)) 2019 if (FRAME_MAC_WINDOW (f))
2009 { 2020 {
2010 if (STRING_MULTIBYTE (name)) 2021 if (STRING_MULTIBYTE (name))
2011#if 0 /* MAC_TODO: encoding title string */ 2022#if TARGET_API_MAC_CARBON
2012 name = ENCODE_SYSTEM (name); 2023 name = ENCODE_UTF_8 (name);
2013#else 2024#else
2014 return; 2025 return;
2015#endif 2026#endif
@@ -2017,6 +2028,14 @@ x_set_title (f, name, old_name)
2017 BLOCK_INPUT; 2028 BLOCK_INPUT;
2018 2029
2019 { 2030 {
2031#if TARGET_API_MAC_CARBON
2032 CFStringRef windowTitle =
2033 CFStringCreateWithCString (NULL, SDATA (name),
2034 kCFStringEncodingUTF8);
2035
2036 SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
2037 CFRelease (windowTitle);
2038#else
2020 Str255 windowTitle; 2039 Str255 windowTitle;
2021 if (strlen (SDATA (name)) < 255) 2040 if (strlen (SDATA (name)) < 255)
2022 { 2041 {
@@ -2024,6 +2043,7 @@ x_set_title (f, name, old_name)
2024 c2pstr (windowTitle); 2043 c2pstr (windowTitle);
2025 SetWTitle (FRAME_MAC_WINDOW (f), windowTitle); 2044 SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
2026 } 2045 }
2046#endif
2027 } 2047 }
2028 2048
2029 UNBLOCK_INPUT; 2049 UNBLOCK_INPUT;
@@ -2981,17 +3001,20 @@ If omitted or nil, that stands for the selected frame's display. */)
2981 (display) 3001 (display)
2982 Lisp_Object display; 3002 Lisp_Object display;
2983{ 3003{
2984 int mac_major_version, mac_minor_version; 3004 int mac_major_version;
2985 SInt32 response; 3005 SInt32 response;
2986 3006
2987 if (Gestalt (gestaltSystemVersion, &response) != noErr) 3007 if (Gestalt (gestaltSystemVersion, &response) != noErr)
2988 error ("Cannot get Mac OS version"); 3008 error ("Cannot get Mac OS version");
2989 3009
2990 mac_major_version = (response >> 8) & 0xf; 3010 mac_major_version = (response >> 8) & 0xff;
2991 mac_minor_version = (response >> 4) & 0xf; 3011 /* convert BCD to int */
3012 mac_major_version -= (mac_major_version >> 4) * 6;
2992 3013
2993 return Fcons (make_number (mac_major_version), 3014 return Fcons (make_number (mac_major_version),
2994 Fcons (make_number (mac_minor_version), Qnil)); 3015 Fcons (make_number ((response >> 4) & 0xf),
3016 Fcons (make_number (response & 0xf),
3017 Qnil)));
2995} 3018}
2996 3019
2997DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, 3020DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
diff --git a/src/macmenu.c b/src/macmenu.c
index 88012b01f73..740bda261d8 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -2240,7 +2240,7 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu,
2240 int force_disable) 2240 int force_disable)
2241{ 2241{
2242 Str255 item_name; 2242 Str255 item_name;
2243 int pos, i; 2243 int pos;
2244 2244
2245 if (name_is_separator (wv->name)) 2245 if (name_is_separator (wv->name))
2246 AppendMenu (menu, "\p-"); 2246 AppendMenu (menu, "\p-");
@@ -2296,9 +2296,9 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu,
2296 else 2296 else
2297 SetItemMark (menu, pos, noMark); 2297 SetItemMark (menu, pos, noMark);
2298 } 2298 }
2299 }
2300 2299
2301 SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data); 2300 SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data);
2301 }
2302 2302
2303 if (submenu != NULL) 2303 if (submenu != NULL)
2304 SetMenuItemHierarchicalID (menu, pos, submenu); 2304 SetMenuItemHierarchicalID (menu, pos, submenu);
diff --git a/src/macterm.c b/src/macterm.c
index eaf7517d71a..4f721fff304 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -1325,6 +1325,10 @@ static void
1325x_update_end (f) 1325x_update_end (f)
1326 struct frame *f; 1326 struct frame *f;
1327{ 1327{
1328 /* Mouse highlight may be displayed again. */
1329 FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
1330
1331 BLOCK_INPUT;
1328 /* Reset the background color of Mac OS Window to that of the frame after 1332 /* Reset the background color of Mac OS Window to that of the frame after
1329 update so that it is used by Mac Toolbox to clear the update region before 1333 update so that it is used by Mac Toolbox to clear the update region before
1330 an update event is generated. */ 1334 an update event is generated. */
@@ -1332,10 +1336,6 @@ x_update_end (f)
1332 1336
1333 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); 1337 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
1334 1338
1335 /* Mouse highlight may be displayed again. */
1336 FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
1337
1338 BLOCK_INPUT;
1339 XFlush (FRAME_MAC_DISPLAY (f)); 1339 XFlush (FRAME_MAC_DISPLAY (f));
1340 UNBLOCK_INPUT; 1340 UNBLOCK_INPUT;
1341} 1341}
@@ -5123,7 +5123,7 @@ x_set_offset (f, xoff, yoff, change_gravity)
5123 modified_left = f->left_pos; 5123 modified_left = f->left_pos;
5124 modified_top = f->top_pos; 5124 modified_top = f->top_pos;
5125 5125
5126 MoveWindow (f->output_data.mac->mWP, modified_left + 6, 5126 MoveWindow (FRAME_MAC_WINDOW (f), modified_left + 6,
5127 modified_top + 42, false); 5127 modified_top + 42, false);
5128 5128
5129 UNBLOCK_INPUT; 5129 UNBLOCK_INPUT;
diff --git a/src/s/darwin.h b/src/s/darwin.h
index 814de2c2c51..f854ed9380b 100644
--- a/src/s/darwin.h
+++ b/src/s/darwin.h
@@ -243,11 +243,18 @@ Boston, MA 02111-1307, USA. */
243 specific headers. */ 243 specific headers. */
244#define C_SWITCH_SYSTEM -fpascal-strings -fno-common -DMAC_OSX -I../mac/src 244#define C_SWITCH_SYSTEM -fpascal-strings -fno-common -DMAC_OSX -I../mac/src
245 245
246/* Link in the Carbon lib. The -headerpad option tells ld (see man 246/* Link in the Carbon lib. */
247 page) to leave room at the end of the header for adding load 247#ifdef HAVE_CARBON
248 commands. Needed for dumping. 0x690 is the total size of 30 248#define LIBS_CARBON -framework Carbon -framework QuickTime
249 segment load commands (at 56 each). */ 249#else
250#define LD_SWITCH_SYSTEM_TEMACS -prebind -framework Carbon -framework QuickTime -lstdc++ -Xlinker -headerpad -Xlinker 690 250#define LIBS_CARBON -framework Carbon
251#endif
252
253/* The -headerpad option tells ld (see man page) to leave room at the
254 end of the header for adding load commands. Needed for dumping.
255 0x690 is the total size of 30 segment load commands (at 56
256 each). */
257#define LD_SWITCH_SYSTEM_TEMACS -prebind LIBS_CARBON -Xlinker -headerpad -Xlinker 690
251 258
252#define C_SWITCH_SYSTEM_TEMACS -Dtemacs 259#define C_SWITCH_SYSTEM_TEMACS -Dtemacs
253 260
diff --git a/src/w32menu.c b/src/w32menu.c
index cc0932d7bf5..f3f3eb785b0 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -45,7 +45,6 @@ Boston, MA 02111-1307, USA. */
45 45
46#include "dispextern.h" 46#include "dispextern.h"
47 47
48#undef HAVE_MULTILINGUAL_MENU
49#undef HAVE_DIALOGS /* TODO: Implement native dialogs. */ 48#undef HAVE_DIALOGS /* TODO: Implement native dialogs. */
50 49
51/******************************************************************/ 50/******************************************************************/
@@ -66,10 +65,12 @@ enum button_type
66typedef struct _widget_value 65typedef struct _widget_value
67{ 66{
68 /* name of widget */ 67 /* name of widget */
68 Lisp_Object lname;
69 char* name; 69 char* name;
70 /* value (meaning depend on widget type) */ 70 /* value (meaning depend on widget type) */
71 char* value; 71 char* value;
72 /* keyboard equivalent. no implications for XtTranslations */ 72 /* keyboard equivalent. no implications for XtTranslations */
73 Lisp_Object lkey;
73 char* key; 74 char* key;
74 /* Help string or nil if none. 75 /* Help string or nil if none.
75 GC finds this string through the frame's menu_bar_vector 76 GC finds this string through the frame's menu_bar_vector
@@ -136,17 +137,21 @@ typedef BOOL (WINAPI * GetMenuItemInfoA_Proc) (
136 IN HMENU, 137 IN HMENU,
137 IN UINT, 138 IN UINT,
138 IN BOOL, 139 IN BOOL,
139 IN OUT LPMENUITEMINFOA 140 IN OUT LPMENUITEMINFOA);
140 );
141typedef BOOL (WINAPI * SetMenuItemInfoA_Proc) ( 141typedef BOOL (WINAPI * SetMenuItemInfoA_Proc) (
142 IN HMENU, 142 IN HMENU,
143 IN UINT, 143 IN UINT,
144 IN BOOL, 144 IN BOOL,
145 IN LPCMENUITEMINFOA 145 IN LPCMENUITEMINFOA);
146 ); 146typedef BOOL (WINAPI * AppendMenuW_Proc) (
147 IN HMENU,
148 IN UINT,
149 IN UINT_PTR,
150 IN LPCWSTR);
147 151
148GetMenuItemInfoA_Proc get_menu_item_info=NULL; 152GetMenuItemInfoA_Proc get_menu_item_info = NULL;
149SetMenuItemInfoA_Proc set_menu_item_info=NULL; 153SetMenuItemInfoA_Proc set_menu_item_info = NULL;
154AppendMenuW_Proc unicode_append_menu = NULL;
150 155
151Lisp_Object Vmenu_updating_frame; 156Lisp_Object Vmenu_updating_frame;
152 157
@@ -1235,13 +1240,17 @@ digest_single_submenu (start, end, top_level_items)
1235 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); 1240 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
1236 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); 1241 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
1237 1242
1238#ifndef HAVE_MULTILINGUAL_MENU 1243 if (STRINGP (pane_name))
1239 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
1240 { 1244 {
1241 pane_name = ENCODE_SYSTEM (pane_name); 1245 if (unicode_append_menu)
1246 /* Encode as UTF-8 for now. */
1247 pane_name = ENCODE_UTF_8 (pane_name);
1248 else if (STRING_MULTIBYTE (pane_name))
1249 pane_name = ENCODE_SYSTEM (pane_name);
1250
1242 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name); 1251 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
1243 } 1252 }
1244#endif 1253
1245 pane_string = (NILP (pane_name) 1254 pane_string = (NILP (pane_name)
1246 ? "" : (char *) SDATA (pane_name)); 1255 ? "" : (char *) SDATA (pane_name));
1247 /* If there is just one top-level pane, put all its items directly 1256 /* If there is just one top-level pane, put all its items directly
@@ -1259,12 +1268,9 @@ digest_single_submenu (start, end, top_level_items)
1259 save_wv->next = wv; 1268 save_wv->next = wv;
1260 else 1269 else
1261 first_wv->contents = wv; 1270 first_wv->contents = wv;
1262 wv->name = pane_string; 1271 wv->lname = pane_name;
1263 /* Ignore the @ that means "separate pane". 1272 /* Set value to 1 so update_submenu_strings can handle '@' */
1264 This is a kludge, but this isn't worth more time. */ 1273 wv->value = (char *) 1;
1265 if (!NILP (prefix) && wv->name[0] == '@')
1266 wv->name++;
1267 wv->value = 0;
1268 wv->enabled = 1; 1274 wv->enabled = 1;
1269 wv->button_type = BUTTON_TYPE_NONE; 1275 wv->button_type = BUTTON_TYPE_NONE;
1270 wv->help = Qnil; 1276 wv->help = Qnil;
@@ -1287,10 +1293,13 @@ digest_single_submenu (start, end, top_level_items)
1287 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED); 1293 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
1288 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP); 1294 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
1289 1295
1290#ifndef HAVE_MULTILINGUAL_MENU 1296 if (STRINGP (item_name))
1291 if (STRING_MULTIBYTE (item_name))
1292 { 1297 {
1293 item_name = ENCODE_SYSTEM (item_name); 1298 if (unicode_append_menu)
1299 item_name = ENCODE_UTF_8 (item_name);
1300 else if (STRING_MULTIBYTE (item_name))
1301 item_name = ENCODE_SYSTEM (item_name);
1302
1294 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name); 1303 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
1295 } 1304 }
1296 1305
@@ -1299,7 +1308,6 @@ digest_single_submenu (start, end, top_level_items)
1299 descrip = ENCODE_SYSTEM (descrip); 1308 descrip = ENCODE_SYSTEM (descrip);
1300 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip); 1309 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
1301 } 1310 }
1302#endif /* not HAVE_MULTILINGUAL_MENU */
1303 1311
1304 wv = xmalloc_widget_value (); 1312 wv = xmalloc_widget_value ();
1305 if (prev_wv) 1313 if (prev_wv)
@@ -1307,9 +1315,9 @@ digest_single_submenu (start, end, top_level_items)
1307 else 1315 else
1308 save_wv->contents = wv; 1316 save_wv->contents = wv;
1309 1317
1310 wv->name = (char *) SDATA (item_name); 1318 wv->lname = item_name;
1311 if (!NILP (descrip)) 1319 if (!NILP (descrip))
1312 wv->key = (char *) SDATA (descrip); 1320 wv->lkey = descrip;
1313 wv->value = 0; 1321 wv->value = 0;
1314 /* The EMACS_INT cast avoids a warning. There's no problem 1322 /* The EMACS_INT cast avoids a warning. There's no problem
1315 as long as pointers have enough bits to hold small integers. */ 1323 as long as pointers have enough bits to hold small integers. */
@@ -1348,6 +1356,43 @@ digest_single_submenu (start, end, top_level_items)
1348 1356
1349 return first_wv; 1357 return first_wv;
1350} 1358}
1359
1360
1361/* Walk through the widget_value tree starting at FIRST_WV and update
1362 the char * pointers from the corresponding lisp values.
1363 We do this after building the whole tree, since GC may happen while the
1364 tree is constructed, and small strings are relocated. So we must wait
1365 until no GC can happen before storing pointers into lisp values. */
1366static void
1367update_submenu_strings (first_wv)
1368 widget_value *first_wv;
1369{
1370 widget_value *wv;
1371
1372 for (wv = first_wv; wv; wv = wv->next)
1373 {
1374 if (wv->lname && ! NILP (wv->lname))
1375 {
1376 wv->name = SDATA (wv->lname);
1377
1378 /* Ignore the @ that means "separate pane".
1379 This is a kludge, but this isn't worth more time. */
1380 if (wv->value == (char *)1)
1381 {
1382 if (wv->name[0] == '@')
1383 wv->name++;
1384 wv->value = 0;
1385 }
1386 }
1387
1388 if (wv->lkey && ! NILP (wv->lkey))
1389 wv->key = SDATA (wv->lkey);
1390
1391 if (wv->contents)
1392 update_submenu_strings (wv->contents);
1393 }
1394}
1395
1351 1396
1352/* Set the contents of the menubar widgets of frame F. 1397/* Set the contents of the menubar widgets of frame F.
1353 The argument FIRST_TIME is currently ignored; 1398 The argument FIRST_TIME is currently ignored;
@@ -1516,6 +1561,7 @@ set_frame_menubar (f, first_time, deep_p)
1516 if (NILP (string)) 1561 if (NILP (string))
1517 break; 1562 break;
1518 wv->name = (char *) SDATA (string); 1563 wv->name = (char *) SDATA (string);
1564 update_submenu_strings (wv->contents);
1519 wv = wv->next; 1565 wv = wv->next;
1520 } 1566 }
1521 1567
@@ -1729,13 +1775,17 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error)
1729 char *pane_string; 1775 char *pane_string;
1730 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); 1776 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
1731 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); 1777 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
1732#ifndef HAVE_MULTILINGUAL_MENU 1778
1733 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name)) 1779 if (STRINGP (pane_name))
1734 { 1780 {
1735 pane_name = ENCODE_SYSTEM (pane_name); 1781 if (unicode_append_menu)
1782 pane_name = ENCODE_UTF_8 (pane_name);
1783 else if (STRING_MULTIBYTE (pane_name))
1784 pane_name = ENCODE_SYSTEM (pane_name);
1785
1736 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name); 1786 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
1737 } 1787 }
1738#endif 1788
1739 pane_string = (NILP (pane_name) 1789 pane_string = (NILP (pane_name)
1740 ? "" : (char *) SDATA (pane_name)); 1790 ? "" : (char *) SDATA (pane_name));
1741 /* If there is just one top-level pane, put all its items directly 1791 /* If there is just one top-level pane, put all its items directly
@@ -1784,18 +1834,21 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error)
1784 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED); 1834 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
1785 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP); 1835 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
1786 1836
1787#ifndef HAVE_MULTILINGUAL_MENU 1837 if (STRINGP (item_name))
1788 if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
1789 { 1838 {
1790 item_name = ENCODE_SYSTEM (item_name); 1839 if (unicode_append_menu)
1840 item_name = ENCODE_UTF_8 (item_name);
1841 else if (STRING_MULTIBYTE (item_name))
1842 item_name = ENCODE_SYSTEM (item_name);
1843
1791 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name); 1844 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
1792 } 1845 }
1793 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) 1846
1847 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
1794 { 1848 {
1795 descrip = ENCODE_SYSTEM (descrip); 1849 descrip = ENCODE_SYSTEM (descrip);
1796 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip); 1850 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
1797 } 1851 }
1798#endif /* not HAVE_MULTILINGUAL_MENU */
1799 1852
1800 wv = xmalloc_widget_value (); 1853 wv = xmalloc_widget_value ();
1801 if (prev_wv) 1854 if (prev_wv)
@@ -1844,10 +1897,11 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error)
1844 wv_sep->next = first_wv->contents; 1897 wv_sep->next = first_wv->contents;
1845 wv_sep->help = Qnil; 1898 wv_sep->help = Qnil;
1846 1899
1847#ifndef HAVE_MULTILINGUAL_MENU 1900 if (unicode_append_menu)
1848 if (STRING_MULTIBYTE (title)) 1901 title = ENCODE_UTF_8 (title);
1902 else if (STRING_MULTIBYTE (title))
1849 title = ENCODE_SYSTEM (title); 1903 title = ENCODE_SYSTEM (title);
1850#endif 1904
1851 wv_title->name = (char *) SDATA (title); 1905 wv_title->name = (char *) SDATA (title);
1852 wv_title->enabled = TRUE; 1906 wv_title->enabled = TRUE;
1853 wv_title->title = TRUE; 1907 wv_title->title = TRUE;
@@ -2150,6 +2204,46 @@ add_left_right_boundary (HMENU menu)
2150 return AppendMenu (menu, MF_MENUBARBREAK, 0, NULL); 2204 return AppendMenu (menu, MF_MENUBARBREAK, 0, NULL);
2151} 2205}
2152 2206
2207/* UTF8: 0xxxxxxx, 110xxxxx 10xxxxxx, 1110xxxx, 10xxxxxx, 10xxxxxx */
2208static void
2209utf8to16 (unsigned char * src, int len, WCHAR * dest)
2210{
2211 while (len > 0)
2212 {
2213 int utf16;
2214 if (*src < 0x80)
2215 {
2216 *dest = (WCHAR) *src;
2217 dest++; src++; len--;
2218 }
2219 /* Since we might get >3 byte sequences which we don't handle, ignore the extra parts. */
2220 else if (*src < 0xC0)
2221 {
2222 src++; len--;
2223 }
2224 /* 2 char UTF-8 sequence. */
2225 else if (*src < 0xE0)
2226 {
2227 *dest = (WCHAR) (((*src & 0x1f) << 6)
2228 | (*(src + 1) & 0x3f));
2229 src += 2; len -= 2; dest++;
2230 }
2231 else if (*src < 0xF0)
2232 {
2233 *dest = (WCHAR) (((*src & 0x0f) << 12)
2234 | ((*(src + 1) & 0x3f) << 6)
2235 | (*(src + 2) & 0x3f));
2236 src += 3; len -= 3; dest++;
2237 }
2238 else /* Not encodable. Insert Unicode Substitution char. */
2239 {
2240 *dest = (WCHAR) 0xfffd;
2241 src++; len--; dest++;
2242 }
2243 }
2244 *dest = 0;
2245}
2246
2153static int 2247static int
2154add_menu_item (HMENU menu, widget_value *wv, HMENU item) 2248add_menu_item (HMENU menu, widget_value *wv, HMENU item)
2155{ 2249{
@@ -2206,11 +2300,32 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
2206 fuFlags |= MF_UNCHECKED; 2300 fuFlags |= MF_UNCHECKED;
2207 } 2301 }
2208 2302
2209 return_value = 2303 if (unicode_append_menu && out_string)
2210 AppendMenu (menu, 2304 {
2211 fuFlags, 2305 /* Convert out_string from UTF-8 to UTF-16-LE. */
2212 item != NULL ? (UINT) item : (UINT) wv->call_data, 2306 int utf8_len = strlen (out_string);
2213 out_string ); 2307 WCHAR * utf16_string;
2308 if (fuFlags & MF_OWNERDRAW)
2309 utf16_string = local_alloc ((utf8_len + 1) * sizeof (WCHAR));
2310 else
2311 utf16_string = alloca ((utf8_len + 1) * sizeof (WCHAR));
2312
2313 utf8to16 (out_string, utf8_len, utf16_string);
2314 return_value = unicode_append_menu (menu, fuFlags,
2315 item != NULL ? (UINT) item
2316 : (UINT) wv->call_data,
2317 utf16_string);
2318 if (fuFlags & MF_OWNERDRAW)
2319 local_free (out_string);
2320 }
2321 else
2322 {
2323 return_value =
2324 AppendMenu (menu,
2325 fuFlags,
2326 item != NULL ? (UINT) item : (UINT) wv->call_data,
2327 out_string );
2328 }
2214 2329
2215 /* This must be done after the menu item is created. */ 2330 /* This must be done after the menu item is created. */
2216 if (!wv->title && wv->call_data != 0) 2331 if (!wv->title && wv->call_data != 0)
@@ -2298,7 +2413,7 @@ w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags)
2298 struct frame *f = x_window_to_frame (&one_w32_display_info, owner); 2413 struct frame *f = x_window_to_frame (&one_w32_display_info, owner);
2299 Lisp_Object frame, help; 2414 Lisp_Object frame, help;
2300 2415
2301 // No help echo on owner-draw menu items. 2416 /* No help echo on owner-draw menu items. */
2302 if (flags & MF_OWNERDRAW || flags & MF_POPUP) 2417 if (flags & MF_OWNERDRAW || flags & MF_POPUP)
2303 help = Qnil; 2418 help = Qnil;
2304 else 2419 else
@@ -2422,6 +2537,7 @@ void globals_of_w32menu ()
2422 HMODULE user32 = GetModuleHandle ("user32.dll"); 2537 HMODULE user32 = GetModuleHandle ("user32.dll");
2423 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA"); 2538 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
2424 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA"); 2539 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
2540 unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW");
2425} 2541}
2426 2542
2427/* arch-tag: 0eaed431-bb4e-4aac-a527-95a1b4f1fed0 2543/* arch-tag: 0eaed431-bb4e-4aac-a527-95a1b4f1fed0
diff --git a/src/xdisp.c b/src/xdisp.c
index 7cbc022380d..6a12cb57551 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -306,6 +306,7 @@ Lisp_Object Qline_height, Qtotal;
306extern Lisp_Object Qheight; 306extern Lisp_Object Qheight;
307extern Lisp_Object QCwidth, QCheight, QCascent; 307extern Lisp_Object QCwidth, QCheight, QCascent;
308extern Lisp_Object Qscroll_bar; 308extern Lisp_Object Qscroll_bar;
309extern Lisp_Object Qcursor;
309 310
310/* Non-nil means highlight trailing whitespace. */ 311/* Non-nil means highlight trailing whitespace. */
311 312
@@ -10643,6 +10644,7 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
10643{ 10644{
10644 struct glyph *glyph = row->glyphs[TEXT_AREA]; 10645 struct glyph *glyph = row->glyphs[TEXT_AREA];
10645 struct glyph *end = glyph + row->used[TEXT_AREA]; 10646 struct glyph *end = glyph + row->used[TEXT_AREA];
10647 struct glyph *cursor = NULL;
10646 /* The first glyph that starts a sequence of glyphs from string. */ 10648 /* The first glyph that starts a sequence of glyphs from string. */
10647 struct glyph *string_start; 10649 struct glyph *string_start;
10648 /* The X coordinate of string_start. */ 10650 /* The X coordinate of string_start. */
@@ -10652,6 +10654,7 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
10652 /* The last known character position before string_start. */ 10654 /* The last known character position before string_start. */
10653 int string_before_pos; 10655 int string_before_pos;
10654 int x = row->x; 10656 int x = row->x;
10657 int cursor_x = x;
10655 int pt_old = PT - delta; 10658 int pt_old = PT - delta;
10656 10659
10657 /* Skip over glyphs not having an object at the start of the row. 10660 /* Skip over glyphs not having an object at the start of the row.
@@ -10684,12 +10687,29 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
10684 string_start = glyph; 10687 string_start = glyph;
10685 string_start_x = x; 10688 string_start_x = x;
10686 /* Skip all glyphs from string. */ 10689 /* Skip all glyphs from string. */
10687 SKIP_GLYPHS (glyph, end, x, STRINGP (glyph->object)); 10690 do
10691 {
10692 if ((cursor == NULL || glyph > cursor)
10693 && !NILP (Fget_char_property (make_number ((glyph)->charpos),
10694 Qcursor, (glyph)->object)))
10695 {
10696 cursor = glyph;
10697 cursor_x = x;
10698 }
10699 x += glyph->pixel_width;
10700 ++glyph;
10701 }
10702 while (glyph < end && STRINGP (glyph->object));
10688 } 10703 }
10689 } 10704 }
10690 10705
10691 if (string_start 10706 if (cursor != NULL)
10692 && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old)) 10707 {
10708 glyph = cursor;
10709 x = cursor_x;
10710 }
10711 else if (string_start
10712 && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old))
10693 { 10713 {
10694 /* We may have skipped over point because the previous glyphs 10714 /* We may have skipped over point because the previous glyphs
10695 are from string. As there's no easy way to know the 10715 are from string. As there's no easy way to know the
@@ -11081,8 +11101,8 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
11081 start_display (&it, w, startp); 11101 start_display (&it, w, startp);
11082 11102
11083 if (scroll_conservatively) 11103 if (scroll_conservatively)
11084 amount_to_scroll = 11104 amount_to_scroll
11085 max (dy, FRAME_LINE_HEIGHT (f) * max (scroll_step, temp_scroll_step)); 11105 = max (dy, FRAME_LINE_HEIGHT (f) * max (scroll_step, temp_scroll_step));
11086 else if (scroll_step || temp_scroll_step) 11106 else if (scroll_step || temp_scroll_step)
11087 amount_to_scroll = scroll_max; 11107 amount_to_scroll = scroll_max;
11088 else 11108 else
@@ -11361,8 +11381,7 @@ try_cursor_movement (window, startp, scroll_step)
11361 else if (PT < XFASTINT (w->last_point)) 11381 else if (PT < XFASTINT (w->last_point))
11362 { 11382 {
11363 /* Cursor has to be moved backward. Note that PT >= 11383 /* Cursor has to be moved backward. Note that PT >=
11364 CHARPOS (startp) because of the outer 11384 CHARPOS (startp) because of the outer if-statement. */
11365 if-statement. */
11366 while (!row->mode_line_p 11385 while (!row->mode_line_p
11367 && (MATRIX_ROW_START_CHARPOS (row) > PT 11386 && (MATRIX_ROW_START_CHARPOS (row) > PT
11368 || (MATRIX_ROW_START_CHARPOS (row) == PT 11387 || (MATRIX_ROW_START_CHARPOS (row) == PT
@@ -11876,8 +11895,8 @@ redisplay_window (window, just_this_one_p)
11876 buffer. */ 11895 buffer. */
11877 || !NILP (Vwindow_scroll_functions) 11896 || !NILP (Vwindow_scroll_functions)
11878 || MINI_WINDOW_P (w) 11897 || MINI_WINDOW_P (w)
11879 || !(used_current_matrix_p = 11898 || !(used_current_matrix_p
11880 try_window_reusing_current_matrix (w))) 11899 = try_window_reusing_current_matrix (w)))
11881 { 11900 {
11882 IF_DEBUG (debug_method_add (w, "1")); 11901 IF_DEBUG (debug_method_add (w, "1"));
11883 try_window (window, startp); 11902 try_window (window, startp);
@@ -12006,8 +12025,8 @@ redisplay_window (window, just_this_one_p)
12006 || !NILP (Vwindow_scroll_functions) 12025 || !NILP (Vwindow_scroll_functions)
12007 || !just_this_one_p 12026 || !just_this_one_p
12008 || MINI_WINDOW_P (w) 12027 || MINI_WINDOW_P (w)
12009 || !(used_current_matrix_p = 12028 || !(used_current_matrix_p
12010 try_window_reusing_current_matrix (w))) 12029 = try_window_reusing_current_matrix (w)))
12011 try_window (window, startp); 12030 try_window (window, startp);
12012 12031
12013 /* If new fonts have been loaded (due to fontsets), give up. We 12032 /* If new fonts have been loaded (due to fontsets), give up. We
@@ -15673,7 +15692,8 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky)
15673 The mode_line_string_face face property is always added to the string. 15692 The mode_line_string_face face property is always added to the string.
15674 */ 15693 */
15675 15694
15676static int store_mode_line_string (string, lisp_string, copy_string, field_width, precision, props) 15695static int
15696store_mode_line_string (string, lisp_string, copy_string, field_width, precision, props)
15677 char *string; 15697 char *string;
15678 Lisp_Object lisp_string; 15698 Lisp_Object lisp_string;
15679 int copy_string; 15699 int copy_string;
@@ -15785,32 +15805,32 @@ If third optional arg NO-PROPS is non-nil, string is not propertized. */)
15785 15805
15786 if (NILP (format) || EQ (format, Qt)) 15806 if (NILP (format) || EQ (format, Qt))
15787 { 15807 {
15788 face_id = NILP (format) 15808 face_id = (NILP (format)
15789 ? CURRENT_MODE_LINE_FACE_ID (w) : 15809 ? CURRENT_MODE_LINE_FACE_ID (w)
15790 HEADER_LINE_FACE_ID; 15810 : HEADER_LINE_FACE_ID);
15791 format = NILP (format) 15811 format = (NILP (format)
15792 ? current_buffer->mode_line_format 15812 ? current_buffer->mode_line_format
15793 : current_buffer->header_line_format; 15813 : current_buffer->header_line_format);
15794 } 15814 }
15795 15815
15796 init_iterator (&it, w, -1, -1, NULL, face_id); 15816 init_iterator (&it, w, -1, -1, NULL, face_id);
15797 15817
15798 if (NILP (no_props)) 15818 if (NILP (no_props))
15799 { 15819 {
15800 mode_line_string_face = 15820 mode_line_string_face
15801 (face_id == MODE_LINE_FACE_ID ? Qmode_line : 15821 = (face_id == MODE_LINE_FACE_ID ? Qmode_line
15802 face_id == MODE_LINE_INACTIVE_FACE_ID ? Qmode_line_inactive : 15822 : face_id == MODE_LINE_INACTIVE_FACE_ID ? Qmode_line_inactive
15803 face_id == HEADER_LINE_FACE_ID ? Qheader_line : Qnil); 15823 : face_id == HEADER_LINE_FACE_ID ? Qheader_line : Qnil);
15804 15824
15805 mode_line_string_face_prop = 15825 mode_line_string_face_prop
15806 NILP (mode_line_string_face) ? Qnil : 15826 = (NILP (mode_line_string_face) ? Qnil
15807 Fcons (Qface, Fcons (mode_line_string_face, Qnil)); 15827 : Fcons (Qface, Fcons (mode_line_string_face, Qnil)));
15808 15828
15809 /* We need a dummy last element in mode_line_string_list to 15829 /* We need a dummy last element in mode_line_string_list to
15810 indicate we are building the propertized mode-line string. 15830 indicate we are building the propertized mode-line string.
15811 Using mode_line_string_face_prop here GC protects it. */ 15831 Using mode_line_string_face_prop here GC protects it. */
15812 mode_line_string_list = 15832 mode_line_string_list
15813 Fcons (mode_line_string_face_prop, Qnil); 15833 = Fcons (mode_line_string_face_prop, Qnil);
15814 frame_title_ptr = NULL; 15834 frame_title_ptr = NULL;
15815 } 15835 }
15816 else 15836 else
@@ -20890,7 +20910,8 @@ note_mouse_highlight (f, x, y)
20890 20910
20891 if (part == ON_VERTICAL_BORDER) 20911 if (part == ON_VERTICAL_BORDER)
20892 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor; 20912 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
20893 else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE) 20913 else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE
20914 || part == ON_SCROLL_BAR)
20894 cursor = FRAME_X_OUTPUT (f)->nontext_cursor; 20915 cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
20895 else 20916 else
20896 cursor = FRAME_X_OUTPUT (f)->text_cursor; 20917 cursor = FRAME_X_OUTPUT (f)->text_cursor;
diff --git a/src/xfns.c b/src/xfns.c
index e03edbbec89..9e9a85749a1 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1570,61 +1570,15 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp)
1570} 1570}
1571 1571
1572 1572
1573/* Change the name of frame F to NAME. If NAME is nil, set F's name to 1573/* Set the WM name to NAME for frame F. Also set the icon name.
1574 x_id_name. 1574 If the frame already has an icon name, use that, otherwise set the
1575 1575 icon name to NAME. */
1576 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1577 name; if NAME is a string, set F's name to NAME and set
1578 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1579 1576
1580 If EXPLICIT is zero, that indicates that Emacs redisplay code is 1577static void
1581 suggesting a new name, which lisp code should override; if 1578x_set_name_internal (f, name)
1582 F->explicit_name is set, ignore the new name; otherwise, set it. */ 1579 FRAME_PTR f;
1583
1584void
1585x_set_name (f, name, explicit)
1586 struct frame *f;
1587 Lisp_Object name; 1580 Lisp_Object name;
1588 int explicit;
1589{ 1581{
1590 /* Make sure that requests from lisp code override requests from
1591 Emacs redisplay code. */
1592 if (explicit)
1593 {
1594 /* If we're switching from explicit to implicit, we had better
1595 update the mode lines and thereby update the title. */
1596 if (f->explicit_name && NILP (name))
1597 update_mode_lines = 1;
1598
1599 f->explicit_name = ! NILP (name);
1600 }
1601 else if (f->explicit_name)
1602 return;
1603
1604 /* If NAME is nil, set the name to the x_id_name. */
1605 if (NILP (name))
1606 {
1607 /* Check for no change needed in this very common case
1608 before we do any consing. */
1609 if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
1610 SDATA (f->name)))
1611 return;
1612 name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
1613 }
1614 else
1615 CHECK_STRING (name);
1616
1617 /* Don't change the name if it's already NAME. */
1618 if (! NILP (Fstring_equal (name, f->name)))
1619 return;
1620
1621 f->name = name;
1622
1623 /* For setting the frame title, the title parameter should override
1624 the name parameter. */
1625 if (! NILP (f->title))
1626 name = f->title;
1627
1628 if (FRAME_X_WINDOW (f)) 1582 if (FRAME_X_WINDOW (f))
1629 { 1583 {
1630 BLOCK_INPUT; 1584 BLOCK_INPUT;
@@ -1632,8 +1586,10 @@ x_set_name (f, name, explicit)
1632 { 1586 {
1633 XTextProperty text, icon; 1587 XTextProperty text, icon;
1634 int bytes, stringp; 1588 int bytes, stringp;
1589 int do_free_icon_value = 0, do_free_text_value = 0;
1635 Lisp_Object coding_system; 1590 Lisp_Object coding_system;
1636 1591
1592 coding_system = Qcompound_text;
1637 /* Note: Encoding strategy 1593 /* Note: Encoding strategy
1638 1594
1639 We encode NAME by compound-text and use "COMPOUND-TEXT" in 1595 We encode NAME by compound-text and use "COMPOUND-TEXT" in
@@ -1648,13 +1604,16 @@ x_set_name (f, name, explicit)
1648 in the future which can encode all Unicode characters. 1604 in the future which can encode all Unicode characters.
1649 But, for the moment, there's no way to know that the 1605 But, for the moment, there's no way to know that the
1650 current window manager supports it or not. */ 1606 current window manager supports it or not. */
1651 coding_system = Qcompound_text;
1652 text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp); 1607 text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
1653 text.encoding = (stringp ? XA_STRING 1608 text.encoding = (stringp ? XA_STRING
1654 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); 1609 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1655 text.format = 8; 1610 text.format = 8;
1656 text.nitems = bytes; 1611 text.nitems = bytes;
1657 1612
1613 /* Check early, because ENCODE_UTF_8 below may GC and name may be
1614 relocated. */
1615 do_free_text_value = text.value != SDATA (name);
1616
1658 if (NILP (f->icon_name)) 1617 if (NILP (f->icon_name))
1659 { 1618 {
1660 icon = text; 1619 icon = text;
@@ -1668,7 +1627,9 @@ x_set_name (f, name, explicit)
1668 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); 1627 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1669 icon.format = 8; 1628 icon.format = 8;
1670 icon.nitems = bytes; 1629 icon.nitems = bytes;
1630 do_free_icon_value = icon.value != SDATA (f->icon_name);
1671 } 1631 }
1632
1672#ifdef USE_GTK 1633#ifdef USE_GTK
1673 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 1634 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1674 SDATA (ENCODE_UTF_8 (name))); 1635 SDATA (ENCODE_UTF_8 (name)));
@@ -1678,10 +1639,9 @@ x_set_name (f, name, explicit)
1678 1639
1679 XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon); 1640 XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);
1680 1641
1681 if (!NILP (f->icon_name) 1642 if (do_free_icon_value)
1682 && icon.value != (unsigned char *) SDATA (f->icon_name))
1683 xfree (icon.value); 1643 xfree (icon.value);
1684 if (text.value != (unsigned char *) SDATA (name)) 1644 if (do_free_text_value)
1685 xfree (text.value); 1645 xfree (text.value);
1686 } 1646 }
1687#else /* not HAVE_X11R4 */ 1647#else /* not HAVE_X11R4 */
@@ -1694,6 +1654,64 @@ x_set_name (f, name, explicit)
1694 } 1654 }
1695} 1655}
1696 1656
1657/* Change the name of frame F to NAME. If NAME is nil, set F's name to
1658 x_id_name.
1659
1660 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1661 name; if NAME is a string, set F's name to NAME and set
1662 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1663
1664 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1665 suggesting a new name, which lisp code should override; if
1666 F->explicit_name is set, ignore the new name; otherwise, set it. */
1667
1668void
1669x_set_name (f, name, explicit)
1670 struct frame *f;
1671 Lisp_Object name;
1672 int explicit;
1673{
1674 /* Make sure that requests from lisp code override requests from
1675 Emacs redisplay code. */
1676 if (explicit)
1677 {
1678 /* If we're switching from explicit to implicit, we had better
1679 update the mode lines and thereby update the title. */
1680 if (f->explicit_name && NILP (name))
1681 update_mode_lines = 1;
1682
1683 f->explicit_name = ! NILP (name);
1684 }
1685 else if (f->explicit_name)
1686 return;
1687
1688 /* If NAME is nil, set the name to the x_id_name. */
1689 if (NILP (name))
1690 {
1691 /* Check for no change needed in this very common case
1692 before we do any consing. */
1693 if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
1694 SDATA (f->name)))
1695 return;
1696 name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
1697 }
1698 else
1699 CHECK_STRING (name);
1700
1701 /* Don't change the name if it's already NAME. */
1702 if (! NILP (Fstring_equal (name, f->name)))
1703 return;
1704
1705 f->name = name;
1706
1707 /* For setting the frame title, the title parameter should override
1708 the name parameter. */
1709 if (! NILP (f->title))
1710 name = f->title;
1711
1712 x_set_name_internal (f, name);
1713}
1714
1697/* This function should be called when the user's lisp code has 1715/* This function should be called when the user's lisp code has
1698 specified a name for the frame; the name will override any set by the 1716 specified a name for the frame; the name will override any set by the
1699 redisplay code. */ 1717 redisplay code. */
@@ -1745,62 +1763,7 @@ x_set_title (f, name, old_name)
1745 else 1763 else
1746 CHECK_STRING (name); 1764 CHECK_STRING (name);
1747 1765
1748 if (FRAME_X_WINDOW (f)) 1766 x_set_name_internal (f, name);
1749 {
1750 BLOCK_INPUT;
1751#ifdef HAVE_X11R4
1752 {
1753 XTextProperty text, icon;
1754 int bytes, stringp;
1755 Lisp_Object coding_system;
1756
1757 coding_system = Qcompound_text;
1758 /* See the comment "Note: Encoding strategy" in x_set_name. */
1759 text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
1760 text.encoding = (stringp ? XA_STRING
1761 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1762 text.format = 8;
1763 text.nitems = bytes;
1764
1765 if (NILP (f->icon_name))
1766 {
1767 icon = text;
1768 }
1769 else
1770 {
1771 /* See the comment "Note: Encoding strategy" in x_set_name. */
1772 icon.value = x_encode_text (f->icon_name, coding_system, 0,
1773 &bytes, &stringp);
1774 icon.encoding = (stringp ? XA_STRING
1775 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1776 icon.format = 8;
1777 icon.nitems = bytes;
1778 }
1779
1780#ifdef USE_GTK
1781 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1782 SDATA (ENCODE_UTF_8 (name)));
1783#else /* not USE_GTK */
1784 XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
1785#endif /* not USE_GTK */
1786
1787 XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
1788 &icon);
1789
1790 if (!NILP (f->icon_name)
1791 && icon.value != (unsigned char *) SDATA (f->icon_name))
1792 xfree (icon.value);
1793 if (text.value != (unsigned char *) SDATA (name))
1794 xfree (text.value);
1795 }
1796#else /* not HAVE_X11R4 */
1797 XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1798 SDATA (name));
1799 XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1800 SDATA (name));
1801#endif /* not HAVE_X11R4 */
1802 UNBLOCK_INPUT;
1803 }
1804} 1767}
1805 1768
1806void 1769void