summaryrefslogtreecommitdiffstats
path: root/ppapi/examples
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-20 19:55:39 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-20 19:55:39 +0000
commit13a8f498151ac4e1e771cb3d70d56f38848be04a (patch)
treea751efce3637a6705caf9dd526574855e0fc09c8 /ppapi/examples
parent40e67ab32b12fbcbbbca4cd0764c9796918e82ae (diff)
downloadchromium_src-13a8f498151ac4e1e771cb3d70d56f38848be04a.zip
chromium_src-13a8f498151ac4e1e771cb3d70d56f38848be04a.tar.gz
chromium_src-13a8f498151ac4e1e771cb3d70d56f38848be04a.tar.bz2
Reland http://codereview.chromium.org/7452002/ again
Update chromoting input events. (Clang caught this. Thanks, Clang!) Note I'm leaving in temporary backwards-compatibility. BUG=None TEST=ppapi tests TBR=brettw,sergeyu Review URL: http://codereview.chromium.org/7466008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/examples')
-rw-r--r--ppapi/examples/2d/graphics_2d_example.c7
-rw-r--r--ppapi/examples/2d/paint_manager_example.cc22
-rw-r--r--ppapi/examples/file_chooser/file_chooser.cc15
3 files changed, 21 insertions, 23 deletions
diff --git a/ppapi/examples/2d/graphics_2d_example.c b/ppapi/examples/2d/graphics_2d_example.c
index ccec9a1..6495cdc 100644
--- a/ppapi/examples/2d/graphics_2d_example.c
+++ b/ppapi/examples/2d/graphics_2d_example.c
@@ -157,12 +157,6 @@ void Instance_DidChangeView(PP_Instance pp_instance,
void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) {
}
-PP_Bool Instance_HandleInputEvent(PP_Instance pp_instance,
- const struct PP_InputEvent* event) {
- /* We don't handle any events. */
- return PP_FALSE;
-}
-
PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance,
PP_Resource pp_url_loader) {
return PP_FALSE;
@@ -173,7 +167,6 @@ static struct PPP_Instance instance_interface = {
&Instance_DidDestroy,
&Instance_DidChangeView,
&Instance_DidChangeFocus,
- &Instance_HandleInputEvent,
&Instance_HandleDocumentLoad
};
diff --git a/ppapi/examples/2d/paint_manager_example.cc b/ppapi/examples/2d/paint_manager_example.cc
index 8a5a2f5..c129f07 100644
--- a/ppapi/examples/2d/paint_manager_example.cc
+++ b/ppapi/examples/2d/paint_manager_example.cc
@@ -5,6 +5,7 @@
#include "ppapi/c/pp_input_event.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/image_data.h"
+#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/paint_manager.h"
@@ -41,25 +42,26 @@ class MyInstance : public pp::Instance, public pp::PaintManager::Client {
last_x_(0),
last_y_(0) {
paint_manager_.Initialize(this, this, false);
+ RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
}
- virtual bool HandleInputEvent(const PP_InputEvent& event) {
- switch (event.type) {
+ virtual bool HandleInputEvent(const pp::InputEvent& event) {
+ switch (event.GetType()) {
case PP_INPUTEVENT_TYPE_MOUSEDOWN: {
- const PP_InputEvent_Mouse& mouse_event = event.u.mouse;
+ pp::MouseInputEvent mouse_event(event);
// Update the square on a mouse down.
- if (mouse_event.button == PP_INPUTEVENT_MOUSEBUTTON_LEFT) {
- UpdateSquare(static_cast<int>(mouse_event.x),
- static_cast<int>(mouse_event.y));
+ if (mouse_event.GetMouseButton() == PP_INPUTEVENT_MOUSEBUTTON_LEFT) {
+ UpdateSquare(static_cast<int>(mouse_event.GetMousePosition().x()),
+ static_cast<int>(mouse_event.GetMousePosition().y()));
}
return true;
}
case PP_INPUTEVENT_TYPE_MOUSEMOVE: {
- const PP_InputEvent_Mouse& mouse_event = event.u.mouse;
+ pp::MouseInputEvent mouse_event(event);
// Update the square on a drag.
- if (mouse_event.button == PP_INPUTEVENT_MOUSEBUTTON_LEFT) {
- UpdateSquare(static_cast<int>(mouse_event.x),
- static_cast<int>(mouse_event.y));
+ if (mouse_event.GetMouseButton() == PP_INPUTEVENT_MOUSEBUTTON_LEFT) {
+ UpdateSquare(static_cast<int>(mouse_event.GetMousePosition().x()),
+ static_cast<int>(mouse_event.GetMousePosition().y()));
}
return true;
}
diff --git a/ppapi/examples/file_chooser/file_chooser.cc b/ppapi/examples/file_chooser/file_chooser.cc
index 598095f..e1eb6bd 100644
--- a/ppapi/examples/file_chooser/file_chooser.cc
+++ b/ppapi/examples/file_chooser/file_chooser.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -7,6 +7,7 @@
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/file_chooser_dev.h"
#include "ppapi/cpp/file_ref.h"
+#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/private/instance_private.h"
#include "ppapi/cpp/private/var_private.h"
@@ -16,15 +17,17 @@ class MyInstance : public pp::InstancePrivate {
MyInstance(PP_Instance instance)
: pp::InstancePrivate(instance) {
callback_factory_.Initialize(this);
+ RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
}
- virtual bool HandleInputEvent(const PP_InputEvent& event) {
- switch (event.type) {
+ virtual bool HandleInputEvent(const pp::InputEvent& event) {
+ switch (event.GetType()) {
case PP_INPUTEVENT_TYPE_MOUSEDOWN: {
- const PP_InputEvent_Mouse& mouse_event = event.u.mouse;
- if (mouse_event.button == PP_INPUTEVENT_MOUSEBUTTON_LEFT)
+ pp::MouseInputEvent mouse_event(event);
+ if (mouse_event.GetMouseButton() == PP_INPUTEVENT_MOUSEBUTTON_LEFT)
ShowFileChooser(false);
- else if (mouse_event.button == PP_INPUTEVENT_MOUSEBUTTON_RIGHT)
+ else if (mouse_event.GetMouseButton()
+ == PP_INPUTEVENT_MOUSEBUTTON_RIGHT)
ShowFileChooser(true);
else
return false;