Commit 7def8cbd authored by Jan Djärv's avatar Jan Djärv
Browse files

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.
parent 34a731f8
2013-12-07 Jan Djärv <jan.h.d@swipnet.se>
* 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 <eliz@gnu.org>
* buffer.c (Fset_buffer_multibyte): Invalidate buffer caches.
......
......@@ -1237,6 +1237,13 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
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 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
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)
{
......
......@@ -1240,7 +1240,11 @@ Free a pool and temporary objects it refers to (callable from C)
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 @@ Free a pool and temporary objects it refers to (callable from C)
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 @@ Free a pool and temporary objects it refers to (callable from C)
[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 @@ Free a pool and temporary objects it refers to (callable from C)
[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 @@ - (void) updateFrameSize: (BOOL) delay;
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 @@ - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
/* 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 @@ - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
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 @@ @implementation EmacsDocument
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 @@ @implementation EmacsDocument
}
/* 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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment