Service workers: Allow HTTPS pages arrived at via HTTP redirect to use SW
[chromium-blink-merge.git] / ppapi / c / ppb_input_event.h
blobca2bf152b9ddb65a662c2e5948cdbdf9c742d538
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
3 * found in the LICENSE file.
4 */
6 /* From ppb_input_event.idl modified Thu Apr 3 14:52:10 2014. */
8 #ifndef PPAPI_C_PPB_INPUT_EVENT_H_
9 #define PPAPI_C_PPB_INPUT_EVENT_H_
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_macros.h"
14 #include "ppapi/c/pp_point.h"
15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/pp_stdint.h"
17 #include "ppapi/c/pp_time.h"
18 #include "ppapi/c/pp_touch_point.h"
19 #include "ppapi/c/pp_var.h"
21 #define PPB_INPUT_EVENT_INTERFACE_1_0 "PPB_InputEvent;1.0"
22 #define PPB_INPUT_EVENT_INTERFACE PPB_INPUT_EVENT_INTERFACE_1_0
24 #define PPB_MOUSE_INPUT_EVENT_INTERFACE_1_0 "PPB_MouseInputEvent;1.0"
25 #define PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1 "PPB_MouseInputEvent;1.1"
26 #define PPB_MOUSE_INPUT_EVENT_INTERFACE PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1
28 #define PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0 "PPB_WheelInputEvent;1.0"
29 #define PPB_WHEEL_INPUT_EVENT_INTERFACE PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0
31 #define PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0 "PPB_KeyboardInputEvent;1.0"
32 #define PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_2 "PPB_KeyboardInputEvent;1.2"
33 #define PPB_KEYBOARD_INPUT_EVENT_INTERFACE \
34 PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_2
36 #define PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0 "PPB_TouchInputEvent;1.0"
37 #define PPB_TOUCH_INPUT_EVENT_INTERFACE PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0
39 #define PPB_IME_INPUT_EVENT_INTERFACE_1_0 "PPB_IMEInputEvent;1.0"
40 #define PPB_IME_INPUT_EVENT_INTERFACE PPB_IME_INPUT_EVENT_INTERFACE_1_0
42 /**
43 * @file
44 * This file defines the Input Event interfaces.
48 /**
49 * @addtogroup Enums
50 * @{
52 /**
53 * This enumeration contains the types of input events.
55 typedef enum {
56 PP_INPUTEVENT_TYPE_UNDEFINED = -1,
57 /**
58 * Notification that a mouse button was pressed.
60 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
62 PP_INPUTEVENT_TYPE_MOUSEDOWN = 0,
63 /**
64 * Notification that a mouse button was released.
66 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
68 PP_INPUTEVENT_TYPE_MOUSEUP = 1,
69 /**
70 * Notification that a mouse button was moved when it is over the instance
71 * or dragged out of it.
73 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
75 PP_INPUTEVENT_TYPE_MOUSEMOVE = 2,
76 /**
77 * Notification that the mouse entered the instance's bounds.
79 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
81 PP_INPUTEVENT_TYPE_MOUSEENTER = 3,
82 /**
83 * Notification that a mouse left the instance's bounds.
85 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
87 PP_INPUTEVENT_TYPE_MOUSELEAVE = 4,
88 /**
89 * Notification that the scroll wheel was used.
91 * Register for this event using the PP_INPUTEVENT_CLASS_WHEEL class.
93 PP_INPUTEVENT_TYPE_WHEEL = 5,
94 /**
95 * Notification that a key transitioned from "up" to "down".
97 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
100 * TODO(brettw) differentiate from KEYDOWN.
102 PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6,
104 * Notification that a key was pressed. This does not necessarily correspond
105 * to a character depending on the key and language. Use the
106 * PP_INPUTEVENT_TYPE_CHAR for character input.
108 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
110 PP_INPUTEVENT_TYPE_KEYDOWN = 7,
112 * Notification that a key was released.
114 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
116 PP_INPUTEVENT_TYPE_KEYUP = 8,
118 * Notification that a character was typed. Use this for text input. Key
119 * down events may generate 0, 1, or more than one character event depending
120 * on the key, locale, and operating system.
122 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
124 PP_INPUTEVENT_TYPE_CHAR = 9,
126 * Notification that a context menu should be shown.
128 * This message will be sent when the user right-clicks or performs another
129 * OS-specific mouse command that should open a context menu. When this event
130 * is delivered depends on the system, on some systems (Mac) it will
131 * delivered after the mouse down event, and on others (Windows) it will be
132 * delivered after the mouse up event.
134 * You will always get the normal mouse events. For example, you may see
135 * MOUSEDOWN,CONTEXTMENU,MOUSEUP or MOUSEDOWN,MOUSEUP,CONTEXTMENU.
137 * The return value from the event handler determines if the context menu
138 * event will be passed to the page when you are using filtered input events
139 * (via RequestFilteringInputEvents()). In non-filtering mode the event will
140 * never be propagated and no context menu will be displayed. If you are
141 * handling mouse events in filtering mode, you may want to return true from
142 * this event even if you do not support a context menu to suppress the
143 * default one.
145 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
147 PP_INPUTEVENT_TYPE_CONTEXTMENU = 10,
149 * Notification that an input method composition process has just started.
151 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
153 PP_INPUTEVENT_TYPE_IME_COMPOSITION_START = 11,
155 * Notification that the input method composition string is updated.
157 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
159 PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE = 12,
161 * Notification that an input method composition process has completed.
163 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
165 PP_INPUTEVENT_TYPE_IME_COMPOSITION_END = 13,
167 * Notification that an input method committed a string.
169 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
171 PP_INPUTEVENT_TYPE_IME_TEXT = 14,
173 * Notification that a finger was placed on a touch-enabled device.
175 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
177 PP_INPUTEVENT_TYPE_TOUCHSTART = 15,
179 * Notification that a finger was moved on a touch-enabled device.
181 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
183 PP_INPUTEVENT_TYPE_TOUCHMOVE = 16,
185 * Notification that a finger was released on a touch-enabled device.
187 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
189 PP_INPUTEVENT_TYPE_TOUCHEND = 17,
191 * Notification that a touch event was canceled.
193 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
195 PP_INPUTEVENT_TYPE_TOUCHCANCEL = 18
196 } PP_InputEvent_Type;
197 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type, 4);
200 * This enumeration contains event modifier constants. Each modifier is one
201 * bit. Retrieve the modifiers from an input event using the GetEventModifiers
202 * function on PPB_InputEvent.
204 typedef enum {
205 PP_INPUTEVENT_MODIFIER_SHIFTKEY = 1 << 0,
206 PP_INPUTEVENT_MODIFIER_CONTROLKEY = 1 << 1,
207 PP_INPUTEVENT_MODIFIER_ALTKEY = 1 << 2,
208 PP_INPUTEVENT_MODIFIER_METAKEY = 1 << 3,
209 PP_INPUTEVENT_MODIFIER_ISKEYPAD = 1 << 4,
210 PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT = 1 << 5,
211 PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN = 1 << 6,
212 PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7,
213 PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN = 1 << 8,
214 PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY = 1 << 9,
215 PP_INPUTEVENT_MODIFIER_NUMLOCKKEY = 1 << 10,
216 PP_INPUTEVENT_MODIFIER_ISLEFT = 1 << 11,
217 PP_INPUTEVENT_MODIFIER_ISRIGHT = 1 << 12
218 } PP_InputEvent_Modifier;
219 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Modifier, 4);
222 * This enumeration contains constants representing each mouse button. To get
223 * the mouse button for a mouse down or up event, use GetMouseButton on
224 * PPB_InputEvent.
226 typedef enum {
227 PP_INPUTEVENT_MOUSEBUTTON_NONE = -1,
228 PP_INPUTEVENT_MOUSEBUTTON_LEFT = 0,
229 PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1,
230 PP_INPUTEVENT_MOUSEBUTTON_RIGHT = 2
231 } PP_InputEvent_MouseButton;
232 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton, 4);
234 typedef enum {
236 * Request mouse input events.
238 * Normally you will request mouse events by calling RequestInputEvents().
239 * The only use case for filtered events (via RequestFilteringInputEvents())
240 * is for instances that have irregular outlines and you want to perform hit
241 * testing, which is very uncommon. Requesting non-filtered mouse events will
242 * lead to higher performance.
244 PP_INPUTEVENT_CLASS_MOUSE = 1 << 0,
246 * Requests keyboard events. Often you will want to request filtered mode
247 * (via RequestFilteringInputEvents) for keyboard events so you can pass on
248 * events (by returning false) that you don't handle. For example, if you
249 * don't request filtered mode and the user pressed "Page Down" when your
250 * instance has focus, the page won't scroll which will be a poor experience.
252 * A small number of tab and window management commands like Alt-F4 are never
253 * sent to the page. You can not request these keyboard commands since it
254 * would allow pages to trap users on a page.
256 PP_INPUTEVENT_CLASS_KEYBOARD = 1 << 1,
258 * Identifies scroll wheel input event. Wheel events must be requested in
259 * filtering mode via RequestFilteringInputEvents(). This is because many
260 * wheel commands should be forwarded to the page.
262 * Most instances will not need this event. Consuming wheel events by
263 * returning true from your filtered event handler will prevent the user from
264 * scrolling the page when the mouse is over the instance which can be very
265 * annoying.
267 * If you handle wheel events (for example, you have a document viewer which
268 * the user can scroll), the recommended behavior is to return false only if
269 * the wheel event actually causes your document to scroll. When the user
270 * reaches the end of the document, return false to indicating that the event
271 * was not handled. This will then forward the event to the containing page
272 * for scrolling, producing the nested scrolling behavior users expect from
273 * frames in a page.
275 PP_INPUTEVENT_CLASS_WHEEL = 1 << 2,
277 * Identifies touch input events.
279 * Request touch events only if you intend to handle them. If the browser
280 * knows you do not need to handle touch events, it can handle them at a
281 * higher level and achieve higher performance. If the plugin does not
282 * register for touch-events, then it will receive synthetic mouse events that
283 * are generated from the touch events (e.g. mouse-down for touch-start,
284 * mouse-move for touch-move (with left-button down), and mouse-up for
285 * touch-end. If the plugin does register for touch events, then the synthetic
286 * mouse events are not created.
288 PP_INPUTEVENT_CLASS_TOUCH = 1 << 3,
290 * Identifies IME composition input events.
292 * Request this input event class if you allow on-the-spot IME input.
294 PP_INPUTEVENT_CLASS_IME = 1 << 4
295 } PP_InputEvent_Class;
296 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Class, 4);
298 * @}
302 * @addtogroup Interfaces
303 * @{
306 * The <code>PPB_InputEvent</code> interface contains pointers to several
307 * functions related to generic input events on the browser.
309 struct PPB_InputEvent_1_0 {
311 * RequestInputEvent() requests that input events corresponding to the given
312 * input events are delivered to the instance.
314 * It's recommended that you use RequestFilteringInputEvents() for keyboard
315 * events instead of this function so that you don't interfere with normal
316 * browser accelerators.
318 * By default, no input events are delivered. Call this function with the
319 * classes of events you are interested in to have them be delivered to
320 * the instance. Calling this function will override any previous setting for
321 * each specified class of input events (for example, if you previously
322 * called RequestFilteringInputEvents(), this function will set those events
323 * to non-filtering mode).
325 * Input events may have high overhead, so you should only request input
326 * events that your plugin will actually handle. For example, the browser may
327 * do optimizations for scroll or touch events that can be processed
328 * substantially faster if it knows there are no non-default receivers for
329 * that message. Requesting that such messages be delivered, even if they are
330 * processed very quickly, may have a noticeable effect on the performance of
331 * the page.
333 * Note that synthetic mouse events will be generated from touch events if
334 * (and only if) you do not request touch events.
336 * When requesting input events through this function, the events will be
337 * delivered and <i>not</i> bubbled to the default handlers.
339 * <strong>Example:</strong>
340 * @code
341 * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
342 * RequestFilteringInputEvents(instance,
343 * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
344 * @endcode
346 * @param instance The <code>PP_Instance</code> of the instance requesting
347 * the given events.
349 * @param event_classes A combination of flags from
350 * <code>PP_InputEvent_Class</code> that identifies the classes of events the
351 * instance is requesting. The flags are combined by logically ORing their
352 * values.
354 * @return <code>PP_OK</code> if the operation succeeded,
355 * <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or
356 * <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were
357 * illegal. In the case of an invalid bit, all valid bits will be applied
358 * and only the illegal bits will be ignored. The most common cause of a
359 * <code>PP_ERROR_NOTSUPPORTED</code> return value is requesting keyboard
360 * events, these must use RequestFilteringInputEvents().
362 int32_t (*RequestInputEvents)(PP_Instance instance, uint32_t event_classes);
364 * RequestFilteringInputEvents() requests that input events corresponding to
365 * the given input events are delivered to the instance for filtering.
367 * By default, no input events are delivered. In most cases you would
368 * register to receive events by calling RequestInputEvents(). In some cases,
369 * however, you may wish to filter events such that they can be bubbled up
370 * to the default handlers. In this case, register for those classes of
371 * events using this function instead of RequestInputEvents().
373 * Filtering input events requires significantly more overhead than just
374 * delivering them to the instance. As such, you should only request
375 * filtering in those cases where it's absolutely necessary. The reason is
376 * that it requires the browser to stop and block for the instance to handle
377 * the input event, rather than sending the input event asynchronously. This
378 * can have significant overhead.
380 * <strong>Example:</strong>
381 * @code
382 * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
383 * RequestFilteringInputEvents(instance,
384 * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
385 * @endcode
387 * @return <code>PP_OK</code> if the operation succeeded,
388 * <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or
389 * <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were
390 * illegal. In the case of an invalid bit, all valid bits will be applied
391 * and only the illegal bits will be ignored.
393 int32_t (*RequestFilteringInputEvents)(PP_Instance instance,
394 uint32_t event_classes);
396 * ClearInputEventRequest() requests that input events corresponding to the
397 * given input classes no longer be delivered to the instance.
399 * By default, no input events are delivered. If you have previously
400 * requested input events via RequestInputEvents() or
401 * RequestFilteringInputEvents(), this function will unregister handling
402 * for the given instance. This will allow greater browser performance for
403 * those events.
405 * Note that you may still get some input events after clearing the flag if
406 * they were dispatched before the request was cleared. For example, if
407 * there are 3 mouse move events waiting to be delivered, and you clear the
408 * mouse event class during the processing of the first one, you'll still
409 * receive the next two. You just won't get more events generated.
411 * @param instance The <code>PP_Instance</code> of the instance requesting
412 * to no longer receive the given events.
414 * @param event_classes A combination of flags from
415 * <code>PP_InputEvent_Class</code> that identify the classes of events the
416 * instance is no longer interested in.
418 void (*ClearInputEventRequest)(PP_Instance instance, uint32_t event_classes);
420 * IsInputEvent() returns true if the given resource is a valid input event
421 * resource.
423 * @param[in] resource A <code>PP_Resource</code> corresponding to a generic
424 * resource.
426 * @return <code>PP_TRUE</code> if the given resource is a valid input event
427 * resource.
429 PP_Bool (*IsInputEvent)(PP_Resource resource);
431 * GetType() returns the type of input event for the given input event
432 * resource.
434 * @param[in] resource A <code>PP_Resource</code> corresponding to an input
435 * event.
437 * @return A <code>PP_InputEvent_Type</code> if its a valid input event or
438 * <code>PP_INPUTEVENT_TYPE_UNDEFINED</code> if the resource is invalid.
440 PP_InputEvent_Type (*GetType)(PP_Resource event);
442 * GetTimeStamp() Returns the time that the event was generated. This will be
443 * before the current time since processing and dispatching the event has
444 * some overhead. Use this value to compare the times the user generated two
445 * events without being sensitive to variable processing time.
447 * @param[in] resource A <code>PP_Resource</code> corresponding to the event.
449 * @return The return value is in time ticks, which is a monotonically
450 * increasing clock not related to the wall clock time. It will not change
451 * if the user changes their clock or daylight savings time starts, so can
452 * be reliably used to compare events. This means, however, that you can't
453 * correlate event times to a particular time of day on the system clock.
455 PP_TimeTicks (*GetTimeStamp)(PP_Resource event);
457 * GetModifiers() returns a bitfield indicating which modifiers were down
458 * at the time of the event. This is a combination of the flags in the
459 * <code>PP_InputEvent_Modifier</code> enum.
461 * @param[in] resource A <code>PP_Resource</code> corresponding to an input
462 * event.
464 * @return The modifiers associated with the event, or 0 if the given
465 * resource is not a valid event resource.
467 uint32_t (*GetModifiers)(PP_Resource event);
470 typedef struct PPB_InputEvent_1_0 PPB_InputEvent;
473 * The <code>PPB_MouseInputEvent</code> interface contains pointers to several
474 * functions related to mouse input events.
476 struct PPB_MouseInputEvent_1_1 {
478 * Create() creates a mouse input event with the given parameters. Normally
479 * you will get a mouse event passed through the
480 * <code>HandleInputEvent</code> and will not need to create them, but some
481 * applications may want to create their own for internal use. The type must
482 * be one of the mouse event types.
484 * @param[in] instance The instance for which this event occurred.
486 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
487 * input event.
489 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
490 * when the event occurred.
492 * @param[in] modifiers A bit field combination of the
493 * <code>PP_InputEvent_Modifier</code> flags.
495 * @param[in] mouse_button The button that changed for mouse down or up
496 * events. This value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for
497 * mouse move, enter, and leave events.
499 * @param[in] mouse_position A <code>Point</code> containing the x and y
500 * position of the mouse when the event occurred.
502 * @param[in] mouse_movement The change in position of the mouse.
504 * @return A <code>PP_Resource</code> containing the new mouse input event.
506 PP_Resource (*Create)(PP_Instance instance,
507 PP_InputEvent_Type type,
508 PP_TimeTicks time_stamp,
509 uint32_t modifiers,
510 PP_InputEvent_MouseButton mouse_button,
511 const struct PP_Point* mouse_position,
512 int32_t click_count,
513 const struct PP_Point* mouse_movement);
515 * IsMouseInputEvent() determines if a resource is a mouse event.
517 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
519 * @return <code>PP_TRUE</code> if the given resource is a valid mouse input
520 * event, otherwise <code>PP_FALSE</code>.
522 PP_Bool (*IsMouseInputEvent)(PP_Resource resource);
524 * GetButton() returns the mouse button that generated a mouse down or up
525 * event.
527 * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
528 * mouse event.
530 * @return The mouse button associated with mouse down and up events. This
531 * value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for mouse move,
532 * enter, and leave events, and for all non-mouse events.
534 PP_InputEvent_MouseButton (*GetButton)(PP_Resource mouse_event);
536 * GetPosition() returns the pixel location of a mouse input event. When
537 * the mouse is locked, it returns the last known mouse position just as
538 * mouse lock was entered.
540 * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
541 * mouse event.
543 * @return The point associated with the mouse event, relative to the upper-
544 * left of the instance receiving the event. These values can be negative for
545 * mouse drags. The return value will be (0, 0) for non-mouse events.
547 struct PP_Point (*GetPosition)(PP_Resource mouse_event);
549 * TODO(brettw) figure out exactly what this means.
551 int32_t (*GetClickCount)(PP_Resource mouse_event);
553 * Returns the change in position of the mouse. When the mouse is locked,
554 * although the mouse position doesn't actually change, this function
555 * still provides movement information, which indicates what the change in
556 * position would be had the mouse not been locked.
558 * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
559 * mouse event.
561 * @return The change in position of the mouse, relative to the previous
562 * position.
564 struct PP_Point (*GetMovement)(PP_Resource mouse_event);
567 typedef struct PPB_MouseInputEvent_1_1 PPB_MouseInputEvent;
569 struct PPB_MouseInputEvent_1_0 {
570 PP_Resource (*Create)(PP_Instance instance,
571 PP_InputEvent_Type type,
572 PP_TimeTicks time_stamp,
573 uint32_t modifiers,
574 PP_InputEvent_MouseButton mouse_button,
575 const struct PP_Point* mouse_position,
576 int32_t click_count);
577 PP_Bool (*IsMouseInputEvent)(PP_Resource resource);
578 PP_InputEvent_MouseButton (*GetButton)(PP_Resource mouse_event);
579 struct PP_Point (*GetPosition)(PP_Resource mouse_event);
580 int32_t (*GetClickCount)(PP_Resource mouse_event);
584 * The <code>PPB_WheelIputEvent</code> interface contains pointers to several
585 * functions related to wheel input events.
587 struct PPB_WheelInputEvent_1_0 {
589 * Create() creates a wheel input event with the given parameters. Normally
590 * you will get a wheel event passed through the
591 * <code>HandleInputEvent</code> and will not need to create them, but some
592 * applications may want to create their own for internal use.
594 * @param[in] instance The instance for which this event occurred.
596 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
597 * when the event occurred.
599 * @param[in] modifiers A bit field combination of the
600 * <code>PP_InputEvent_Modifier</code> flags.
602 * @param[in] wheel_delta The scroll wheel's horizontal and vertical scroll
603 * amounts.
605 * @param[in] wheel_ticks The number of "clicks" of the scroll wheel that
606 * have produced the event.
608 * @param[in] scroll_by_page When true, the user is requesting to scroll
609 * by pages. When false, the user is requesting to scroll by lines.
611 * @return A <code>PP_Resource</code> containing the new wheel input event.
613 PP_Resource (*Create)(PP_Instance instance,
614 PP_TimeTicks time_stamp,
615 uint32_t modifiers,
616 const struct PP_FloatPoint* wheel_delta,
617 const struct PP_FloatPoint* wheel_ticks,
618 PP_Bool scroll_by_page);
620 * IsWheelInputEvent() determines if a resource is a wheel event.
622 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to an
623 * event.
625 * @return <code>PP_TRUE</code> if the given resource is a valid wheel input
626 * event.
628 PP_Bool (*IsWheelInputEvent)(PP_Resource resource);
630 * GetDelta() returns the amount vertically and horizontally the user has
631 * requested to scroll by with their mouse wheel. A scroll down or to the
632 * right (where the content moves up or left) is represented as positive
633 * values, and a scroll up or to the left (where the content moves down or
634 * right) is represented as negative values.
636 * This amount is system dependent and will take into account the user's
637 * preferred scroll sensitivity and potentially also nonlinear acceleration
638 * based on the speed of the scrolling.
640 * Devices will be of varying resolution. Some mice with large detents will
641 * only generate integer scroll amounts. But fractional values are also
642 * possible, for example, on some trackpads and newer mice that don't have
643 * "clicks".
645 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
646 * event.
648 * @return The vertical and horizontal scroll values. The units are either in
649 * pixels (when scroll_by_page is false) or pages (when scroll_by_page is
650 * true). For example, y = -3 means scroll up 3 pixels when scroll_by_page
651 * is false, and scroll up 3 pages when scroll_by_page is true.
653 struct PP_FloatPoint (*GetDelta)(PP_Resource wheel_event);
655 * GetTicks() returns the number of "clicks" of the scroll wheel
656 * that have produced the event. The value may have system-specific
657 * acceleration applied to it, depending on the device. The positive and
658 * negative meanings are the same as for GetDelta().
660 * If you are scrolling, you probably want to use the delta values. These
661 * tick events can be useful if you aren't doing actual scrolling and don't
662 * want or pixel values. An example may be cycling between different items in
663 * a game.
665 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
666 * event.
668 * @return The number of "clicks" of the scroll wheel. You may receive
669 * fractional values for the wheel ticks if the mouse wheel is high
670 * resolution or doesn't have "clicks". If your program wants discrete
671 * events (as in the "picking items" example) you should accumulate
672 * fractional click values from multiple messages until the total value
673 * reaches positive or negative one. This should represent a similar amount
674 * of scrolling as for a mouse that has a discrete mouse wheel.
676 struct PP_FloatPoint (*GetTicks)(PP_Resource wheel_event);
678 * GetScrollByPage() indicates if the scroll delta x/y indicates pages or
679 * lines to scroll by.
681 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
682 * event.
684 * @return <code>PP_TRUE</code> if the event is a wheel event and the user is
685 * scrolling by pages. <code>PP_FALSE</code> if not or if the resource is not
686 * a wheel event.
688 PP_Bool (*GetScrollByPage)(PP_Resource wheel_event);
691 typedef struct PPB_WheelInputEvent_1_0 PPB_WheelInputEvent;
694 * The <code>PPB_KeyboardInputEvent</code> interface contains pointers to
695 * several functions related to keyboard input events.
697 struct PPB_KeyboardInputEvent_1_2 {
699 * Creates a keyboard input event with the given parameters. Normally you
700 * will get a keyboard event passed through the HandleInputEvent and will not
701 * need to create them, but some applications may want to create their own
702 * for internal use. The type must be one of the keyboard event types.
704 * @param[in] instance The instance for which this event occurred.
706 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
707 * input event.
709 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
710 * when the event occurred.
712 * @param[in] modifiers A bit field combination of the
713 * <code>PP_InputEvent_Modifier</code> flags.
715 * @param[in] key_code This value reflects the DOM KeyboardEvent
716 * <code>keyCode</code> field, which is the Windows-style Virtual Key
717 * code of the key.
719 * @param[in] character_text This value represents the typed character as a
720 * UTF-8 string.
722 * @param[in] code This value represents the DOM3 |code| string that
723 * corresponds to the physical key being pressed.
725 * @return A <code>PP_Resource</code> containing the new keyboard input
726 * event.
728 PP_Resource (*Create)(PP_Instance instance,
729 PP_InputEvent_Type type,
730 PP_TimeTicks time_stamp,
731 uint32_t modifiers,
732 uint32_t key_code,
733 struct PP_Var character_text,
734 struct PP_Var code);
736 * IsKeyboardInputEvent() determines if a resource is a keyboard event.
738 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
740 * @return <code>PP_TRUE</code> if the given resource is a valid input event.
742 PP_Bool (*IsKeyboardInputEvent)(PP_Resource resource);
744 * GetKeyCode() returns the DOM keyCode field for the keyboard event.
745 * Chrome populates this with the Windows-style Virtual Key code of the key.
747 * @param[in] key_event A <code>PP_Resource</code> corresponding to a
748 * keyboard event.
750 * @return The DOM keyCode field for the keyboard event.
752 uint32_t (*GetKeyCode)(PP_Resource key_event);
754 * GetCharacterText() returns the typed character as a UTF-8 string for the
755 * given character event.
757 * @param[in] character_event A <code>PP_Resource</code> corresponding to a
758 * keyboard event.
760 * @return A string var representing a single typed character for character
761 * input events. For non-character input events the return value will be an
762 * undefined var.
764 struct PP_Var (*GetCharacterText)(PP_Resource character_event);
766 * GetCode() returns the DOM |code| field for this keyboard event, as
767 * defined in the DOM3 Events spec:
768 * http://www.w3.org/TR/DOM-Level-3-Events/
770 * @param[in] key_event The key event for which to return the key code.
772 * @return The string that contains the DOM |code| for the keyboard event.
774 struct PP_Var (*GetCode)(PP_Resource key_event);
777 typedef struct PPB_KeyboardInputEvent_1_2 PPB_KeyboardInputEvent;
779 struct PPB_KeyboardInputEvent_1_0 {
780 PP_Resource (*Create)(PP_Instance instance,
781 PP_InputEvent_Type type,
782 PP_TimeTicks time_stamp,
783 uint32_t modifiers,
784 uint32_t key_code,
785 struct PP_Var character_text);
786 PP_Bool (*IsKeyboardInputEvent)(PP_Resource resource);
787 uint32_t (*GetKeyCode)(PP_Resource key_event);
788 struct PP_Var (*GetCharacterText)(PP_Resource character_event);
791 * @}
795 * @addtogroup Enums
796 * @{
798 typedef enum {
800 * The list of all TouchPoints which are currently down.
802 PP_TOUCHLIST_TYPE_TOUCHES = 0,
804 * The list of all TouchPoints whose state has changed since the last
805 * TouchInputEvent.
807 PP_TOUCHLIST_TYPE_CHANGEDTOUCHES = 1,
809 * The list of all TouchPoints which are targeting this plugin. This is a
810 * subset of Touches.
812 PP_TOUCHLIST_TYPE_TARGETTOUCHES = 2
813 } PP_TouchListType;
814 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TouchListType, 4);
816 * @}
820 * @addtogroup Interfaces
821 * @{
824 * The <code>PPB_TouchInputEvent</code> interface contains pointers to several
825 * functions related to touch events.
827 struct PPB_TouchInputEvent_1_0 {
829 * Creates a touch input event with the given parameters. Normally you
830 * will get a touch event passed through the HandleInputEvent and will not
831 * need to create them, but some applications may want to create their own
832 * for internal use. The type must be one of the touch event types.
833 * This newly created touch input event does not have any touch point in any
834 * of the touch-point lists. <code>AddTouchPoint</code> should be called to
835 * add the touch-points.
837 * @param[in] instance The instance for which this event occurred.
839 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
840 * input event.
842 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
843 * when the event occurred.
845 * @param[in] modifiers A bit field combination of the
846 * <code>PP_InputEvent_Modifier</code> flags.
848 * @return A <code>PP_Resource</code> containing the new touch input event.
850 PP_Resource (*Create)(PP_Instance instance,
851 PP_InputEvent_Type type,
852 PP_TimeTicks time_stamp,
853 uint32_t modifiers);
855 * Adds a touch point to the touch event in the specified touch-list.
857 * @param[in] touch_event A <code>PP_Resource</code> corresponding to a touch
858 * event.
860 * @param[in] list The list to add the touch point to.
862 * @param[in] point The point to add to the list.
864 void (*AddTouchPoint)(PP_Resource touch_event,
865 PP_TouchListType list,
866 const struct PP_TouchPoint* point);
868 * IsTouchInputEvent() determines if a resource is a touch event.
870 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
872 * @return <code>PP_TRUE</code> if the given resource is a valid touch input
873 * event, otherwise <code>PP_FALSE</code>.
875 PP_Bool (*IsTouchInputEvent)(PP_Resource resource);
877 * Returns the number of touch-points in the specified list.
879 * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
880 * event.
882 * @param[in] list The list.
884 * @return The number of touch-points in the specified list.
886 uint32_t (*GetTouchCount)(PP_Resource resource, PP_TouchListType list);
888 * Returns the touch-point at the specified index from the specified list.
890 * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
891 * event.
893 * @param[in] list The list.
895 * @param[in] index The index.
897 * @return A <code>PP_TouchPoint</code> representing the touch-point.
899 struct PP_TouchPoint (*GetTouchByIndex)(PP_Resource resource,
900 PP_TouchListType list,
901 uint32_t index);
903 * Returns the touch-point with the specified touch-id in the specified list.
905 * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
906 * event.
908 * @param[in] list The list.
910 * @param[in] touch_id The id of the touch-point.
912 * @return A <code>PP_TouchPoint</code> representing the touch-point.
914 struct PP_TouchPoint (*GetTouchById)(PP_Resource resource,
915 PP_TouchListType list,
916 uint32_t touch_id);
919 typedef struct PPB_TouchInputEvent_1_0 PPB_TouchInputEvent;
921 struct PPB_IMEInputEvent_1_0 {
923 * Create() creates an IME input event with the given parameters. Normally
924 * you will get an IME event passed through the <code>HandleInputEvent</code>
925 * and will not need to create them, but some applications may want to create
926 * their own for internal use.
928 * @param[in] instance The instance for which this event occurred.
930 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
931 * input event. The type must be one of the IME event types.
933 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
934 * when the event occurred.
936 * @param[in] text The string returned by <code>GetText</code>.
938 * @param[in] segment_number The number returned by
939 * <code>GetSegmentNumber</code>.
941 * @param[in] segment_offsets The array of numbers returned by
942 * <code>GetSegmentOffset</code>. If <code>segment_number</code> is zero,
943 * the number of elements of the array should be zero. If
944 * <code>segment_number</code> is non-zero, the length of the array must be
945 * <code>segment_number</code> + 1.
947 * @param[in] target_segment The number returned by
948 * <code>GetTargetSegment</code>.
950 * @param[in] selection_start The start index returned by
951 * <code>GetSelection</code>.
953 * @param[in] selection_end The end index returned by
954 * <code>GetSelection</code>.
956 * @return A <code>PP_Resource</code> containing the new IME input event.
958 PP_Resource (*Create)(PP_Instance instance,
959 PP_InputEvent_Type type,
960 PP_TimeTicks time_stamp,
961 struct PP_Var text,
962 uint32_t segment_number,
963 const uint32_t segment_offsets[],
964 int32_t target_segment,
965 uint32_t selection_start,
966 uint32_t selection_end);
968 * IsIMEInputEvent() determines if a resource is an IME event.
970 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
972 * @return <code>PP_TRUE</code> if the given resource is a valid input event.
974 PP_Bool (*IsIMEInputEvent)(PP_Resource resource);
976 * GetText() returns the composition text as a UTF-8 string for the given IME
977 * event.
979 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
980 * event.
982 * @return A string var representing the composition text. For non-IME input
983 * events the return value will be an undefined var.
985 struct PP_Var (*GetText)(PP_Resource ime_event);
987 * GetSegmentNumber() returns the number of segments in the composition text.
989 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
990 * event.
992 * @return The number of segments. For events other than COMPOSITION_UPDATE,
993 * returns 0.
995 uint32_t (*GetSegmentNumber)(PP_Resource ime_event);
997 * GetSegmentOffset() returns the position of the index-th segmentation point
998 * in the composition text. The position is given by a byte-offset (not a
999 * character-offset) of the string returned by GetText(). It always satisfies
1000 * 0=GetSegmentOffset(0) < ... < GetSegmentOffset(i) < GetSegmentOffset(i+1)
1001 * < ... < GetSegmentOffset(GetSegmentNumber())=(byte-length of GetText()).
1002 * Note that [GetSegmentOffset(i), GetSegmentOffset(i+1)) represents the range
1003 * of the i-th segment, and hence GetSegmentNumber() can be a valid argument
1004 * to this function instead of an off-by-1 error.
1006 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
1007 * event.
1009 * @param[in] index An integer indicating a segment.
1011 * @return The byte-offset of the segmentation point. If the event is not
1012 * COMPOSITION_UPDATE or index is out of range, returns 0.
1014 uint32_t (*GetSegmentOffset)(PP_Resource ime_event, uint32_t index);
1016 * GetTargetSegment() returns the index of the current target segment of
1017 * composition.
1019 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
1020 * event.
1022 * @return An integer indicating the index of the target segment. When there
1023 * is no active target segment, or the event is not COMPOSITION_UPDATE,
1024 * returns -1.
1026 int32_t (*GetTargetSegment)(PP_Resource ime_event);
1028 * GetSelection() returns the range selected by caret in the composition text.
1030 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
1031 * event.
1033 * @param[out] start The start position of the current selection.
1035 * @param[out] end The end position of the current selection.
1037 void (*GetSelection)(PP_Resource ime_event, uint32_t* start, uint32_t* end);
1040 typedef struct PPB_IMEInputEvent_1_0 PPB_IMEInputEvent;
1042 * @}
1045 #endif /* PPAPI_C_PPB_INPUT_EVENT_H_ */