|
@@ -169,9 +169,6 @@ NativeWindowViews::NativeWindowViews(
|
|
|
menu_bar_autohide_(false),
|
|
|
menu_bar_visible_(false),
|
|
|
menu_bar_alt_pressed_(false),
|
|
|
-#if defined(OS_WIN)
|
|
|
- is_minimized_(false),
|
|
|
-#endif
|
|
|
keyboard_event_handler_(new views::UnhandledKeyboardEventHandler),
|
|
|
use_content_size_(false),
|
|
|
resizable_(true) {
|
|
@@ -228,6 +225,9 @@ NativeWindowViews::NativeWindowViews(
|
|
|
|
|
|
window_->Init(params);
|
|
|
|
|
|
+ bool fullscreen = false;
|
|
|
+ options.Get(switches::kFullscreen, &fullscreen);
|
|
|
+
|
|
|
#if defined(USE_X11)
|
|
|
// Start monitoring window states.
|
|
|
window_state_watcher_.reset(new WindowStateWatcher(this));
|
|
@@ -253,8 +253,7 @@ NativeWindowViews::NativeWindowViews(
|
|
|
}
|
|
|
|
|
|
// Before the window is mapped, there is no SHOW_FULLSCREEN_STATE.
|
|
|
- bool fullscreen = false;
|
|
|
- if (options.Get(switches::kFullscreen, & fullscreen) && fullscreen) {
|
|
|
+ if (fullscreen) {
|
|
|
state_atom_list.push_back(GetAtom("_NET_WM_STATE_FULLSCREEN"));
|
|
|
}
|
|
|
|
|
@@ -278,6 +277,12 @@ NativeWindowViews::NativeWindowViews(
|
|
|
bounds = ContentBoundsToWindowBounds(bounds);
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
+ // Save initial window state.
|
|
|
+ if (fullscreen)
|
|
|
+ last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
|
|
|
+ else
|
|
|
+ last_window_state_ = ui::SHOW_STATE_NORMAL;
|
|
|
+
|
|
|
if (!has_frame()) {
|
|
|
// Set Window style so that we get a minimize and maximize animation when
|
|
|
// frameless.
|
|
@@ -338,17 +343,14 @@ bool NativeWindowViews::IsFocused() {
|
|
|
}
|
|
|
|
|
|
void NativeWindowViews::Show() {
|
|
|
- web_contents()->WasShown();
|
|
|
window_->native_widget_private()->ShowWithWindowState(GetRestoredState());
|
|
|
}
|
|
|
|
|
|
void NativeWindowViews::ShowInactive() {
|
|
|
- web_contents()->WasShown();
|
|
|
window_->ShowInactive();
|
|
|
}
|
|
|
|
|
|
void NativeWindowViews::Hide() {
|
|
|
- window_->Hide();
|
|
|
web_contents()->WasHidden();
|
|
|
}
|
|
|
|
|
@@ -391,11 +393,16 @@ bool NativeWindowViews::IsMinimized() {
|
|
|
void NativeWindowViews::SetFullScreen(bool fullscreen) {
|
|
|
#if defined(OS_WIN)
|
|
|
// There is no native fullscreen state on Windows.
|
|
|
- window_->SetFullscreen(fullscreen);
|
|
|
- if (fullscreen)
|
|
|
+ if (fullscreen) {
|
|
|
+ last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
|
|
|
NotifyWindowEnterFullScreen();
|
|
|
- else
|
|
|
+ } else {
|
|
|
+ last_window_state_ = ui::SHOW_STATE_NORMAL;
|
|
|
NotifyWindowLeaveFullScreen();
|
|
|
+ }
|
|
|
+ // We set the new value after notifying, so we can handle the size event
|
|
|
+ // correctly.
|
|
|
+ window_->SetFullscreen(fullscreen);
|
|
|
#else
|
|
|
if (IsVisible())
|
|
|
window_->SetFullscreen(fullscreen);
|
|
@@ -807,48 +814,63 @@ void NativeWindowViews::OnWidgetMove() {
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
|
|
|
- // Windows uses the 4 lower order bits of |command_id| for type-specific
|
|
|
- // information so we must exclude this when comparing.
|
|
|
- static const int sc_mask = 0xFFF0;
|
|
|
- if ((command_id & sc_mask) == SC_MINIMIZE) {
|
|
|
- NotifyWindowMinimize();
|
|
|
- is_minimized_ = true;
|
|
|
- } else if ((command_id & sc_mask) == SC_RESTORE) {
|
|
|
- if (is_minimized_)
|
|
|
- NotifyWindowRestore();
|
|
|
- else
|
|
|
- NotifyWindowUnmaximize();
|
|
|
- is_minimized_ = false;
|
|
|
- } else if ((command_id & sc_mask) == SC_MAXIMIZE) {
|
|
|
- NotifyWindowMaximize();
|
|
|
- } else {
|
|
|
- std::string command = AppCommandToString(command_id);
|
|
|
- NotifyWindowExecuteWindowsCommand(command);
|
|
|
- }
|
|
|
+ std::string command = AppCommandToString(command_id);
|
|
|
+ NotifyWindowExecuteWindowsCommand(command);
|
|
|
return false;
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
-gfx::ImageSkia NativeWindowViews::GetDevToolsWindowIcon() {
|
|
|
- return GetWindowAppIcon();
|
|
|
-}
|
|
|
-
|
|
|
-#if defined(USE_X11)
|
|
|
-void NativeWindowViews::GetDevToolsWindowWMClass(
|
|
|
- std::string* name, std::string* class_name) {
|
|
|
- *class_name = Browser::Get()->GetName();
|
|
|
- *name = base::StringToLowerASCII(*class_name);
|
|
|
-}
|
|
|
-#endif
|
|
|
-
|
|
|
#if defined(OS_WIN)
|
|
|
bool NativeWindowViews::PreHandleMSG(
|
|
|
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) {
|
|
|
- // Handle thumbar button click message.
|
|
|
- if (message == WM_COMMAND && HIWORD(w_param) == THBN_CLICKED)
|
|
|
- return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param));
|
|
|
- else
|
|
|
- return false;
|
|
|
+ switch (message) {
|
|
|
+ case WM_COMMAND:
|
|
|
+ // Handle thumbar button click message.
|
|
|
+ if (HIWORD(w_param) == THBN_CLICKED)
|
|
|
+ return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param));
|
|
|
+ return false;
|
|
|
+ case WM_SIZE:
|
|
|
+ // Handle window state change.
|
|
|
+ HandleSizeEvent(w_param, l_param);
|
|
|
+ return false;
|
|
|
+ default:
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
|
|
|
+ // Here we handle the WM_SIZE event in order to figure out what is the current
|
|
|
+ // window state and notify the user accordingly.
|
|
|
+ switch (w_param) {
|
|
|
+ case SIZE_MAXIMIZED:
|
|
|
+ last_window_state_ = ui::SHOW_STATE_MAXIMIZED;
|
|
|
+ NotifyWindowMaximize();
|
|
|
+ break;
|
|
|
+ case SIZE_MINIMIZED:
|
|
|
+ last_window_state_ = ui::SHOW_STATE_MINIMIZED;
|
|
|
+ NotifyWindowMinimize();
|
|
|
+ break;
|
|
|
+ case SIZE_RESTORED:
|
|
|
+ if (last_window_state_ == ui::SHOW_STATE_NORMAL)
|
|
|
+ return;
|
|
|
+
|
|
|
+ switch (last_window_state_) {
|
|
|
+ case ui::SHOW_STATE_MAXIMIZED:
|
|
|
+ last_window_state_ = ui::SHOW_STATE_NORMAL;
|
|
|
+ NotifyWindowUnmaximize();
|
|
|
+ break;
|
|
|
+ case ui::SHOW_STATE_MINIMIZED:
|
|
|
+ if (IsFullscreen()) {
|
|
|
+ last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
|
|
|
+ NotifyWindowEnterFullScreen();
|
|
|
+ } else {
|
|
|
+ last_window_state_ = ui::SHOW_STATE_NORMAL;
|
|
|
+ NotifyWindowRestore();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
#endif
|
|
|
|