diff --git a/lisp/window.el b/lisp/window.el index a11293d372..706c988b2e 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -10596,6 +10596,21 @@ window-prefix-map "0" #'delete-windows-on) (define-key ctl-x-map "w" window-prefix-map) +(defun foo-it (&rest rest) + (with-current-buffer (get-buffer-create "*foo*") + (goto-char (point-max)) + (when rest + (if (consp (car rest)) + (insert (format "%sx%s" (caar rest) (cdar rest))) + (insert (format "%s" (car rest)))) + (setq rest (cdr rest)) + (while rest + (if (consp (car rest)) + (insert (format " %sx%s" (caar rest) (cdar rest))) + (insert (format " %s" (car rest)))) + (setq rest (cdr rest))) + (insert "\n")))) + (provide 'window) ;;; window.el ends here diff --git a/src/frame.c b/src/frame.c index b57b296be5..d7d069d908 100644 --- a/src/frame.c +++ b/src/frame.c @@ -906,6 +906,32 @@ adjust_frame_size (struct frame *f, int new_text_width, int new_text_height, unblock_input (); + if (old_native_width != new_native_width + || old_native_height != new_native_height + || old_text_width != new_text_width + || old_text_height != new_text_height + || old_text_cols != new_text_cols + || old_text_lines != new_text_lines) + CALLN (Ffuncall, Qfoo_it, intern ("adjust_frame_size"), + intern ("old native pixels"), + Fcons (make_fixnum (old_native_width), + make_fixnum (old_native_height)), + intern ("new native pixels"), + Fcons (make_fixnum (new_native_width), + make_fixnum (new_native_height)), + intern ("old text pixels"), + Fcons (make_fixnum (old_text_width), + make_fixnum (old_text_height)), + intern ("new text pixels"), + Fcons (make_fixnum (new_text_width), + make_fixnum (new_text_height)), + intern ("old text chars"), + Fcons (make_fixnum (old_text_cols), + make_fixnum (old_text_lines)), + intern ("new text chars"), + Fcons (make_fixnum (new_text_cols), + make_fixnum (new_text_lines))); + #ifdef HAVE_WINDOW_SYSTEM { /* Adjust size of F's child frames. */ diff --git a/src/gtkutil.c b/src/gtkutil.c index a6bba096a4..167329ccb8 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -1149,6 +1149,14 @@ xg_frame_resized (struct frame *f, int width, int height) f->new_size_p ? f->new_height : -1); FRAME_RIF (f)->clear_under_internal_border (f); + + CALLN (Ffuncall, Qfoo_it, intern ("xg_frame_resized"), + intern ("old native pixels"), + Fcons (make_fixnum (FRAME_PIXEL_WIDTH (f)), + make_fixnum (FRAME_PIXEL_HEIGHT (f))), + intern ("new native pixels"), + Fcons (make_fixnum (width), make_fixnum (height))); + change_frame_size (f, width, height, false, true, false); SET_FRAME_GARBAGED (f); cancel_mouse_face (f); @@ -1174,6 +1182,8 @@ xg_frame_set_char_size (struct frame *f, int width, int height) int outer_width = width + FRAME_TOOLBAR_WIDTH (f); bool was_visible = false; bool hide_child_frame; + int scale = xg_get_scale (f); + GdkGeometry size_hints = f->output_data.xp->size_hints; #ifndef HAVE_PGTK gtk_window_get_size (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), @@ -1196,8 +1206,42 @@ xg_frame_set_char_size (struct frame *f, int width, int height) /* Do this before resize, as we don't know yet if we will be resized. */ FRAME_RIF (f)->clear_under_internal_border (f); - outer_height /= xg_get_scale (f); - outer_width /= xg_get_scale (f); + outer_height /= scale; + outer_width /= scale; + + if (scale != 1 && !frame_resize_pixelwise) + { + int base_width_unscaled = (FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 1) + + FRAME_TOOLBAR_WIDTH (f)); + int base_width_scaled = base_width_unscaled / scale; + int base_height_unscaled = (FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 1) + + FRAME_MENUBAR_HEIGHT (f) + + FRAME_TOOLBAR_HEIGHT (f)); + int base_height_scaled = base_height_unscaled / scale; + int width_inc = FRAME_COLUMN_WIDTH (f) / scale; + int height_inc = FRAME_LINE_HEIGHT (f) / scale; + int width_rest, height_rest; + + if (width_inc < 1) + width_inc = 1; + + if (height_inc < 1) + height_inc = 1; + + if (outer_width < base_width_scaled) + outer_width = base_width_scaled; + + if (outer_height < base_height_scaled) + outer_height = base_height_scaled; + + width_rest = (outer_width - base_width_scaled) % width_inc; + height_rest = (outer_height - base_height_scaled) % height_inc; + + if (width_rest > 0 || (base_width_unscaled % scale) > 0) + outer_width = outer_width + width_inc - width_rest; + if (height_rest > 0 || (base_height_unscaled % scale) > 0) + outer_height = outer_height + height_inc - height_rest; + } xg_wm_set_size_hint (f, 0, 0); @@ -1317,6 +1361,30 @@ xg_frame_set_char_size (struct frame *f, int width, int height) SET_FRAME_GARBAGED (f); cancel_mouse_face (f); + size_hints = f->output_data.xp->size_hints; + if (outer_width > 0 && size_hints.base_width > 0 && size_hints.width_inc > 0 + && outer_height > 0 && size_hints.base_height > 0 && size_hints.height_inc > 0) + CALLN (Ffuncall, Qfoo_it, intern ("xg_frame_set_char_size"), + intern ("old native pixels"), + Fcons (make_fixnum (FRAME_PIXEL_WIDTH (f)), + make_fixnum (FRAME_PIXEL_HEIGHT (f))), + intern ("new native pixels"), + Fcons (make_fixnum (width), make_fixnum (height)), + intern ("outer pixels"), + Fcons (make_fixnum (outer_width), make_fixnum (outer_height)), + intern ("outer rest"), + Fcons (make_fixnum ((outer_width - size_hints.base_width) % size_hints.width_inc), + make_fixnum ((outer_height - size_hints.base_height) % size_hints.height_inc))); + else + CALLN (Ffuncall, Qfoo_it, intern ("xg_frame_set_char_size"), + intern ("old native pixels"), + Fcons (make_fixnum (FRAME_PIXEL_WIDTH (f)), + make_fixnum (FRAME_PIXEL_HEIGHT (f))), + intern ("new native pixels"), + Fcons (make_fixnum (width), make_fixnum (height)), + intern ("outer pixels"), + Fcons (make_fixnum (outer_width), make_fixnum (outer_height))); + /* We can not call change_frame_size for a mapped frame, we can not set pixel width/height either. The window manager may override our resize request, XMonad does this all the time. @@ -2028,6 +2096,24 @@ xg_wm_set_size_hint (struct frame *f, long int flags, bool user_position) &f->output_data.xp->size_hints, sizeof (size_hints)) != 0) { + CALLN (Ffuncall, Qfoo_it, intern ("xg_wm_set_size_hint"), + intern ("scale"), make_fixnum (scale), + intern ("char width"), make_fixnum (FRAME_COLUMN_WIDTH (f)), + intern ("toolbar"), make_fixnum (FRAME_TOOLBAR_WIDTH (f)), + intern ("vscroll"), make_fixnum (FRAME_SCROLL_BAR_AREA_WIDTH (f)), + intern ("fringes"), make_fixnum (FRAME_TOTAL_FRINGE_WIDTH (f)), + intern ("borders"), make_fixnum (2 * FRAME_INTERNAL_BORDER_WIDTH (f)), + intern ("base width"), make_fixnum (size_hints.base_width), + intern ("width inc"), make_fixnum (size_hints.width_inc)); + CALLN (Ffuncall, Qfoo_it, intern (" "), + intern ("char height"), make_fixnum (FRAME_LINE_HEIGHT (f)), + intern ("menubar"), make_fixnum (FRAME_MENUBAR_HEIGHT (f)), + intern ("toolbar"), make_fixnum (FRAME_TOOLBAR_HEIGHT (f)), + intern ("hscroll"), make_fixnum (FRAME_SCROLL_BAR_AREA_HEIGHT (f)), + intern ("borders"), make_fixnum (2 * FRAME_INTERNAL_BORDER_WIDTH (f)), + intern ("base height"), make_fixnum (size_hints.base_height), + intern ("height inc"), make_fixnum (size_hints.height_inc)); + block_input (); gtk_window_set_geometry_hints (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), NULL, &size_hints, hint_flags); diff --git a/src/widget.c b/src/widget.c index aaab33b6d8..83ec7ef15e 100644 --- a/src/widget.c +++ b/src/widget.c @@ -154,15 +154,6 @@ emacsFrameClass (void) return (WidgetClass) &emacsFrameClassRec; } -static void -get_default_char_pixel_size (EmacsFrame ew, int *pixel_width, int *pixel_height) -{ - struct frame *f = ew->emacs_frame.frame; - - *pixel_width = FRAME_COLUMN_WIDTH (f); - *pixel_height = FRAME_LINE_HEIGHT (f); -} - static void pixel_to_char_size (EmacsFrame ew, Dimension pixel_width, Dimension pixel_height, int *char_width, int *char_height) @@ -207,104 +198,42 @@ get_wm_shell (Widget w) return (WMShellWidget) wmshell; } -#if 0 /* Currently not used. */ - -static void -mark_shell_size_user_specified (Widget wmshell) -{ - if (! XtIsWMShell (wmshell)) emacs_abort (); - /* This is kind of sleazy, but I can't see how else to tell it to make it - mark the WM_SIZE_HINTS size as user specified when appropriate. */ - ((WMShellWidget) wmshell)->wm.size_hints.flags |= USSize; -} - -#endif - - static void set_frame_size (EmacsFrame ew) { - /* The widget hierarchy is - - argv[0] emacsShell pane Frame-NAME - ApplicationShell EmacsShell Paned EmacsFrame - - We accept geometry specs in this order: - - *Frame-NAME.geometry - *EmacsFrame.geometry - Emacs.geometry - - Other possibilities for widget hierarchies might be - - argv[0] frame pane Frame-NAME - ApplicationShell EmacsShell Paned EmacsFrame - or - argv[0] Frame-NAME pane Frame-NAME - ApplicationShell EmacsShell Paned EmacsFrame - or - argv[0] Frame-NAME pane emacsTextPane - ApplicationShell EmacsFrame Paned EmacsTextPane - - With the current setup, the text-display-area is the part which is - an emacs "frame", since that's the only part managed by emacs proper - (the menubar and the parent of the menubar and all that sort of thing - are managed by lwlib.) - - The EmacsShell widget is simply a replacement for the Shell widget - which is able to deal with using an externally-supplied window instead - of always creating its own. It is not actually emacs specific, and - should possibly have class "Shell" instead of "EmacsShell" to simplify - the resources. - - */ - struct frame *f = ew->emacs_frame.frame; ew->core.width = FRAME_PIXEL_WIDTH (f); ew->core.height = FRAME_PIXEL_HEIGHT (f); - if (CONSP (frame_size_history)) - frame_size_history_plain - (f, build_string ("set_frame_size")); + CALLN (Ffuncall, Qfoo_it, build_string ("set_frame_size"), + build_string ("native pixels"), + Fcons (make_fixnum (FRAME_PIXEL_WIDTH (f)), + make_fixnum (FRAME_PIXEL_HEIGHT (f)))); } static bool update_wm_hints (WMShellWidget wmshell, EmacsFrame ew) { - int cw; - int ch; - Dimension rounded_width; - Dimension rounded_height; - int char_width; - int char_height; - int base_width; - int base_height; + struct frame *f = ew->emacs_frame.frame; + int char_width = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f); + int char_height = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f); + int base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 1); + int base_height = (FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 1) + + FRAME_MENUBAR_HEIGHT (f)); + int min_width = base_width; + int min_height = base_height; char buffer[sizeof wmshell->wm.size_hints]; char *hints_ptr; - - /* Copy the old size hints to the buffer. */ - memcpy (buffer, &wmshell->wm.size_hints, - sizeof wmshell->wm.size_hints); - - pixel_to_char_size (ew, ew->core.width, ew->core.height, - &char_width, &char_height); - char_to_pixel_size (ew, char_width, char_height, - &rounded_width, &rounded_height); - get_default_char_pixel_size (ew, &cw, &ch); - - base_width = (wmshell->core.width - ew->core.width - + (rounded_width - (char_width * cw))); - base_height = (wmshell->core.height - ew->core.height - + (rounded_height - (char_height * ch))); + int value; XtVaSetValues ((Widget) wmshell, XtNbaseWidth, (XtArgVal) base_width, XtNbaseHeight, (XtArgVal) base_height, - XtNwidthInc, (XtArgVal) (frame_resize_pixelwise ? 1 : cw), - XtNheightInc, (XtArgVal) (frame_resize_pixelwise ? 1 : ch), - XtNminWidth, (XtArgVal) base_width, - XtNminHeight, (XtArgVal) base_height, + XtNwidthInc, (XtArgVal) char_width, + XtNheightInc, (XtArgVal) char_height, + XtNminWidth, (XtArgVal) min_width, + XtNminHeight, (XtArgVal) min_height, NULL); /* Return if size hints really changed. If they did not, then Xt @@ -313,8 +242,28 @@ update_wm_hints (WMShellWidget wmshell, EmacsFrame ew) hints_ptr = (char *) &wmshell->wm.size_hints; /* Skip flags, which is unsigned long. */ - return memcmp (hints_ptr + sizeof (long), buffer + sizeof (long), - sizeof wmshell->wm.wm_hints - sizeof (long)); + value = memcmp (hints_ptr + sizeof (long), buffer + sizeof (long), + sizeof wmshell->wm.wm_hints - sizeof (long)); + + if (value != 0) + { + CALLN (Ffuncall, Qfoo_it, build_string ("update_wm_hints"), + build_string ("char width"), make_fixnum (FRAME_COLUMN_WIDTH (f)), + build_string ("vscroll"), make_fixnum (FRAME_SCROLL_BAR_AREA_WIDTH (f)), + build_string ("fringes"), make_fixnum (FRAME_TOTAL_FRINGE_WIDTH (f)), + build_string ("borders"), make_fixnum (2 * FRAME_INTERNAL_BORDER_WIDTH (f)), + build_string ("base width"), make_fixnum (base_width), + build_string ("min width"), make_fixnum (min_width)); + CALLN (Ffuncall, Qfoo_it, build_string (" "), + build_string ("char height"), make_fixnum (FRAME_LINE_HEIGHT (f)), + build_string ("menubar"), make_fixnum (FRAME_MENUBAR_HEIGHT (f)), + build_string ("hscroll"), make_fixnum (FRAME_SCROLL_BAR_AREA_HEIGHT (f)), + build_string ("borders"), make_fixnum (2 * FRAME_INTERNAL_BORDER_WIDTH (f)), + build_string ("base height"), make_fixnum (base_height), + build_string ("min height"), make_fixnum (min_height)); + } + + return value; } bool @@ -337,7 +286,7 @@ update_from_various_frame_slots (EmacsFrame ew) struct frame *f = ew->emacs_frame.frame; struct x_output *x = f->output_data.x; - ew->core.height = FRAME_PIXEL_HEIGHT (f) - x->menubar_height; + ew->core.height = FRAME_PIXEL_HEIGHT (f); // - x->menubar_height; ew->core.width = FRAME_PIXEL_WIDTH (f); ew->core.background_pixel = FRAME_BACKGROUND_PIXEL (f); ew->emacs_frame.internal_border_width = f->internal_border_width; @@ -345,12 +294,11 @@ update_from_various_frame_slots (EmacsFrame ew) ew->emacs_frame.cursor_color = x->cursor_pixel; ew->core.border_pixel = x->border_pixel; - if (CONSP (frame_size_history)) - frame_size_history_extra - (f, build_string ("update_from_various_frame_slots"), - FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f), - ew->core.width, ew->core.height, - f->new_width, f->new_height); + CALLN (Ffuncall, Qfoo_it, + build_string ("update_from_various_frame_slots"), + build_string ("native pixels"), + (Fcons (make_fixnum (FRAME_PIXEL_WIDTH (f)), + make_fixnum (FRAME_PIXEL_HEIGHT (f))))); } static void @@ -384,7 +332,6 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs) { EmacsFrame ew = (EmacsFrame) widget; - struct frame *f = ew->emacs_frame.frame; /* This used to contain SubstructureRedirectMask, but this turns out to be a problem with XIM on Solaris, and events from that mask @@ -399,10 +346,6 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, make sure we get them all. Seen with xfcwm4 for example. */ XtAddRawEventHandler (widget, StructureNotifyMask, False, resize_cb, NULL); - if (CONSP (frame_size_history)) - frame_size_history_plain - (f, build_string ("EmacsFrameRealize")); - if (get_wm_shell (widget)) update_wm_hints (get_wm_shell (widget), ew); } @@ -419,12 +362,13 @@ EmacsFrameResize (Widget widget) EmacsFrame ew = (EmacsFrame) widget; struct frame *f = ew->emacs_frame.frame; - if (CONSP (frame_size_history)) - frame_size_history_extra - (f, build_string ("EmacsFrameResize"), - FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f), - ew->core.width, ew->core.height, - f->new_width, f->new_height); + CALLN (Ffuncall, Qfoo_it, build_string ("EmacsFrameResize"), + build_string ("old native pixels"), + Fcons (make_fixnum (FRAME_PIXEL_WIDTH (f)), + make_fixnum (FRAME_PIXEL_HEIGHT (f))), + build_string ("new native pixels"), + Fcons (make_fixnum (ew->core.width), + make_fixnum (ew->core.height))); change_frame_size (f, ew->core.width, ew->core.height, false, true, false); @@ -472,13 +416,6 @@ EmacsFrameSetCharSize (Widget widget, int columns, int rows) EmacsFrame ew = (EmacsFrame) widget; struct frame *f = ew->emacs_frame.frame; - if (CONSP (frame_size_history)) - frame_size_history_extra - (f, build_string ("EmacsFrameSetCharSize"), - FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f), - columns, rows, - f->new_width, f->new_height); - if (!frame_inhibit_resize (f, 0, Qfont) && !frame_inhibit_resize (f, 1, Qfont)) x_set_window_size (f, 0, columns * FRAME_COLUMN_WIDTH (f), diff --git a/src/window.c b/src/window.c index f116b9a9d7..c090f29461 100644 --- a/src/window.c +++ b/src/window.c @@ -8394,6 +8394,7 @@ syms_of_window (void) DEFSYM (Qheader_line_format, "header-line-format"); DEFSYM (Qtab_line_format, "tab-line-format"); DEFSYM (Qno_other_window, "no-other-window"); + DEFSYM (Qfoo_it, "foo-it"); DEFVAR_LISP ("temp-buffer-show-function", Vtemp_buffer_show_function, doc: /* Non-nil means call as function to display a help buffer. diff --git a/src/xterm.c b/src/xterm.c index 7eaf59d54b..b2e689fe84 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -26160,6 +26160,8 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset) { struct font *font = XFONT_OBJECT (font_object); int unit, font_ascent, font_descent; + int old_width = FRAME_COLUMN_WIDTH (f); + int old_height = FRAME_LINE_HEIGHT (f); if (fontset < 0) fontset = fontset_from_font (font_object); @@ -26197,9 +26199,27 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset) because it's done in Fx_show_tip, and it leads to problems because the tip frame has no widget. */ if (FRAME_X_WINDOW (f) != 0 && !FRAME_TOOLTIP_P (f)) - adjust_frame_size - (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f), - FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3, false, Qfont); + { + CALLN (Ffuncall, Qfoo_it, intern ("\nx_new_font"), + intern ("old char size"), + Fcons (make_fixnum (old_width), make_fixnum (old_height)), + intern ("new char size"), + Fcons (make_fixnum (FRAME_COLUMN_WIDTH (f)), + make_fixnum (FRAME_LINE_HEIGHT (f))), + intern ("text chars"), + Fcons (make_fixnum (FRAME_COLS (f)), + make_fixnum (FRAME_LINES (f))), + intern ("old text pixels"), + Fcons (make_fixnum (FRAME_TEXT_WIDTH (f)), + make_fixnum (FRAME_TEXT_HEIGHT (f))), + intern ("new text pixels"), + Fcons (make_fixnum (FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f)), + make_fixnum (FRAME_LINES (f) * FRAME_LINE_HEIGHT (f)))); + + adjust_frame_size + (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f), + FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3, false, Qfont); + } #ifdef HAVE_X_I18N if (FRAME_XIC (f)