comparison src/widget.c @ 105693:964ff7cbc8a6

Fix resize due to font change on a maximized/xmonad-controlled frame. * xterm.h (x_wait_for_event): Declare it. * xterm.c (pending_event_wait): New variable. (handle_one_xevent): Set pending_event_wait.eventtype to 0 if we see pending_event_wait.eventtype. (handle_one_xevent): Don't change gravity when parent changes. (x_new_font): Call change_frame_size with new rows/columns before we try to resize the frame. (x_wait_for_event): New function. (x_set_window_size_1): Don't change gravity unless change_gravity is set. Call XResizeWindow with FRAME_OUTER_WINDOW. If we are visible, don't change frame size, instead wait for the ConfigureNotify. (x_set_window_size): Call x_set_window_size_1 for USE_X_TOOLKIT also. (x_wm_set_size_hint): Remove ifdefs for USE_X_TOOLKIT. (x_initialize): Initialize pending_event_wait. * xmenu.c (set_frame_menubar): Add internal border width to menu bar size. * widget.c (EmacsFrameSetValues): Add comment. (EmacsFrameSetCharSize): Just call x_set_window_size. * gtkutil.c (xg_frame_set_char_size): Flush events and call x_wait_for_event. (flush_and_sync): Removed again. (xg_get_font_name): Suggest monospace if no previous font is known.
author Jan Djärv <jan.h.d@swipnet.se>
date Wed, 21 Oct 2009 18:29:46 +0000
parents 68dd71358159
children 1d1d5d9bd884
comparison
equal deleted inserted replaced
105692:15b4b661ceb1 105693:964ff7cbc8a6
773 773
774 int char_width, char_height; 774 int char_width, char_height;
775 Dimension pixel_width; 775 Dimension pixel_width;
776 Dimension pixel_height; 776 Dimension pixel_height;
777 777
778 /* AFAIK, this function is never called. -- Jan D, Oct 2009. */
778 has_to_recompute_gcs = (cur->emacs_frame.font != new->emacs_frame.font 779 has_to_recompute_gcs = (cur->emacs_frame.font != new->emacs_frame.font
779 || (cur->emacs_frame.foreground_pixel 780 || (cur->emacs_frame.foreground_pixel
780 != new->emacs_frame.foreground_pixel) 781 != new->emacs_frame.foreground_pixel)
781 || (cur->core.background_pixel 782 || (cur->core.background_pixel
782 != new->core.background_pixel) 783 != new->core.background_pixel)
870 Widget widget; 871 Widget widget;
871 int columns; 872 int columns;
872 int rows; 873 int rows;
873 { 874 {
874 EmacsFrame ew = (EmacsFrame) widget; 875 EmacsFrame ew = (EmacsFrame) widget;
875 Dimension pixel_width, pixel_height;
876 struct frame *f = ew->emacs_frame.frame; 876 struct frame *f = ew->emacs_frame.frame;
877 877
878 if (columns < 3) columns = 3; /* no way buddy */ 878 x_set_window_size (f, 0, columns, rows);
879
880 check_frame_size (f, &rows, &columns);
881 f->scroll_bar_actual_width
882 = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
883
884 compute_fringe_widths (f, 0);
885
886 char_to_pixel_size (ew, columns, rows, &pixel_width, &pixel_height);
887
888 #if 0 /* This doesn't seem to be right. The frame gets too wide. --gerd. */
889 /* Something is really strange here wrt to the border width:
890 Apparently, XtNwidth and XtNheight include the border, so we have
891 to add it here. But the XtNborderWidth set for the widgets has
892 no similarity to what f->border_width is set to. */
893 XtVaGetValues (widget, XtNborderWidth, &border_width, NULL);
894 pixel_height += 2 * border_width;
895 pixel_width += 2 * border_width;
896 #endif
897
898 /* Manually change the height and width of all our widgets,
899 adjusting each widget by the same increments. */
900 if (ew->core.width != pixel_width
901 || ew->core.height != pixel_height)
902 {
903 int hdelta = pixel_height - ew->core.height;
904 int wdelta = pixel_width - ew->core.width;
905 int column_widget_height = f->output_data.x->column_widget->core.height;
906 int column_widget_width = f->output_data.x->column_widget->core.width;
907 int outer_widget_height = f->output_data.x->widget->core.height;
908 int outer_widget_width = f->output_data.x->widget->core.width;
909 int old_left = f->output_data.x->widget->core.x;
910 int old_top = f->output_data.x->widget->core.y;
911
912 /* Input is blocked here, and Xt waits for some event to
913 occur. */
914
915 lw_refigure_widget (f->output_data.x->column_widget, False);
916 update_hints_inhibit = 1;
917
918 /* Xt waits for a ConfigureNotify event from the window manager
919 in EmacsFrameSetCharSize when the shell widget is resized.
920 For some window managers like fvwm2 2.2.5 and KDE 2.1 this
921 event doesn't arrive for an unknown reason and Emacs hangs in
922 Xt when the default font is changed. Tell Xt not to wait,
923 depending on the value of the frame parameter
924 `wait-for-wm'. */
925 x_catch_errors (FRAME_X_DISPLAY (f));
926 XtVaSetValues (f->output_data.x->widget,
927 XtNwaitForWm, (XtArgVal) f->output_data.x->wait_for_wm,
928 NULL);
929 x_uncatch_errors ();
930
931 /* Workaround: When a SIGIO or SIGALRM occurs while Xt is
932 waiting for a ConfigureNotify event (see above), this leads
933 to Xt waiting indefinitely instead of using its default
934 timeout (5 seconds). */
935 turn_on_atimers (0);
936 #ifdef SIGIO
937 sigblock (sigmask (SIGIO));
938 #endif
939
940 /* Do parents first, otherwise LessTif's geometry management
941 enters an infinite loop (as of 2000-01-15). This is fixed in
942 later versions of LessTif (as of 2001-03-13); I'll leave it
943 as is because I think it can't do any harm. */
944 /* In April 2002, simon.marshall@misys.com reports the problem
945 seems not to occur any longer. */
946 x_catch_errors (FRAME_X_DISPLAY (f));
947 XtVaSetValues (f->output_data.x->widget,
948 XtNheight, (XtArgVal) (outer_widget_height + hdelta),
949 XtNwidth, (XtArgVal) (outer_widget_width + wdelta),
950 NULL);
951 XtVaSetValues (f->output_data.x->column_widget,
952 XtNheight, (XtArgVal) (column_widget_height + hdelta),
953 XtNwidth, (XtArgVal) column_widget_width + wdelta,
954 NULL);
955 XtVaSetValues ((Widget) ew,
956 XtNheight, (XtArgVal) pixel_height,
957 XtNwidth, (XtArgVal) pixel_width,
958 NULL);
959 x_uncatch_errors ();
960
961 #ifdef SIGIO
962 sigunblock (sigmask (SIGIO));
963 #endif
964 turn_on_atimers (1);
965
966 lw_refigure_widget (f->output_data.x->column_widget, True);
967
968 update_hints_inhibit = 0;
969 update_wm_hints (ew);
970
971 /* These seem to get clobbered. I don't know why. - rms. */
972 f->output_data.x->widget->core.x = old_left;
973 f->output_data.x->widget->core.y = old_top;
974 }
975
976 /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
977 receive in the ConfigureNotify event; if we get what we asked
978 for, then the event won't cause the screen to become garbaged, so
979 we have to make sure to do it here. */
980 SET_FRAME_GARBAGED (f);
981 } 879 }
982 880
983 881
984 void 882 void
985 widget_store_internal_border (widget) 883 widget_store_internal_border (widget)