| 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 "views/controls/menu/menu_host_gtk.h" | 5 #include "views/controls/menu/menu_host_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 | 8 |
| 9 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) | 9 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) |
| 10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
| 11 #include <X11/extensions/XInput2.h> | 11 #include <X11/extensions/XInput2.h> |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #include "views/controls/menu/native_menu_host_delegate.h" | 14 #include "views/controls/menu/native_menu_host_delegate.h" |
| 15 | 15 |
| 16 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) | 16 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) |
| 17 #include "views/touchui/touch_factory.h" | 17 #include "views/touchui/touch_factory.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 namespace views { | 20 namespace views { |
| 21 | 21 |
| 22 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
| 23 // MenuHostGtk, public: | 23 // MenuHostGtk, public: |
| 24 | 24 |
| 25 MenuHostGtk::MenuHostGtk(internal::NativeMenuHostDelegate* delegate) | 25 MenuHostGtk::MenuHostGtk(internal::NativeMenuHostDelegate* delegate) |
| 26 : did_input_grab_(false), | 26 : WidgetGtk(delegate->AsNativeWidgetDelegate()), |
| 27 did_input_grab_(false), |
| 27 delegate_(delegate) { | 28 delegate_(delegate) { |
| 28 } | 29 } |
| 29 | 30 |
| 30 MenuHostGtk::~MenuHostGtk() { | 31 MenuHostGtk::~MenuHostGtk() { |
| 31 } | 32 } |
| 32 | 33 |
| 33 //////////////////////////////////////////////////////////////////////////////// | 34 //////////////////////////////////////////////////////////////////////////////// |
| 34 // MenuHostGtk, NativeMenuHost implementation: | 35 // MenuHostGtk, NativeMenuHost implementation: |
| 35 | 36 |
| 36 void MenuHostGtk::StartCapturing() { | 37 void MenuHostGtk::StartCapturing() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 76 } |
| 76 | 77 |
| 77 NativeWidget* MenuHostGtk::AsNativeWidget() { | 78 NativeWidget* MenuHostGtk::AsNativeWidget() { |
| 78 return this; | 79 return this; |
| 79 } | 80 } |
| 80 | 81 |
| 81 //////////////////////////////////////////////////////////////////////////////// | 82 //////////////////////////////////////////////////////////////////////////////// |
| 82 // MenuHostGtk, WidgetGtk overrides: | 83 // MenuHostGtk, WidgetGtk overrides: |
| 83 | 84 |
| 84 void MenuHostGtk::InitNativeWidget(const Widget::InitParams& params) { | 85 void MenuHostGtk::InitNativeWidget(const Widget::InitParams& params) { |
| 85 make_transient_to_parent(); | |
| 86 WidgetGtk::InitNativeWidget(params); | 86 WidgetGtk::InitNativeWidget(params); |
| 87 // Make sure we get destroyed when the parent is destroyed. | 87 // Make sure we get destroyed when the parent is destroyed. |
| 88 gtk_window_set_destroy_with_parent(GTK_WINDOW(GetNativeView()), TRUE); | 88 gtk_window_set_destroy_with_parent(GTK_WINDOW(GetNativeView()), TRUE); |
| 89 gtk_window_set_type_hint(GTK_WINDOW(GetNativeView()), | 89 gtk_window_set_type_hint(GTK_WINDOW(GetNativeView()), |
| 90 GDK_WINDOW_TYPE_HINT_MENU); | 90 GDK_WINDOW_TYPE_HINT_MENU); |
| 91 } | 91 } |
| 92 | 92 |
| 93 // TODO(beng): remove once MenuHost is-a Widget | |
| 94 RootView* MenuHostGtk::CreateRootView() { | |
| 95 return delegate_->CreateRootView(); | |
| 96 } | |
| 97 | |
| 98 bool MenuHostGtk::ShouldReleaseCaptureOnMouseReleased() const { | |
| 99 return delegate_->ShouldReleaseCaptureOnMouseRelease(); | |
| 100 } | |
| 101 | |
| 102 void MenuHostGtk::ReleaseMouseCapture() { | 93 void MenuHostGtk::ReleaseMouseCapture() { |
| 103 WidgetGtk::ReleaseMouseCapture(); | 94 WidgetGtk::ReleaseMouseCapture(); |
| 104 if (did_input_grab_) { | 95 if (did_input_grab_) { |
| 105 did_input_grab_ = false; | 96 did_input_grab_ = false; |
| 106 gdk_pointer_ungrab(GDK_CURRENT_TIME); | 97 gdk_pointer_ungrab(GDK_CURRENT_TIME); |
| 107 gdk_keyboard_ungrab(GDK_CURRENT_TIME); | 98 gdk_keyboard_ungrab(GDK_CURRENT_TIME); |
| 108 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) | 99 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) |
| 109 TouchFactory::GetInstance()->UngrabTouchDevices( | 100 TouchFactory::GetInstance()->UngrabTouchDevices( |
| 110 GDK_WINDOW_XDISPLAY(window_contents()->window)); | 101 GDK_WINDOW_XDISPLAY(window_contents()->window)); |
| 111 #endif | 102 #endif |
| (...skipping 26 matching lines...) Expand all Loading... |
| 138 //////////////////////////////////////////////////////////////////////////////// | 129 //////////////////////////////////////////////////////////////////////////////// |
| 139 // NativeMenuHost, public: | 130 // NativeMenuHost, public: |
| 140 | 131 |
| 141 // static | 132 // static |
| 142 NativeMenuHost* NativeMenuHost::CreateNativeMenuHost( | 133 NativeMenuHost* NativeMenuHost::CreateNativeMenuHost( |
| 143 internal::NativeMenuHostDelegate* delegate) { | 134 internal::NativeMenuHostDelegate* delegate) { |
| 144 return new MenuHostGtk(delegate); | 135 return new MenuHostGtk(delegate); |
| 145 } | 136 } |
| 146 | 137 |
| 147 } // namespace views | 138 } // namespace views |
| OLD | NEW |