aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-07-20 20:14:58 +0400
committerDmitry Antipov2014-07-20 20:14:58 +0400
commita1edea0c88ac69acc1b386a67859a674dd5af5aa (patch)
treed261496c28269a6d608fac39cf55af4a5f15bca4 /src
parenta54493b02fc90ab163aa88dfe68c2b5e44a2536e (diff)
downloademacs-a1edea0c88ac69acc1b386a67859a674dd5af5aa.tar.gz
emacs-a1edea0c88ac69acc1b386a67859a674dd5af5aa.zip
* frame.h (struct frame) [USE_X_TOOLKIT]: New member shell_position.
* xfns.c (x_window): Use it to allow xfree later. (x_encode_text): Drop 3rd arg; unused. Tweak comment and adjust users where appropriate. Use bool for booleans and remove redundant checks. (Fx_backspace_delete_keys_p): Use XkbFreeKeyboard; explain why. * xterm.c (x_free_frame_resources): Free shell_position.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/frame.h5
-rw-r--r--src/xfns.c54
-rw-r--r--src/xterm.c3
4 files changed, 40 insertions, 31 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 51569f14f31..d4f6321faf7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12014-07-20 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * frame.h (struct frame) [USE_X_TOOLKIT]: New member shell_position.
4 * xfns.c (x_window): Use it to allow xfree later.
5 (x_encode_text): Drop 3rd arg; unused. Tweak comment and adjust users
6 where appropriate. Use bool for booleans and remove redundant checks.
7 (Fx_backspace_delete_keys_p): Use XkbFreeKeyboard; explain why.
8 * xterm.c (x_free_frame_resources): Free shell_position.
9
12014-07-19 K. Handa <handa@gnu.org> 102014-07-19 K. Handa <handa@gnu.org>
2 11
3 * xfaces.c (realize_x_face): Call font_load_for_lface with no 12 * xfaces.c (realize_x_face): Call font_load_for_lface with no
diff --git a/src/frame.h b/src/frame.h
index faeac2ad625..999a29d56ae 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -192,6 +192,11 @@ struct frame
192 char *namebuf; 192 char *namebuf;
193#endif 193#endif
194 194
195#ifdef USE_X_TOOLKIT
196 /* Used to pass geometry parameters to toolkit functions. */
197 char *shell_position;
198#endif
199
195 /* Glyph pool and matrix. */ 200 /* Glyph pool and matrix. */
196 struct glyph_pool *current_pool; 201 struct glyph_pool *current_pool;
197 struct glyph_pool *desired_pool; 202 struct glyph_pool *desired_pool;
diff --git a/src/xfns.c b/src/xfns.c
index cd95ea8ab72..868c5b68850 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1260,10 +1260,6 @@ x_set_scroll_bar_background (struct frame *f, Lisp_Object value, Lisp_Object old
1260 CODING_SYSTEM, and return a newly allocated memory area which 1260 CODING_SYSTEM, and return a newly allocated memory area which
1261 should be freed by `xfree' by a caller. 1261 should be freed by `xfree' by a caller.
1262 1262
1263 SELECTIONP non-zero means the string is being encoded for an X
1264 selection, so it is safe to run pre-write conversions (which
1265 may run Lisp code).
1266
1267 Store the byte length of resulting text in *TEXT_BYTES. 1263 Store the byte length of resulting text in *TEXT_BYTES.
1268 1264
1269 If the text contains only ASCII and Latin-1, store 1 in *STRING_P, 1265 If the text contains only ASCII and Latin-1, store 1 in *STRING_P,
@@ -1272,8 +1268,8 @@ x_set_scroll_bar_background (struct frame *f, Lisp_Object value, Lisp_Object old
1272 the result should be `COMPOUND_TEXT'. */ 1268 the result should be `COMPOUND_TEXT'. */
1273 1269
1274static unsigned char * 1270static unsigned char *
1275x_encode_text (Lisp_Object string, Lisp_Object coding_system, int selectionp, 1271x_encode_text (Lisp_Object string, Lisp_Object coding_system,
1276 ptrdiff_t *text_bytes, int *stringp, int *freep) 1272 ptrdiff_t *text_bytes, int *stringp, bool *freep)
1277{ 1273{
1278 int result = string_xstring_p (string); 1274 int result = string_xstring_p (string);
1279 struct coding_system coding; 1275 struct coding_system coding;
@@ -1316,7 +1312,7 @@ x_set_name_internal (struct frame *f, Lisp_Object name)
1316 XTextProperty text, icon; 1312 XTextProperty text, icon;
1317 ptrdiff_t bytes; 1313 ptrdiff_t bytes;
1318 int stringp; 1314 int stringp;
1319 int do_free_icon_value = 0, do_free_text_value = 0; 1315 bool do_free_icon_value = 0, do_free_text_value = 0;
1320 Lisp_Object coding_system; 1316 Lisp_Object coding_system;
1321 Lisp_Object encoded_name; 1317 Lisp_Object encoded_name;
1322 Lisp_Object encoded_icon_name; 1318 Lisp_Object encoded_icon_name;
@@ -1348,14 +1344,12 @@ x_set_name_internal (struct frame *f, Lisp_Object name)
1348 properties. Per the EWMH specification, those two properties 1344 properties. Per the EWMH specification, those two properties
1349 are always UTF8_STRING. This matches what gtk_window_set_title() 1345 are always UTF8_STRING. This matches what gtk_window_set_title()
1350 does in the USE_GTK case. */ 1346 does in the USE_GTK case. */
1351 text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp, 1347 text.value = x_encode_text (name, coding_system, &bytes,
1352 &do_free_text_value); 1348 &stringp, &do_free_text_value);
1353 text.encoding = (stringp ? XA_STRING 1349 text.encoding = (stringp ? XA_STRING
1354 : FRAME_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); 1350 : FRAME_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1355 text.format = 8; 1351 text.format = 8;
1356 text.nitems = bytes; 1352 text.nitems = bytes;
1357 if (text.nitems != bytes)
1358 error ("Window name too large");
1359 1353
1360 if (!STRINGP (f->icon_name)) 1354 if (!STRINGP (f->icon_name))
1361 { 1355 {
@@ -1365,14 +1359,12 @@ x_set_name_internal (struct frame *f, Lisp_Object name)
1365 else 1359 else
1366 { 1360 {
1367 /* See the above comment "Note: Encoding strategy". */ 1361 /* See the above comment "Note: Encoding strategy". */
1368 icon.value = x_encode_text (f->icon_name, coding_system, 0, 1362 icon.value = x_encode_text (f->icon_name, coding_system, &bytes,
1369 &bytes, &stringp, &do_free_icon_value); 1363 &stringp, &do_free_icon_value);
1370 icon.encoding = (stringp ? XA_STRING 1364 icon.encoding = (stringp ? XA_STRING
1371 : FRAME_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); 1365 : FRAME_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1372 icon.format = 8; 1366 icon.format = 8;
1373 icon.nitems = bytes; 1367 icon.nitems = bytes;
1374 if (icon.nitems != bytes)
1375 error ("Icon name too large");
1376 1368
1377 encoded_icon_name = ENCODE_UTF_8 (f->icon_name); 1369 encoded_icon_name = ENCODE_UTF_8 (f->icon_name);
1378 } 1370 }
@@ -1410,16 +1402,16 @@ x_set_name_internal (struct frame *f, Lisp_Object name)
1410/* Change the name of frame F to NAME. If NAME is nil, set F's name to 1402/* Change the name of frame F to NAME. If NAME is nil, set F's name to
1411 x_id_name. 1403 x_id_name.
1412 1404
1413 If EXPLICIT is non-zero, that indicates that lisp code is setting the 1405 If EXPLICIT is true, that indicates that lisp code is setting the
1414 name; if NAME is a string, set F's name to NAME and set 1406 name; if NAME is a string, set F's name to NAME and set
1415 F->explicit_name; if NAME is Qnil, then clear F->explicit_name. 1407 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1416 1408
1417 If EXPLICIT is zero, that indicates that Emacs redisplay code is 1409 If EXPLICIT is false, that indicates that Emacs redisplay code is
1418 suggesting a new name, which lisp code should override; if 1410 suggesting a new name, which lisp code should override; if
1419 F->explicit_name is set, ignore the new name; otherwise, set it. */ 1411 F->explicit_name is set, ignore the new name; otherwise, set it. */
1420 1412
1421static void 1413static void
1422x_set_name (struct frame *f, Lisp_Object name, int explicit) 1414x_set_name (struct frame *f, Lisp_Object name, bool explicit)
1423{ 1415{
1424 /* Make sure that requests from lisp code override requests from 1416 /* Make sure that requests from lisp code override requests from
1425 Emacs redisplay code. */ 1417 Emacs redisplay code. */
@@ -2263,8 +2255,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
2263 2255
2264 /* Do some needed geometry management. */ 2256 /* Do some needed geometry management. */
2265 { 2257 {
2266 char *tem, shell_position[sizeof "=x++" + 4 * INT_STRLEN_BOUND (int)]; 2258 Arg gal[3];
2267 Arg gal[10];
2268 int gac = 0; 2259 int gac = 0;
2269 int extra_borders = 0; 2260 int extra_borders = 0;
2270 int menubar_size 2261 int menubar_size
@@ -2294,6 +2285,8 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
2294 extra_borders *= 2; 2285 extra_borders *= 2;
2295#endif 2286#endif
2296 2287
2288 f->shell_position = xmalloc (sizeof "=x++" + 4 * INT_STRLEN_BOUND (int));
2289
2297 /* Convert our geometry parameters into a geometry string 2290 /* Convert our geometry parameters into a geometry string
2298 and specify it. 2291 and specify it.
2299 Note that we do not specify here whether the position 2292 Note that we do not specify here whether the position
@@ -2310,14 +2303,14 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
2310 top = -top; 2303 top = -top;
2311 2304
2312 if (window_prompting & USPosition) 2305 if (window_prompting & USPosition)
2313 sprintf (shell_position, "=%dx%d%c%d%c%d", 2306 sprintf (f->shell_position, "=%dx%d%c%d%c%d",
2314 FRAME_PIXEL_WIDTH (f) + extra_borders, 2307 FRAME_PIXEL_WIDTH (f) + extra_borders,
2315 FRAME_PIXEL_HEIGHT (f) + menubar_size + extra_borders, 2308 FRAME_PIXEL_HEIGHT (f) + menubar_size + extra_borders,
2316 (xneg ? '-' : '+'), left, 2309 (xneg ? '-' : '+'), left,
2317 (yneg ? '-' : '+'), top); 2310 (yneg ? '-' : '+'), top);
2318 else 2311 else
2319 { 2312 {
2320 sprintf (shell_position, "=%dx%d", 2313 sprintf (f->shell_position, "=%dx%d",
2321 FRAME_PIXEL_WIDTH (f) + extra_borders, 2314 FRAME_PIXEL_WIDTH (f) + extra_borders,
2322 FRAME_PIXEL_HEIGHT (f) + menubar_size + extra_borders); 2315 FRAME_PIXEL_HEIGHT (f) + menubar_size + extra_borders);
2323 2316
@@ -2331,12 +2324,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
2331 } 2324 }
2332 } 2325 }
2333 2326
2334 /* We don't free this because we don't know whether 2327 XtSetArg (gal[gac], XtNgeometry, f->shell_position); gac++;
2335 it is safe to free it while the frame exists.
2336 It isn't worth the trouble of arranging to free it
2337 when the frame is deleted. */
2338 tem = xstrdup (shell_position);
2339 XtSetArg (gal[gac], XtNgeometry, tem); gac++;
2340 XtSetValues (shell_widget, gal, gac); 2328 XtSetValues (shell_widget, gal, gac);
2341 } 2329 }
2342 2330
@@ -2405,7 +2393,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
2405 the X server hasn't been told. */ 2393 the X server hasn't been told. */
2406 { 2394 {
2407 Lisp_Object name; 2395 Lisp_Object name;
2408 int explicit = f->explicit_name; 2396 bool explicit = f->explicit_name;
2409 2397
2410 f->explicit_name = 0; 2398 f->explicit_name = 0;
2411 name = f->name; 2399 name = f->name;
@@ -2548,7 +2536,7 @@ x_window (struct frame *f)
2548 the X server hasn't been told. */ 2536 the X server hasn't been told. */
2549 { 2537 {
2550 Lisp_Object name; 2538 Lisp_Object name;
2551 int explicit = f->explicit_name; 2539 bool explicit = f->explicit_name;
2552 2540
2553 f->explicit_name = 0; 2541 f->explicit_name = 0;
2554 name = f->name; 2542 name = f->name;
@@ -6091,7 +6079,11 @@ present and mapped to the usual X keysyms. */)
6091 XkbFreeNames (kb, 0, True); 6079 XkbFreeNames (kb, 0, True);
6092 } 6080 }
6093 6081
6094 XkbFreeClientMap (kb, 0, True); 6082 /* As of libX11-1.6.2, XkbGetMap manual says that you should use
6083 XkbFreeClientMap to free the data returned by XkbGetMap. But
6084 this function just frees the data referenced from KB and not
6085 KB itself. To free KB as well, call XkbFreeKeyboard. */
6086 XkbFreeKeyboard (kb, XkbAllMapComponentsMask, True);
6095 6087
6096 if (delete_keycode 6088 if (delete_keycode
6097 && backspace_keycode 6089 && backspace_keycode
diff --git a/src/xterm.c b/src/xterm.c
index 22a24864c9d..c3eb0028206 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9245,6 +9245,9 @@ x_free_frame_resources (struct frame *f)
9245 XDestroyWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); 9245 XDestroyWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
9246 9246
9247 free_frame_menubar (f); 9247 free_frame_menubar (f);
9248
9249 if (f->shell_position)
9250 xfree (f->shell_position);
9248#else /* !USE_X_TOOLKIT */ 9251#else /* !USE_X_TOOLKIT */
9249 9252
9250#ifdef USE_GTK 9253#ifdef USE_GTK