input.Event is enough if we stretch "input" to mean both input
devices and other events such as profiling events and system
commands.
The pointer and key packages are separate already, so I don't
expanding the meaning is unreasonable.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Android can only run c-shared libraries which means that every
Gio program must create its window and event loop from an init
function.
The same applies to iOS but for a more benign reason: the gio tool
builds programs in c-archive mode for iOS and links the binary with
a Objective-C driver.
Allow Gio programs to run off its main function by linking to and
invoking main even from Android libraries and iOS ditto.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The app data dir is not set until after Go's init functions have
run, which means that DataDir is inherently racy. Avoid that race
by blocking in DataDir until it is set from Java.
In other words, trade a race condition with a deadlock.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
It is never a good idea not to draw in response to a DrawEvent, but
let's not hang the program if it doesn't call Window.Draw.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Instead of querying the backing store scale for every pointer event,
use the scale from the last window draw. It might not make any visible
difference because we redraw on scale changes, but it is more correct.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
When moving a window to another monitor, update is called when the
opengl backing store updates its internal size.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Compute and keep constant the pixel density, to avoid window content
changes when moving to another monitor with a different density.
Use backing store scale, not content scale for input events.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Now that the input router triggers a redraw when a focus event is
added, it is no longer necessary to check for that condition in
Window.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Input events are asynchronous, so add buffered to the event queue
so that a slow client does not stall the native window.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
I haven't found a reliable way to re-create the context and redraw
after deminiaturization or app unhide.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The NSOpenGLView owns the NSOpenGLContext so we can't just CFRelease
the context. Use [NSOpenGLView releaseGLContext] instead.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The CVDisplayLink used for synchronizing rendering to the display
refresh rate runs on a separate thread from the main thread.
View callbacks must therefore be serialized. Implement that by
introducing a singleton goroutine that owns the view map and runs
incoming commands.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Delete a redundant loop; dropHandlers already does the required work.
Fixes pointer event issues found after pointer events with no side
effects no longer trigger redraws.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Replace the StageDead stage with DestroyEvent dedicated to ending
the event loop and, for premature window closes, the error.
Drop the error return from NewWindow; any errors in window creation
will appear as an immediate DestroyEvent with its Err field set.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Replace CreateWindow with NewWindow that immediately creates a Window
ready to use.
Drop the Windows channel of windows created by the system. For iOS
and Android where the system creates the windows, let them rendezvous
with the window created in the first NewWindow call.
Android is further changed so that destroying and re-creating the
Java Activity simply reconnects with the original Window.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
And add ProfileOp and ProfileEvent for registering and receiving
profile data.
Remove the Profiling field and Timings method from app.Window.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Redrawing should only be scheduled when some UI state has changed.
Window has no way to know whether a CommandEvent was ignored by
the client, so push the onus to the client to schedule a redraw.
Signed-off-by: Elias Naur <mail@eliasnaur.com>