@@ -247,7 +247,8 @@ NativeWindowWin::NativeWindowWin(const base::WeakPtr<content::Shell>& shell,
247
247
resizable_(true ),
248
248
minimum_size_(0 , 0 ),
249
249
maximum_size_(),
250
- initial_focus_(true ) {
250
+ initial_focus_(true ),
251
+ last_width_(-1 ), last_height_(-1 ) {
251
252
manifest->GetBoolean (" focus" , &initial_focus_);
252
253
253
254
window_ = new views::Widget;
@@ -265,6 +266,9 @@ NativeWindowWin::NativeWindowWin(const base::WeakPtr<content::Shell>& shell,
265
266
gfx::Rect window_bounds =
266
267
window_->non_client_view ()->GetWindowBoundsForClientBounds (
267
268
gfx::Rect (width,height));
269
+ last_width_ = width;
270
+ last_height_ = height;
271
+ window_->AddObserver (this );
268
272
window_->SetSize (window_bounds.size ());
269
273
window_->CenterWindow (window_bounds.size ());
270
274
@@ -372,6 +376,19 @@ void NativeWindowWin::SetAlwaysOnTop(bool top) {
372
376
window_->SetAlwaysOnTop (top);
373
377
}
374
378
379
+ void NativeWindowWin::OnWidgetBoundsChanged (views::Widget* widget, const gfx::Rect& new_bounds) {
380
+ int w = new_bounds.width ();
381
+ int h = new_bounds.height ();
382
+ if (shell () && (w != last_width_ || h != last_height_)) {
383
+ base::ListValue args;
384
+ args.AppendInteger (w);
385
+ args.AppendInteger (h);
386
+ shell ()->SendEvent (" resize" , args);
387
+ last_width_ = w;
388
+ last_height_ = h;
389
+ }
390
+ }
391
+
375
392
void NativeWindowWin::SetPosition (const std::string& position) {
376
393
if (position == " center" ) {
377
394
gfx::Rect bounds = window_->GetWindowBoundsInScreen ();
@@ -465,6 +482,16 @@ views::NonClientFrameView* NativeWindowWin::CreateNonClientFrameView(
465
482
return frame_view;
466
483
}
467
484
485
+ void NativeWindowWin::OnWidgetMove () {
486
+ gfx::Point origin = GetPosition ();
487
+ if (shell ()) {
488
+ base::ListValue args;
489
+ args.AppendInteger (origin.x ());
490
+ args.AppendInteger (origin.y ());
491
+ shell ()->SendEvent (" move" , args);
492
+ }
493
+ }
494
+
468
495
bool NativeWindowWin::CanResize () const {
469
496
return resizable_;
470
497
}
0 commit comments