Add a stub __cxa_demangle to disable LLVM's demangler.
[chromium-blink-merge.git] / ui / aura / window_tree_host_win.cc
blob6f879ab1cad9cd283c51e6c2524213f5480c636c
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/aura/window_tree_host_win.h"
7 #include <windows.h>
9 #include <algorithm>
11 #include "base/message_loop/message_loop.h"
12 #include "ui/aura/client/cursor_client.h"
13 #include "ui/aura/window_event_dispatcher.h"
14 #include "ui/base/cursor/cursor_loader_win.h"
15 #include "ui/base/view_prop.h"
16 #include "ui/compositor/compositor.h"
17 #include "ui/events/event.h"
18 #include "ui/gfx/display.h"
19 #include "ui/gfx/geometry/insets.h"
20 #include "ui/gfx/native_widget_types.h"
21 #include "ui/gfx/screen.h"
22 #include "ui/platform_window/win/win_window.h"
24 using std::max;
25 using std::min;
27 namespace aura {
28 namespace {
30 bool use_popup_as_root_window_for_test = false;
32 } // namespace
34 // static
35 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
36 return new WindowTreeHostWin(bounds);
39 // static
40 gfx::Size WindowTreeHost::GetNativeScreenSize() {
41 return gfx::Size(GetSystemMetrics(SM_CXSCREEN),
42 GetSystemMetrics(SM_CYSCREEN));
45 WindowTreeHostWin::WindowTreeHostWin(const gfx::Rect& bounds)
46 : has_capture_(false),
47 widget_(gfx::kNullAcceleratedWidget),
48 window_(new ui::WinWindow(this, bounds)) {
51 WindowTreeHostWin::~WindowTreeHostWin() {
52 DestroyCompositor();
53 DestroyDispatcher();
54 window_.reset();
57 ui::EventSource* WindowTreeHostWin::GetEventSource() {
58 return this;
61 gfx::AcceleratedWidget WindowTreeHostWin::GetAcceleratedWidget() {
62 return widget_;
65 void WindowTreeHostWin::ShowImpl() {
66 window_->Show();
69 void WindowTreeHostWin::HideImpl() {
70 window_->Hide();
73 gfx::Rect WindowTreeHostWin::GetBounds() const {
74 return window_->GetBounds();
77 void WindowTreeHostWin::SetBounds(const gfx::Rect& bounds) {
78 window_->SetBounds(bounds);
81 gfx::Point WindowTreeHostWin::GetLocationOnNativeScreen() const {
82 return window_->GetBounds().origin();
85 void WindowTreeHostWin::SetCapture() {
86 if (!has_capture_) {
87 has_capture_ = true;
88 window_->SetCapture();
92 void WindowTreeHostWin::ReleaseCapture() {
93 if (has_capture_)
94 window_->ReleaseCapture();
97 void WindowTreeHostWin::SetCursorNative(gfx::NativeCursor native_cursor) {
98 // Custom web cursors are handled directly.
99 if (native_cursor == ui::kCursorCustom)
100 return;
102 ui::CursorLoaderWin cursor_loader;
103 cursor_loader.SetPlatformCursor(&native_cursor);
104 ::SetCursor(native_cursor.platform());
107 void WindowTreeHostWin::MoveCursorToNative(const gfx::Point& location) {
108 // Deliberately not implemented.
111 void WindowTreeHostWin::OnCursorVisibilityChangedNative(bool show) {
112 NOTIMPLEMENTED();
115 void WindowTreeHostWin::OnBoundsChanged(const gfx::Rect& new_bounds) {
116 gfx::Rect old_bounds = bounds_;
117 bounds_ = new_bounds;
118 if (bounds_.origin() != old_bounds.origin())
119 OnHostMoved(bounds_.origin());
120 if (bounds_.size() != old_bounds.size())
121 OnHostResized(bounds_.size());
124 void WindowTreeHostWin::OnDamageRect(const gfx::Rect& damage_rect) {
125 compositor()->ScheduleRedrawRect(damage_rect);
128 void WindowTreeHostWin::DispatchEvent(ui::Event* event) {
129 ui::EventDispatchDetails details = SendEventToProcessor(event);
130 if (details.dispatcher_destroyed)
131 event->SetHandled();
134 void WindowTreeHostWin::OnCloseRequest() {
135 // TODO: this obviously shouldn't be here.
136 base::MessageLoopForUI::current()->Quit();
139 void WindowTreeHostWin::OnClosed() {
142 void WindowTreeHostWin::OnWindowStateChanged(
143 ui::PlatformWindowState new_state) {
146 void WindowTreeHostWin::OnLostCapture() {
147 if (has_capture_) {
148 has_capture_ = false;
149 OnHostLostWindowCapture();
153 void WindowTreeHostWin::OnAcceleratedWidgetAvailable(
154 gfx::AcceleratedWidget widget,
155 float device_pixel_ratio) {
156 widget_ = widget;
157 CreateCompositor(widget);
160 void WindowTreeHostWin::OnActivationChanged(bool active) {
161 if (active)
162 OnHostActivated();
165 } // namespace aura