diff options
| author | Bill Wohler | 2014-02-23 18:04:35 -0800 |
|---|---|---|
| committer | Bill Wohler | 2014-02-23 18:04:35 -0800 |
| commit | 3e93bafb95608467e438ba7f725fd1f020669f8c (patch) | |
| tree | f2f90109f283e06a18caea3cb2a2623abcfb3a92 /src/widget.c | |
| parent | 791c0d7634e44bb92ca85af605be84ff2ae08963 (diff) | |
| parent | e918e27fdf331e89268fc2c9d7cf838d3ecf7aa7 (diff) | |
| download | emacs-3e93bafb95608467e438ba7f725fd1f020669f8c.tar.gz emacs-3e93bafb95608467e438ba7f725fd1f020669f8c.zip | |
Merge from trunk; up to 2014-02-23T23:41:17Z!lekktu@gmail.com.
Diffstat (limited to 'src/widget.c')
| -rw-r--r-- | src/widget.c | 109 |
1 files changed, 54 insertions, 55 deletions
diff --git a/src/widget.c b/src/widget.c index 28e9fc29a91..838e775f918 100644 --- a/src/widget.c +++ b/src/widget.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* The emacs frame widget. | 1 | /* The emacs frame widget. |
| 2 | Copyright (C) 1992-1993, 2000-2013 Free Software Foundation, Inc. | 2 | Copyright (C) 1992-1993, 2000-2014 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
| @@ -190,6 +190,14 @@ pixel_to_char_size (EmacsFrame ew, Dimension pixel_width, Dimension pixel_height | |||
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | static void | 192 | static void |
| 193 | pixel_to_text_size (EmacsFrame ew, Dimension pixel_width, Dimension pixel_height, int *text_width, int *text_height) | ||
| 194 | { | ||
| 195 | struct frame* f = ew->emacs_frame.frame; | ||
| 196 | *text_width = FRAME_PIXEL_TO_TEXT_WIDTH (f, (int) pixel_width); | ||
| 197 | *text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, (int) pixel_height); | ||
| 198 | } | ||
| 199 | |||
| 200 | static void | ||
| 193 | char_to_pixel_size (EmacsFrame ew, int char_width, int char_height, Dimension *pixel_width, Dimension *pixel_height) | 201 | char_to_pixel_size (EmacsFrame ew, int char_width, int char_height, Dimension *pixel_width, Dimension *pixel_height) |
| 194 | { | 202 | { |
| 195 | struct frame* f = ew->emacs_frame.frame; | 203 | struct frame* f = ew->emacs_frame.frame; |
| @@ -404,15 +412,13 @@ set_frame_size (EmacsFrame ew) | |||
| 404 | might end up with a frame width that is not a multiple of the | 412 | might end up with a frame width that is not a multiple of the |
| 405 | frame's character width which is bad for vertically split | 413 | frame's character width which is bad for vertically split |
| 406 | windows. */ | 414 | windows. */ |
| 407 | f->scroll_bar_actual_width | ||
| 408 | = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f); | ||
| 409 | 415 | ||
| 410 | compute_fringe_widths (f, 0); | 416 | compute_fringe_widths (f, 0); |
| 411 | 417 | ||
| 412 | #if 0 /* This can run Lisp code, and it is dangerous to give | 418 | #if 0 /* This can run Lisp code, and it is dangerous to give |
| 413 | out the frame to Lisp code before it officially exists. | 419 | out the frame to Lisp code before it officially exists. |
| 414 | This is handled in Fx_create_frame so not needed here. */ | 420 | This is handled in Fx_create_frame so not needed here. */ |
| 415 | change_frame_size (f, h, w, 1, 0, 0); | 421 | change_frame_size (f, w, h, 1, 0, 0, 0); |
| 416 | #endif | 422 | #endif |
| 417 | char_to_pixel_size (ew, w, h, &pixel_width, &pixel_height); | 423 | char_to_pixel_size (ew, w, h, &pixel_width, &pixel_height); |
| 418 | ew->core.width = pixel_width; | 424 | ew->core.width = pixel_width; |
| @@ -467,7 +473,7 @@ update_wm_hints (EmacsFrame ew) | |||
| 467 | if (! wmshell) return; | 473 | if (! wmshell) return; |
| 468 | 474 | ||
| 469 | #if 0 | 475 | #if 0 |
| 470 | check_frame_size (ew->emacs_frame.frame, &min_rows, &min_cols); | 476 | check_frame_size (ew->emacs_frame.frame, &min_cols, &min_rows, 0); |
| 471 | #endif | 477 | #endif |
| 472 | 478 | ||
| 473 | pixel_to_char_size (ew, ew->core.width, ew->core.height, | 479 | pixel_to_char_size (ew, ew->core.width, ew->core.height, |
| @@ -489,8 +495,8 @@ update_wm_hints (EmacsFrame ew) | |||
| 489 | XtVaSetValues (wmshell, | 495 | XtVaSetValues (wmshell, |
| 490 | XtNbaseWidth, (XtArgVal) base_width, | 496 | XtNbaseWidth, (XtArgVal) base_width, |
| 491 | XtNbaseHeight, (XtArgVal) base_height, | 497 | XtNbaseHeight, (XtArgVal) base_height, |
| 492 | XtNwidthInc, (XtArgVal) cw, | 498 | XtNwidthInc, (XtArgVal) (frame_resize_pixelwise ? 1 : cw), |
| 493 | XtNheightInc, (XtArgVal) ch, | 499 | XtNheightInc, (XtArgVal) (frame_resize_pixelwise ? 1 : ch), |
| 494 | XtNminWidth, (XtArgVal) (base_width + min_cols * cw), | 500 | XtNminWidth, (XtArgVal) (base_width + min_cols * cw), |
| 495 | XtNminHeight, (XtArgVal) (base_height + min_rows * ch), | 501 | XtNminHeight, (XtArgVal) (base_height + min_rows * ch), |
| 496 | NULL); | 502 | NULL); |
| @@ -503,26 +509,6 @@ widget_update_wm_size_hints (Widget widget) | |||
| 503 | update_wm_hints (ew); | 509 | update_wm_hints (ew); |
| 504 | } | 510 | } |
| 505 | 511 | ||
| 506 | |||
| 507 | #if 0 | ||
| 508 | |||
| 509 | static void | ||
| 510 | create_frame_gcs (EmacsFrame ew) | ||
| 511 | { | ||
| 512 | struct frame *s = ew->emacs_frame.frame; | ||
| 513 | |||
| 514 | s->output_data.x->normal_gc | ||
| 515 | = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0); | ||
| 516 | s->output_data.x->reverse_gc | ||
| 517 | = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0); | ||
| 518 | s->output_data.x->cursor_gc | ||
| 519 | = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0); | ||
| 520 | s->output_data.x->black_relief.gc = 0; | ||
| 521 | s->output_data.x->white_relief.gc = 0; | ||
| 522 | } | ||
| 523 | |||
| 524 | #endif /* 0 */ | ||
| 525 | |||
| 526 | static char setup_frame_cursor_bits[] = | 512 | static char setup_frame_cursor_bits[] = |
| 527 | { | 513 | { |
| 528 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 514 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| @@ -545,7 +531,7 @@ setup_frame_gcs (EmacsFrame ew) | |||
| 545 | font = Ffont_xlfd_name (font, Qnil); | 531 | font = Ffont_xlfd_name (font, Qnil); |
| 546 | if (STRINGP (font)) | 532 | if (STRINGP (font)) |
| 547 | { | 533 | { |
| 548 | XFontStruct *xfont = XLoadQueryFont (FRAME_X_DISPLAY_INFO (s)->display, | 534 | XFontStruct *xfont = XLoadQueryFont (FRAME_DISPLAY_INFO (s)->display, |
| 549 | SSDATA (font)); | 535 | SSDATA (font)); |
| 550 | if (xfont) | 536 | if (xfont) |
| 551 | { | 537 | { |
| @@ -613,8 +599,13 @@ update_various_frame_slots (EmacsFrame ew) | |||
| 613 | { | 599 | { |
| 614 | struct frame *f = ew->emacs_frame.frame; | 600 | struct frame *f = ew->emacs_frame.frame; |
| 615 | struct x_output *x = f->output_data.x; | 601 | struct x_output *x = f->output_data.x; |
| 602 | /* Don't do that: It confuses the check in change_frame_size_1 whether | ||
| 603 | the pixel size of the frame changed due to a change of the internal | ||
| 604 | border width. Bug#16736. */ | ||
| 605 | #if 0 | ||
| 616 | FRAME_PIXEL_HEIGHT (f) = ew->core.height + x->menubar_height; | 606 | FRAME_PIXEL_HEIGHT (f) = ew->core.height + x->menubar_height; |
| 617 | FRAME_PIXEL_WIDTH (f) = ew->core.width; | 607 | FRAME_PIXEL_WIDTH (f) = ew->core.width; |
| 608 | #endif | ||
| 618 | f->internal_border_width = ew->emacs_frame.internal_border_width; | 609 | f->internal_border_width = ew->emacs_frame.internal_border_width; |
| 619 | 610 | ||
| 620 | } | 611 | } |
| @@ -656,7 +647,6 @@ resize_cb (Widget widget, | |||
| 656 | XEvent* event, | 647 | XEvent* event, |
| 657 | Boolean* continue_to_dispatch) | 648 | Boolean* continue_to_dispatch) |
| 658 | { | 649 | { |
| 659 | EmacsFrame ew = (EmacsFrame) widget; | ||
| 660 | EmacsFrameResize (widget); | 650 | EmacsFrameResize (widget); |
| 661 | } | 651 | } |
| 662 | 652 | ||
| @@ -684,19 +674,7 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs | |||
| 684 | static void | 674 | static void |
| 685 | EmacsFrameDestroy (Widget widget) | 675 | EmacsFrameDestroy (Widget widget) |
| 686 | { | 676 | { |
| 687 | EmacsFrame ew = (EmacsFrame) widget; | 677 | /* All GCs are now freed in x_free_frame_resources. */ |
| 688 | struct frame* s = ew->emacs_frame.frame; | ||
| 689 | |||
| 690 | if (! s) emacs_abort (); | ||
| 691 | if (! s->output_data.x) emacs_abort (); | ||
| 692 | |||
| 693 | block_input (); | ||
| 694 | x_free_gcs (s); | ||
| 695 | if (s->output_data.x->white_relief.gc) | ||
| 696 | XFreeGC (XtDisplay (widget), s->output_data.x->white_relief.gc); | ||
| 697 | if (s->output_data.x->black_relief.gc) | ||
| 698 | XFreeGC (XtDisplay (widget), s->output_data.x->black_relief.gc); | ||
| 699 | unblock_input (); | ||
| 700 | } | 678 | } |
| 701 | 679 | ||
| 702 | static void | 680 | static void |
| @@ -705,21 +683,41 @@ EmacsFrameResize (Widget widget) | |||
| 705 | EmacsFrame ew = (EmacsFrame)widget; | 683 | EmacsFrame ew = (EmacsFrame)widget; |
| 706 | struct frame *f = ew->emacs_frame.frame; | 684 | struct frame *f = ew->emacs_frame.frame; |
| 707 | struct x_output *x = f->output_data.x; | 685 | struct x_output *x = f->output_data.x; |
| 708 | int columns; | 686 | |
| 709 | int rows; | 687 | #if 0 /* Always process resize requests pixelwise. Frame maximizing |
| 710 | 688 | should work even when frame_resize_pixelwise is nil. */ | |
| 711 | pixel_to_char_size (ew, ew->core.width, ew->core.height, &columns, &rows); | 689 | if (frame_resize_pixelwise) |
| 712 | if (columns != FRAME_COLS (f) | ||
| 713 | || rows != FRAME_LINES (f) | ||
| 714 | || ew->core.width != FRAME_PIXEL_WIDTH (f) | ||
| 715 | || ew->core.height + x->menubar_height != FRAME_PIXEL_HEIGHT (f)) | ||
| 716 | { | 690 | { |
| 717 | change_frame_size (f, rows, columns, 0, 1, 0); | 691 | #endif /* 0 */ |
| 692 | int width, height; | ||
| 693 | |||
| 694 | pixel_to_text_size (ew, ew->core.width, ew->core.height, &width, &height); | ||
| 695 | change_frame_size (f, width, height, 0, 1, 0, 1); | ||
| 696 | |||
| 718 | update_wm_hints (ew); | 697 | update_wm_hints (ew); |
| 719 | update_various_frame_slots (ew); | 698 | update_various_frame_slots (ew); |
| 720 | 699 | ||
| 721 | cancel_mouse_face (f); | 700 | cancel_mouse_face (f); |
| 701 | #if 0 /* See comment above. */ | ||
| 722 | } | 702 | } |
| 703 | else | ||
| 704 | { | ||
| 705 | int columns, rows; | ||
| 706 | |||
| 707 | pixel_to_char_size (ew, ew->core.width, ew->core.height, &columns, &rows); | ||
| 708 | if (columns != FRAME_COLS (f) | ||
| 709 | || rows != FRAME_LINES (f) | ||
| 710 | || ew->core.width != FRAME_PIXEL_WIDTH (f) | ||
| 711 | || ew->core.height + x->menubar_height != FRAME_PIXEL_HEIGHT (f)) | ||
| 712 | { | ||
| 713 | change_frame_size (f, columns, rows, 0, 1, 0, 0); | ||
| 714 | update_wm_hints (ew); | ||
| 715 | update_various_frame_slots (ew); | ||
| 716 | |||
| 717 | cancel_mouse_face (f); | ||
| 718 | } | ||
| 719 | } | ||
| 720 | #endif /* 0 */ | ||
| 723 | } | 721 | } |
| 724 | 722 | ||
| 725 | static Boolean | 723 | static Boolean |
| @@ -759,6 +757,7 @@ EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget, Ar | |||
| 759 | 757 | ||
| 760 | if (has_to_recompute_size) | 758 | if (has_to_recompute_size) |
| 761 | { | 759 | { |
| 760 | /* Don't do this pixelwise, hopefully. */ | ||
| 762 | pixel_width = new->core.width; | 761 | pixel_width = new->core.width; |
| 763 | pixel_height = new->core.height; | 762 | pixel_height = new->core.height; |
| 764 | pixel_to_char_size (new, pixel_width, pixel_height, &char_width, | 763 | pixel_to_char_size (new, pixel_width, pixel_height, &char_width, |
| @@ -768,8 +767,8 @@ EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget, Ar | |||
| 768 | new->core.width = pixel_width; | 767 | new->core.width = pixel_width; |
| 769 | new->core.height = pixel_height; | 768 | new->core.height = pixel_height; |
| 770 | 769 | ||
| 771 | change_frame_size (new->emacs_frame.frame, char_height, char_width, | 770 | change_frame_size (new->emacs_frame.frame, char_width, char_height, |
| 772 | 1, 0, 0); | 771 | 1, 0, 0, 0); |
| 773 | needs_a_refresh = True; | 772 | needs_a_refresh = True; |
| 774 | } | 773 | } |
| 775 | 774 | ||
| @@ -831,7 +830,7 @@ EmacsFrameSetCharSize (Widget widget, int columns, int rows) | |||
| 831 | EmacsFrame ew = (EmacsFrame) widget; | 830 | EmacsFrame ew = (EmacsFrame) widget; |
| 832 | struct frame *f = ew->emacs_frame.frame; | 831 | struct frame *f = ew->emacs_frame.frame; |
| 833 | 832 | ||
| 834 | x_set_window_size (f, 0, columns, rows); | 833 | x_set_window_size (f, 0, columns, rows, 0); |
| 835 | } | 834 | } |
| 836 | 835 | ||
| 837 | 836 | ||
| @@ -839,7 +838,7 @@ void | |||
| 839 | widget_store_internal_border (Widget widget) | 838 | widget_store_internal_border (Widget widget) |
| 840 | { | 839 | { |
| 841 | EmacsFrame ew = (EmacsFrame) widget; | 840 | EmacsFrame ew = (EmacsFrame) widget; |
| 842 | FRAME_PTR f = ew->emacs_frame.frame; | 841 | struct frame *f = ew->emacs_frame.frame; |
| 843 | 842 | ||
| 844 | ew->emacs_frame.internal_border_width = f->internal_border_width; | 843 | ew->emacs_frame.internal_border_width = f->internal_border_width; |
| 845 | } | 844 | } |