diff options
Diffstat (limited to 'src/gtkutil.c')
| -rw-r--r-- | src/gtkutil.c | 118 |
1 files changed, 90 insertions, 28 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index 21f3cb15e66..6f1707894c1 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -50,12 +50,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 50 | #include "emacsgtkfixed.h" | 50 | #include "emacsgtkfixed.h" |
| 51 | #endif | 51 | #endif |
| 52 | 52 | ||
| 53 | /** #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ **/ | ||
| 54 | /** (FRAME_PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f)) **/ | ||
| 55 | |||
| 56 | /** #define FRAME_TOTAL_PIXEL_WIDTH(f) \ **/ | ||
| 57 | /** (FRAME_PIXEL_WIDTH (f) + FRAME_TOOLBAR_WIDTH (f)) **/ | ||
| 58 | |||
| 59 | #ifndef HAVE_GTK_WIDGET_SET_HAS_WINDOW | 53 | #ifndef HAVE_GTK_WIDGET_SET_HAS_WINDOW |
| 60 | #define gtk_widget_set_has_window(w, b) \ | 54 | #define gtk_widget_set_has_window(w, b) \ |
| 61 | (gtk_fixed_set_has_window (GTK_FIXED (w), b)) | 55 | (gtk_fixed_set_has_window (GTK_FIXED (w), b)) |
| @@ -886,24 +880,23 @@ xg_frame_resized (struct frame *f, int pixelwidth, int pixelheight) | |||
| 886 | if (pixelwidth == -1 && pixelheight == -1) | 880 | if (pixelwidth == -1 && pixelheight == -1) |
| 887 | { | 881 | { |
| 888 | if (FRAME_GTK_WIDGET (f) && gtk_widget_get_mapped (FRAME_GTK_WIDGET (f))) | 882 | if (FRAME_GTK_WIDGET (f) && gtk_widget_get_mapped (FRAME_GTK_WIDGET (f))) |
| 889 | gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET (f)), | 883 | gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET (f)), |
| 890 | 0, 0, | 884 | 0, 0, &pixelwidth, &pixelheight); |
| 891 | &pixelwidth, &pixelheight); | 885 | else |
| 892 | else return; | 886 | return; |
| 893 | } | 887 | } |
| 894 | 888 | ||
| 895 | |||
| 896 | width = FRAME_PIXEL_TO_TEXT_WIDTH (f, pixelwidth); | 889 | width = FRAME_PIXEL_TO_TEXT_WIDTH (f, pixelwidth); |
| 897 | height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, pixelheight); | 890 | height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, pixelheight); |
| 898 | 891 | ||
| 892 | frame_size_history_add | ||
| 893 | (f, Qxg_frame_resized, width, height, Qnil); | ||
| 894 | |||
| 899 | if (width != FRAME_TEXT_WIDTH (f) | 895 | if (width != FRAME_TEXT_WIDTH (f) |
| 900 | || height != FRAME_TEXT_HEIGHT (f) | 896 | || height != FRAME_TEXT_HEIGHT (f) |
| 901 | || pixelwidth != FRAME_PIXEL_WIDTH (f) | 897 | || pixelwidth != FRAME_PIXEL_WIDTH (f) |
| 902 | || pixelheight != FRAME_PIXEL_HEIGHT (f)) | 898 | || pixelheight != FRAME_PIXEL_HEIGHT (f)) |
| 903 | { | 899 | { |
| 904 | FRAME_PIXEL_WIDTH (f) = pixelwidth; | ||
| 905 | FRAME_PIXEL_HEIGHT (f) = pixelheight; | ||
| 906 | |||
| 907 | xg_clear_under_internal_border (f); | 900 | xg_clear_under_internal_border (f); |
| 908 | change_frame_size (f, width, height, 0, 1, 0, 1); | 901 | change_frame_size (f, width, height, 0, 1, 0, 1); |
| 909 | SET_FRAME_GARBAGED (f); | 902 | SET_FRAME_GARBAGED (f); |
| @@ -921,24 +914,71 @@ xg_frame_set_char_size (struct frame *f, int width, int height) | |||
| 921 | { | 914 | { |
| 922 | int pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width); | 915 | int pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width); |
| 923 | int pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, height); | 916 | int pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, height); |
| 917 | Lisp_Object fullscreen = get_frame_param (f, Qfullscreen); | ||
| 918 | gint gwidth, gheight; | ||
| 924 | 919 | ||
| 925 | if (FRAME_PIXEL_HEIGHT (f) == 0) | 920 | if (FRAME_PIXEL_HEIGHT (f) == 0) |
| 926 | return; | 921 | return; |
| 927 | 922 | ||
| 923 | gtk_window_get_size (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | ||
| 924 | &gwidth, &gheight); | ||
| 925 | |||
| 928 | /* Do this before resize, as we don't know yet if we will be resized. */ | 926 | /* Do this before resize, as we don't know yet if we will be resized. */ |
| 929 | xg_clear_under_internal_border (f); | 927 | xg_clear_under_internal_border (f); |
| 930 | 928 | ||
| 931 | /* Must resize our top level widget. Font size may have changed, | 929 | /* Resize the top level widget so rows and columns remain constant. |
| 932 | but not rows/cols. */ | 930 | |
| 933 | gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | 931 | When the frame is fullheight and we only want to change the width |
| 934 | pixelwidth + FRAME_TOOLBAR_WIDTH (f), | 932 | or it is fullwidth and we only want to change the height we should |
| 935 | pixelheight + FRAME_TOOLBAR_HEIGHT (f) | 933 | be able to preserve the fullscreen property. However, due to the |
| 936 | + FRAME_MENUBAR_HEIGHT (f)); | 934 | fact that we have to send a resize request anyway, the window |
| 937 | x_wm_set_size_hint (f, 0, 0); | 935 | manager will abolish it. At least the respective size should |
| 936 | remain unchanged but giving the frame back its normal size will | ||
| 937 | be broken ... */ | ||
| 938 | if (EQ (fullscreen, Qfullwidth) && width == FRAME_TEXT_WIDTH (f)) | ||
| 939 | { | ||
| 940 | frame_size_history_add | ||
| 941 | (f, Qxg_frame_set_char_size_1, width, height, | ||
| 942 | list2 (make_number (gheight), | ||
| 943 | make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f) | ||
| 944 | + FRAME_MENUBAR_HEIGHT (f)))); | ||
| 945 | |||
| 946 | gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | ||
| 947 | gwidth, | ||
| 948 | pixelheight + FRAME_TOOLBAR_HEIGHT (f) | ||
| 949 | + FRAME_MENUBAR_HEIGHT (f)); | ||
| 950 | } | ||
| 951 | else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f)) | ||
| 952 | { | ||
| 953 | frame_size_history_add | ||
| 954 | (f, Qxg_frame_set_char_size_2, width, height, | ||
| 955 | list2 (make_number (gwidth), | ||
| 956 | make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)))); | ||
| 957 | |||
| 958 | gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | ||
| 959 | pixelwidth + FRAME_TOOLBAR_WIDTH (f), | ||
| 960 | gheight); | ||
| 961 | } | ||
| 962 | |||
| 963 | else | ||
| 964 | { | ||
| 965 | frame_size_history_add | ||
| 966 | (f, Qxg_frame_set_char_size_3, width, height, | ||
| 967 | list2 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)), | ||
| 968 | make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f) | ||
| 969 | + FRAME_MENUBAR_HEIGHT (f)))); | ||
| 970 | |||
| 971 | gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | ||
| 972 | pixelwidth + FRAME_TOOLBAR_WIDTH (f), | ||
| 973 | pixelheight + FRAME_TOOLBAR_HEIGHT (f) | ||
| 974 | + FRAME_MENUBAR_HEIGHT (f)); | ||
| 975 | fullscreen = Qnil; | ||
| 976 | } | ||
| 938 | 977 | ||
| 939 | SET_FRAME_GARBAGED (f); | 978 | SET_FRAME_GARBAGED (f); |
| 940 | cancel_mouse_face (f); | 979 | cancel_mouse_face (f); |
| 941 | 980 | ||
| 981 | x_wm_set_size_hint (f, 0, 0); | ||
| 942 | /* We can not call change_frame_size for a mapped frame, | 982 | /* We can not call change_frame_size for a mapped frame, |
| 943 | we can not set pixel width/height either. The window manager may | 983 | we can not set pixel width/height either. The window manager may |
| 944 | override our resize request, XMonad does this all the time. | 984 | override our resize request, XMonad does this all the time. |
| @@ -952,9 +992,17 @@ xg_frame_set_char_size (struct frame *f, int width, int height) | |||
| 952 | (void)gtk_events_pending (); | 992 | (void)gtk_events_pending (); |
| 953 | gdk_flush (); | 993 | gdk_flush (); |
| 954 | x_wait_for_event (f, ConfigureNotify); | 994 | x_wait_for_event (f, ConfigureNotify); |
| 995 | |||
| 996 | if (!NILP (fullscreen)) | ||
| 997 | /* Try to restore fullscreen state. */ | ||
| 998 | { | ||
| 999 | store_frame_param (f, Qfullscreen, fullscreen); | ||
| 1000 | x_set_fullscreen (f, fullscreen, fullscreen); | ||
| 1001 | } | ||
| 955 | } | 1002 | } |
| 956 | else | 1003 | else |
| 957 | adjust_frame_size (f, -1, -1, 5, 0, Qxg_frame_set_char_size); | 1004 | adjust_frame_size (f, width, height, 5, 0, Qxg_frame_set_char_size); |
| 1005 | |||
| 958 | } | 1006 | } |
| 959 | 1007 | ||
| 960 | /* Handle height/width changes (i.e. add/remove/move menu/toolbar). | 1008 | /* Handle height/width changes (i.e. add/remove/move menu/toolbar). |
| @@ -4214,8 +4262,12 @@ tb_size_cb (GtkWidget *widget, | |||
| 4214 | allocated between widgets, it may get another. So we must update | 4262 | allocated between widgets, it may get another. So we must update |
| 4215 | size hints if tool bar size changes. Seen on Fedora 18 at least. */ | 4263 | size hints if tool bar size changes. Seen on Fedora 18 at least. */ |
| 4216 | struct frame *f = user_data; | 4264 | struct frame *f = user_data; |
| 4265 | |||
| 4217 | if (xg_update_tool_bar_sizes (f)) | 4266 | if (xg_update_tool_bar_sizes (f)) |
| 4218 | adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines); | 4267 | { |
| 4268 | frame_size_history_add (f, Qtb_size_cb, 0, 0, Qnil); | ||
| 4269 | adjust_frame_size (f, -1, -1, 5, 0, Qtool_bar_lines); | ||
| 4270 | } | ||
| 4219 | } | 4271 | } |
| 4220 | 4272 | ||
| 4221 | /* Create a tool bar for frame F. */ | 4273 | /* Create a tool bar for frame F. */ |
| @@ -4489,10 +4541,11 @@ xg_update_tool_bar_sizes (struct frame *f) | |||
| 4489 | FRAME_TOOLBAR_RIGHT_WIDTH (f) = nr; | 4541 | FRAME_TOOLBAR_RIGHT_WIDTH (f) = nr; |
| 4490 | FRAME_TOOLBAR_TOP_HEIGHT (f) = nt; | 4542 | FRAME_TOOLBAR_TOP_HEIGHT (f) = nt; |
| 4491 | FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = nb; | 4543 | FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = nb; |
| 4492 | return 1; | ||
| 4493 | } | ||
| 4494 | 4544 | ||
| 4495 | return 0; | 4545 | return true; |
| 4546 | } | ||
| 4547 | else | ||
| 4548 | return false; | ||
| 4496 | } | 4549 | } |
| 4497 | 4550 | ||
| 4498 | static char * | 4551 | static char * |
| @@ -4815,7 +4868,10 @@ update_frame_tool_bar (struct frame *f) | |||
| 4815 | xg_pack_tool_bar (f, FRAME_TOOL_BAR_POSITION (f)); | 4868 | xg_pack_tool_bar (f, FRAME_TOOL_BAR_POSITION (f)); |
| 4816 | gtk_widget_show_all (x->toolbar_widget); | 4869 | gtk_widget_show_all (x->toolbar_widget); |
| 4817 | if (xg_update_tool_bar_sizes (f)) | 4870 | if (xg_update_tool_bar_sizes (f)) |
| 4818 | adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines); | 4871 | { |
| 4872 | frame_size_history_add (f, Qupdate_frame_tool_bar, 0, 0, Qnil); | ||
| 4873 | adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines); | ||
| 4874 | } | ||
| 4819 | } | 4875 | } |
| 4820 | 4876 | ||
| 4821 | unblock_input (); | 4877 | unblock_input (); |
| @@ -4863,6 +4919,7 @@ free_frame_tool_bar (struct frame *f) | |||
| 4863 | NULL); | 4919 | NULL); |
| 4864 | } | 4920 | } |
| 4865 | 4921 | ||
| 4922 | frame_size_history_add (f, Qfree_frame_tool_bar, 0, 0, Qnil); | ||
| 4866 | adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines); | 4923 | adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines); |
| 4867 | 4924 | ||
| 4868 | unblock_input (); | 4925 | unblock_input (); |
| @@ -4892,8 +4949,13 @@ xg_change_toolbar_position (struct frame *f, Lisp_Object pos) | |||
| 4892 | 4949 | ||
| 4893 | xg_pack_tool_bar (f, pos); | 4950 | xg_pack_tool_bar (f, pos); |
| 4894 | g_object_unref (top_widget); | 4951 | g_object_unref (top_widget); |
| 4952 | |||
| 4895 | if (xg_update_tool_bar_sizes (f)) | 4953 | if (xg_update_tool_bar_sizes (f)) |
| 4896 | adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines); | 4954 | { |
| 4955 | frame_size_history_add (f, Qxg_change_toolbar_position, 0, 0, Qnil); | ||
| 4956 | adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines); | ||
| 4957 | } | ||
| 4958 | |||
| 4897 | 4959 | ||
| 4898 | unblock_input (); | 4960 | unblock_input (); |
| 4899 | } | 4961 | } |