OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/widget/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "ui/aura/client/activation_client.h" | 9 #include "ui/aura/client/activation_client.h" |
10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
11 #include "ui/aura/client/drag_drop_client.h" | 11 #include "ui/aura/client/drag_drop_client.h" |
12 #include "ui/aura/client/shadow_types.h" | 12 #include "ui/aura/client/shadow_types.h" |
13 #include "ui/aura/event.h" | 13 #include "ui/aura/event.h" |
14 #include "ui/aura/root_window.h" | 14 #include "ui/aura/root_window.h" |
15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
16 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
17 #include "ui/aura/window_types.h" | 17 #include "ui/aura/window_types.h" |
18 #include "ui/base/dragdrop/os_exchange_data.h" | 18 #include "ui/base/dragdrop/os_exchange_data.h" |
19 #include "ui/base/ui_base_types.h" | 19 #include "ui/base/ui_base_types.h" |
20 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
21 #include "ui/gfx/compositor/layer.h" | 21 #include "ui/gfx/compositor/layer.h" |
22 #include "ui/gfx/font.h" | 22 #include "ui/gfx/font.h" |
23 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
| 24 #include "ui/views/ime/input_method_bridge.h" |
24 #include "ui/views/widget/drop_helper.h" | 25 #include "ui/views/widget/drop_helper.h" |
25 #include "ui/views/widget/native_widget_delegate.h" | 26 #include "ui/views/widget/native_widget_delegate.h" |
26 #include "ui/views/widget/tooltip_manager_aura.h" | 27 #include "ui/views/widget/tooltip_manager_aura.h" |
27 #include "ui/views/widget/widget_delegate.h" | 28 #include "ui/views/widget/widget_delegate.h" |
28 | 29 |
29 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
30 #include "base/win/scoped_gdi_object.h" | 31 #include "base/win/scoped_gdi_object.h" |
31 #include "base/win/win_util.h" | 32 #include "base/win/win_util.h" |
32 #include "ui/base/l10n/l10n_util_win.h" | 33 #include "ui/base/l10n/l10n_util_win.h" |
33 #endif | 34 #endif |
34 | 35 |
35 #if defined(HAVE_IBUS) | |
36 #include "ui/views/ime/input_method_ibus.h" | |
37 #else | |
38 #include "ui/views/ime/mock_input_method.h" | |
39 #endif | |
40 | |
41 namespace views { | 36 namespace views { |
42 | 37 |
43 namespace { | 38 namespace { |
44 | 39 |
45 aura::WindowType GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) { | 40 aura::WindowType GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) { |
46 switch (type) { | 41 switch (type) { |
47 case Widget::InitParams::TYPE_WINDOW: | 42 case Widget::InitParams::TYPE_WINDOW: |
48 return aura::WINDOW_TYPE_NORMAL; | 43 return aura::WINDOW_TYPE_NORMAL; |
49 case Widget::InitParams::TYPE_WINDOW_FRAMELESS: | 44 case Widget::InitParams::TYPE_WINDOW_FRAMELESS: |
50 case Widget::InitParams::TYPE_CONTROL: | 45 case Widget::InitParams::TYPE_CONTROL: |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 288 |
294 void NativeWidgetAura::ReleaseMouseCapture() { | 289 void NativeWidgetAura::ReleaseMouseCapture() { |
295 window_->ReleaseCapture(); | 290 window_->ReleaseCapture(); |
296 } | 291 } |
297 | 292 |
298 bool NativeWidgetAura::HasMouseCapture() const { | 293 bool NativeWidgetAura::HasMouseCapture() const { |
299 return window_->HasCapture(); | 294 return window_->HasCapture(); |
300 } | 295 } |
301 | 296 |
302 InputMethod* NativeWidgetAura::CreateInputMethod() { | 297 InputMethod* NativeWidgetAura::CreateInputMethod() { |
303 #if defined(HAVE_IBUS) | 298 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
304 InputMethod* input_method = new InputMethodIBus(this); | 299 ui::InputMethod* host = reinterpret_cast<ui::InputMethod*>( |
305 #else | 300 root_window->GetProperty(aura::kRootWindowInputMethod)); |
306 InputMethod* input_method = new MockInputMethod(this); | 301 InputMethod* input_method = new InputMethodBridge(this, host); |
307 #endif | |
308 input_method->Init(GetWidget()); | 302 input_method->Init(GetWidget()); |
309 return input_method; | 303 return input_method; |
310 } | 304 } |
311 | 305 |
312 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { | 306 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
313 const gfx::Rect parent_bounds = window_->parent()->bounds(); | 307 const gfx::Rect parent_bounds = window_->parent()->bounds(); |
314 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, | 308 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, |
315 (parent_bounds.height() - size.height())/2, | 309 (parent_bounds.height() - size.height())/2, |
316 size.width(), | 310 size.width(), |
317 size.height())); | 311 size.height())); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 void NativeWidgetAura::OnBlur() { | 615 void NativeWidgetAura::OnBlur() { |
622 Widget* widget = GetWidget(); | 616 Widget* widget = GetWidget(); |
623 if (widget->is_top_level()) { | 617 if (widget->is_top_level()) { |
624 InputMethod* input_method = widget->GetInputMethod(); | 618 InputMethod* input_method = widget->GetInputMethod(); |
625 input_method->OnBlur(); | 619 input_method->OnBlur(); |
626 } | 620 } |
627 delegate_->OnNativeBlur(NULL); | 621 delegate_->OnNativeBlur(NULL); |
628 } | 622 } |
629 | 623 |
630 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { | 624 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { |
631 // TODO(beng): Need an InputMethodAura to properly handle character events. | 625 // TODO(yusukes): Need an ui::InputMethod to properly handle character events. |
632 // Right now, we just skip these. | 626 // Right now, we just skip these. |
633 if (event->is_char()) | 627 if (event->is_char()) |
634 return false; | 628 return false; |
635 | 629 |
636 DCHECK(window_->IsVisible()); | 630 DCHECK(window_->IsVisible()); |
637 InputMethod* input_method = GetWidget()->GetInputMethod(); | 631 InputMethod* input_method = GetWidget()->GetInputMethod(); |
638 DCHECK(input_method); | 632 DCHECK(input_method); |
639 // TODO(oshima): DispatchKeyEvent should return bool? | |
640 KeyEvent views_event(event); | 633 KeyEvent views_event(event); |
641 input_method->DispatchKeyEvent(views_event); | 634 input_method->DispatchKeyEvent(views_event); |
642 return true; | 635 return true; |
643 } | 636 } |
644 | 637 |
645 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { | 638 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { |
646 return cursor_; | 639 return cursor_; |
647 } | 640 } |
648 | 641 |
649 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { | 642 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 } | 846 } |
854 } | 847 } |
855 | 848 |
856 // static | 849 // static |
857 bool NativeWidgetPrivate::IsMouseButtonDown() { | 850 bool NativeWidgetPrivate::IsMouseButtonDown() { |
858 return aura::RootWindow::GetInstance()->IsMouseButtonDown(); | 851 return aura::RootWindow::GetInstance()->IsMouseButtonDown(); |
859 } | 852 } |
860 | 853 |
861 } // namespace internal | 854 } // namespace internal |
862 } // namespace views | 855 } // namespace views |
OLD | NEW |