Commit d30e9dd0 authored by sadrul@chromium.org's avatar sadrul@chromium.org

aura: Use PlatformWindow from WindowTreeHostWin.

With this patch, both Windows and Ozone implementations use PlatformWindow for
interacting with the native windowing system. Eventually, the X11 implementations
will also use this, and WindowTreeHost will have a single implementation on all
platforms.

BUG=none
R=ben@chromium.org

Previously landed in r284850, but reverted in r284905 because it broke a multi-
window ash unit-test on Windows. The test is now disabled (r284931).

Review URL: https://codereview.chromium.org/400413002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284986 0039d316-1c4b-4281-b951-d872f2087c98
parent 26efe319
...@@ -1031,6 +1031,7 @@ ...@@ -1031,6 +1031,7 @@
'dependencies': [ 'dependencies': [
'../ipc/ipc.gyp:ipc', '../ipc/ipc.gyp:ipc',
'../ui/metro_viewer/metro_viewer.gyp:metro_viewer_messages', '../ui/metro_viewer/metro_viewer.gyp:metro_viewer_messages',
'../ui/platform_window/win/win_window.gyp:win_window',
'../win8/win8.gyp:metro_viewer', '../win8/win8.gyp:metro_viewer',
'../win8/win8.gyp:test_support_win8', '../win8/win8.gyp:test_support_win8',
'../win8/win8_tests.gyp:test_registrar', '../win8/win8_tests.gyp:test_registrar',
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
#include "ui/aura/remote_window_tree_host_win.h" #include "ui/aura/remote_window_tree_host_win.h"
#include "ui/aura/window_tree_host_win.h" #include "ui/aura/window_tree_host_win.h"
#include "ui/platform_window/win/win_window.h"
#include "win8/test/test_registrar_constants.h" #include "win8/test/test_registrar_constants.h"
#endif #endif
...@@ -123,7 +124,7 @@ void AshTestBase::SetUp() { ...@@ -123,7 +124,7 @@ void AshTestBase::SetUp() {
switches::kAshHostWindowBounds, "1+1-800x600"); switches::kAshHostWindowBounds, "1+1-800x600");
} }
#if defined(OS_WIN) #if defined(OS_WIN)
aura::test::SetUsePopupAsRootWindowForTest(true); ui::test::SetUsePopupAsRootWindowForTest(true);
#endif #endif
ash_test_helper_->SetUp(start_session_); ash_test_helper_->SetUp(start_session_);
...@@ -173,7 +174,7 @@ void AshTestBase::TearDown() { ...@@ -173,7 +174,7 @@ void AshTestBase::TearDown() {
ash_test_helper_->TearDown(); ash_test_helper_->TearDown();
#if defined(OS_WIN) #if defined(OS_WIN)
aura::test::SetUsePopupAsRootWindowForTest(false); ui::test::SetUsePopupAsRootWindowForTest(false);
// Kill the viewer process if we spun one up. // Kill the viewer process if we spun one up.
metro_viewer_host_.reset(); metro_viewer_host_.reset();
......
...@@ -81,6 +81,8 @@ class NativeViewportOzone : public NativeViewport, ...@@ -81,6 +81,8 @@ class NativeViewportOzone : public NativeViewport,
delegate_->OnAcceleratedWidgetAvailable(widget); delegate_->OnAcceleratedWidgetAvailable(widget);
} }
virtual void OnActivationChanged(bool active) OVERRIDE {}
scoped_ptr<ui::PlatformWindow> platform_window_; scoped_ptr<ui::PlatformWindow> platform_window_;
NativeViewportDelegate* delegate_; NativeViewportDelegate* delegate_;
......
...@@ -89,6 +89,8 @@ class NativeViewportWin : public NativeViewport, ...@@ -89,6 +89,8 @@ class NativeViewportWin : public NativeViewport,
delegate_->OnAcceleratedWidgetAvailable(widget); delegate_->OnAcceleratedWidgetAvailable(widget);
} }
virtual void OnActivationChanged(bool active) OVERRIDE {}
scoped_ptr<ui::PlatformWindow> platform_window_; scoped_ptr<ui::PlatformWindow> platform_window_;
NativeViewportDelegate* delegate_; NativeViewportDelegate* delegate_;
......
...@@ -102,6 +102,8 @@ class NativeViewportX11 : public NativeViewport, ...@@ -102,6 +102,8 @@ class NativeViewportX11 : public NativeViewport,
delegate_->OnAcceleratedWidgetAvailable(widget); delegate_->OnAcceleratedWidgetAvailable(widget);
} }
virtual void OnActivationChanged(bool active) OVERRIDE {}
scoped_ptr<ui::PlatformEventSource> event_source_; scoped_ptr<ui::PlatformEventSource> event_source_;
scoped_ptr<ui::PlatformWindow> platform_window_; scoped_ptr<ui::PlatformWindow> platform_window_;
NativeViewportDelegate* delegate_; NativeViewportDelegate* delegate_;
......
...@@ -124,6 +124,7 @@ ...@@ -124,6 +124,7 @@
['OS=="win"', { ['OS=="win"', {
'dependencies': [ 'dependencies': [
'../metro_viewer/metro_viewer.gyp:metro_viewer_messages', '../metro_viewer/metro_viewer.gyp:metro_viewer_messages',
'../platform_window/win/win_window.gyp:win_window',
'../../ipc/ipc.gyp:ipc', '../../ipc/ipc.gyp:ipc',
], ],
'sources!': [ 'sources!': [
......
...@@ -56,6 +56,9 @@ void WindowTreeHostOzone::OnAcceleratedWidgetAvailable( ...@@ -56,6 +56,9 @@ void WindowTreeHostOzone::OnAcceleratedWidgetAvailable(
CreateCompositor(widget_); CreateCompositor(widget_);
} }
void WindowTreeHostOzone::OnActivationChanged(bool active) {
}
ui::EventSource* WindowTreeHostOzone::GetEventSource() { ui::EventSource* WindowTreeHostOzone::GetEventSource() {
return this; return this;
} }
......
...@@ -35,6 +35,7 @@ class AURA_EXPORT WindowTreeHostOzone : public WindowTreeHost, ...@@ -35,6 +35,7 @@ class AURA_EXPORT WindowTreeHostOzone : public WindowTreeHost,
virtual void OnLostCapture() OVERRIDE; virtual void OnLostCapture() OVERRIDE;
virtual void OnAcceleratedWidgetAvailable( virtual void OnAcceleratedWidgetAvailable(
gfx::AcceleratedWidget widget) OVERRIDE; gfx::AcceleratedWidget widget) OVERRIDE;
virtual void OnActivationChanged(bool active) OVERRIDE;
// WindowTreeHost: // WindowTreeHost:
virtual ui::EventSource* GetEventSource() OVERRIDE; virtual ui::EventSource* GetEventSource() OVERRIDE;
......
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/gfx/display.h" #include "ui/gfx/display.h"
#include "ui/gfx/insets.h" #include "ui/gfx/insets.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
#include "ui/platform_window/win/win_window.h"
using std::max; using std::max;
using std::min; using std::min;
...@@ -41,18 +43,15 @@ gfx::Size WindowTreeHost::GetNativeScreenSize() { ...@@ -41,18 +43,15 @@ gfx::Size WindowTreeHost::GetNativeScreenSize() {
} }
WindowTreeHostWin::WindowTreeHostWin(const gfx::Rect& bounds) WindowTreeHostWin::WindowTreeHostWin(const gfx::Rect& bounds)
: has_capture_(false) { : has_capture_(false),
if (use_popup_as_root_window_for_test) widget_(gfx::kNullAcceleratedWidget),
set_window_style(WS_POPUP); window_(new ui::WinWindow(this, bounds)) {
Init(NULL, bounds);
SetWindowText(hwnd(), L"aura::RootWindow!");
CreateCompositor(GetAcceleratedWidget());
} }
WindowTreeHostWin::~WindowTreeHostWin() { WindowTreeHostWin::~WindowTreeHostWin() {
DestroyCompositor(); DestroyCompositor();
DestroyDispatcher(); DestroyDispatcher();
DestroyWindow(hwnd()); window_.reset();
} }
ui::EventSource* WindowTreeHostWin::GetEventSource() { ui::EventSource* WindowTreeHostWin::GetEventSource() {
...@@ -60,70 +59,39 @@ ui::EventSource* WindowTreeHostWin::GetEventSource() { ...@@ -60,70 +59,39 @@ ui::EventSource* WindowTreeHostWin::GetEventSource() {
} }
gfx::AcceleratedWidget WindowTreeHostWin::GetAcceleratedWidget() { gfx::AcceleratedWidget WindowTreeHostWin::GetAcceleratedWidget() {
return hwnd(); return widget_;
} }
void WindowTreeHostWin::Show() { void WindowTreeHostWin::Show() {
ShowWindow(hwnd(), SW_SHOWNORMAL); window_->Show();
} }
void WindowTreeHostWin::Hide() { void WindowTreeHostWin::Hide() {
NOTIMPLEMENTED(); window_->Hide();
} }
gfx::Rect WindowTreeHostWin::GetBounds() const { gfx::Rect WindowTreeHostWin::GetBounds() const {
RECT r; return window_->GetBounds();
GetClientRect(hwnd(), &r);
return gfx::Rect(r);
} }
void WindowTreeHostWin::SetBounds(const gfx::Rect& bounds) { void WindowTreeHostWin::SetBounds(const gfx::Rect& bounds) {
RECT window_rect; window_->SetBounds(bounds);
window_rect.left = bounds.x();
window_rect.top = bounds.y();
window_rect.right = bounds.right() ;
window_rect.bottom = bounds.bottom();
AdjustWindowRectEx(&window_rect,
GetWindowLong(hwnd(), GWL_STYLE),
FALSE,
GetWindowLong(hwnd(), GWL_EXSTYLE));
SetWindowPos(
hwnd(),
NULL,
window_rect.left,
window_rect.top,
window_rect.right - window_rect.left,
window_rect.bottom - window_rect.top,
SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOREPOSITION);
// Explicity call OnHostResized when the scale has changed because
// the window size may not have changed.
float current_scale = compositor()->device_scale_factor();
float new_scale = gfx::Screen::GetScreenFor(window())->
GetDisplayNearestWindow(window()).device_scale_factor();
if (current_scale != new_scale)
OnHostResized(bounds.size());
} }
gfx::Point WindowTreeHostWin::GetLocationOnNativeScreen() const { gfx::Point WindowTreeHostWin::GetLocationOnNativeScreen() const {
RECT r; return window_->GetBounds().origin();
GetClientRect(hwnd(), &r);
return gfx::Point(r.left, r.top);
} }
void WindowTreeHostWin::SetCapture() { void WindowTreeHostWin::SetCapture() {
if (!has_capture_) { if (!has_capture_) {
has_capture_ = true; has_capture_ = true;
::SetCapture(hwnd()); window_->SetCapture();
} }
} }
void WindowTreeHostWin::ReleaseCapture() { void WindowTreeHostWin::ReleaseCapture() {
if (has_capture_) { if (has_capture_)
has_capture_ = false; window_->ReleaseCapture();
::ReleaseCapture();
}
} }
void WindowTreeHostWin::SetCursorNative(gfx::NativeCursor native_cursor) { void WindowTreeHostWin::SetCursorNative(gfx::NativeCursor native_cursor) {
...@@ -146,88 +114,60 @@ void WindowTreeHostWin::OnCursorVisibilityChangedNative(bool show) { ...@@ -146,88 +114,60 @@ void WindowTreeHostWin::OnCursorVisibilityChangedNative(bool show) {
void WindowTreeHostWin::PostNativeEvent(const base::NativeEvent& native_event) { void WindowTreeHostWin::PostNativeEvent(const base::NativeEvent& native_event) {
::PostMessage( ::PostMessage(
hwnd(), native_event.message, native_event.wParam, native_event.lParam); widget_, native_event.message, native_event.wParam, native_event.lParam);
} }
ui::EventProcessor* WindowTreeHostWin::GetEventProcessor() { ui::EventProcessor* WindowTreeHostWin::GetEventProcessor() {
return dispatcher(); return dispatcher();
} }
void WindowTreeHostWin::OnClose() { void WindowTreeHostWin::OnBoundsChanged(const gfx::Rect& new_bounds) {
// TODO: this obviously shouldn't be here. gfx::Rect old_bounds = bounds_;
base::MessageLoopForUI::current()->Quit(); bounds_ = new_bounds;
if (bounds_.origin() != old_bounds.origin())
OnHostMoved(bounds_.origin());
if (bounds_.size() != old_bounds.size())
OnHostResized(bounds_.size());
} }
LRESULT WindowTreeHostWin::OnKeyEvent(UINT message, void WindowTreeHostWin::OnDamageRect(const gfx::Rect& damage_rect) {
WPARAM w_param, compositor()->ScheduleRedrawRect(damage_rect);
LPARAM l_param) {
MSG msg = { hwnd(), message, w_param, l_param };
ui::KeyEvent keyev(msg, message == WM_CHAR);
ui::EventDispatchDetails details = SendEventToProcessor(&keyev);
SetMsgHandled(keyev.handled() || details.dispatcher_destroyed);
return 0;
}
LRESULT WindowTreeHostWin::OnMouseRange(UINT message,
WPARAM w_param,
LPARAM l_param) {
MSG msg = { hwnd(), message, w_param, l_param, 0,
{ CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param) } };
ui::MouseEvent event(msg);
bool handled = false;
if (!(event.flags() & ui::EF_IS_NON_CLIENT)) {
ui::EventDispatchDetails details = SendEventToProcessor(&event);
handled = event.handled() || details.dispatcher_destroyed;
}
SetMsgHandled(handled);
return 0;
} }
LRESULT WindowTreeHostWin::OnCaptureChanged(UINT message, void WindowTreeHostWin::DispatchEvent(ui::Event* event) {
WPARAM w_param, ui::EventDispatchDetails details = SendEventToProcessor(event);
LPARAM l_param) { if (details.dispatcher_destroyed)
if (has_capture_) { event->SetHandled();
has_capture_ = false;
OnHostLostWindowCapture();
}
return 0;
} }
LRESULT WindowTreeHostWin::OnNCActivate(UINT message, void WindowTreeHostWin::OnCloseRequest() {
WPARAM w_param, // TODO: this obviously shouldn't be here.
LPARAM l_param) { base::MessageLoopForUI::current()->Quit();
if (!!w_param)
OnHostActivated();
return DefWindowProc(hwnd(), message, w_param, l_param);
} }
void WindowTreeHostWin::OnMove(const gfx::Point& point) { void WindowTreeHostWin::OnClosed() {
OnHostMoved(point);
} }
void WindowTreeHostWin::OnPaint(HDC dc) { void WindowTreeHostWin::OnWindowStateChanged(
gfx::Rect damage_rect; ui::PlatformWindowState new_state) {
RECT update_rect = {0};
if (GetUpdateRect(hwnd(), &update_rect, FALSE))
damage_rect = gfx::Rect(update_rect);
compositor()->ScheduleRedrawRect(damage_rect);
ValidateRect(hwnd(), NULL);
} }
void WindowTreeHostWin::OnSize(UINT param, const gfx::Size& size) { void WindowTreeHostWin::OnLostCapture() {
// Minimizing resizes the window to 0x0 which causes our layout to go all if (has_capture_) {
// screwy, so we just ignore it. has_capture_ = false;
if (dispatcher() && param != SIZE_MINIMIZED) OnHostLostWindowCapture();
OnHostResized(size); }
} }
namespace test { void WindowTreeHostWin::OnAcceleratedWidgetAvailable(
gfx::AcceleratedWidget widget) {
// static widget_ = widget;
void SetUsePopupAsRootWindowForTest(bool use) { CreateCompositor(widget);
use_popup_as_root_window_for_test = use;
} }
} // namespace test void WindowTreeHostWin::OnActivationChanged(bool active) {
if (active)
OnHostActivated();
}
} // namespace aura } // namespace aura
...@@ -6,19 +6,23 @@ ...@@ -6,19 +6,23 @@
#define UI_AURA_WINDOW_TREE_HOST_WIN_H_ #define UI_AURA_WINDOW_TREE_HOST_WIN_H_
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/aura_export.h" #include "ui/aura/aura_export.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/events/event_source.h" #include "ui/events/event_source.h"
#include "ui/gfx/win/window_impl.h" #include "ui/platform_window/platform_window.h"
#include "ui/platform_window/platform_window_delegate.h"
namespace aura { namespace aura {
class AURA_EXPORT WindowTreeHostWin : public WindowTreeHost, class AURA_EXPORT WindowTreeHostWin
public ui::EventSource, : public WindowTreeHost,
public gfx::WindowImpl { public ui::EventSource,
public NON_EXPORTED_BASE(ui::PlatformWindowDelegate) {
public: public:
explicit WindowTreeHostWin(const gfx::Rect& bounds); explicit WindowTreeHostWin(const gfx::Rect& bounds);
virtual ~WindowTreeHostWin(); virtual ~WindowTreeHostWin();
// WindowTreeHost: // WindowTreeHost:
virtual ui::EventSource* GetEventSource() OVERRIDE; virtual ui::EventSource* GetEventSource() OVERRIDE;
virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
...@@ -37,56 +41,30 @@ class AURA_EXPORT WindowTreeHostWin : public WindowTreeHost, ...@@ -37,56 +41,30 @@ class AURA_EXPORT WindowTreeHostWin : public WindowTreeHost,
// ui::EventSource: // ui::EventSource:
virtual ui::EventProcessor* GetEventProcessor() OVERRIDE; virtual ui::EventProcessor* GetEventProcessor() OVERRIDE;
private: protected:
CR_BEGIN_MSG_MAP_EX(WindowTreeHostWin) gfx::AcceleratedWidget hwnd() const { return widget_; }
// Range handlers must go first!
CR_MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
CR_MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE,
WM_NCXBUTTONDBLCLK,
OnMouseRange)
// Mouse capture events.
CR_MESSAGE_HANDLER_EX(WM_CAPTURECHANGED, OnCaptureChanged)
// Key events.
CR_MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyEvent)
CR_MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyEvent)
CR_MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyEvent)
CR_MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyEvent)
CR_MESSAGE_HANDLER_EX(WM_CHAR, OnKeyEvent)
CR_MESSAGE_HANDLER_EX(WM_SYSCHAR, OnKeyEvent)
CR_MESSAGE_HANDLER_EX(WM_IME_CHAR, OnKeyEvent)
CR_MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate)
CR_MSG_WM_CLOSE(OnClose)
CR_MSG_WM_MOVE(OnMove)
CR_MSG_WM_PAINT(OnPaint)
CR_MSG_WM_SIZE(OnSize)
CR_END_MSG_MAP()
void OnClose(); private:
LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param); // ui::PlatformWindowDelegate:
LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param); virtual void OnBoundsChanged(const gfx::Rect& new_bounds) OVERRIDE;
LRESULT OnCaptureChanged(UINT message, WPARAM w_param, LPARAM l_param); virtual void OnDamageRect(const gfx::Rect& damaged_region) OVERRIDE;
LRESULT OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param); virtual void DispatchEvent(ui::Event* event) OVERRIDE;
void OnMove(const gfx::Point& point); virtual void OnCloseRequest() OVERRIDE;
void OnPaint(HDC dc); virtual void OnClosed() OVERRIDE;
void OnSize(UINT param, const gfx::Size& size); virtual void OnWindowStateChanged(ui::PlatformWindowState new_state) OVERRIDE;
virtual void OnLostCapture() OVERRIDE;
virtual void OnAcceleratedWidgetAvailable(
gfx::AcceleratedWidget widget) OVERRIDE;
virtual void OnActivationChanged(bool active) OVERRIDE;
bool has_capture_; bool has_capture_;
gfx::Rect bounds_;
gfx::AcceleratedWidget widget_;
scoped_ptr<ui::PlatformWindow> window_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeHostWin); DISALLOW_COPY_AND_ASSIGN(WindowTreeHostWin);
}; };
namespace test {
// Set true to let WindowTreeHostWin use a popup window
// with no frame/title so that the window size and test's
// expectations matches.
AURA_EXPORT void SetUsePopupAsRootWindowForTest(bool use);
} // namespace
} // namespace aura } // namespace aura
#endif // UI_AURA_WINDOW_TREE_HOST_WIN_H_ #endif // UI_AURA_WINDOW_TREE_HOST_WIN_H_
...@@ -48,6 +48,7 @@ class DemoWindow : public ui::PlatformWindowDelegate { ...@@ -48,6 +48,7 @@ class DemoWindow : public ui::PlatformWindowDelegate {
CHECK_NE(widget, gfx::kNullAcceleratedWidget); CHECK_NE(widget, gfx::kNullAcceleratedWidget);
widget_ = widget; widget_ = widget;
} }
virtual void OnActivationChanged(bool active) OVERRIDE {}
private: private:
scoped_ptr<ui::PlatformWindow> platform_window_; scoped_ptr<ui::PlatformWindow> platform_window_;
......
...@@ -44,6 +44,8 @@ class PlatformWindowDelegate { ...@@ -44,6 +44,8 @@ class PlatformWindowDelegate {
virtual void OnLostCapture() = 0; virtual void OnLostCapture() = 0;
virtual void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) = 0; virtual void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) = 0;
virtual void OnActivationChanged(bool active) = 0;
}; };
} // namespace ui } // namespace ui
......
...@@ -13,6 +13,8 @@ namespace ui { ...@@ -13,6 +13,8 @@ namespace ui {
namespace { namespace {
bool use_popup_as_root_window_for_test = false;
gfx::Rect GetWindowBoundsForClientBounds(DWORD style, DWORD ex_style, gfx::Rect GetWindowBoundsForClientBounds(DWORD style, DWORD ex_style,
const gfx::Rect& bounds) { const gfx::Rect& bounds) {
RECT wr; RECT wr;
...@@ -37,6 +39,8 @@ WinWindow::WinWindow(PlatformWindowDelegate* delegate, ...@@ -37,6 +39,8 @@ WinWindow::WinWindow(PlatformWindowDelegate* delegate,
const gfx::Rect& bounds) const gfx::Rect& bounds)
: delegate_(delegate) { : delegate_(delegate) {
CHECK(delegate_); CHECK(delegate_);
if (use_popup_as_root_window_for_test)
set_window_style(WS_POPUP);
gfx::Rect window_bounds = GetWindowBoundsForClientBounds( gfx::Rect window_bounds = GetWindowBoundsForClientBounds(
WS_OVERLAPPEDWINDOW, window_ex_style(), bounds); WS_OVERLAPPEDWINDOW, window_ex_style(), bounds);
gfx::WindowImpl::Init(NULL, window_bounds); gfx::WindowImpl::Init(NULL, window_bounds);
...@@ -126,6 +130,7 @@ LRESULT WinWindow::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { ...@@ -126,6 +130,7 @@ LRESULT WinWindow::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) {
} }
LRESULT WinWindow::OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param) { LRESULT WinWindow::OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param) {
delegate_->OnActivationChanged(!!w_param);
return DefWindowProc(hwnd(), message, w_param, l_param); return DefWindowProc(hwnd(), message, w_param, l_param);
} }
...@@ -162,4 +167,12 @@ void WinWindow::OnWindowPosChanged(WINDOWPOS* window_pos) { ...@@ -162,4 +167,12 @@ void WinWindow::OnWindowPosChanged(WINDOWPOS* window_pos) {
} }
} }
namespace test {
// static
void SetUsePopupAsRootWindowForTest(bool use) {
use_popup_as_root_window_for_test = use;
}
} // namespace test
} // namespace ui } // namespace ui
...@@ -72,6 +72,15 @@ class WIN_WINDOW_EXPORT WinWindow : public NON_EXPORTED_BASE(PlatformWindow), ...@@ -72,6 +72,15 @@ class WIN_WINDOW_EXPORT WinWindow : public NON_EXPORTED_BASE(PlatformWindow),
DISALLOW_COPY_AND_ASSIGN(WinWindow); DISALLOW_COPY_AND_ASSIGN(WinWindow);
}; };
namespace test {
// Set true to let WindowTreeHostWin use a popup window
// with no frame/title so that the window size and test's
// expectations matches.
WIN_WINDOW_EXPORT void SetUsePopupAsRootWindowForTest(bool use);
} // namespace test
} // namespace ui } // namespace ui
#endif // UI_PLATFORM_WINDOW_WIN_WIN_WINDOW_H_ #endif // UI_PLATFORM_WINDOW_WIN_WIN_WINDOW_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment