summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 17:51:04 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 17:51:04 +0000
commit4fea07faa60c88589599bf60b33a36961be68491 (patch)
treee82d02260a590898641ffd7520cfd9e62c0c8764 /views/widget
parent97afa066c572a1f56e0e8cbf1e93e8437a201eb7 (diff)
downloadchromium_src-4fea07faa60c88589599bf60b33a36961be68491.zip
chromium_src-4fea07faa60c88589599bf60b33a36961be68491.tar.gz
chromium_src-4fea07faa60c88589599bf60b33a36961be68491.tar.bz2
Fleshes out the tooltip implementation for views on Gtk. It doesn't
support explicit positioning of the tooltip as windows does. That'll have to be added later. BUG=none TEST=make sure tooltips still work correctly on windows Review URL: http://codereview.chromium.org/197031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/tooltip_manager.cc82
-rw-r--r--views/widget/tooltip_manager.h15
-rw-r--r--views/widget/tooltip_manager_gtk.cc185
-rw-r--r--views/widget/tooltip_manager_gtk.h23
-rw-r--r--views/widget/tooltip_manager_win.cc83
-rw-r--r--views/widget/tooltip_manager_win.h10
-rw-r--r--views/widget/widget_gtk.cc24
-rw-r--r--views/widget/widget_gtk.h10
8 files changed, 329 insertions, 103 deletions
diff --git a/views/widget/tooltip_manager.cc b/views/widget/tooltip_manager.cc
new file mode 100644
index 0000000..6f159be
--- /dev/null
+++ b/views/widget/tooltip_manager.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "views/widget/tooltip_manager.h"
+
+#include <vector>
+
+#include "app/gfx/text_elider.h"
+#include "views/screen.h"
+
+namespace views {
+
+// Maximum number of characters we allow in a tooltip.
+static const size_t kMaxTooltipLength = 1024;
+
+// Maximum number of lines we allow in the tooltip.
+static const size_t kMaxLines = 6;
+
+// Breaks |text| along line boundaries, placing each line of text into lines.
+static void SplitTooltipString(const std::wstring& text,
+ std::vector<std::wstring>* lines) {
+ size_t index = 0;
+ size_t next_index;
+ while ((next_index = text.find(TooltipManager::GetLineSeparator(), index))
+ != std::wstring::npos && lines->size() < kMaxLines) {
+ lines->push_back(text.substr(index, next_index - index));
+ index = next_index + TooltipManager::GetLineSeparator().size();
+ }
+ if (next_index != text.size() && lines->size() < kMaxLines)
+ lines->push_back(text.substr(index, text.size() - index));
+}
+
+// static
+int TooltipManager::GetMaxWidth(int x, int y) {
+ gfx::Rect monitor_bounds =
+ Screen::GetMonitorAreaNearestPoint(gfx::Point(x, y));
+ // We don't want the tooltip to get too big, otherwise it looks wrong.
+ return monitor_bounds.width() == 0 ? 400 : monitor_bounds.width() / 4;
+}
+
+// static
+void TooltipManager::TrimTooltipToFit(std::wstring* text,
+ int* max_width,
+ int* line_count,
+ int x,
+ int y) {
+ *max_width = 0;
+ *line_count = 0;
+
+ // Clamp the tooltip length to kMaxTooltipLength so that we don't
+ // accidentally DOS the user with a mega tooltip.
+ if (text->length() > kMaxTooltipLength)
+ *text = text->substr(0, kMaxTooltipLength);
+
+ // Determine the available width for the tooltip.
+ int available_width = GetMaxWidth(x, y);
+
+ // Split the string.
+ std::vector<std::wstring> lines;
+ SplitTooltipString(*text, &lines);
+ *line_count = static_cast<int>(lines.size());
+
+ // Format each line to fit.
+ gfx::Font font = GetDefaultFont();
+ std::wstring result;
+ for (std::vector<std::wstring>::iterator i = lines.begin(); i != lines.end();
+ ++i) {
+ std::wstring elided_text = gfx::ElideText(*i, font, available_width);
+ *max_width = std::max(*max_width, font.GetStringWidth(elided_text));
+ if (i == lines.begin() && i + 1 == lines.end()) {
+ *text = elided_text;
+ return;
+ }
+ if (!result.empty())
+ result.append(GetLineSeparator());
+ result.append(elided_text);
+ }
+ *text = result;
+}
+
+} // namespace views
diff --git a/views/widget/tooltip_manager.h b/views/widget/tooltip_manager.h
index cb48973..48708eb 100644
--- a/views/widget/tooltip_manager.h
+++ b/views/widget/tooltip_manager.h
@@ -32,6 +32,10 @@ class TooltipManager {
// Returns the separator for lines of text in a tooltip.
static const std::wstring& GetLineSeparator();
+ // Returns the maximum width of the tooltip. |x| and |y| give the location
+ // the tooltip is to be displayed on in screen coordinates.
+ static int GetMaxWidth(int x, int y);
+
TooltipManager() {}
virtual ~TooltipManager() {}
@@ -46,6 +50,17 @@ class TooltipManager {
// Invoked when toolbar loses focus.
virtual void HideKeyboardTooltip() = 0;
+
+ protected:
+ // Trims the tooltip to fit, setting |text| to the clipped result,
+ // |max_width| to the width (in pixels) of the clipped text and |line_count|
+ // to the number of lines of text in the tooltip. |x| and |y| give the
+ // location of the tooltip in screen coordinates.
+ static void TrimTooltipToFit(std::wstring* text,
+ int* max_width,
+ int* line_count,
+ int x,
+ int y);
};
} // namespace views
diff --git a/views/widget/tooltip_manager_gtk.cc b/views/widget/tooltip_manager_gtk.cc
index 702514a..f3bcb61 100644
--- a/views/widget/tooltip_manager_gtk.cc
+++ b/views/widget/tooltip_manager_gtk.cc
@@ -6,19 +6,52 @@
#include "app/gfx/font.h"
#include "base/logging.h"
+#include "base/string_util.h"
+#include "views/focus/focus_manager.h"
+#include "views/widget/root_view.h"
+#include "views/widget/widget_gtk.h"
+
+// WARNING: this implementation is good for a start, but it doesn't give us
+// control of tooltip positioning both on mouse events and when showing from
+// keyboard. We may need to write our own to give us the control we need.
namespace views {
+static gfx::Font* LoadDefaultFont() {
+ // Create a tooltip widget and extract the font from it (we have to realize
+ // it to make sure the correct font gets set).
+ GtkWidget* window = gtk_window_new(GTK_WINDOW_POPUP);
+ gtk_widget_set_name(window, "gtk-tooltip");
+ GtkWidget* label = gtk_label_new("");
+ gtk_widget_show(label);
+
+ gtk_container_add(GTK_CONTAINER(window), label);
+ gtk_widget_realize(window);
+
+ GtkStyle* style = gtk_widget_get_style(label);
+ PangoFontDescription* pfd = style->font_desc;
+ gfx::Font* font = new gfx::Font(gfx::Font::CreateFont(pfd));
+ pango_font_description_free(pfd);
+
+ gtk_widget_destroy(window);
+
+ return font;
+}
+
// static
int TooltipManager::GetTooltipHeight() {
- NOTIMPLEMENTED();
+ // This is only used to position the tooltip, and we don't yet support
+ // positioning the tooltip, it isn't worth trying to implement this.
return 0;
}
// static
gfx::Font TooltipManager::GetDefaultFont() {
- NOTIMPLEMENTED();
- return gfx::Font();
+ static gfx::Font* font = NULL;
+ if (!font)
+ font = LoadDefaultFont();
+
+ return *font;
}
// static
@@ -29,23 +62,159 @@ const std::wstring& TooltipManager::GetLineSeparator() {
return *line_separator;
}
-TooltipManagerGtk::TooltipManagerGtk(Widget* widget) : widget_(widget) {
+// Callback from gtk_container_foreach. If |*label_p| is NULL and |widget| is
+// a GtkLabel, |*label_p| is set to |widget|. Used to find the first GtkLabel
+// in a container.
+static void LabelLocatorCallback(GtkWidget* widget,
+ gpointer label_p) {
+ GtkWidget** label = static_cast<GtkWidget**>(label_p);
+ if (!*label && GTK_IS_LABEL(widget))
+ *label = widget;
+}
+
+// By default GtkTooltip wraps at a longish string. We want more control over
+// that wrapping. The only way to do that is dig out the label and set
+// gtk_label_set_max_width_chars, which is what this code does. I also tried
+// setting a custom widget on the tooltip, but there is a bug in Gtk that
+// triggers continually hiding/showing the widget in that case.
+static void AdjustLabel(GtkTooltip* tooltip) {
+ static const char kAdjustedLabelPropertyValue[] = "_adjusted_label_";
+ gpointer adjusted_value = g_object_get_data(G_OBJECT(tooltip),
+ kAdjustedLabelPropertyValue);
+ if (adjusted_value)
+ return;
+
+ adjusted_value = reinterpret_cast<gpointer>(1);
+ g_object_set_data(G_OBJECT(tooltip), kAdjustedLabelPropertyValue,
+ adjusted_value);
+
+ GtkWidget* parent;
+ {
+ // Create a label so that we can get the parent. The Tooltip ends up taking
+ // ownership of the label and deleting it.
+ GtkWidget* label = gtk_label_new("");
+ gtk_tooltip_set_custom(tooltip, label);
+ parent = gtk_widget_get_parent(label);
+ gtk_tooltip_set_custom(tooltip, NULL);
+ }
+ if (parent) {
+ // We found the parent, find the first label, which is where the tooltip
+ // text ends up going.
+ GtkLabel* real_label = NULL;
+ gtk_container_foreach(GTK_CONTAINER(parent), LabelLocatorCallback,
+ static_cast<gpointer>(&real_label));
+ if (real_label)
+ gtk_label_set_max_width_chars(GTK_LABEL(real_label), 3000);
+ }
+}
+
+TooltipManagerGtk::TooltipManagerGtk(WidgetGtk* widget)
+ : widget_(widget),
+ keyboard_view_(NULL) {
+}
+
+bool TooltipManagerGtk::ShowTooltip(int x, int y, bool for_keyboard,
+ GtkTooltip* tooltip) {
+ View* view = NULL;
+ gfx::Point view_loc;
+ if (keyboard_view_) {
+ view = keyboard_view_;
+ view_loc.SetPoint(view->width() / 2, view->height() / 2);
+ } else if (!for_keyboard) {
+ RootView* root_view = widget_->GetRootView();
+ view = root_view->GetViewForPoint(gfx::Point(x, y));
+ view_loc.SetPoint(x, y);
+ View::ConvertPointFromWidget(view, &view_loc);
+ } else {
+ FocusManager* focus_manager = widget_->GetFocusManager();
+ if (focus_manager) {
+ view = focus_manager->GetFocusedView();
+ if (view)
+ view_loc.SetPoint(view->width() / 2, view->height() / 2);
+ }
+ }
+
+ if (!view)
+ return false;
+
+ std::wstring text;
+ if (!view->GetTooltipText(view_loc.x(), view_loc.y(), &text))
+ return false;
+
+ AdjustLabel(tooltip);
+
+ // Sets the area of the tooltip. This way if different views in the same
+ // widget have tooltips the tooltip doesn't get stuck at the same location.
+ gfx::Rect vis_bounds = view->GetVisibleBounds();
+ gfx::Point widget_loc(vis_bounds.x(), vis_bounds.y());
+ View::ConvertPointToWidget(view, &widget_loc);
+ GdkRectangle tip_area = { widget_loc.x(), widget_loc.y(),
+ vis_bounds.width(), vis_bounds.height() };
+ gtk_tooltip_set_tip_area(tooltip, &tip_area);
+
+ int max_width, line_count;
+ gfx::Point screen_loc(x, y);
+ View::ConvertPointToScreen(widget_->GetRootView(), &screen_loc);
+ TrimTooltipToFit(&text, &max_width, &line_count, screen_loc.x(),
+ screen_loc.y());
+ gtk_tooltip_set_text(tooltip, WideToUTF8(text).c_str());
+
+ return true;
}
void TooltipManagerGtk::UpdateTooltip() {
- NOTIMPLEMENTED();
+ // UpdateTooltip may be invoked after the widget has been destroyed.
+ GtkWidget* widget = widget_->GetNativeView();
+ if (!widget)
+ return;
+
+ GdkDisplay* display = gtk_widget_get_display(widget);
+ if (display)
+ gtk_tooltip_trigger_tooltip_query(display);
}
void TooltipManagerGtk::TooltipTextChanged(View* view) {
- NOTIMPLEMENTED();
+ UpdateTooltip();
}
void TooltipManagerGtk::ShowKeyboardTooltip(View* view) {
- NOTIMPLEMENTED();
+ if (view == keyboard_view_)
+ return; // We're already showing the tip for the specified view.
+
+ // We have to hide the current tooltip, then show again.
+ HideKeyboardTooltip();
+
+ std::wstring tooltip_text;
+ if (!view->GetTooltipText(0, 0, &tooltip_text))
+ return; // The view doesn't have a tooltip, nothing to do.
+
+ keyboard_view_ = view;
+ if (!SendShowHelpSignal()) {
+ keyboard_view_ = NULL;
+ return;
+ }
}
void TooltipManagerGtk::HideKeyboardTooltip() {
- NOTIMPLEMENTED();
+ if (!keyboard_view_)
+ return;
+
+ SendShowHelpSignal();
+ keyboard_view_ = NULL;
+}
+
+bool TooltipManagerGtk::SendShowHelpSignal() {
+ GtkWidget* widget = widget_->window_contents();
+ GType itype = G_TYPE_FROM_INSTANCE(G_OBJECT(widget));
+ guint signal_id;
+ GQuark detail;
+ if (!g_signal_parse_name("show_help", itype, &signal_id, &detail, FALSE)) {
+ NOTREACHED();
+ return false;
+ }
+ gboolean result;
+ g_signal_emit(widget, signal_id, 0, GTK_WIDGET_HELP_TOOLTIP, &result);
+ return true;
}
} // namespace views
diff --git a/views/widget/tooltip_manager_gtk.h b/views/widget/tooltip_manager_gtk.h
index 447f6ce..ca690ab 100644
--- a/views/widget/tooltip_manager_gtk.h
+++ b/views/widget/tooltip_manager_gtk.h
@@ -7,18 +7,22 @@
#include "views/widget/tooltip_manager.h"
+#include <gtk/gtk.h>
+
namespace views {
-class Widget;
+class WidgetGtk;
-// TooltipManager takes care of the wiring to support tooltips for Views. You
-// almost never need to interact directly with TooltipManager, rather look to
-// the various tooltip methods on View.
+// TooltipManager implementation for Gtk.
class TooltipManagerGtk : public TooltipManager {
public:
- explicit TooltipManagerGtk(Widget* widget);
+ explicit TooltipManagerGtk(WidgetGtk* widget);
virtual ~TooltipManagerGtk() {}
+ // Shows the tooltip at the specified location. Returns true if the tooltip
+ // should be shown, false otherwise.
+ bool ShowTooltip(int x, int y, bool for_keyboard, GtkTooltip* gtk_tooltip);
+
// TooltipManager.
virtual void UpdateTooltip();
virtual void TooltipTextChanged(View* view);
@@ -26,8 +30,15 @@ class TooltipManagerGtk : public TooltipManager {
virtual void HideKeyboardTooltip();
private:
+ // Sends the show_help signal to widget_. This signal triggers showing the
+ // keyboard tooltip if it isn't showing, or hides it if it is showing.
+ bool SendShowHelpSignal();
+
// Our owner.
- Widget* widget_;
+ WidgetGtk* widget_;
+
+ // The view supplied to the last invocation of ShowKeyboardTooltip.
+ View* keyboard_view_;
DISALLOW_COPY_AND_ASSIGN(TooltipManagerGtk);
};
diff --git a/views/widget/tooltip_manager_win.cc b/views/widget/tooltip_manager_win.cc
index 3c20da0..fed6c02 100644
--- a/views/widget/tooltip_manager_win.cc
+++ b/views/widget/tooltip_manager_win.cc
@@ -7,7 +7,7 @@
#include <windowsx.h>
#include <limits>
-#include "app/gfx/text_elider.h"
+#include "app/gfx/font.h"
#include "app/l10n_util.h"
#include "app/l10n_util_win.h"
#include "app/win_util.h"
@@ -25,26 +25,6 @@ static int tooltip_height_ = 0;
// Timeout is mentioned in milliseconds.
static const int kDefaultTimeout = 4000;
-// Maximum number of lines we allow in the tooltip.
-static const int kMaxLines = 6;
-
-// Maximum number of characters we allow in a tooltip.
-static const int kMaxTooltipLength = 1024;
-
-// Breaks |text| along line boundaries, placing each line of text into lines.
-static void SplitTooltipString(const std::wstring& text,
- std::vector<std::wstring>* lines) {
- size_t index = 0;
- size_t next_index;
- while ((next_index = text.find(TooltipManagerWin::GetLineSeparator(), index))
- != std::wstring::npos && lines->size() < kMaxLines) {
- lines->push_back(text.substr(index, next_index - index));
- index = next_index + TooltipManagerWin::GetLineSeparator().size();
- }
- if (next_index != text.size() && lines->size() < kMaxLines)
- lines->push_back(text.substr(index, text.size() - index));
-}
-
// static
int TooltipManager::GetTooltipHeight() {
DCHECK(tooltip_height_ > 0);
@@ -181,8 +161,10 @@ LRESULT TooltipManagerWin::OnNotify(int w_param,
!tooltip_text_.empty()) {
// View has a valid tip, copy it into TOOLTIPINFO.
clipped_text_ = tooltip_text_;
+ gfx::Point screen_loc(last_mouse_x_, last_mouse_y_);
+ View::ConvertPointToScreen(widget_->GetRootView(), &screen_loc);
TrimTooltipToFit(&clipped_text_, &tooltip_width_, &line_count_,
- last_mouse_x_, last_mouse_y_, tooltip_hwnd_);
+ screen_loc.x(), screen_loc.y());
// Adjust the clipped tooltip text for locale direction.
l10n_util::AdjustStringForLocaleDirection(clipped_text_,
&clipped_text_);
@@ -279,58 +261,6 @@ int TooltipManagerWin::CalcTooltipHeight() {
return height + tooltip_margin.top + tooltip_margin.bottom;
}
-void TooltipManagerWin::TrimTooltipToFit(std::wstring* text,
- int* max_width,
- int* line_count,
- int position_x,
- int position_y,
- HWND window) {
- *max_width = 0;
- *line_count = 0;
-
- // Clamp the tooltip length to kMaxTooltipLength so that we don't
- // accidentally DOS the user with a mega tooltip (since Windows doesn't seem
- // to do this itself).
- if (text->length() > kMaxTooltipLength)
- *text = text->substr(0, kMaxTooltipLength);
-
- // Determine the available width for the tooltip.
- gfx::Point screen_loc(position_x, position_y);
- View::ConvertPointToScreen(widget_->GetRootView(), &screen_loc);
- gfx::Rect monitor_bounds =
- win_util::GetMonitorBoundsForRect(gfx::Rect(screen_loc.x(),
- screen_loc.y(),
- 0, 0));
- RECT tooltip_margin;
- SendMessage(window, TTM_GETMARGIN, 0, (LPARAM)&tooltip_margin);
- const int available_width = monitor_bounds.width() - tooltip_margin.left -
- tooltip_margin.right;
- if (available_width <= 0)
- return;
-
- // Split the string.
- std::vector<std::wstring> lines;
- SplitTooltipString(*text, &lines);
- *line_count = static_cast<int>(lines.size());
-
- // Format each line to fit.
- gfx::Font font = GetDefaultFont();
- std::wstring result;
- for (std::vector<std::wstring>::iterator i = lines.begin(); i != lines.end();
- ++i) {
- std::wstring elided_text = gfx::ElideText(*i, font, available_width);
- *max_width = std::max(*max_width, font.GetStringWidth(elided_text));
- if (i == lines.begin() && i + 1 == lines.end()) {
- *text = elided_text;
- return;
- }
- if (!result.empty())
- result.append(GetLineSeparator());
- result.append(elided_text);
- }
- *text = result;
-}
-
void TooltipManagerWin::UpdateTooltip(int x, int y) {
RootView* root_view = widget_->GetRootView();
View* view = root_view->GetViewForPoint(gfx::Point(x, y));
@@ -397,8 +327,6 @@ void TooltipManagerWin::ShowKeyboardTooltip(View* focused_view) {
gfx::Rect focused_bounds = focused_view->bounds();
gfx::Point screen_point;
focused_view->ConvertPointToScreen(focused_view, &screen_point);
- gfx::Point relative_point_coordinates;
- focused_view->ConvertPointToWidget(focused_view, &relative_point_coordinates);
keyboard_tooltip_hwnd_ = CreateWindowEx(
WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(),
TOOLTIPS_CLASS, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
@@ -407,8 +335,7 @@ void TooltipManagerWin::ShowKeyboardTooltip(View* focused_view) {
int tooltip_width;
int line_count;
TrimTooltipToFit(&tooltip_text, &tooltip_width, &line_count,
- relative_point_coordinates.x(),
- relative_point_coordinates.y(), keyboard_tooltip_hwnd_);
+ screen_point.x(), screen_point.y());
TOOLINFO keyboard_toolinfo;
memset(&keyboard_toolinfo, 0, sizeof(keyboard_toolinfo));
keyboard_toolinfo.cbSize = sizeof(keyboard_toolinfo);
diff --git a/views/widget/tooltip_manager_win.h b/views/widget/tooltip_manager_win.h
index b2213c3..7b8f467 100644
--- a/views/widget/tooltip_manager_win.h
+++ b/views/widget/tooltip_manager_win.h
@@ -108,16 +108,6 @@ class TooltipManagerWin : public TooltipManager {
// positive value.
int CalcTooltipHeight();
- // Trims the tooltip to fit, setting text to the clipped result, width to the
- // width (in pixels) of the clipped text and line_count to the number of lines
- // of text in the tooltip.
- void TrimTooltipToFit(std::wstring* text,
- int* width,
- int* line_count,
- int position_x,
- int position_y,
- HWND window);
-
// Invoked when the timer elapses and tooltip has to be destroyed.
void DestroyKeyboardTooltipWindow(HWND window_to_destroy);
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 4f24498..89561cd 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -287,6 +287,11 @@ void WidgetGtk::Init(GtkWidget* parent,
tooltip_manager_.reset(new TooltipManagerGtk(this));
+ // Register for tooltips.
+ g_object_set(G_OBJECT(window_contents_), "has-tooltip", TRUE, NULL);
+ g_signal_connect(G_OBJECT(window_contents_), "query_tooltip",
+ G_CALLBACK(CallQueryTooltip), this);
+
if (type_ == TYPE_CHILD) {
if (parent) {
WidgetGtk* parent_widget = GetViewForNative(parent);
@@ -678,7 +683,7 @@ gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) {
last_mouse_event_was_move_ = false;
if (!has_capture_ && !is_mouse_down_)
root_view_->ProcessOnMouseExited();
- return true;
+ return false;
}
gboolean WidgetGtk::OnKeyPress(GtkWidget* widget, GdkEventKey* event) {
@@ -691,6 +696,13 @@ gboolean WidgetGtk::OnKeyRelease(GtkWidget* widget, GdkEventKey* event) {
return root_view_->ProcessKeyEvent(key_event);
}
+gboolean WidgetGtk::OnQueryTooltip(gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip* tooltip) {
+ return tooltip_manager_->ShowTooltip(x, y, keyboard_mode, tooltip);
+}
+
gboolean WidgetGtk::OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) {
HandleGrabBroke();
return false; // To let other widgets get the event.
@@ -982,6 +994,16 @@ gboolean WidgetGtk::CallKeyRelease(GtkWidget* widget, GdkEventKey* event) {
return widget_gtk->OnKeyRelease(widget, event);
}
+// static
+gboolean WidgetGtk::CallQueryTooltip(GtkWidget* widget,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip* tooltip,
+ WidgetGtk* host) {
+ return host->OnQueryTooltip(x, y, keyboard_mode, tooltip);
+}
+
gboolean WidgetGtk::CallScroll(GtkWidget* widget, GdkEventScroll* event) {
WidgetGtk* widget_gtk = GetViewForNative(widget);
if (!widget_gtk)
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index 7a3738a..eedb1f7 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -155,6 +155,10 @@ class WidgetGtk : public Widget, public MessageLoopForUI::Observer {
virtual gboolean OnFocusOut(GtkWidget* widget, GdkEventFocus* event);
virtual gboolean OnKeyPress(GtkWidget* widget, GdkEventKey* event);
virtual gboolean OnKeyRelease(GtkWidget* widget, GdkEventKey* event);
+ virtual gboolean OnQueryTooltip(gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip* tooltip);
virtual gboolean OnScroll(GtkWidget* widget, GdkEventScroll* event) {
return false;
}
@@ -258,6 +262,12 @@ class WidgetGtk : public Widget, public MessageLoopForUI::Observer {
static gboolean CallFocusOut(GtkWidget* widget, GdkEventFocus* event);
static gboolean CallKeyPress(GtkWidget* widget, GdkEventKey* event);
static gboolean CallKeyRelease(GtkWidget* widget, GdkEventKey* event);
+ static gboolean CallQueryTooltip(GtkWidget* widget,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip* tooltip,
+ WidgetGtk* host);
static gboolean CallScroll(GtkWidget* widget, GdkEventScroll* event);
static gboolean CallVisibilityNotify(GtkWidget* widget,
GdkEventVisibility* event);