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/widget/tooltip_manager_views.h" | 5 #include "views/widget/tooltip_manager_views.h" |
6 | 6 |
7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "third_party/skia/include/core/SkColor.h" | 13 #include "third_party/skia/include/core/SkColor.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/gfx/font.h" | 15 #include "ui/gfx/font.h" |
16 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
17 #include "views/background.h" | 17 #include "views/background.h" |
18 #include "views/border.h" | 18 #include "views/border.h" |
19 #include "views/focus/focus_manager.h" | 19 #include "views/focus/focus_manager.h" |
20 #include "views/view.h" | 20 #include "views/view.h" |
21 #include "views/widget/native_widget.h" | 21 #include "views/widget/native_widget.h" |
22 #include "views/widget/root_view.h" | 22 #include "views/widget/root_view.h" |
23 | 23 |
| 24 #if defined(USE_WAYLAND) |
| 25 #include "ui/wayland/events/wayland_event.h" |
| 26 #endif |
| 27 |
24 namespace { | 28 namespace { |
25 SkColor kTooltipBackground = 0xFF7F7F00; | 29 SkColor kTooltipBackground = 0xFF7F7F00; |
26 int kTooltipTimeoutMs = 500; | 30 int kTooltipTimeoutMs = 500; |
27 | 31 |
28 // FIXME: get cursor offset from actual cursor size. | 32 // FIXME: get cursor offset from actual cursor size. |
29 int kCursorOffsetX = 10; | 33 int kCursorOffsetX = 10; |
30 int kCursorOffsetY = 15; | 34 int kCursorOffsetY = 15; |
31 } | 35 } |
32 | 36 |
33 namespace views { | 37 namespace views { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 97 } |
94 | 98 |
95 void TooltipManagerViews::ShowKeyboardTooltip(View* view) { | 99 void TooltipManagerViews::ShowKeyboardTooltip(View* view) { |
96 NOTREACHED(); | 100 NOTREACHED(); |
97 } | 101 } |
98 | 102 |
99 void TooltipManagerViews::HideKeyboardTooltip() { | 103 void TooltipManagerViews::HideKeyboardTooltip() { |
100 NOTREACHED(); | 104 NOTREACHED(); |
101 } | 105 } |
102 | 106 |
| 107 #if defined(USE_WAYLAND) |
| 108 base::MessagePumpObserver::EventStatus TooltipManagerViews::WillProcessEvent( |
| 109 ui::WaylandEvent* event) { |
| 110 if (event->type == ui::WAYLAND_MOTION) { |
| 111 if (tooltip_timer_.IsRunning()) |
| 112 tooltip_timer_.Reset(); |
| 113 curr_mouse_pos_.SetPoint(event->motion.x, event->motion.y); |
| 114 |
| 115 // If tooltip is visible, we may want to hide it. If it is not, we are ok. |
| 116 if (tooltip_widget_->IsVisible()) |
| 117 UpdateIfRequired(curr_mouse_pos_.x(), curr_mouse_pos_.y(), false); |
| 118 } |
| 119 return base::MessagePumpObserver::EVENT_CONTINUE; |
| 120 } |
| 121 #else |
103 base::MessagePumpObserver::EventStatus TooltipManagerViews::WillProcessXEvent( | 122 base::MessagePumpObserver::EventStatus TooltipManagerViews::WillProcessXEvent( |
104 XEvent* xevent) { | 123 XEvent* xevent) { |
105 XGenericEventCookie* cookie = &xevent->xcookie; | 124 XGenericEventCookie* cookie = &xevent->xcookie; |
106 if (cookie->evtype == XI_Motion) { | 125 if (cookie->evtype == XI_Motion) { |
107 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(cookie->data); | 126 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(cookie->data); |
108 if (tooltip_timer_.IsRunning()) | 127 if (tooltip_timer_.IsRunning()) |
109 tooltip_timer_.Reset(); | 128 tooltip_timer_.Reset(); |
110 curr_mouse_pos_.SetPoint((int) xievent->event_x, (int) xievent->event_y); | 129 curr_mouse_pos_.SetPoint((int) xievent->event_x, (int) xievent->event_y); |
111 | 130 |
112 // If tooltip is visible, we may want to hide it. If it is not, we are ok. | 131 // If tooltip is visible, we may want to hide it. If it is not, we are ok. |
113 if (tooltip_widget_->IsVisible()) | 132 if (tooltip_widget_->IsVisible()) |
114 UpdateIfRequired(curr_mouse_pos_.x(), curr_mouse_pos_.y(), false); | 133 UpdateIfRequired(curr_mouse_pos_.x(), curr_mouse_pos_.y(), false); |
115 } | 134 } |
116 return base::MessagePumpObserver::EVENT_CONTINUE; | 135 return base::MessagePumpObserver::EVENT_CONTINUE; |
117 } | 136 } |
| 137 #endif |
118 | 138 |
119 void TooltipManagerViews::TooltipTimerFired() { | 139 void TooltipManagerViews::TooltipTimerFired() { |
120 if (tooltip_widget_->IsVisible()) { | 140 if (tooltip_widget_->IsVisible()) { |
121 UpdateIfRequired(curr_mouse_pos_.x(), curr_mouse_pos_.y(), false); | 141 UpdateIfRequired(curr_mouse_pos_.x(), curr_mouse_pos_.y(), false); |
122 } else { | 142 } else { |
123 tooltip_view_ = GetViewForTooltip(curr_mouse_pos_.x(), curr_mouse_pos_.y(), | 143 tooltip_view_ = GetViewForTooltip(curr_mouse_pos_.x(), curr_mouse_pos_.y(), |
124 false); | 144 false); |
125 Update(); | 145 Update(); |
126 } | 146 } |
127 } | 147 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 params.type = Widget::InitParams::TYPE_TOOLTIP; | 209 params.type = Widget::InitParams::TYPE_TOOLTIP; |
190 params.keep_on_top = true; | 210 params.keep_on_top = true; |
191 params.accept_events = false; | 211 params.accept_events = false; |
192 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 212 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
193 widget->Init(params); | 213 widget->Init(params); |
194 widget->SetOpacity(0x00); | 214 widget->SetOpacity(0x00); |
195 return widget; | 215 return widget; |
196 } | 216 } |
197 | 217 |
198 } // namespace views | 218 } // namespace views |
OLD | NEW |