Skip to content

Commit ec76cbc

Browse files
committed
[OSX] support move and resize events
Fix nwjs#799
1 parent 4c14c6f commit ec76cbc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/browser/native_window_mac.mm

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,29 @@ - (void)windowDidDeminiaturize:(NSNotification *)notification {
139139
shell_->SendEvent("restore");
140140
}
141141

142+
- (void)windowDidMove:(NSNotification*)notification {
143+
if (shell_) {
144+
gfx::Point origin =
145+
static_cast<nw::NativeWindowCocoa*>(shell_->window())->GetPosition();
146+
base::ListValue args;
147+
args.AppendInteger(origin.x());
148+
args.AppendInteger(origin.y());
149+
shell_->SendEvent("move", args);
150+
}
151+
}
152+
153+
- (void)windowDidResize:(NSNotification*)notification {
154+
if (shell_) {
155+
NSWindow* window =
156+
static_cast<nw::NativeWindowCocoa*>(shell_->window())->window();
157+
NSRect frame = [window frame];
158+
base::ListValue args;
159+
args.AppendInteger(frame.size.width);
160+
args.AppendInteger(frame.size.height);
161+
shell_->SendEvent("resize", args);
162+
}
163+
}
164+
142165
- (BOOL)windowShouldZoom:(NSWindow*)window toFrame:(NSRect)newFrame {
143166
// Cocoa doen't have concept of maximize/unmaximize, so wee need to emulate
144167
// them by calculating size change when zooming.

0 commit comments

Comments
 (0)