summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/render_widget_host_view_gtk.h
diff options
context:
space:
mode:
authorscheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-11 19:00:53 +0000
committerscheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-11 19:00:53 +0000
commit57e02bedcb1a410fef4b67bf67ebd710de65b205 (patch)
treec09d8fb50b8f02de16f048bb51ba6bf2d3fc511c /content/browser/renderer_host/render_widget_host_view_gtk.h
parent67c125db892ec5222d74012da3c6d353cdf24671 (diff)
downloadchromium_src-57e02bedcb1a410fef4b67bf67ebd710de65b205.zip
chromium_src-57e02bedcb1a410fef4b67bf67ebd710de65b205.tar.gz
chromium_src-57e02bedcb1a410fef4b67bf67ebd710de65b205.tar.bz2
Linux implementation of mouse lock in render widget host view.
Also, fix to render view to disable mouse capture when mouse lock is engaged. BUG=41781 TEST=Manual test in ppapi/examples/mouse_lock. Review URL: http://codereview.chromium.org/8163007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104932 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host/render_widget_host_view_gtk.h')
-rw-r--r--content/browser/renderer_host/render_widget_host_view_gtk.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.h b/content/browser/renderer_host/render_widget_host_view_gtk.h
index 2322dd8..dd4a3f7 100644
--- a/content/browser/renderer_host/render_widget_host_view_gtk.h
+++ b/content/browser/renderer_host/render_widget_host_view_gtk.h
@@ -18,8 +18,10 @@
#include "ui/base/animation/animation_delegate.h"
#include "ui/base/animation/slide_animation.h"
#include "ui/base/gtk/gtk_signal.h"
+#include "ui/base/gtk/gtk_signal_registrar.h"
#include "ui/base/gtk/owned_widget_gtk.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "webkit/glue/webcursor.h"
#include "webkit/plugins/npapi/gtk_plugin_container_manager.h"
@@ -122,6 +124,12 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView,
// occurred, so that we can force the widget to scroll when it otherwise
// would be unable to.
void ModifyEventForEdgeDragging(GtkWidget* widget, GdkEventMotion* event);
+
+ // Mouse events always provide a movementX/Y which needs to be computed.
+ // Also, mouse lock requires knowledge of last unlocked cursor coordinates.
+ // State is stored on the host view to do this, and the mouse event modified.
+ void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event);
+
void Paint(const gfx::Rect&);
// Called by GtkIMContextWrapper to forward a keyboard event to renderer.
@@ -173,6 +181,8 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView,
void set_last_mouse_down(GdkEventButton* event);
+ gfx::Point GetWidgetCenter();
+
// The model object.
RenderWidgetHost* host_;
@@ -234,6 +244,18 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView,
// Is the widget fullscreen?
bool is_fullscreen_;
+ // Used to record the last position of the mouse.
+ // While the mouse is locked, they store the last known position just as mouse
+ // lock was entered.
+ // Relative to the upper-left corner of the view.
+ gfx::Point unlocked_mouse_position_;
+ // Relative to the upper-left corner of the screen.
+ gfx::Point unlocked_global_mouse_position_;
+ // Last hidden cursor position. Relative to screen.
+ gfx::Point global_mouse_position_;
+ // Indicates when mouse motion is valid after the widget has moved.
+ bool mouse_has_been_warped_to_new_center_;
+
// For full-screen windows we have a OnDestroy handler that we need to remove,
// so we keep it ID here.
unsigned long destroy_handler_id_;
@@ -254,6 +276,11 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView,
// variable because resizing in GTK+ is async.
gfx::Size requested_size_;
+ // The latest reported center of the widget, use GetWidgetCenter() to access.
+ gfx::Point widget_center_;
+ // If the window moves the widget_center will not be valid until we recompute.
+ bool widget_center_valid_;
+
// The number of times the user has dragged against horizontal edge of the
// monitor (if the widget is aligned with that edge). Negative values
// indicate the left edge, positive the right.
@@ -274,6 +301,8 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView,
// Custimized tooltip window.
scoped_ptr<ui::TooltipWindowGtk> tooltip_window_;
#endif // defined(OS_CHROMEOS)
+
+ ui::GtkSignalRegistrar signals_;
};
#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_