Merge branch 'master' into chrome52
This commit is contained in:
commit
b57665330c
203 changed files with 2352 additions and 1220 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "ui/aura/window_tree_host.h"
|
||||
#include "ui/base/hit_test.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "ui/gfx/screen.h"
|
||||
#include "ui/views/background.h"
|
||||
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
|
||||
#include "ui/views/controls/webview/webview.h"
|
||||
|
@ -135,6 +136,10 @@ NativeWindowViews::NativeWindowViews(
|
|||
menu_bar_autohide_(false),
|
||||
menu_bar_visible_(false),
|
||||
menu_bar_alt_pressed_(false),
|
||||
#if defined(OS_WIN)
|
||||
enabled_a11y_support_(false),
|
||||
thick_frame_(true),
|
||||
#endif
|
||||
keyboard_event_handler_(new views::UnhandledKeyboardEventHandler),
|
||||
disable_count_(0),
|
||||
use_content_size_(false),
|
||||
|
@ -152,6 +157,11 @@ NativeWindowViews::NativeWindowViews(
|
|||
options.Get(options::kResizable, &resizable_);
|
||||
options.Get(options::kMinimizable, &minimizable_);
|
||||
options.Get(options::kMaximizable, &maximizable_);
|
||||
|
||||
// Transparent window must not have thick frame.
|
||||
options.Get("thickFrame", &thick_frame_);
|
||||
if (transparent())
|
||||
thick_frame_ = false;
|
||||
#endif
|
||||
|
||||
if (enable_larger_than_screen())
|
||||
|
@ -214,6 +224,9 @@ NativeWindowViews::NativeWindowViews(
|
|||
bool fullscreen = false;
|
||||
options.Get(options::kFullscreen, &fullscreen);
|
||||
|
||||
std::string window_type;
|
||||
options.Get(options::kType, &window_type);
|
||||
|
||||
#if defined(USE_X11)
|
||||
// Start monitoring window states.
|
||||
window_state_watcher_.reset(new WindowStateWatcher(this));
|
||||
|
@ -243,9 +256,6 @@ NativeWindowViews::NativeWindowViews(
|
|||
state_atom_list.push_back(GetAtom("_NET_WM_STATE_FULLSCREEN"));
|
||||
}
|
||||
|
||||
std::string window_type;
|
||||
options.Get(options::kType, &window_type);
|
||||
|
||||
if (parent) {
|
||||
SetParentWindow(parent);
|
||||
// Force using dialog type for child window.
|
||||
|
@ -269,13 +279,6 @@ NativeWindowViews::NativeWindowViews(
|
|||
AddChildView(web_view_);
|
||||
|
||||
#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;
|
||||
last_normal_size_ = gfx::Size(widget_size_);
|
||||
|
||||
if (!has_frame()) {
|
||||
// Set Window style so that we get a minimize and maximize animation when
|
||||
// frameless.
|
||||
|
@ -287,17 +290,18 @@ NativeWindowViews::NativeWindowViews(
|
|||
if (maximizable_)
|
||||
frame_style |= WS_MAXIMIZEBOX;
|
||||
// We should not show a frame for transparent window.
|
||||
if (transparent())
|
||||
if (!thick_frame_)
|
||||
frame_style &= ~(WS_THICKFRAME | WS_CAPTION);
|
||||
::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, frame_style);
|
||||
}
|
||||
|
||||
if (transparent()) {
|
||||
// Transparent window on Windows has to have WS_EX_COMPOSITED style.
|
||||
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
|
||||
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
|
||||
// Window without thick frame has to have WS_EX_COMPOSITED style.
|
||||
if (!thick_frame_)
|
||||
ex_style |= WS_EX_COMPOSITED;
|
||||
::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style);
|
||||
}
|
||||
if (window_type == "toolbar")
|
||||
ex_style |= WS_EX_TOOLWINDOW;
|
||||
::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style);
|
||||
#endif
|
||||
|
||||
// TODO(zcbenz): This was used to force using native frame on Windows 2003, we
|
||||
|
@ -315,6 +319,15 @@ NativeWindowViews::NativeWindowViews(
|
|||
|
||||
window_->CenterWindow(size);
|
||||
Layout();
|
||||
|
||||
#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;
|
||||
last_normal_bounds_ = GetBounds();
|
||||
#endif
|
||||
}
|
||||
|
||||
NativeWindowViews::~NativeWindowViews() {
|
||||
|
@ -410,6 +423,17 @@ bool NativeWindowViews::IsEnabled() {
|
|||
}
|
||||
|
||||
void NativeWindowViews::Maximize() {
|
||||
#if defined(OS_WIN)
|
||||
// For window without WS_THICKFRAME style, we can not call Maximize().
|
||||
if (!thick_frame_) {
|
||||
restore_bounds_ = GetBounds();
|
||||
auto display =
|
||||
gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
|
||||
SetBounds(display.work_area(), false);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (IsVisible())
|
||||
window_->Maximize();
|
||||
else
|
||||
|
@ -418,6 +442,13 @@ void NativeWindowViews::Maximize() {
|
|||
}
|
||||
|
||||
void NativeWindowViews::Unmaximize() {
|
||||
#if defined(OS_WIN)
|
||||
if (!thick_frame_) {
|
||||
SetBounds(restore_bounds_, false);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
window_->Restore();
|
||||
}
|
||||
|
||||
|
@ -454,6 +485,20 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
|
|||
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
||||
NotifyWindowLeaveFullScreen();
|
||||
}
|
||||
|
||||
// For window without WS_THICKFRAME style, we can not call SetFullscreen().
|
||||
if (!thick_frame_) {
|
||||
if (fullscreen) {
|
||||
restore_bounds_ = GetBounds();
|
||||
auto display =
|
||||
gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
|
||||
SetBounds(display.bounds(), false);
|
||||
} else {
|
||||
SetBounds(restore_bounds_, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// We set the new value after notifying, so we can handle the size event
|
||||
// correctly.
|
||||
window_->SetFullscreen(fullscreen);
|
||||
|
@ -463,6 +508,12 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
|
|||
else
|
||||
window_->native_widget_private()->ShowWithWindowState(
|
||||
ui::SHOW_STATE_FULLSCREEN);
|
||||
|
||||
// Auto-hide menubar when in fullscreen.
|
||||
if (fullscreen)
|
||||
SetMenuBarVisibility(false);
|
||||
else
|
||||
SetMenuBarVisibility(!menu_bar_autohide_);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -470,8 +521,7 @@ bool NativeWindowViews::IsFullscreen() const {
|
|||
return window_->IsFullscreen();
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetBounds(const gfx::Rect& bounds,
|
||||
bool animate = false) {
|
||||
void NativeWindowViews::SetBounds(const gfx::Rect& bounds, bool animate) {
|
||||
#if defined(USE_X11)
|
||||
// On Linux the minimum and maximum size should be updated with window size
|
||||
// when window is not resizable.
|
||||
|
@ -517,7 +567,7 @@ void NativeWindowViews::SetContentSizeConstraints(
|
|||
|
||||
void NativeWindowViews::SetResizable(bool resizable) {
|
||||
#if defined(OS_WIN)
|
||||
if (!transparent())
|
||||
if (thick_frame_)
|
||||
FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME);
|
||||
#elif defined(USE_X11)
|
||||
if (resizable != resizable_) {
|
||||
|
@ -540,7 +590,11 @@ void NativeWindowViews::SetResizable(bool resizable) {
|
|||
|
||||
bool NativeWindowViews::IsResizable() {
|
||||
#if defined(OS_WIN)
|
||||
return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME;
|
||||
if (thick_frame_) {
|
||||
return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME;
|
||||
} else {
|
||||
return CanResize();
|
||||
}
|
||||
#else
|
||||
return CanResize();
|
||||
#endif
|
||||
|
@ -752,7 +806,7 @@ void NativeWindowViews::SetFocusable(bool focusable) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetMenu(ui::MenuModel* menu_model) {
|
||||
void NativeWindowViews::SetMenu(AtomMenuModel* menu_model) {
|
||||
if (menu_model == nullptr) {
|
||||
// Remove accelerators
|
||||
accelerator_table_.clear();
|
||||
|
@ -1188,7 +1242,7 @@ bool NativeWindowViews::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
|||
&accelerator_table_, accelerator);
|
||||
}
|
||||
|
||||
void NativeWindowViews::RegisterAccelerators(ui::MenuModel* menu_model) {
|
||||
void NativeWindowViews::RegisterAccelerators(AtomMenuModel* menu_model) {
|
||||
// Clear previous accelerators.
|
||||
views::FocusManager* focus_manager = GetFocusManager();
|
||||
accelerator_table_.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue