diff options
| author | Jan Djärv | 2009-10-21 18:29:46 +0000 |
|---|---|---|
| committer | Jan Djärv | 2009-10-21 18:29:46 +0000 |
| commit | 5c646d5a31903acabeb267a69f6fa7d1f21dcad7 (patch) | |
| tree | a1bd8fb98d92ac18f6d3584817c02f78807cac67 /src | |
| parent | 8d106ea001f5a258da2a36a70587cc8fc9695b1c (diff) | |
| download | emacs-5c646d5a31903acabeb267a69f6fa7d1f21dcad7.tar.gz emacs-5c646d5a31903acabeb267a69f6fa7d1f21dcad7.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 29 | ||||
| -rw-r--r-- | src/gtkutil.c | 35 | ||||
| -rw-r--r-- | src/widget.c | 106 | ||||
| -rw-r--r-- | src/xmenu.c | 8 | ||||
| -rw-r--r-- | src/xterm.c | 179 | ||||
| -rw-r--r-- | src/xterm.h | 1 |
6 files changed, 150 insertions, 208 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0589a4ba50a..c1f8b8cef83 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,32 @@ | |||
| 1 | 2009-10-21 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * xterm.h (x_wait_for_event): Declare it. | ||
| 4 | |||
| 5 | * xterm.c (pending_event_wait): New variable. | ||
| 6 | (handle_one_xevent): Set pending_event_wait.eventtype to 0 if we | ||
| 7 | see pending_event_wait.eventtype. | ||
| 8 | (handle_one_xevent): Don't change gravity when parent changes. | ||
| 9 | (x_new_font): Call change_frame_size with new rows/columns before we try | ||
| 10 | to resize the frame. | ||
| 11 | (x_wait_for_event): New function. | ||
| 12 | (x_set_window_size_1): Don't change gravity unless change_gravity is set. | ||
| 13 | Call XResizeWindow with FRAME_OUTER_WINDOW. If we are visible, | ||
| 14 | don't change frame size, instead wait for the ConfigureNotify. | ||
| 15 | (x_set_window_size): Call x_set_window_size_1 for USE_X_TOOLKIT also. | ||
| 16 | (x_wm_set_size_hint): Remove ifdefs for USE_X_TOOLKIT. | ||
| 17 | (x_initialize): Initialize pending_event_wait. | ||
| 18 | |||
| 19 | * xmenu.c (set_frame_menubar): Add internal border width to menu bar | ||
| 20 | size. | ||
| 21 | |||
| 22 | * widget.c (EmacsFrameSetValues): Add comment. | ||
| 23 | (EmacsFrameSetCharSize): Just call x_set_window_size. | ||
| 24 | |||
| 25 | * gtkutil.c (xg_frame_set_char_size): Flush events and call | ||
| 26 | x_wait_for_event. | ||
| 27 | (flush_and_sync): Removed again. | ||
| 28 | (xg_get_font_name): Suggest monospace if no previous font is known. | ||
| 29 | |||
| 1 | 2009-10-20 Stefan Monnier <monnier@iro.umontreal.ca> | 30 | 2009-10-20 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 31 | ||
| 3 | * character.c (char_resolve_modifier_mask): Don't resolve meta to the | 32 | * character.c (char_resolve_modifier_mask): Don't resolve meta to the |
diff --git a/src/gtkutil.c b/src/gtkutil.c index 8aa877a8f83..e95601c7fdd 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -665,20 +665,6 @@ xg_frame_resized (f, pixelwidth, pixelheight) | |||
| 665 | } | 665 | } |
| 666 | } | 666 | } |
| 667 | 667 | ||
| 668 | static void | ||
| 669 | flush_and_sync (f) | ||
| 670 | FRAME_PTR f; | ||
| 671 | { | ||
| 672 | gdk_window_process_all_updates (); | ||
| 673 | x_sync (f); | ||
| 674 | while (gtk_events_pending ()) | ||
| 675 | { | ||
| 676 | gtk_main_iteration (); | ||
| 677 | gdk_window_process_all_updates (); | ||
| 678 | x_sync (f); | ||
| 679 | } | ||
| 680 | } | ||
| 681 | |||
| 682 | /* Resize the outer window of frame F after chainging the height. | 668 | /* Resize the outer window of frame F after chainging the height. |
| 683 | COLUMNS/ROWS is the size the edit area shall have after the resize. */ | 669 | COLUMNS/ROWS is the size the edit area shall have after the resize. */ |
| 684 | 670 | ||
| @@ -715,6 +701,9 @@ xg_frame_set_char_size (f, cols, rows) | |||
| 715 | pixelwidth, pixelheight); | 701 | pixelwidth, pixelheight); |
| 716 | x_wm_set_size_hint (f, 0, 0); | 702 | x_wm_set_size_hint (f, 0, 0); |
| 717 | 703 | ||
| 704 | SET_FRAME_GARBAGED (f); | ||
| 705 | cancel_mouse_face (f); | ||
| 706 | |||
| 718 | /* We can not call change_frame_size for a mapped frame, | 707 | /* We can not call change_frame_size for a mapped frame, |
| 719 | we can not set pixel width/height either. The window manager may | 708 | we can not set pixel width/height either. The window manager may |
| 720 | override our resize request, XMonad does this all the time. | 709 | override our resize request, XMonad does this all the time. |
| @@ -723,14 +712,17 @@ xg_frame_set_char_size (f, cols, rows) | |||
| 723 | For unmapped windows, we can set rows/cols. When | 712 | For unmapped windows, we can set rows/cols. When |
| 724 | the frame is mapped again we will (hopefully) get the correct size. */ | 713 | the frame is mapped again we will (hopefully) get the correct size. */ |
| 725 | if (f->async_visible) | 714 | if (f->async_visible) |
| 726 | flush_and_sync (f); | 715 | { |
| 716 | /* Must call this to flush out events */ | ||
| 717 | (void)gtk_events_pending (); | ||
| 718 | gdk_flush (); | ||
| 719 | x_wait_for_event (f, ConfigureNotify); | ||
| 720 | } | ||
| 727 | else | 721 | else |
| 728 | { | 722 | { |
| 723 | change_frame_size (f, rows, cols, 0, 1, 0); | ||
| 729 | FRAME_PIXEL_WIDTH (f) = pixelwidth; | 724 | FRAME_PIXEL_WIDTH (f) = pixelwidth; |
| 730 | FRAME_PIXEL_HEIGHT (f) = pixelheight; | 725 | FRAME_PIXEL_HEIGHT (f) = pixelheight; |
| 731 | change_frame_size (f, rows, cols, 0, 1, 0); | ||
| 732 | SET_FRAME_GARBAGED (f); | ||
| 733 | cancel_mouse_face (f); | ||
| 734 | } | 726 | } |
| 735 | } | 727 | } |
| 736 | 728 | ||
| @@ -1640,9 +1632,10 @@ xg_get_font_name (f, default_name) | |||
| 1640 | #endif /* HAVE_GTK_AND_PTHREAD */ | 1632 | #endif /* HAVE_GTK_AND_PTHREAD */ |
| 1641 | 1633 | ||
| 1642 | w = gtk_font_selection_dialog_new ("Pick a font"); | 1634 | w = gtk_font_selection_dialog_new ("Pick a font"); |
| 1643 | if (default_name) | 1635 | if (!default_name) |
| 1644 | gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (w), | 1636 | default_name = "Monospace 10"; |
| 1645 | default_name); | 1637 | gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (w), |
| 1638 | default_name); | ||
| 1646 | 1639 | ||
| 1647 | xg_set_screen (w, f); | 1640 | xg_set_screen (w, f); |
| 1648 | gtk_widget_set_name (w, "emacs-fontdialog"); | 1641 | gtk_widget_set_name (w, "emacs-fontdialog"); |
diff --git a/src/widget.c b/src/widget.c index 32b3649be5d..8e1e207004a 100644 --- a/src/widget.c +++ b/src/widget.c | |||
| @@ -775,6 +775,7 @@ EmacsFrameSetValues (cur_widget, req_widget, new_widget, dum1, dum2) | |||
| 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) |
| @@ -872,112 +873,9 @@ EmacsFrameSetCharSize (widget, columns, rows) | |||
| 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 | ||
diff --git a/src/xmenu.c b/src/xmenu.c index f899ddaa631..a2c9fbaaeaf 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -1555,8 +1555,10 @@ set_frame_menubar (f, first_time, deep_p) | |||
| 1555 | + f->output_data.x->menubar_widget->core.border_width) | 1555 | + f->output_data.x->menubar_widget->core.border_width) |
| 1556 | : 0); | 1556 | : 0); |
| 1557 | 1557 | ||
| 1558 | #if 0 /* Experimentally, we now get the right results | 1558 | #if 1 /* Experimentally, we now get the right results |
| 1559 | for -geometry -0-0 without this. 24 Aug 96, rms. */ | 1559 | for -geometry -0-0 without this. 24 Aug 96, rms. |
| 1560 | Maybe so, but the menu bar size is missing the pixels so the | ||
| 1561 | WM size hints are off by theses pixel. Jan D, oct 2009. */ | ||
| 1560 | #ifdef USE_LUCID | 1562 | #ifdef USE_LUCID |
| 1561 | if (FRAME_EXTERNAL_MENU_BAR (f)) | 1563 | if (FRAME_EXTERNAL_MENU_BAR (f)) |
| 1562 | { | 1564 | { |
| @@ -1566,7 +1568,7 @@ set_frame_menubar (f, first_time, deep_p) | |||
| 1566 | menubar_size += ibw; | 1568 | menubar_size += ibw; |
| 1567 | } | 1569 | } |
| 1568 | #endif /* USE_LUCID */ | 1570 | #endif /* USE_LUCID */ |
| 1569 | #endif /* 0 */ | 1571 | #endif /* 1 */ |
| 1570 | 1572 | ||
| 1571 | f->output_data.x->menubar_height = menubar_size; | 1573 | f->output_data.x->menubar_height = menubar_size; |
| 1572 | } | 1574 | } |
diff --git a/src/xterm.c b/src/xterm.c index 0eebb029a93..e3a70a07fe4 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -86,6 +86,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 86 | #include "keymap.h" | 86 | #include "keymap.h" |
| 87 | #include "font.h" | 87 | #include "font.h" |
| 88 | #include "fontset.h" | 88 | #include "fontset.h" |
| 89 | #include "sysselect.h" | ||
| 89 | 90 | ||
| 90 | #ifdef USE_X_TOOLKIT | 91 | #ifdef USE_X_TOOLKIT |
| 91 | #include <X11/Shell.h> | 92 | #include <X11/Shell.h> |
| @@ -199,7 +200,14 @@ extern struct frame *updating_frame; | |||
| 199 | 200 | ||
| 200 | /* This is a frame waiting to be auto-raised, within XTread_socket. */ | 201 | /* This is a frame waiting to be auto-raised, within XTread_socket. */ |
| 201 | 202 | ||
| 202 | struct frame *pending_autoraise_frame; | 203 | static struct frame *pending_autoraise_frame; |
| 204 | |||
| 205 | /* This is a frame waiting for an event matching mask, within XTread_socket. */ | ||
| 206 | |||
| 207 | static struct { | ||
| 208 | struct frame *f; | ||
| 209 | int eventtype; | ||
| 210 | } pending_event_wait; | ||
| 203 | 211 | ||
| 204 | #ifdef USE_X_TOOLKIT | 212 | #ifdef USE_X_TOOLKIT |
| 205 | /* The application context for Xt use. */ | 213 | /* The application context for Xt use. */ |
| @@ -5833,7 +5841,10 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) | |||
| 5833 | EVENT_INIT (inev.ie); | 5841 | EVENT_INIT (inev.ie); |
| 5834 | inev.ie.kind = NO_EVENT; | 5842 | inev.ie.kind = NO_EVENT; |
| 5835 | inev.ie.arg = Qnil; | 5843 | inev.ie.arg = Qnil; |
| 5836 | 5844 | ||
| 5845 | if (pending_event_wait.eventtype == event.type) | ||
| 5846 | pending_event_wait.eventtype = 0; /* Indicates we got it. */ | ||
| 5847 | |||
| 5837 | switch (event.type) | 5848 | switch (event.type) |
| 5838 | { | 5849 | { |
| 5839 | case ClientMessage: | 5850 | case ClientMessage: |
| @@ -6779,7 +6790,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) | |||
| 6779 | 6790 | ||
| 6780 | #ifdef USE_GTK | 6791 | #ifdef USE_GTK |
| 6781 | /* GTK creates windows but doesn't map them. | 6792 | /* GTK creates windows but doesn't map them. |
| 6782 | Only get real positions and check fullscreen when mapped. */ | 6793 | Only get real positions when mapped. */ |
| 6783 | if (FRAME_GTK_OUTER_WIDGET (f) | 6794 | if (FRAME_GTK_OUTER_WIDGET (f) |
| 6784 | && GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f))) | 6795 | && GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f))) |
| 6785 | #endif | 6796 | #endif |
| @@ -6792,15 +6803,6 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) | |||
| 6792 | xic_set_statusarea (f); | 6803 | xic_set_statusarea (f); |
| 6793 | #endif | 6804 | #endif |
| 6794 | 6805 | ||
| 6795 | #ifndef USE_GTK | ||
| 6796 | if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) | ||
| 6797 | { | ||
| 6798 | /* Since the WM decorations come below top_pos now, | ||
| 6799 | we must put them below top_pos in the future. */ | ||
| 6800 | f->win_gravity = NorthWestGravity; | ||
| 6801 | x_wm_set_size_hint (f, (long) 0, 0); | ||
| 6802 | } | ||
| 6803 | #endif | ||
| 6804 | } | 6806 | } |
| 6805 | goto OTHER; | 6807 | goto OTHER; |
| 6806 | 6808 | ||
| @@ -8043,9 +8045,15 @@ x_new_font (f, font_object, fontset) | |||
| 8043 | turns out to not be a no-op (there is no way to know). | 8045 | turns out to not be a no-op (there is no way to know). |
| 8044 | The size will be adjusted again if the frame gets a | 8046 | The size will be adjusted again if the frame gets a |
| 8045 | ConfigureNotify event as a result of x_set_window_size. */ | 8047 | ConfigureNotify event as a result of x_set_window_size. */ |
| 8046 | int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, | 8048 | int pixelh = FRAME_PIXEL_HEIGHT (f); |
| 8047 | FRAME_PIXEL_HEIGHT (f)); | 8049 | #ifdef USE_X_TOOLKIT |
| 8050 | /* The menu bar is not part of text lines. The tool bar | ||
| 8051 | is however. */ | ||
| 8052 | pixelh -= FRAME_MENUBAR_HEIGHT (f); | ||
| 8053 | #endif | ||
| 8054 | int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixelh); | ||
| 8048 | int cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, FRAME_PIXEL_WIDTH (f)); | 8055 | int cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, FRAME_PIXEL_WIDTH (f)); |
| 8056 | |||
| 8049 | change_frame_size (f, rows, cols, 0, 1, 0); | 8057 | change_frame_size (f, rows, cols, 0, 1, 0); |
| 8050 | x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); | 8058 | x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); |
| 8051 | } | 8059 | } |
| @@ -8810,6 +8818,49 @@ x_sync_with_move (f, left, top, fuzzy) | |||
| 8810 | } | 8818 | } |
| 8811 | 8819 | ||
| 8812 | 8820 | ||
| 8821 | /* Wait for an event on frame F matching EVENTTYPE. */ | ||
| 8822 | void | ||
| 8823 | x_wait_for_event (f, eventtype) | ||
| 8824 | struct frame *f; | ||
| 8825 | int eventtype; | ||
| 8826 | { | ||
| 8827 | int level = interrupt_input_blocked; | ||
| 8828 | |||
| 8829 | SELECT_TYPE fds; | ||
| 8830 | EMACS_TIME tmo, tmo_at, time_now; | ||
| 8831 | int fd = ConnectionNumber (FRAME_X_DISPLAY (f)); | ||
| 8832 | |||
| 8833 | pending_event_wait.f = f; | ||
| 8834 | pending_event_wait.eventtype = eventtype; | ||
| 8835 | |||
| 8836 | /* Set timeout to 0.1 second. Hopefully not noticable. | ||
| 8837 | Maybe it should be configurable. */ | ||
| 8838 | EMACS_SET_SECS_USECS (tmo, 0, 100000); | ||
| 8839 | EMACS_GET_TIME (tmo_at); | ||
| 8840 | EMACS_ADD_TIME (tmo_at, tmo_at, tmo); | ||
| 8841 | |||
| 8842 | while (pending_event_wait.eventtype) | ||
| 8843 | { | ||
| 8844 | interrupt_input_pending = 1; | ||
| 8845 | TOTALLY_UNBLOCK_INPUT; | ||
| 8846 | /* XTread_socket is called after unblock. */ | ||
| 8847 | BLOCK_INPUT; | ||
| 8848 | interrupt_input_blocked = level; | ||
| 8849 | |||
| 8850 | FD_ZERO (&fds); | ||
| 8851 | FD_SET (fd, &fds); | ||
| 8852 | |||
| 8853 | EMACS_GET_TIME (time_now); | ||
| 8854 | EMACS_SUB_TIME (tmo, tmo_at, time_now); | ||
| 8855 | |||
| 8856 | if (EMACS_TIME_NEG_P (tmo) || select (fd+1, &fds, NULL, NULL, &tmo) == 0) | ||
| 8857 | break; /* Timeout */ | ||
| 8858 | } | ||
| 8859 | pending_event_wait.f = 0; | ||
| 8860 | pending_event_wait.eventtype = 0; | ||
| 8861 | } | ||
| 8862 | |||
| 8863 | |||
| 8813 | /* Change the size of frame F's X window to COLS/ROWS in the case F | 8864 | /* Change the size of frame F's X window to COLS/ROWS in the case F |
| 8814 | doesn't have a widget. If CHANGE_GRAVITY is 1, we change to | 8865 | doesn't have a widget. If CHANGE_GRAVITY is 1, we change to |
| 8815 | top-left-corner window gravity for this size change and subsequent | 8866 | top-left-corner window gravity for this size change and subsequent |
| @@ -8833,16 +8884,24 @@ x_set_window_size_1 (f, change_gravity, cols, rows) | |||
| 8833 | 8884 | ||
| 8834 | compute_fringe_widths (f, 0); | 8885 | compute_fringe_widths (f, 0); |
| 8835 | 8886 | ||
| 8836 | pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); | 8887 | pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols) |
| 8837 | pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows); | 8888 | + 2*f->border_width; |
| 8889 | pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows) | ||
| 8890 | + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f) | ||
| 8891 | + 2*f->border_width; | ||
| 8838 | 8892 | ||
| 8839 | f->win_gravity = NorthWestGravity; | 8893 | if (change_gravity) f->win_gravity = NorthWestGravity; |
| 8840 | x_wm_set_size_hint (f, (long) 0, 0); | 8894 | x_wm_set_size_hint (f, (long) 0, 0); |
| 8841 | 8895 | XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), | |
| 8842 | XSync (FRAME_X_DISPLAY (f), False); | ||
| 8843 | XResizeWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 8844 | pixelwidth, pixelheight); | 8896 | pixelwidth, pixelheight); |
| 8845 | 8897 | ||
| 8898 | |||
| 8899 | /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to | ||
| 8900 | receive in the ConfigureNotify event; if we get what we asked | ||
| 8901 | for, then the event won't cause the screen to become garbaged, so | ||
| 8902 | we have to make sure to do it here. */ | ||
| 8903 | SET_FRAME_GARBAGED (f); | ||
| 8904 | |||
| 8846 | /* Now, strictly speaking, we can't be sure that this is accurate, | 8905 | /* Now, strictly speaking, we can't be sure that this is accurate, |
| 8847 | but the window manager will get around to dealing with the size | 8906 | but the window manager will get around to dealing with the size |
| 8848 | change request eventually, and we'll hear how it went when the | 8907 | change request eventually, and we'll hear how it went when the |
| @@ -8856,17 +8915,19 @@ x_set_window_size_1 (f, change_gravity, cols, rows) | |||
| 8856 | 8915 | ||
| 8857 | We pass 1 for DELAY since we can't run Lisp code inside of | 8916 | We pass 1 for DELAY since we can't run Lisp code inside of |
| 8858 | a BLOCK_INPUT. */ | 8917 | a BLOCK_INPUT. */ |
| 8859 | change_frame_size (f, rows, cols, 0, 1, 0); | ||
| 8860 | FRAME_PIXEL_WIDTH (f) = pixelwidth; | ||
| 8861 | FRAME_PIXEL_HEIGHT (f) = pixelheight; | ||
| 8862 | 8918 | ||
| 8863 | /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to | 8919 | /* But the ConfigureNotify may in fact never arrive, and then this is |
| 8864 | receive in the ConfigureNotify event; if we get what we asked | 8920 | not right if the frame is visible. Instead wait (with timeout) |
| 8865 | for, then the event won't cause the screen to become garbaged, so | 8921 | for the ConfigureNotify. */ |
| 8866 | we have to make sure to do it here. */ | 8922 | if (f->async_visible) |
| 8867 | SET_FRAME_GARBAGED (f); | 8923 | x_wait_for_event (f, ConfigureNotify); |
| 8868 | 8924 | else | |
| 8869 | XFlush (FRAME_X_DISPLAY (f)); | 8925 | { |
| 8926 | change_frame_size (f, rows, cols, 0, 1, 0); | ||
| 8927 | FRAME_PIXEL_WIDTH (f) = pixelwidth; | ||
| 8928 | FRAME_PIXEL_HEIGHT (f) = pixelheight; | ||
| 8929 | x_sync (f); | ||
| 8930 | } | ||
| 8870 | } | 8931 | } |
| 8871 | 8932 | ||
| 8872 | 8933 | ||
| @@ -8888,28 +8949,11 @@ x_set_window_size (f, change_gravity, cols, rows) | |||
| 8888 | xg_frame_set_char_size (f, cols, rows); | 8949 | xg_frame_set_char_size (f, cols, rows); |
| 8889 | else | 8950 | else |
| 8890 | x_set_window_size_1 (f, change_gravity, cols, rows); | 8951 | x_set_window_size_1 (f, change_gravity, cols, rows); |
| 8891 | #elif USE_X_TOOLKIT | 8952 | #else /* not USE_GTK */ |
| 8892 | |||
| 8893 | if (f->output_data.x->widget != NULL) | ||
| 8894 | { | ||
| 8895 | /* The x and y position of the widget is clobbered by the | ||
| 8896 | call to XtSetValues within EmacsFrameSetCharSize. | ||
| 8897 | This is a real kludge, but I don't understand Xt so I can't | ||
| 8898 | figure out a correct fix. Can anyone else tell me? -- rms. */ | ||
| 8899 | int xpos = f->output_data.x->widget->core.x; | ||
| 8900 | int ypos = f->output_data.x->widget->core.y; | ||
| 8901 | EmacsFrameSetCharSize (f->output_data.x->edit_widget, cols, rows); | ||
| 8902 | f->output_data.x->widget->core.x = xpos; | ||
| 8903 | f->output_data.x->widget->core.y = ypos; | ||
| 8904 | } | ||
| 8905 | else | ||
| 8906 | x_set_window_size_1 (f, change_gravity, cols, rows); | ||
| 8907 | |||
| 8908 | #else /* not USE_X_TOOLKIT */ | ||
| 8909 | 8953 | ||
| 8910 | x_set_window_size_1 (f, change_gravity, cols, rows); | 8954 | x_set_window_size_1 (f, change_gravity, cols, rows); |
| 8911 | 8955 | ||
| 8912 | #endif /* not USE_X_TOOLKIT */ | 8956 | #endif /* not USE_GTK */ |
| 8913 | 8957 | ||
| 8914 | /* If cursor was outside the new size, mark it as off. */ | 8958 | /* If cursor was outside the new size, mark it as off. */ |
| 8915 | mark_window_cursors_off (XWINDOW (f->root_window)); | 8959 | mark_window_cursors_off (XWINDOW (f->root_window)); |
| @@ -9611,13 +9655,6 @@ x_wm_set_size_hint (f, flags, user_position) | |||
| 9611 | int user_position; | 9655 | int user_position; |
| 9612 | { | 9656 | { |
| 9613 | XSizeHints size_hints; | 9657 | XSizeHints size_hints; |
| 9614 | |||
| 9615 | #ifdef USE_X_TOOLKIT | ||
| 9616 | Arg al[2]; | ||
| 9617 | int ac = 0; | ||
| 9618 | Dimension widget_width, widget_height; | ||
| 9619 | #endif | ||
| 9620 | |||
| 9621 | Window window = FRAME_OUTER_WINDOW (f); | 9658 | Window window = FRAME_OUTER_WINDOW (f); |
| 9622 | 9659 | ||
| 9623 | /* Setting PMaxSize caused various problems. */ | 9660 | /* Setting PMaxSize caused various problems. */ |
| @@ -9626,16 +9663,8 @@ x_wm_set_size_hint (f, flags, user_position) | |||
| 9626 | size_hints.x = f->left_pos; | 9663 | size_hints.x = f->left_pos; |
| 9627 | size_hints.y = f->top_pos; | 9664 | size_hints.y = f->top_pos; |
| 9628 | 9665 | ||
| 9629 | #ifdef USE_X_TOOLKIT | ||
| 9630 | XtSetArg (al[ac], XtNwidth, &widget_width); ac++; | ||
| 9631 | XtSetArg (al[ac], XtNheight, &widget_height); ac++; | ||
| 9632 | XtGetValues (f->output_data.x->widget, al, ac); | ||
| 9633 | size_hints.height = widget_height; | ||
| 9634 | size_hints.width = widget_width; | ||
| 9635 | #else /* not USE_X_TOOLKIT */ | ||
| 9636 | size_hints.height = FRAME_PIXEL_HEIGHT (f); | 9666 | size_hints.height = FRAME_PIXEL_HEIGHT (f); |
| 9637 | size_hints.width = FRAME_PIXEL_WIDTH (f); | 9667 | size_hints.width = FRAME_PIXEL_WIDTH (f); |
| 9638 | #endif /* not USE_X_TOOLKIT */ | ||
| 9639 | 9668 | ||
| 9640 | size_hints.width_inc = FRAME_COLUMN_WIDTH (f); | 9669 | size_hints.width_inc = FRAME_COLUMN_WIDTH (f); |
| 9641 | size_hints.height_inc = FRAME_LINE_HEIGHT (f); | 9670 | size_hints.height_inc = FRAME_LINE_HEIGHT (f); |
| @@ -9644,11 +9673,7 @@ x_wm_set_size_hint (f, flags, user_position) | |||
| 9644 | size_hints.max_height = x_display_pixel_height (FRAME_X_DISPLAY_INFO (f)) | 9673 | size_hints.max_height = x_display_pixel_height (FRAME_X_DISPLAY_INFO (f)) |
| 9645 | - FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0); | 9674 | - FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0); |
| 9646 | 9675 | ||
| 9647 | /* Calculate the base and minimum sizes. | 9676 | /* Calculate the base and minimum sizes. */ |
| 9648 | |||
| 9649 | (When we use the X toolkit, we don't do it here. | ||
| 9650 | Instead we copy the values that the widgets are using, below.) */ | ||
| 9651 | #ifndef USE_X_TOOLKIT | ||
| 9652 | { | 9677 | { |
| 9653 | int base_width, base_height; | 9678 | int base_width, base_height; |
| 9654 | int min_rows = 0, min_cols = 0; | 9679 | int min_rows = 0, min_cols = 0; |
| @@ -9670,7 +9695,7 @@ x_wm_set_size_hint (f, flags, user_position) | |||
| 9670 | 9695 | ||
| 9671 | size_hints.flags |= PBaseSize; | 9696 | size_hints.flags |= PBaseSize; |
| 9672 | size_hints.base_width = base_width; | 9697 | size_hints.base_width = base_width; |
| 9673 | size_hints.base_height = base_height; | 9698 | size_hints.base_height = base_height + FRAME_MENUBAR_HEIGHT (f); |
| 9674 | size_hints.min_width = base_width + min_cols * size_hints.width_inc; | 9699 | size_hints.min_width = base_width + min_cols * size_hints.width_inc; |
| 9675 | size_hints.min_height = base_height + min_rows * size_hints.height_inc; | 9700 | size_hints.min_height = base_height + min_rows * size_hints.height_inc; |
| 9676 | } | 9701 | } |
| @@ -9681,7 +9706,6 @@ x_wm_set_size_hint (f, flags, user_position) | |||
| 9681 | size_hints.flags |= flags; | 9706 | size_hints.flags |= flags; |
| 9682 | goto no_read; | 9707 | goto no_read; |
| 9683 | } | 9708 | } |
| 9684 | #endif /* not USE_X_TOOLKIT */ | ||
| 9685 | 9709 | ||
| 9686 | { | 9710 | { |
| 9687 | XSizeHints hints; /* Sometimes I hate X Windows... */ | 9711 | XSizeHints hints; /* Sometimes I hate X Windows... */ |
| @@ -9691,13 +9715,6 @@ x_wm_set_size_hint (f, flags, user_position) | |||
| 9691 | value = XGetWMNormalHints (FRAME_X_DISPLAY (f), window, &hints, | 9715 | value = XGetWMNormalHints (FRAME_X_DISPLAY (f), window, &hints, |
| 9692 | &supplied_return); | 9716 | &supplied_return); |
| 9693 | 9717 | ||
| 9694 | #ifdef USE_X_TOOLKIT | ||
| 9695 | size_hints.base_height = hints.base_height; | ||
| 9696 | size_hints.base_width = hints.base_width; | ||
| 9697 | size_hints.min_height = hints.min_height; | ||
| 9698 | size_hints.min_width = hints.min_width; | ||
| 9699 | #endif | ||
| 9700 | |||
| 9701 | if (flags) | 9718 | if (flags) |
| 9702 | size_hints.flags |= flags; | 9719 | size_hints.flags |= flags; |
| 9703 | else | 9720 | else |
| @@ -9715,9 +9732,7 @@ x_wm_set_size_hint (f, flags, user_position) | |||
| 9715 | } | 9732 | } |
| 9716 | } | 9733 | } |
| 9717 | 9734 | ||
| 9718 | #ifndef USE_X_TOOLKIT | ||
| 9719 | no_read: | 9735 | no_read: |
| 9720 | #endif | ||
| 9721 | 9736 | ||
| 9722 | #ifdef PWinGravity | 9737 | #ifdef PWinGravity |
| 9723 | size_hints.win_gravity = f->win_gravity; | 9738 | size_hints.win_gravity = f->win_gravity; |
| @@ -10791,6 +10806,10 @@ x_initialize () | |||
| 10791 | #endif | 10806 | #endif |
| 10792 | #endif | 10807 | #endif |
| 10793 | 10808 | ||
| 10809 | pending_autoraise_frame = 0; | ||
| 10810 | pending_event_wait.f = 0; | ||
| 10811 | pending_event_wait.eventtype = 0; | ||
| 10812 | |||
| 10794 | /* Note that there is no real way portable across R3/R4 to get the | 10813 | /* Note that there is no real way portable across R3/R4 to get the |
| 10795 | original error handler. */ | 10814 | original error handler. */ |
| 10796 | XSetErrorHandler (x_error_handler); | 10815 | XSetErrorHandler (x_error_handler); |
diff --git a/src/xterm.h b/src/xterm.h index a3d5f717193..e76634d7d43 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -973,6 +973,7 @@ extern int x_display_pixel_height P_ ((struct x_display_info *)); | |||
| 973 | extern int x_display_pixel_width P_ ((struct x_display_info *)); | 973 | extern int x_display_pixel_width P_ ((struct x_display_info *)); |
| 974 | 974 | ||
| 975 | extern void x_set_sticky P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 975 | extern void x_set_sticky P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 976 | extern void x_wait_for_event P_ ((struct frame *, int)); | ||
| 976 | 977 | ||
| 977 | /* Defined in xselect.c */ | 978 | /* Defined in xselect.c */ |
| 978 | 979 | ||