From: Jan Djärv Date: Sat, 7 Dec 2013 14:21:53 +0000 (+0100) Subject: Handle pixelwise resize changes in NS port. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~530 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7def8cbd8b37773a1c45b05e79af38a5d5cb69a3;p=emacs.git Handle pixelwise resize changes in NS port. * src/nsfns.m (Fx_create_frame): Call change_frame_size twice as per comment in xfns.c. Change to pixelwise call. * src/nsterm.m (x_set_window_size): Change parameters rows/cols to height/width. row/cols are locals. Pass pixelwise to check_frame_size. Don't set FRAME_PIXEL_WIDTH/HEIGHT. (updateFrameSize:): Remove gsextra. Adjust for pixelwise resize. (windowWillResize): Remove gsextra. Calculate extra as in updateFrameSize. (x_new_font): Don't change frame size if fullscreen. Change size pixelwise. --- diff --git a/src/ChangeLog b/src/ChangeLog index 082102bc3d8..0f4d2f49ebf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2013-12-07 Jan Djärv + + * nsterm.m (x_set_window_size): Change parameters rows/cols to + height/width. row/cols are locals. + Pass pixelwise to check_frame_size. Don't set FRAME_PIXEL_WIDTH/HEIGHT. + (updateFrameSize:): Remove gsextra. Adjust for pixelwise resize. + (windowWillResize): Remove gsextra. Calculate extra as in + updateFrameSize. + (x_new_font): Don't change frame size if fullscreen. Change + size pixelwise. + + * nsfns.m (Fx_create_frame): Call change_frame_size twice as per + comment in xfns.c. Change to pixelwise call. + 2013-12-06 Eli Zaretskii * buffer.c (Fset_buffer_multibyte): Invalidate buffer caches. diff --git a/src/nsfns.m b/src/nsfns.m index 13103582891..8f14915ea65 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1237,6 +1237,13 @@ This function is an internal primitive--use `make-frame' instead. */) init_frame_faces (f); + /* Read comment about this code in corresponding place in xfns.c. */ + width = FRAME_TEXT_WIDTH (f); + height = FRAME_TEXT_HEIGHT (f); + FRAME_TEXT_HEIGHT (f) = 0; + SET_FRAME_WIDTH (f, 0); + change_frame_size (f, width, height, 1, 0, 0, 1); + /* The resources controlling the menu-bar and tool-bar are processed specially at startup, and reflected in the mode variables; ignore them here. */ @@ -1301,12 +1308,11 @@ This function is an internal primitive--use `make-frame' instead. */) x_default_parameter (f, parms, Qfullscreen, Qnil, "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); - width = FRAME_COLS (f); - height = FRAME_LINES (f); - - SET_FRAME_COLS (f, 0); - FRAME_LINES (f) = 0; - change_frame_size (f, width, height, 1, 0, 0, 0); + width = FRAME_TEXT_WIDTH (f); + height = FRAME_TEXT_HEIGHT (f); + FRAME_TEXT_HEIGHT (f) = 0; + SET_FRAME_WIDTH (f, 0); + change_frame_size (f, width, height, 1, 0, 0, 1); if (! f->output_data.ns->explicit_parent) { diff --git a/src/nsterm.m b/src/nsterm.m index 3e6ceae6580..37edfb238a9 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1240,7 +1240,11 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_grav) void -x_set_window_size (struct frame *f, int change_grav, int cols, int rows, bool pixelwise) +x_set_window_size (struct frame *f, + int change_grav, + int width, + int height, + bool pixelwise) /* -------------------------------------------------------------------------- Adjust window pixel size based on given character grid size Impl is a bit more complex than other terms, need to do some @@ -1252,32 +1256,35 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows, bool pi NSRect wr = [window frame]; int tb = FRAME_EXTERNAL_TOOL_BAR (f); int pixelwidth, pixelheight; + int rows, cols; NSTRACE (x_set_window_size); if (view == nil) return; -/*fprintf (stderr, "\tsetWindowSize: %d x %d, pixelwise %d, font size %d x %d\n", cols, rows, pixelwise, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f));*/ +/*fprintf (stderr, "\tsetWindowSize: %d x %d, pixelwise %d, font size %d x %d\n", width, height, pixelwise, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f));*/ block_input (); - check_frame_size (f, &cols, &rows, 0); + check_frame_size (f, &width, &height, pixelwise); f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f); compute_fringe_widths (f, 0); if (pixelwise) { - pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, cols); - pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, rows); + pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width); + pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, height); cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixelwidth); rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixelheight); } else { - pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); - pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows); + pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, width); + pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, height); + cols = width; + rows = height; } /* If we have a toolbar, take its height into account. */ @@ -1313,7 +1320,7 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows, bool pi [view setRows: rows andColumns: cols]; [window setFrame: wr display: YES]; -/*fprintf (stderr, "\tx_set_window_size %d, %d\t%d, %d\n", cols, rows, pixelwidth, pixelheight); */ + fprintf (stderr, "\tx_set_window_size %d, %d\t%d, %d\n", cols, rows, pixelwidth, pixelheight); /* This is a trick to compensate for Emacs' managing the scrollbar area as a fixed number of standard character columns. Instead of leaving @@ -1331,9 +1338,7 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows, bool pi [view setBoundsOrigin: origin]; } - change_frame_size (f, cols, rows, 0, 1, 0, 0); /* pretend, delay, safe */ - FRAME_PIXEL_WIDTH (f) = pixelwidth; - FRAME_PIXEL_HEIGHT (f) = pixelheight; + change_frame_size (f, width, height, 0, 1, 0, pixelwise); /* SET_FRAME_GARBAGED (f); // this short-circuits expose call in drawRect */ mark_window_cursors_off (XWINDOW (f->root_window)); @@ -5658,44 +5663,39 @@ not_in_argv (NSString *arg) NSWindow *window = [self window]; NSRect wr = [window frame]; int extra = 0; - int gsextra = 0; -#ifdef NS_IMPL_GNUSTEP - gsextra = 3; -#endif - int oldc = cols, oldr = rows; int oldw = FRAME_PIXEL_WIDTH (emacsframe), oldh = FRAME_PIXEL_HEIGHT (emacsframe); int neww, newh; - cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, wr.size.width + gsextra); - - if (cols < MINWIDTH) - cols = MINWIDTH; - if (! [self isFullscreen]) { extra = FRAME_NS_TITLEBAR_HEIGHT (emacsframe) - + FRAME_TOOLBAR_HEIGHT (emacsframe) - gsextra; + + FRAME_TOOLBAR_HEIGHT (emacsframe); } - rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, wr.size.height - extra); + neww = (int)wr.size.width - emacsframe->border_width; + newh = (int)wr.size.height - extra; + + cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, neww); + rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, newh); + + if (cols < MINWIDTH) + cols = MINWIDTH; if (rows < MINHEIGHT) rows = MINHEIGHT; - neww = (int)wr.size.width - emacsframe->border_width; - newh = (int)wr.size.height - extra; - if (oldr != rows || oldc != cols || neww != oldw || newh != oldh) { NSView *view = FRAME_NS_VIEW (emacsframe); NSWindow *win = [view window]; NSSize sz = [win resizeIncrements]; - FRAME_PIXEL_WIDTH (emacsframe) = neww; - FRAME_PIXEL_HEIGHT (emacsframe) = newh; - change_frame_size (emacsframe, cols, rows, 0, delay, 0, 0); + change_frame_size (emacsframe, + FRAME_PIXEL_TO_TEXT_WIDTH (emacsframe, neww), + FRAME_PIXEL_TO_TEXT_HEIGHT (emacsframe, newh), + 0, delay, 0, 1); SET_FRAME_GARBAGED (emacsframe); cancel_mouse_face (emacsframe); @@ -5717,10 +5717,6 @@ not_in_argv (NSString *arg) /* normalize frame to gridded text size */ { int extra = 0; - int gsextra = 0; -#ifdef NS_IMPL_GNUSTEP - gsextra = 3; -#endif NSTRACE (windowWillResize); /*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */ @@ -5738,8 +5734,13 @@ not_in_argv (NSString *arg) if (fs_state == FULLSCREEN_NONE) maximized_width = maximized_height = -1; - cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, - frameSize.width + gsextra); + if (! [self isFullscreen]) + { + extra = FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + + FRAME_TOOLBAR_HEIGHT (emacsframe); + } + + cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, frameSize.width); if (cols < MINWIDTH) cols = MINWIDTH; @@ -7335,6 +7336,7 @@ Lisp_Object x_new_font (struct frame *f, Lisp_Object font_object, int fontset) { struct font *font = XFONT_OBJECT (font_object); + EmacsView *view = FRAME_NS_VIEW (f); if (fontset < 0) fontset = fontset_from_font (font_object); @@ -7367,8 +7369,9 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset) } /* Now make the frame display the given font. */ - if (FRAME_NS_WINDOW (f) != 0) - x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f), 0); + if (FRAME_NS_WINDOW (f) != 0 && ! [view isFullscreen]) + x_set_window_size (f, 0, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f), + FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 1); return font_object; }