1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-05 03:20:39 -08:00

Fix NS frame position update after resize/move

Fixes bug#74074, bug#79164.

* src/nsterm.m ([EmacsView windowDidEndLiveResize:]):
([EmacsView updateFramePosition]): New functions.
([EmacsView windowDidMove:]): Move contents of this function into
updateFramePosition and call it.

Copyright-paperwork-exempt: yes
This commit is contained in:
Dr.Sc.KAWAMOTO,Takuji 2025-08-02 13:15:06 +09:00 committed by Alan Third
parent 4293a7678b
commit 5b9f4ee76e

View file

@ -6818,6 +6818,11 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action)
@implementation EmacsView
- (void)windowDidEndLiveResize:(NSNotification *)notification
{
[self updateFramePosition];
}
/* Needed to inform when window closed from lisp. */
- (void) setWindowClosing: (BOOL)closing
{
@ -7970,6 +7975,37 @@ ns_in_echo_area (void)
}
- (void)updateFramePosition
{
NSWindow *win = [self window];
NSRect r = [win frame];
NSArray *screens = [NSScreen screens];
NSScreen *screen = [screens objectAtIndex: 0];
if (!emacsframe->output_data.ns)
return;
if (screen != nil)
{
emacsframe->left_pos = (NSMinX (r)
- NS_PARENT_WINDOW_LEFT_POS (emacsframe));
emacsframe->top_pos = (NS_PARENT_WINDOW_TOP_POS (emacsframe)
- NSMaxY (r));
if (emacs_event)
{
struct input_event ie;
EVENT_INIT (ie);
ie.kind = MOVE_FRAME_EVENT;
XSETFRAME (ie.frame_or_window, emacsframe);
XSETINT (ie.x, emacsframe->left_pos);
XSETINT (ie.y, emacsframe->top_pos);
kbd_buffer_store_event (&ie);
}
}
}
- (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
/* Normalize frame to gridded text size. */
{
@ -8304,34 +8340,9 @@ ns_in_echo_area (void)
- (void)windowDidMove: sender
{
NSWindow *win = [self window];
NSRect r = [win frame];
NSArray *screens = [NSScreen screens];
NSScreen *screen = [screens objectAtIndex: 0];
NSTRACE ("[EmacsView windowDidMove:]");
if (!emacsframe->output_data.ns)
return;
if (screen != nil)
{
emacsframe->left_pos = (NSMinX (r)
- NS_PARENT_WINDOW_LEFT_POS (emacsframe));
emacsframe->top_pos = (NS_PARENT_WINDOW_TOP_POS (emacsframe)
- NSMaxY (r));
if (emacs_event)
{
struct input_event ie;
EVENT_INIT (ie);
ie.kind = MOVE_FRAME_EVENT;
XSETFRAME (ie.frame_or_window, emacsframe);
XSETINT (ie.x, emacsframe->left_pos);
XSETINT (ie.y, emacsframe->top_pos);
kbd_buffer_store_event (&ie);
}
}
[self updateFramePosition];
}