Change input.Events interface to return one event at a time until
the queue is empty.
Change text.Editor and gestures to match.
Re-add Editor.Submit while we're here; we don't want to enable
submit mode always.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Before this change, the Editor cleared its content after each
Submission event. If it didn't multiple submits for a frame would
not result in the cleared text for clients that wants to clear the
Editor between submits.
However, for clients that do not want to clear the content or that
wants to validate the text before accepting it were not supported.
Instead, switch to a event stepping model, where the client can
call Next to receive each EditorEvent (that is, Submit event) in
turn.
We can then delete the Submit flag on Editor and always report Submit
events.
We can also make Layout flush the pending events now that Editor
always has access to its Config and input queue.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
We are going to encourage a model where pointers to a central
(program global) Configs are passed to widgets at setup time, and
not pass Configs at every frame.
That way, the global Gonfig can change, but the pointers won't need
updating.
This change only switches the Draw event's Config pointer to a value
to avoid tempting programs to use the event Config instead of
updating their own central Configs.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Wayland requires its clients to handle key repeating themselves.
Our strategy is simple: start a timer on key down and fire key
events at regular intervals until another key event arrives.
However, if the program blocks the event loop while processing a
synchronous event, key repeats might pile up before the stopping
key event is processed.
This change use the timestamp of the stopping key event to only
dispatch the repeats queued up before the stop time.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
We don't have full IME-aware editor yet. Fortunately, the BaseInputConnection
has a "dummy mode" setting to allow us to receive input from the fancier keyboards
without implementing the full IME interface.
Fixes gio#7 (I hope; I tested with SwiftKey that had the same symptoms)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
It seems that the iOS simulator can return NaN from texture2D, so
even though width == 0, the resulting cover is not.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
With a <textarea> DOM element pressing the enter key will result in
a "Enter" key down event and a "\n" input event. We're only
interested in the key event, so switching to a single line <input>
avoids the extra "\n".
Signed-off-by: Elias Naur <mail@eliasnaur.com>
To avoid passing a queue type for each kind of input (pointer, key),
introduce package input for mapping a handler key to all input events.
Future input sources can be added without changes to programs, and
as an added bonus, event ordering is preserved across input sources.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
When merging the key and pointers input sources, we can't return
the text input state as a side effect of the Frame method.
Expose it as a method in the key event queue instead.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Similar to the previous change for pointers, only determine the
activeness of a handler from its presence in the ops list.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
We're about to merge the pointer and key event streams in a single
input queue. To do that, we need to simplify Queue.For to just returning
events for the given handler.
First step is the handler active flag.
Dropping handlers that haven't had their events read doesn't seem
worth it. Drop that special case and only determine a handler's activeness
from its presence in the ops list.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Layouts and path builders are transient and need an ops list for
operation. However, instead of passing the ops list to every method,
pass the list in an init method and store it for subsequent methods.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Instead of using the most recent area for hit testing a pointer handler,
use the intersection of the areas up until the handler.
Fixes a bug where layout.List children received pointer events in their
clipped areas.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Split out OpArea from OpHandler to allow stacked areas in a followup.
Replace hit closures with static shapes (rectangles and ellipses) to
avoid allocations. If needed, generic hit functions can be introduced
again later.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Instead of allocating and constructing a clip path, store path data
directly in op lists. Use separate op lists for cached text layout
paths.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
We're about to allow OpBlock for invoking ops from multiple (cached)
Ops containers. To allow for drawing state changes to stick after
invoking such a cached block, we can't let OpBlock perform an implicit
save and restore of drawing state.
Instead, introduce OpPush and OpPop for explicit drawing state stack
management.
Signed-off-by: Elias Naur <mail@eliasnaur.com>