Skip to content

Commit c93489c

Browse files
committed
[WIN] Handle WM_SIZE in maximize case
Fix nwjs#753
1 parent 0ad59a5 commit c93489c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/browser/native_window_win.cc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,10 @@ bool NativeWindowWin::ShouldShowWindowTitle() const {
520520
return has_frame();
521521
}
522522

523+
bool NativeWindowWin::ShouldHandleOnSize() const {
524+
return true;
525+
}
526+
523527
void NativeWindowWin::OnNativeFocusChange(gfx::NativeView focused_before,
524528
gfx::NativeView focused_now) {
525529
gfx::NativeView this_window = GetWidget()->GetNativeView();
@@ -659,12 +663,20 @@ bool NativeWindowWin::ExecuteWindowsCommand(int command_id) {
659663
is_maximized_ = false;
660664
if (shell())
661665
shell()->SendEvent("unmaximize");
662-
} else if ((command_id & sc_mask) == SC_MAXIMIZE) {
666+
}
667+
return false;
668+
}
669+
670+
bool NativeWindowWin::HandleSize(unsigned int param, const gfx::Size& size) {
671+
if (param == SIZE_MAXIMIZED) {
663672
is_maximized_ = true;
664673
if (shell())
665674
shell()->SendEvent("maximize");
675+
}else if (param == SIZE_RESTORED && is_maximized_) {
676+
is_maximized_ = false;
677+
if (shell())
678+
shell()->SendEvent("unmaximize");
666679
}
667-
668680
return false;
669681
}
670682

@@ -681,7 +693,7 @@ void NativeWindowWin::SaveWindowPlacement(const gfx::Rect& bounds,
681693
ui::WindowShowState show_state) {
682694
// views::WidgetDelegate::SaveWindowPlacement(bounds, show_state);
683695
}
684-
696+
685697
void NativeWindowWin::OnViewWasResized() {
686698
// Set the window shape of the RWHV.
687699
DCHECK(window_);

src/browser/native_window_win.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class NativeWindowWin : public NativeWindow,
100100
virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE;
101101
virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
102102
virtual bool ShouldShowWindowTitle() const OVERRIDE;
103+
virtual bool ShouldHandleOnSize() const OVERRIDE;
103104

104105
// WidgetFocusChangeListener implementation.
105106
virtual void OnNativeFocusChange(gfx::NativeView focused_before,
@@ -126,6 +127,7 @@ class NativeWindowWin : public NativeWindow,
126127

127128
// views::WidgetDelegate implementation.
128129
virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE;
130+
virtual bool HandleSize(unsigned int param, const gfx::Size& size) OVERRIDE;
129131
virtual bool ExecuteAppCommand(int command_id) OVERRIDE;
130132
virtual void SaveWindowPlacement(const gfx::Rect& bounds,
131133
ui::WindowShowState show_state) OVERRIDE;

0 commit comments

Comments
 (0)