15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/* Copyright (c) 2012 The Chromium Authors. All rights reserved. 25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer * Use of this source code is governed by a BSD-style license that can be 35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer * found in the LICENSE file. 45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer */ 50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner 60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner/* From ppp_input_event.idl modified Tue Apr 8 15:19:45 2014. */ 75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef PPAPI_C_PPP_INPUT_EVENT_H_ 92f7f5b1f5ff023cb8c4008ae53a12b09e3ea2622James Dennett#define PPAPI_C_PPP_INPUT_EVENT_H_ 102f7f5b1f5ff023cb8c4008ae53a12b09e3ea2622James Dennett 112f7f5b1f5ff023cb8c4008ae53a12b09e3ea2622James Dennett#include "ppapi/c/pp_bool.h" 122f7f5b1f5ff023cb8c4008ae53a12b09e3ea2622James Dennett#include "ppapi/c/pp_instance.h" 135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "ppapi/c/pp_macros.h" 145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "ppapi/c/pp_resource.h" 155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "ppapi/c/pp_stdint.h" 165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define PPP_INPUT_EVENT_INTERFACE_0_1 "PPP_InputEvent;0.1" 186ebf09130479bc7605aa09a3e6c4dc2ba3513495Dmitri Gribenko#define PPP_INPUT_EVENT_INTERFACE PPP_INPUT_EVENT_INTERFACE_0_1 19c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmith 20260611a32535c851237926bfcf78869b13c07d5bJohn McCall/** 211fb0caaa7bef765b85972274e3b434af2572c141John McCall * @file 2230a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth * This file defines the API for receiving input events from the browser. 231b0969590e712d7d52fc9c0d43d3ab85c36d07a6Daniel Dunbar */ 245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 264f45bc099f2665bc6e4bcbb169aa452390dbf3feWill Dietz/** 274f45bc099f2665bc6e4bcbb169aa452390dbf3feWill Dietz * @addtogroup Interfaces 284f45bc099f2665bc6e4bcbb169aa452390dbf3feWill Dietz * @{ 294f45bc099f2665bc6e4bcbb169aa452390dbf3feWill Dietz */ 304f45bc099f2665bc6e4bcbb169aa452390dbf3feWill Dietzstruct PPP_InputEvent_0_1 { 314f45bc099f2665bc6e4bcbb169aa452390dbf3feWill Dietz /** 324f45bc099f2665bc6e4bcbb169aa452390dbf3feWill Dietz * Function for receiving input events from the browser. 334f45bc099f2665bc6e4bcbb169aa452390dbf3feWill Dietz * 341f73ae227b18073a5d1792b41094e61329179acfRichard Smith * In order to receive input events, you must register for them by calling 351f73ae227b18073a5d1792b41094e61329179acfRichard Smith * PPB_InputEvent.RequestInputEvents() or RequestFilteringInputEvents(). By 361f73ae227b18073a5d1792b41094e61329179acfRichard Smith * default, no events are delivered. 371f73ae227b18073a5d1792b41094e61329179acfRichard Smith * 381f73ae227b18073a5d1792b41094e61329179acfRichard Smith * If the event was handled, it will not be forwarded to the default handlers 391f73ae227b18073a5d1792b41094e61329179acfRichard Smith * in the web page. If it was not handled, it may be dispatched to a default 401f73ae227b18073a5d1792b41094e61329179acfRichard Smith * handler. So it is important that an instance respond accurately with 411f73ae227b18073a5d1792b41094e61329179acfRichard Smith * whether event propagation should continue. 421f73ae227b18073a5d1792b41094e61329179acfRichard Smith * 434f45bc099f2665bc6e4bcbb169aa452390dbf3feWill Dietz * Event propagation also controls focus. If you handle an event like a mouse 441f73ae227b18073a5d1792b41094e61329179acfRichard Smith * event, typically the instance will be given focus. Returning false from 451f73ae227b18073a5d1792b41094e61329179acfRichard Smith * a filtered event handler or not registering for an event type means that 461f73ae227b18073a5d1792b41094e61329179acfRichard Smith * the click will be given to a lower part of the page and your instance will 471f73ae227b18073a5d1792b41094e61329179acfRichard Smith * not receive focus. This allows an instance to be partially transparent, 481f73ae227b18073a5d1792b41094e61329179acfRichard Smith * where clicks on the transparent areas will behave like clicks to the 491f73ae227b18073a5d1792b41094e61329179acfRichard Smith * underlying page. 501f73ae227b18073a5d1792b41094e61329179acfRichard Smith * 511f73ae227b18073a5d1792b41094e61329179acfRichard Smith * In general, you should try to keep input event handling short. Especially 521f73ae227b18073a5d1792b41094e61329179acfRichard Smith * for filtered input events, the browser or page may be blocked waiting for 53af50aab0c317462129d73ae8000c6394c718598dJames Dennett * you to respond. 54af50aab0c317462129d73ae8000c6394c718598dJames Dennett * 55ef8225444452a1486bd721f3285301fe84643b00Stephen Hines * The caller of this function will maintain a reference to the input event 56ea684e699ea84e61711e279f5fa7a1b9f3d46bc2Cedric Venet * resource during this call. Unless you take a reference to the resource 577d5e81bf24dbfd334a7c62a7ae51043c79a69aa9Douglas Gregor * to hold it for later, you don't need to release it. 587d5e81bf24dbfd334a7c62a7ae51043c79a69aa9Douglas Gregor * 5901d9dbf4ae627e2ba42fc23485789a33fa296516Ted Kremenek * <strong>Note:</strong> If you're not receiving input events, make sure you 60651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines * register for the event classes you want by calling RequestInputEvents or 61e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor * RequestFilteringInputEvents. If you're still not receiving keyboard input 62a4d71455f0d418e16cc0c5c5aa55a3bad3494aeeChris Lattner * events, make sure you're returning true (or using a non-filtered event 63a4d71455f0d418e16cc0c5c5aa55a3bad3494aeeChris Lattner * handler) for mouse events. Otherwise, the instance will not receive focus 64a4d71455f0d418e16cc0c5c5aa55a3bad3494aeeChris Lattner * and keyboard events will not be sent. 65a4d71455f0d418e16cc0c5c5aa55a3bad3494aeeChris Lattner * 66a4d71455f0d418e16cc0c5c5aa55a3bad3494aeeChris Lattner * \see PPB_InputEvent.RequestInputEvents and 67e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor * PPB_InputEvent.RequestFilteringInputEvents 68651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines * 69651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines * @return PP_TRUE if the event was handled, PP_FALSE if not. If you have 70651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines * registered to filter this class of events by calling 71651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines * RequestFilteringInputEvents, and you return PP_FALSE, the event will 72651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines * be forwarded to the page (and eventually the browser) for the default 73651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines * handling. For non-filtered events, the return value will be ignored. 74651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines */ 751eef85246b411b55c493098266746d0d83c241eaDavid Tweed PP_Bool (*HandleInputEvent)(PP_Instance instance, PP_Resource input_event); 761eef85246b411b55c493098266746d0d83c241eaDavid Tweed}; 77e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor 78260611a32535c851237926bfcf78869b13c07d5bJohn McCalltypedef struct PPP_InputEvent_0_1 PPP_InputEvent; 79260611a32535c851237926bfcf78869b13c07d5bJohn McCall/** 80e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor * @} 81e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor */ 82af50aab0c317462129d73ae8000c6394c718598dJames Dennett 83af50aab0c317462129d73ae8000c6394c718598dJames Dennett#endif /* PPAPI_C_PPP_INPUT_EVENT_H_ */ 84af50aab0c317462129d73ae8000c6394c718598dJames Dennett 857f18e67e1b577a50402e8b43508ab2311a5c45b5David Chisnall