aboutsummaryrefslogtreecommitdiffstats
path: root/src/xfns.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/xfns.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/xfns.c')
-rw-r--r--src/xfns.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/xfns.c b/src/xfns.c
index fefd8e8f91f..8251f939b8c 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1090,7 +1090,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1090#else /* not USE_X_TOOLKIT && not USE_GTK */ 1090#else /* not USE_X_TOOLKIT && not USE_GTK */
1091 FRAME_MENU_BAR_LINES (f) = nlines; 1091 FRAME_MENU_BAR_LINES (f) = nlines;
1092 FRAME_MENU_BAR_HEIGHT (f) = nlines * FRAME_LINE_HEIGHT (f); 1092 FRAME_MENU_BAR_HEIGHT (f) = nlines * FRAME_LINE_HEIGHT (f);
1093 adjust_frame_size (f, -1, -1, 2, true, Qmenu_bar_lines); 1093 adjust_frame_size (f, -1, -1, 2, true, Qx_set_menu_bar_lines);
1094 if (FRAME_X_WINDOW (f)) 1094 if (FRAME_X_WINDOW (f))
1095 x_clear_under_internal_border (f); 1095 x_clear_under_internal_border (f);
1096 1096
@@ -1212,14 +1212,24 @@ x_change_tool_bar_height (struct frame *f, int height)
1212 1212
1213 /* Recalculate toolbar height. */ 1213 /* Recalculate toolbar height. */
1214 f->n_tool_bar_rows = 0; 1214 f->n_tool_bar_rows = 0;
1215 if (old_height == 0
1216 && (!f->after_make_frame
1217 || NILP (frame_inhibit_implied_resize)
1218 || (CONSP (frame_inhibit_implied_resize)
1219 && NILP (Fmemq (Qtool_bar_lines, frame_inhibit_implied_resize)))))
1220 f->tool_bar_redisplayed = f->tool_bar_resized = false;
1215 1221
1216 adjust_frame_size (f, -1, -1, 1222 adjust_frame_size (f, -1, -1,
1217 ((NILP (fullscreen = get_frame_param (f, Qfullscreen)) 1223 ((!f->tool_bar_resized
1218 || EQ (fullscreen, Qfullwidth)) ? 1 1224 && (NILP (fullscreen =
1225 get_frame_param (f, Qfullscreen))
1226 || EQ (fullscreen, Qfullwidth))) ? 1
1219 : (old_height == 0 || height == 0) ? 2 1227 : (old_height == 0 || height == 0) ? 2
1220 : 4), 1228 : 4),
1221 false, Qtool_bar_lines); 1229 false, Qtool_bar_lines);
1222 1230
1231 f->tool_bar_resized = f->tool_bar_redisplayed;
1232
1223 /* adjust_frame_size might not have done anything, garbage frame 1233 /* adjust_frame_size might not have done anything, garbage frame
1224 here. */ 1234 here. */
1225 adjust_frame_glyphs (f); 1235 adjust_frame_glyphs (f);
@@ -3001,6 +3011,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3001 struct x_display_info *dpyinfo = NULL; 3011 struct x_display_info *dpyinfo = NULL;
3002 Lisp_Object parent; 3012 Lisp_Object parent;
3003 struct kboard *kb; 3013 struct kboard *kb;
3014 int x_width = 0, x_height = 0;
3004 3015
3005 parms = Fcopy_alist (parms); 3016 parms = Fcopy_alist (parms);
3006 3017
@@ -3275,7 +3286,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3275 FRAME_TOOL_BAR_POSITION (f), 0, 0, RES_TYPE_SYMBOL); 3286 FRAME_TOOL_BAR_POSITION (f), 0, 0, RES_TYPE_SYMBOL);
3276 3287
3277 /* Compute the size of the X window. */ 3288 /* Compute the size of the X window. */
3278 window_prompting = x_figure_window_size (f, parms, true); 3289 window_prompting = x_figure_window_size (f, parms, true, &x_width, &x_height);
3279 3290
3280 tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); 3291 tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
3281 f->no_split = minibuffer_only || EQ (tem, Qt); 3292 f->no_split = minibuffer_only || EQ (tem, Qt);
@@ -3317,12 +3328,6 @@ This function is an internal primitive--use `make-frame' instead. */)
3317 x_default_parameter (f, parms, Qalpha, Qnil, 3328 x_default_parameter (f, parms, Qalpha, Qnil,
3318 "alpha", "Alpha", RES_TYPE_NUMBER); 3329 "alpha", "Alpha", RES_TYPE_NUMBER);
3319 3330
3320 /* Consider frame official, now. */
3321 f->can_x_set_window_size = true;
3322
3323 adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, true,
3324 Qx_create_frame_2);
3325
3326#if defined (USE_X_TOOLKIT) || defined (USE_GTK) 3331#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
3327 /* Create the menu bar. */ 3332 /* Create the menu bar. */
3328 if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f)) 3333 if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
@@ -3341,6 +3346,14 @@ This function is an internal primitive--use `make-frame' instead. */)
3341 } 3346 }
3342#endif /* USE_X_TOOLKIT || USE_GTK */ 3347#endif /* USE_X_TOOLKIT || USE_GTK */
3343 3348
3349 /* Consider frame official, now. */
3350 f->can_x_set_window_size = true;
3351
3352 if (x_width > 0)
3353 SET_FRAME_WIDTH (f, x_width);
3354 if (x_height > 0)
3355 SET_FRAME_HEIGHT (f, x_height);
3356
3344 /* Tell the server what size and position, etc, we want, and how 3357 /* Tell the server what size and position, etc, we want, and how
3345 badly we want them. This should be done after we have the menu 3358 badly we want them. This should be done after we have the menu
3346 bar so that its size can be taken into account. */ 3359 bar so that its size can be taken into account. */
@@ -3348,6 +3361,9 @@ This function is an internal primitive--use `make-frame' instead. */)
3348 x_wm_set_size_hint (f, window_prompting, false); 3361 x_wm_set_size_hint (f, window_prompting, false);
3349 unblock_input (); 3362 unblock_input ();
3350 3363
3364 adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
3365 0, true, Qx_create_frame_2);
3366
3351 /* Process fullscreen parameter here in the hope that normalizing a 3367 /* Process fullscreen parameter here in the hope that normalizing a
3352 fullheight/fullwidth frame will produce the size set by the last 3368 fullheight/fullwidth frame will produce the size set by the last
3353 adjust_frame_size call. */ 3369 adjust_frame_size call. */
@@ -5161,6 +5177,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
5161 bool face_change_before = face_change; 5177 bool face_change_before = face_change;
5162 Lisp_Object buffer; 5178 Lisp_Object buffer;
5163 struct buffer *old_buffer; 5179 struct buffer *old_buffer;
5180 int x_width = 0, x_height = 0;
5164 5181
5165 if (!dpyinfo->terminal->name) 5182 if (!dpyinfo->terminal->name)
5166 error ("Terminal is not live, can't create new frames on it"); 5183 error ("Terminal is not live, can't create new frames on it");
@@ -5333,7 +5350,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
5333 5350
5334 f->output_data.x->parent_desc = FRAME_DISPLAY_INFO (f)->root_window; 5351 f->output_data.x->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
5335 5352
5336 x_figure_window_size (f, parms, false); 5353 x_figure_window_size (f, parms, false, &x_width, &x_height);
5337 5354
5338 { 5355 {
5339 XSetWindowAttributes attrs; 5356 XSetWindowAttributes attrs;