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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/renderer_host/render_widget_host_view_gtk.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <gdk/gdk.h> 8 #include <gdk/gdk.h>
9 #include <gdk/gdkkeysyms.h> 9 #include <gdk/gdkkeysyms.h>
10 #include <gdk/gdkx.h> 10 #include <gdk/gdkx.h>
11 #include <cairo/cairo.h> 11 #include <cairo/cairo.h>
12 12
13 #include "base/gfx/gtk_util.h" 13 #include "base/gfx/gtk_util.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/task.h" 17 #include "base/task.h"
18 #include "base/time.h"
18 #include "chrome/common/native_web_keyboard_event.h" 19 #include "chrome/common/native_web_keyboard_event.h"
19 #include "chrome/common/render_messages.h" 20 #include "chrome/common/render_messages.h"
20 #include "chrome/common/x11_util.h" 21 #include "chrome/common/x11_util.h"
21 #include "chrome/browser/renderer_host/backing_store.h" 22 #include "chrome/browser/renderer_host/backing_store.h"
22 #include "chrome/browser/renderer_host/render_widget_host.h" 23 #include "chrome/browser/renderer_host/render_widget_host.h"
23 #include "webkit/api/public/gtk/WebInputEventFactory.h" 24 #include "webkit/api/public/gtk/WebInputEventFactory.h"
24 #include "webkit/glue/webcursor_gtk_data.h" 25 #include "webkit/glue/webcursor_gtk_data.h"
25 26
26 using WebKit::WebInputEventFactory; 27 using WebKit::WebInputEventFactory;
27 28
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 host_view->GetRenderWidgetHost()->ForwardKeyboardEvent(wke); 107 host_view->GetRenderWidgetHost()->ForwardKeyboardEvent(wke);
107 } 108 }
108 // We return TRUE because we did handle the event. If it turns out webkit 109 // We return TRUE because we did handle the event. If it turns out webkit
109 // can't handle the event, we'll deal with it in 110 // can't handle the event, we'll deal with it in
110 // RenderView::UnhandledKeyboardEvent(). 111 // RenderView::UnhandledKeyboardEvent().
111 return TRUE; 112 return TRUE;
112 } 113 }
113 114
114 static gboolean OnFocusIn(GtkWidget* widget, GdkEventFocus* focus, 115 static gboolean OnFocusIn(GtkWidget* widget, GdkEventFocus* focus,
115 RenderWidgetHostViewGtk* host_view) { 116 RenderWidgetHostViewGtk* host_view) {
117 int x, y;
118 gtk_widget_get_pointer(widget, &x, &y);
119 // If the cursor is in the render view, fake a mouse move event so that
120 // webkit updates its state. Otherwise webkit might think the cursor is
121 // somewhere it's not.
122 if (x >= 0 && y >= 0 && x < widget->allocation.width &&
123 y < widget->allocation.height) {
124 WebKit::WebMouseEvent fake_event;
125 fake_event.timeStampSeconds = base::Time::Now().ToDoubleT();
126 fake_event.modifiers = 0;
127 fake_event.windowX = fake_event.x = x;
128 fake_event.windowY = fake_event.y = y;
129 gdk_window_get_origin(widget->window, &x, &y);
130 fake_event.globalX = fake_event.x + x;
131 fake_event.globalY = fake_event.y + y;
132 fake_event.type = WebKit::WebInputEvent::MouseMove;
133 fake_event.button = WebKit::WebMouseEvent::ButtonNone;
134 host_view->GetRenderWidgetHost()->ForwardMouseEvent(fake_event);
135 }
136
116 host_view->ShowCurrentCursor(); 137 host_view->ShowCurrentCursor();
117 host_view->GetRenderWidgetHost()->Focus(); 138 host_view->GetRenderWidgetHost()->Focus();
118 return FALSE; 139 return FALSE;
119 } 140 }
120 141
121 static gboolean OnFocusOut(GtkWidget* widget, GdkEventFocus* focus, 142 static gboolean OnFocusOut(GtkWidget* widget, GdkEventFocus* focus,
122 RenderWidgetHostViewGtk* host_view) { 143 RenderWidgetHostViewGtk* host_view) {
123 // Whenever we lose focus, set the cursor back to that of our parent window, 144 // Whenever we lose focus, set the cursor back to that of our parent window,
124 // which should be the default arrow. 145 // which should be the default arrow.
125 gdk_window_set_cursor(widget->window, NULL); 146 gdk_window_set_cursor(widget->window, NULL);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, 526 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard,
506 const gchar* text, gpointer userdata) { 527 const gchar* text, gpointer userdata) {
507 // If there's nothing to paste (|text| is NULL), do nothing. 528 // If there's nothing to paste (|text| is NULL), do nothing.
508 if (!text) 529 if (!text)
509 return; 530 return;
510 RenderWidgetHostViewGtk* host_view = 531 RenderWidgetHostViewGtk* host_view =
511 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); 532 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata);
512 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), 533 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(),
513 UTF8ToUTF16(text))); 534 UTF8ToUTF16(text)));
514 } 535 }
OLDNEW
« 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