aboutsummaryrefslogtreecommitdiffstats
path: root/src/gtkutil.c
diff options
context:
space:
mode:
authorMartin Rudalics2015-10-13 12:11:43 +0200
committerMartin Rudalics2015-10-13 12:11:43 +0200
commitd4fe840df0b5fdb3aed538fae2ced143a471f60a (patch)
tree13ff9d7115616a99af7e0257277a1ca6edf31f72 /src/gtkutil.c
parente53e1a0426539aa3f2902632fdd8025da8f710f2 (diff)
downloademacs-d4fe840df0b5fdb3aed538fae2ced143a471f60a.tar.gz
emacs-d4fe840df0b5fdb3aed538fae2ced143a471f60a.zip
Allow setting frame pixel sizes from frame parameters (Bug#21415)
Also fix some misfeatures in frame (re-)sizing code, add more debugging information and remove some dead code. * lisp/frame.el (frame-notice-user-settings, make-frame): Change parameter names when setting `frame-size-history'. (frame--size-history): New function. * src/frame.c (frame_inhibit_resize): If frame has not been made yet, return t if inhibit_horizontal_resize or inhibit_vertical_resize bit have been set. (adjust_frame_size): Simplify. (make_frame): Initialize inhibit_horizontal_resize, inhibit_vertical_resize, tool_bar_redisplayed, tool_bar_resized. (Fframe_after_make_frame): Reset inhibit_horizontal_resize and inhibit_vertical_resize slots. (x_set_frame_parameters): Handle `text-pixels' specification for width and height parameters. Don't consider new_height or new_width changes. Call adjust_frame_size instead of Fset_frame_size. (x_figure_window_size): Two new arguments x_width and y_width returning frame's figures width and height. Calculate tool bar height before frame sizes so SET_FRAME_HEIGHT can pick it up. Handle `text-pixels' specification for width and height parameters. (Qtext_pixels, Qx_set_frame_parameters, Qset_frame_size) (Qx_set_window_size_1, Qx_set_window_size_2) (Qx_set_window_size_3, Qx_set_menu_bar_lines) (Qupdate_frame_menubar, Qfree_frame_menubar_1) (Qfree_frame_menubar_2): New symbols. * src/frame.h (structure frame): New booleans tool_bar_redisplayed, tool_bar_resized, inhibit_horizontal_resize, inhibit_vertical_resize. (x_figure_window_size): Update external declaration. * src/gtkutil.c (xg_frame_set_char_size): Set size hints before calling gtk_window_resize. (update_frame_tool_bar): Make inhibiting of frame resizing more discriminative. Set tool_bar_resized bit. * src/nsfns.m (x_set_tool_bar_lines): Make inhibiting of frame resizing more discriminative. Call adjust_frame_size instead of x_set_window_size. (Fx_create_frame): Handle x_width and x_height if set by x_figure_window_size. * src/nsterm.m (x_set_window_size): For GNUSTEP build don't subtract 3 from tool bar height. (x_set_window_size): Add frame_size_history_add call. (x_new_font): Call adjust_frame_size instead of x_set_window_size. * src/w32fns.c (x_change_tool_bar_height): Reset tool_bar_redisplayed and tool_bar_resized bits when adding tool bar. Make inhibiting of frame resizing more discriminative. (w32_wnd_proc): Remove dead code in WM_WINDOWPOSCHANGING case. (Fx_create_frame): Handle x_width and x_height if set by x_figure_window_size. Set size hints before adjusting frame size. (x_create_tip_frame): Adjust x_figure_window_size call. * src/w32term.c (x_set_window_size): Add frame_size_history_add call. * src/widget.c (set_frame_size): Remove dead code. Add frame_size_history_add call. When frame_resize_pixelwise is t use FRAME_PIXEL_WIDTH and FRAME_PIXEL_HEIGHT instead of pixel_width and pixel_height. (update_various_frame_slots): Remove dead code. (EmacsFrameResize): Add more information in frame_size_history_add call. (EmacsFrameQueryGeometry): Round only when frame_resize_pixelwise is not set. * src/xdisp.c (redisplay_tool_bar): Set tool_bar_redisplayed bits. * src/xfns.c (x_set_menu_bar_lines): Change argument name. (x_change_tool_bar_height): Reset tool_bar_redisplayed and tool_bar_resized bits when adding tool bar. Make inhibiting of frame resizing more discriminative. (Fx_create_frame): Handle x_width and x_height if set by x_figure_window_size. Set size hints before adjusting frame size. (x_create_tip_frame): Adjust x_figure_window_size call. * src/xmenu.c (update_frame_menubar): Don't handle Lucid specially. (set_frame_menubar): On Lucid never add core-border-width to avoid that adding XtNinternalBorderWidth adds it again. (free_frame_menubar): Handle frame_inhibit_resize true for Motif. * src/xterm.c (x_new_font): In non-toolkit case handle size change of menu bar. (x_set_window_size_1): Fix calls to frame_size_history_add. (x_wm_set_size_hint): Remove dead code. Set size_hints.min_width and size_hints.min_height to base_width and base_height.
Diffstat (limited to 'src/gtkutil.c')
-rw-r--r--src/gtkutil.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 34e81b5c104..ad71b9ccbcb 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -951,6 +951,8 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
951 totalwidth /= scale; 951 totalwidth /= scale;
952 } 952 }
953 953
954 x_wm_set_size_hint (f, 0, 0);
955
954 /* Resize the top level widget so rows and columns remain constant. 956 /* Resize the top level widget so rows and columns remain constant.
955 957
956 When the frame is fullheight and we only want to change the width 958 When the frame is fullheight and we only want to change the width
@@ -964,41 +966,34 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
964 { 966 {
965 frame_size_history_add 967 frame_size_history_add
966 (f, Qxg_frame_set_char_size_1, width, height, 968 (f, Qxg_frame_set_char_size_1, width, height,
967 list2 (make_number (gheight), 969 list2 (make_number (gheight), make_number (totalheight)));
968 make_number (totalheight)));
969 970
970 gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 971 gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
971 gwidth, 972 gwidth, totalheight);
972 totalheight);
973 } 973 }
974 else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f)) 974 else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f))
975 { 975 {
976 frame_size_history_add 976 frame_size_history_add
977 (f, Qxg_frame_set_char_size_2, width, height, 977 (f, Qxg_frame_set_char_size_2, width, height,
978 list2 (make_number (gwidth), 978 list2 (make_number (gwidth), make_number (totalwidth)));
979 make_number (totalwidth)));
980 979
981 gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 980 gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
982 totalwidth, 981 totalwidth, gheight);
983 gheight);
984 } 982 }
985 else 983 else
986 { 984 {
987 frame_size_history_add 985 frame_size_history_add
988 (f, Qxg_frame_set_char_size_3, width, height, 986 (f, Qxg_frame_set_char_size_3, width, height,
989 list2 (make_number (totalwidth), 987 list2 (make_number (totalwidth), make_number (totalheight)));
990 make_number (totalheight)));
991 988
992 gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 989 gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
993 totalwidth, 990 totalwidth, totalheight);
994 totalheight);
995 fullscreen = Qnil; 991 fullscreen = Qnil;
996 } 992 }
997 993
998 SET_FRAME_GARBAGED (f); 994 SET_FRAME_GARBAGED (f);
999 cancel_mouse_face (f); 995 cancel_mouse_face (f);
1000 996
1001 x_wm_set_size_hint (f, 0, 0);
1002 /* We can not call change_frame_size for a mapped frame, 997 /* We can not call change_frame_size for a mapped frame,
1003 we can not set pixel width/height either. The window manager may 998 we can not set pixel width/height either. The window manager may
1004 override our resize request, XMonad does this all the time. 999 override our resize request, XMonad does this all the time.
@@ -1399,7 +1394,8 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
1399 1394
1400 hint_flags |= GDK_HINT_BASE_SIZE; 1395 hint_flags |= GDK_HINT_BASE_SIZE;
1401 /* Use one row/col here so base_height/width does not become zero. 1396 /* Use one row/col here so base_height/width does not become zero.
1402 Gtk+ and/or Unity on Ubuntu 12.04 can't handle it. */ 1397 Gtk+ and/or Unity on Ubuntu 12.04 can't handle it.
1398 Obviously this makes the row/col value displayed off by 1. */
1403 base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 1) + FRAME_TOOLBAR_WIDTH (f); 1399 base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 1) + FRAME_TOOLBAR_WIDTH (f);
1404 base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 1) 1400 base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 1)
1405 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); 1401 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
@@ -4998,9 +4994,23 @@ update_frame_tool_bar (struct frame *f)
4998 gtk_widget_show_all (x->toolbar_widget); 4994 gtk_widget_show_all (x->toolbar_widget);
4999 if (xg_update_tool_bar_sizes (f)) 4995 if (xg_update_tool_bar_sizes (f))
5000 { 4996 {
4997 int inhibit
4998 = ((f->after_make_frame
4999 && !f->tool_bar_resized
5000 && (EQ (frame_inhibit_implied_resize, Qt)
5001 || (CONSP (frame_inhibit_implied_resize)
5002 && !NILP (Fmemq (Qtool_bar_lines,
5003 frame_inhibit_implied_resize))))
5004 /* This will probably fail to DTRT in the
5005 fullheight/-width cases. */
5006 && NILP (get_frame_param (f, Qfullscreen)))
5007 ? 0
5008 : 2);
5009
5001 frame_size_history_add (f, Qupdate_frame_tool_bar, 0, 0, Qnil); 5010 frame_size_history_add (f, Qupdate_frame_tool_bar, 0, 0, Qnil);
5002 adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines); 5011 adjust_frame_size (f, -1, -1, inhibit, 0, Qtool_bar_lines);
5003 } 5012 }
5013 f->tool_bar_resized = f->tool_bar_redisplayed;
5004 } 5014 }
5005 5015
5006 unblock_input (); 5016 unblock_input ();