OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "chrome/browser/views/dropdown_bar_host.h" | 5 #include "chrome/browser/views/dropdown_bar_host.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include "chrome/browser/tab_contents/tab_contents.h" | 9 #include "chrome/browser/tab_contents/tab_contents.h" |
10 #include "chrome/browser/views/frame/browser_view.h" | 10 #include "chrome/browser/views/frame/browser_view.h" |
11 #include "views/widget/widget_gtk.h" | 11 #include "views/widget/widget_gtk.h" |
12 #include "views/controls/textfield/textfield.h" | 12 #include "views/controls/textfield/textfield.h" |
13 | 13 |
| 14 #if defined(TOUCH_UI) |
| 15 #include "app/keyboard_code_conversion_gtk.h" |
| 16 #endif |
| 17 |
14 views::Widget* DropdownBarHost::CreateHost() { | 18 views::Widget* DropdownBarHost::CreateHost() { |
15 views::WidgetGtk* host = new views::WidgetGtk(views::WidgetGtk::TYPE_CHILD); | 19 views::WidgetGtk* host = new views::WidgetGtk(views::WidgetGtk::TYPE_CHILD); |
16 // We own the host. | 20 // We own the host. |
17 host->set_delete_on_destroy(false); | 21 host->set_delete_on_destroy(false); |
18 return host; | 22 return host; |
19 } | 23 } |
20 | 24 |
21 void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos, | 25 void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos, |
22 bool no_redraw) { | 26 bool no_redraw) { |
23 host_->SetBounds(new_pos); | 27 host_->SetBounds(new_pos); |
24 host_->Show(); | 28 host_->Show(); |
25 } | 29 } |
26 | 30 |
27 NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent( | 31 NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent( |
28 const TabContents* contents, | 32 const TabContents* contents, |
29 const views::Textfield::Keystroke& key_stroke) { | 33 const views::Textfield::Keystroke& key_stroke) { |
| 34 #if defined(TOUCH_UI) |
| 35 // TODO(oshima): This is a copy from |
| 36 // RenderWidgetHostViewViews::OnKeyPressed(). |
| 37 // Refactor and eliminate the dup code. |
| 38 const views::KeyEvent& e = key_stroke.key_event(); |
| 39 NativeWebKeyboardEvent wke; |
| 40 wke.type = WebKit::WebInputEvent::KeyDown; |
| 41 wke.windowsKeyCode = e.GetKeyCode(); |
| 42 wke.setKeyIdentifierFromWindowsKeyCode(); |
| 43 |
| 44 wke.text[0] = wke.unmodifiedText[0] = |
| 45 static_cast<unsigned short>(gdk_keyval_to_unicode( |
| 46 app::GdkKeyCodeForWindowsKeyCode(e.GetKeyCode(), |
| 47 e.IsShiftDown() ^ e.IsCapsLockDown()))); |
| 48 return wke; |
| 49 #else |
30 return NativeWebKeyboardEvent(key_stroke.event()); | 50 return NativeWebKeyboardEvent(key_stroke.event()); |
| 51 #endif |
31 } | 52 } |
OLD | NEW |