aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2017-06-25 12:46:50 -0700
committerPaul Eggert2017-06-25 12:54:12 -0700
commitb2f81598670d19684e65ce4587a0ebaf92443b27 (patch)
treed1dde0f444c0c0d117d57eaaace7eed21ea6ee9d
parent68e03d1eb40e8766b9bb51d9519188d8a21db0c3 (diff)
downloademacs-b2f81598670d19684e65ce4587a0ebaf92443b27.tar.gz
emacs-b2f81598670d19684e65ce4587a0ebaf92443b27.zip
Port recent frame changes to GCC 7
* src/frame.c (keep_ratio): New arg P. Caller changed. Since it is non-null, it avoids a GCC 7 warning that FRAME_PARENT_FRAME might return null. This also avoids a run-time test.
-rw-r--r--src/frame.c52
1 files changed, 23 insertions, 29 deletions
diff --git a/src/frame.c b/src/frame.c
index b2377aefb8d..1e5e4bbdb48 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -378,7 +378,7 @@ frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal,
378 * keep_ratio: 378 * keep_ratio:
379 * 379 *
380 * Preserve ratios of frame F which usually happens after its parent 380 * Preserve ratios of frame F which usually happens after its parent
381 * frame got resized. OLD_WIDTH, OLD_HEIGHT specifies the old native 381 * frame P got resized. OLD_WIDTH, OLD_HEIGHT specifies the old native
382 * size of F's parent, NEW_WIDTH and NEW_HEIGHT its new size. 382 * size of F's parent, NEW_WIDTH and NEW_HEIGHT its new size.
383 * 383 *
384 * Adjust F's width if F's 'keep_ratio' parameter is non-nil and, if 384 * Adjust F's width if F's 'keep_ratio' parameter is non-nil and, if
@@ -403,8 +403,8 @@ frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal,
403 * different resolutions. 403 * different resolutions.
404 */ 404 */
405static void 405static void
406keep_ratio (struct frame *f, int old_width, int old_height, 406keep_ratio (struct frame *f, struct frame *p, int old_width, int old_height,
407 int new_width, int new_height) 407 int new_width, int new_height)
408{ 408{
409 Lisp_Object keep_ratio = get_frame_param (f, Qkeep_ratio); 409 Lisp_Object keep_ratio = get_frame_param (f, Qkeep_ratio);
410 410
@@ -423,20 +423,17 @@ keep_ratio (struct frame *f, int old_width, int old_height,
423 { 423 {
424 pos_x = (int)(f->left_pos * width_factor + 0.5); 424 pos_x = (int)(f->left_pos * width_factor + 0.5);
425 425
426 if (CONSP (keep_ratio) && 426 if (CONSP (keep_ratio)
427 (NILP (Fcar (keep_ratio)) || EQ (Fcar (keep_ratio), Qheight_only))) 427 && (NILP (Fcar (keep_ratio))
428 || EQ (Fcar (keep_ratio), Qheight_only))
429 && p->pixel_width - f->pixel_width < pos_x)
428 { 430 {
429 struct frame *p = FRAME_PARENT_FRAME (f); 431 int p_f_width = p->pixel_width - f->pixel_width;
430 432
431 if (pos_x + f->pixel_width > p->pixel_width) 433 if (p_f_width <= 0)
432 { 434 pos_x = 0;
433 int p_f_width = p->pixel_width - f->pixel_width; 435 else
434 436 pos_x = (int)(p_f_width * width_factor * 0.5 + 0.5);
435 if (p_f_width <= 0)
436 pos_x = 0;
437 else
438 pos_x = (int)(p_f_width * width_factor * 0.5 + 0.5);
439 }
440 } 437 }
441 438
442 f->left_pos = pos_x; 439 f->left_pos = pos_x;
@@ -448,25 +445,22 @@ keep_ratio (struct frame *f, int old_width, int old_height,
448 { 445 {
449 pos_y = (int)(f->top_pos * height_factor + 0.5); 446 pos_y = (int)(f->top_pos * height_factor + 0.5);
450 447
451 if (CONSP (keep_ratio) && 448 if (CONSP (keep_ratio)
452 (NILP (Fcar (keep_ratio)) || EQ (Fcar (keep_ratio), Qwidth_only))) 449 && (NILP (Fcar (keep_ratio))
450 || EQ (Fcar (keep_ratio), Qwidth_only))
451 && p->pixel_height - f->pixel_height < pos_y)
453 /* When positional adjustment was requested and the 452 /* When positional adjustment was requested and the
454 width of F should remain unaltered, try to constrain 453 width of F should remain unaltered, try to constrain
455 F to its parent. This means that when the parent 454 F to its parent. This means that when the parent
456 frame is enlarged later the child's original position 455 frame is enlarged later the child's original position
457 won't get restored. */ 456 won't get restored. */
458 { 457 {
459 struct frame *p = FRAME_PARENT_FRAME (f); 458 int p_f_height = p->pixel_height - f->pixel_height;
460 459
461 if (pos_y + f->pixel_height > p->pixel_height) 460 if (p_f_height <= 0)
462 { 461 pos_y = 0;
463 int p_f_height = p->pixel_height - f->pixel_height; 462 else
464 463 pos_y = (int)(p_f_height * height_factor * 0.5 + 0.5);
465 if (p_f_height <= 0)
466 pos_y = 0;
467 else
468 pos_y = (int)(p_f_height * height_factor * 0.5 + 0.5);
469 }
470 } 464 }
471 465
472 f->top_pos = pos_y; 466 f->top_pos = pos_y;
@@ -777,8 +771,8 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
777 771
778 FOR_EACH_FRAME (frames, frame1) 772 FOR_EACH_FRAME (frames, frame1)
779 if (FRAME_PARENT_FRAME (XFRAME (frame1)) == f) 773 if (FRAME_PARENT_FRAME (XFRAME (frame1)) == f)
780 keep_ratio (XFRAME (frame1), old_pixel_width, old_pixel_height, 774 keep_ratio (XFRAME (frame1), f, old_pixel_width, old_pixel_height,
781 new_pixel_width, new_pixel_height); 775 new_pixel_width, new_pixel_height);
782 } 776 }
783#endif 777#endif
784} 778}