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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_gtk.cc

Issue 19776016: Add files. Does not compile yet! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: builders Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_gtk.h" 5 #include "content/browser/renderer_host/render_widget_host_view_gtk.h"
6 6
7 #include <cairo/cairo.h> 7 #include <cairo/cairo.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>
(...skipping 11 matching lines...) Expand all
22 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/utf_offset_string_conversions.h" 23 #include "base/strings/utf_offset_string_conversions.h"
24 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
25 #include "base/time/time.h" 25 #include "base/time/time.h"
26 #include "content/browser/accessibility/browser_accessibility_gtk.h" 26 #include "content/browser/accessibility/browser_accessibility_gtk.h"
27 #include "content/browser/accessibility/browser_accessibility_manager_gtk.h" 27 #include "content/browser/accessibility/browser_accessibility_manager_gtk.h"
28 #include "content/browser/renderer_host/backing_store_gtk.h" 28 #include "content/browser/renderer_host/backing_store_gtk.h"
29 #include "content/browser/renderer_host/gtk_im_context_wrapper.h" 29 #include "content/browser/renderer_host/gtk_im_context_wrapper.h"
30 #include "content/browser/renderer_host/gtk_key_bindings_handler.h" 30 #include "content/browser/renderer_host/gtk_key_bindings_handler.h"
31 #include "content/browser/renderer_host/gtk_window_utils.h" 31 #include "content/browser/renderer_host/gtk_window_utils.h"
32 #include "content/browser/renderer_host/input/web_input_event_builders_gtk.h"
32 #include "content/browser/renderer_host/render_view_host_delegate.h" 33 #include "content/browser/renderer_host/render_view_host_delegate.h"
33 #include "content/browser/renderer_host/render_view_host_impl.h" 34 #include "content/browser/renderer_host/render_view_host_impl.h"
34 #include "content/common/gpu/gpu_messages.h" 35 #include "content/common/gpu/gpu_messages.h"
35 #include "content/common/input_messages.h" 36 #include "content/common/input_messages.h"
36 #include "content/common/view_messages.h" 37 #include "content/common/view_messages.h"
37 #include "content/common/webplugin_geometry.h" 38 #include "content/common/webplugin_geometry.h"
38 #include "content/public/browser/native_web_keyboard_event.h" 39 #include "content/public/browser/native_web_keyboard_event.h"
39 #include "content/public/common/content_switches.h" 40 #include "content/public/common/content_switches.h"
40 #include "skia/ext/platform_canvas.h" 41 #include "skia/ext/platform_canvas.h"
41 #include "third_party/WebKit/public/web/WebInputEvent.h" 42 #include "third_party/WebKit/public/web/WebInputEvent.h"
42 #include "third_party/WebKit/public/web/WebScreenInfo.h" 43 #include "third_party/WebKit/public/web/WebScreenInfo.h"
43 #include "third_party/WebKit/public/web/gtk/WebInputEventFactory.h"
44 #include "ui/base/clipboard/scoped_clipboard_writer.h" 44 #include "ui/base/clipboard/scoped_clipboard_writer.h"
45 #include "ui/base/gtk/gtk_compat.h" 45 #include "ui/base/gtk/gtk_compat.h"
46 #include "ui/base/text/text_elider.h" 46 #include "ui/base/text/text_elider.h"
47 #include "ui/base/x/active_window_watcher_x.h" 47 #include "ui/base/x/active_window_watcher_x.h"
48 #include "ui/base/x/x11_util.h" 48 #include "ui/base/x/x11_util.h"
49 #include "ui/gfx/gtk_native_view_id_manager.h" 49 #include "ui/gfx/gtk_native_view_id_manager.h"
50 #include "ui/gfx/gtk_preserve_window.h" 50 #include "ui/gfx/gtk_preserve_window.h"
51 #include "webkit/common/cursors/webcursor_gtk_data.h" 51 #include "webkit/common/cursors/webcursor_gtk_data.h"
52 52
53 using WebKit::WebInputEventFactory;
54 using WebKit::WebMouseWheelEvent; 53 using WebKit::WebMouseWheelEvent;
55 using WebKit::WebScreenInfo; 54 using WebKit::WebScreenInfo;
56 55
57 namespace content { 56 namespace content {
58 namespace { 57 namespace {
59 58
60 // Paint rects on Linux are bounded by the maximum size of a shared memory 59 // Paint rects on Linux are bounded by the maximum size of a shared memory
61 // region. By default that's 32MB, but many distros increase it significantly 60 // region. By default that's 32MB, but many distros increase it significantly
62 // (i.e. to 256MB). 61 // (i.e. to 256MB).
63 // 62 //
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 346
348 // TODO(evanm): why is this necessary here but not in test shell? 347 // TODO(evanm): why is this necessary here but not in test shell?
349 // This logic is the same as GtkButton. 348 // This logic is the same as GtkButton.
350 if (event->type == GDK_BUTTON_PRESS && !gtk_widget_has_focus(widget)) 349 if (event->type == GDK_BUTTON_PRESS && !gtk_widget_has_focus(widget))
351 gtk_widget_grab_focus(widget); 350 gtk_widget_grab_focus(widget);
352 351
353 host_view->is_popup_first_mouse_release_ = false; 352 host_view->is_popup_first_mouse_release_ = false;
354 RenderWidgetHostImpl* widget_host = 353 RenderWidgetHostImpl* widget_host =
355 RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost()); 354 RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost());
356 if (widget_host) 355 if (widget_host)
357 widget_host->ForwardMouseEvent(WebInputEventFactory::mouseEvent(event)); 356 widget_host->ForwardMouseEvent(WebMouseEventBuilder::Build(event));
358 357
359 // Although we did handle the mouse event, we need to let other handlers 358 // Although we did handle the mouse event, we need to let other handlers
360 // run (in particular the one installed by WebContentsViewGtk). 359 // run (in particular the one installed by WebContentsViewGtk).
361 return FALSE; 360 return FALSE;
362 } 361 }
363 362
364 static gboolean OnMouseMoveEvent(GtkWidget* widget, 363 static gboolean OnMouseMoveEvent(GtkWidget* widget,
365 GdkEventMotion* event, 364 GdkEventMotion* event,
366 RenderWidgetHostViewGtk* host_view) { 365 RenderWidgetHostViewGtk* host_view) {
367 TRACE_EVENT0("browser", 366 TRACE_EVENT0("browser",
368 "RenderWidgetHostViewGtkWidget::OnMouseMoveEvent"); 367 "RenderWidgetHostViewGtkWidget::OnMouseMoveEvent");
369 // We want to translate the coordinates of events that do not originate 368 // We want to translate the coordinates of events that do not originate
370 // from this widget to be relative to the top left of the widget. 369 // from this widget to be relative to the top left of the widget.
371 GtkWidget* event_widget = gtk_get_event_widget( 370 GtkWidget* event_widget = gtk_get_event_widget(
372 reinterpret_cast<GdkEvent*>(event)); 371 reinterpret_cast<GdkEvent*>(event));
373 if (event_widget != widget) { 372 if (event_widget != widget) {
374 int x = 0; 373 int x = 0;
375 int y = 0; 374 int y = 0;
376 gtk_widget_get_pointer(widget, &x, &y); 375 gtk_widget_get_pointer(widget, &x, &y);
377 event->x = x; 376 event->x = x;
378 event->y = y; 377 event->y = y;
379 } 378 }
380 379
381 host_view->ModifyEventForEdgeDragging(widget, event); 380 host_view->ModifyEventForEdgeDragging(widget, event);
382 381
383 WebKit::WebMouseEvent mouse_event = 382 WebKit::WebMouseEvent mouse_event = WebMouseEventBuilder::Build(event);
384 WebInputEventFactory::mouseEvent(event);
385 383
386 if (host_view->mouse_locked_) { 384 if (host_view->mouse_locked_) {
387 gfx::Point center = host_view->GetWidgetCenter(); 385 gfx::Point center = host_view->GetWidgetCenter();
388 386
389 bool moved_to_center = MovedToPoint(mouse_event, center); 387 bool moved_to_center = MovedToPoint(mouse_event, center);
390 if (moved_to_center) 388 if (moved_to_center)
391 host_view->mouse_has_been_warped_to_new_center_ = true; 389 host_view->mouse_has_been_warped_to_new_center_ = true;
392 390
393 host_view->ModifyEventMovementAndCoords(&mouse_event); 391 host_view->ModifyEventMovementAndCoords(&mouse_event);
394 392
(...skipping 29 matching lines...) Expand all
424 GDK_BUTTON3_MASK | 422 GDK_BUTTON3_MASK |
425 GDK_BUTTON4_MASK | 423 GDK_BUTTON4_MASK |
426 GDK_BUTTON5_MASK; 424 GDK_BUTTON5_MASK;
427 425
428 // Only forward crossing events if the mouse button is not down. 426 // Only forward crossing events if the mouse button is not down.
429 // (When the mouse button is down, the proper events are already being 427 // (When the mouse button is down, the proper events are already being
430 // sent by ButtonPressReleaseEvent and MouseMoveEvent, above, and if we 428 // sent by ButtonPressReleaseEvent and MouseMoveEvent, above, and if we
431 // additionally send this crossing event with the state indicating the 429 // additionally send this crossing event with the state indicating the
432 // button is down, it causes problems with drag and drop in WebKit.) 430 // button is down, it causes problems with drag and drop in WebKit.)
433 if (!(event->state & any_button_mask)) { 431 if (!(event->state & any_button_mask)) {
434 WebKit::WebMouseEvent mouse_event = 432 WebKit::WebMouseEvent mouse_event = WebMouseEventBuilder::Build(event);
435 WebInputEventFactory::mouseEvent(event);
436 host_view->ModifyEventMovementAndCoords(&mouse_event); 433 host_view->ModifyEventMovementAndCoords(&mouse_event);
437 // When crossing out and back into a render view the movement values 434 // When crossing out and back into a render view the movement values
438 // must represent the instantaneous movement of the mouse, not the jump 435 // must represent the instantaneous movement of the mouse, not the jump
439 // from the exit to re-entry point. 436 // from the exit to re-entry point.
440 mouse_event.movementX = 0; 437 mouse_event.movementX = 0;
441 mouse_event.movementY = 0; 438 mouse_event.movementY = 0;
442 RenderWidgetHostImpl::From( 439 RenderWidgetHostImpl::From(
443 host_view->GetRenderWidgetHost())->ForwardMouseEvent(mouse_event); 440 host_view->GetRenderWidgetHost())->ForwardMouseEvent(mouse_event);
444 } 441 }
445 442
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 // If the user is holding shift, translate it into a horizontal scroll. We 508 // If the user is holding shift, translate it into a horizontal scroll. We
512 // don't care what other modifiers the user may be holding (zooming is 509 // don't care what other modifiers the user may be holding (zooming is
513 // handled at the WebContentsView level). 510 // handled at the WebContentsView level).
514 if (event->state & GDK_SHIFT_MASK) { 511 if (event->state & GDK_SHIFT_MASK) {
515 if (event->direction == GDK_SCROLL_UP) 512 if (event->direction == GDK_SCROLL_UP)
516 event->direction = GDK_SCROLL_LEFT; 513 event->direction = GDK_SCROLL_LEFT;
517 else if (event->direction == GDK_SCROLL_DOWN) 514 else if (event->direction == GDK_SCROLL_DOWN)
518 event->direction = GDK_SCROLL_RIGHT; 515 event->direction = GDK_SCROLL_RIGHT;
519 } 516 }
520 517
521 WebMouseWheelEvent web_event = WebInputEventFactory::mouseWheelEvent(event); 518 WebMouseWheelEvent web_event = WebMouseWheelEventBuilder::Build(event);
522 // We peek ahead at the top of the queue to look for additional pending 519 // We peek ahead at the top of the queue to look for additional pending
523 // scroll events. 520 // scroll events.
524 if (event->direction == GDK_SCROLL_UP || 521 if (event->direction == GDK_SCROLL_UP ||
525 event->direction == GDK_SCROLL_DOWN) { 522 event->direction == GDK_SCROLL_DOWN) {
526 if (event->direction == GDK_SCROLL_UP) 523 if (event->direction == GDK_SCROLL_UP)
527 web_event.deltaY = kDefaultScrollPixelsPerTick; 524 web_event.deltaY = kDefaultScrollPixelsPerTick;
528 else 525 else
529 web_event.deltaY = -kDefaultScrollPixelsPerTick; 526 web_event.deltaY = -kDefaultScrollPixelsPerTick;
530 web_event.deltaY += GetPendingScrollDelta(true, event->state); 527 web_event.deltaY += GetPendingScrollDelta(true, event->state);
531 } else { 528 } else {
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 gfx::PluginWindowHandle id) { 1572 gfx::PluginWindowHandle id) {
1576 plugin_container_manager_.CreatePluginContainer(id); 1573 plugin_container_manager_.CreatePluginContainer(id);
1577 } 1574 }
1578 1575
1579 void RenderWidgetHostViewGtk::OnDestroyPluginContainer( 1576 void RenderWidgetHostViewGtk::OnDestroyPluginContainer(
1580 gfx::PluginWindowHandle id) { 1577 gfx::PluginWindowHandle id) {
1581 plugin_container_manager_.DestroyPluginContainer(id); 1578 plugin_container_manager_.DestroyPluginContainer(id);
1582 } 1579 }
1583 1580
1584 } // namespace content 1581 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/native_web_keyboard_event_gtk.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698