Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6856)

Unified Diff: chrome/browser/renderer_host/render_widget_host_view_gtk.cc

Issue 113987: Linux: Fake a mouse move event when the render view gains focus and the mouse... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: make WebMouseEvent directly Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/render_widget_host_view_gtk.cc
===================================================================
--- chrome/browser/renderer_host/render_widget_host_view_gtk.cc (revision 17106)
+++ chrome/browser/renderer_host/render_widget_host_view_gtk.cc (working copy)
@@ -15,6 +15,7 @@
#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/task.h"
+#include "base/time.h"
#include "chrome/common/native_web_keyboard_event.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/x11_util.h"
@@ -113,6 +114,26 @@
static gboolean OnFocusIn(GtkWidget* widget, GdkEventFocus* focus,
RenderWidgetHostViewGtk* host_view) {
+ int x, y;
+ gtk_widget_get_pointer(widget, &x, &y);
+ // If the cursor is in the render view, fake a mouse move event so that
+ // webkit updates its state. Otherwise webkit might think the cursor is
+ // somewhere it's not.
+ if (x >= 0 && y >= 0 && x < widget->allocation.width &&
+ y < widget->allocation.height) {
+ WebKit::WebMouseEvent fake_event;
+ fake_event.timeStampSeconds = base::Time::Now().ToDoubleT();
+ fake_event.modifiers = 0;
+ fake_event.windowX = fake_event.x = x;
+ fake_event.windowY = fake_event.y = y;
+ gdk_window_get_origin(widget->window, &x, &y);
+ fake_event.globalX = fake_event.x + x;
+ fake_event.globalY = fake_event.y + y;
+ fake_event.type = WebKit::WebInputEvent::MouseMove;
+ fake_event.button = WebKit::WebMouseEvent::ButtonNone;
+ host_view->GetRenderWidgetHost()->ForwardMouseEvent(fake_event);
+ }
+
host_view->ShowCurrentCursor();
host_view->GetRenderWidgetHost()->Focus();
return FALSE;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698