Commit Graph

397 Commits

Author SHA1 Message Date
Inkeliz f4c82adeff app/internal/windows: don't crash on app.Fullscreen on windows/386
Before this patch, use of `app.Fullscreen` would result in "Failed to
find SetWindowLongPtrW procedure in user32.dll" when running on 32 bit
Windows.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-11-16 16:31:13 +01:00
Jan Kåre Vatne 9835cd5996 app: add Window.Maximize and Center, add Windows implementation
Signed-off-by: Jan Kare Vatne <jkvatne@online.no>
2021-11-10 17:03:23 +01:00
Pierre Curto 2f66ed1dc8 app: add Window.Raise to bring a window to the front
Fixes gio#252

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-09-09 07:46:09 +02:00
Elias Naur 45da52cee7 app: merge app/internal/wm into package app
The app and app/internal/wm packages are tightly coupled, requiring
quite a bit of forwarding types, values and constants from the internal
package to export it. Further, no other package imports package wm.

This change merges the two packages.

While here, drop the pre-Go 1.14 SIGPIPE workaround.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-29 22:00:16 +02:00
Elias Naur baa98e7737 app/internal/wm: [macOS] avoid crash in window.Wakeup
window.Wakeup assumes the window.w field is never reset to nil. Avoid
doing that in gio_onClose.

While here, ensure a valid window handle in window.Close by calling
the checked window.runOnMain method, not the bare runOnMain function.

Fixes gio#258

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-27 06:01:21 +02:00
Elias Naur a4a2d517e7 app/internal/wm: [Metal] don't limit CAMetalDrawable count
We shouldn't need more than 2 drawables, but changing the count from the
default of 3 introduces framerate lags in fullscreen mode.

This changes leaves the drawable count alone. No good deed goes
unpunished.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-22 10:48:55 +02:00
Elias Naur 3b2992c37e gpu,app/internal/wm: add Metal port
The OpenGL (ES) implementations on Apple platforms are deprecated and
don't support GPU compute programs. This change adds support for the
replacement, the Metal GPU API.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-21 08:31:46 +02:00
Chris Waldon ae3103e180 app/internal/wm: implement ViewEvent for X11
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2021-08-20 06:59:17 +02:00
Elias Naur 71f834d26f app/internal/wm: remove superfluous main thread switching
The affected code paths are guaranteed to be run on the main thread by
the app.Window callers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-16 15:45:46 +02:00
Elias Naur 23640ec38f app,app/internal/wm: create contexts on the main thread
Instead of handing the internal/wm driver a method to run code on the
(blocked) main thread, just run the necessary driver methods on the main
thread.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-12 15:21:37 +02:00
Elias Naur 06556986c5 app/internal/wm: remove gio_ prefixes from static (local) C functions
Static C functions don't pollute the global namespace.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-08 15:36:49 +02:00
Elias Naur 18b4442393 all: remove Z buffer support
It is no longer needed by any rendering backend.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-08 13:47:37 +01:00
Elias Naur 2059862416 all: merge .m files with their .go counterparts
The only reason for separate files is Objective-C callbacks into Go,
or when the Go side is common, yet the Objective-C side differs from
macOS to iOS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-08 13:46:16 +01:00
Elias Naur 7d84e419c9 gpu,gpu/headless,app/internal/wm: add explicit RenderTarget API
Both the OpenGL and the Direct3D API are stateful and gpu.GPU renders to
the render target current when Frame is called.

Modern GPU API such as Metal don't have a concept of a current render
target, and the target even changes each frame.

Add RenderTarget and add an explicit target argument to GPU.Frame as
well as the underlying driver.Device.BeginFrame.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-08 13:45:23 +01:00
Elias Naur 0bdc2e0432 app,app/internal/wm: fold context MakeCurrent/ReleaseCurrent into Lock/Unlock
While here, make context Refresh useful and remove the redundant
MakeCurrent from the window loop.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-08 13:53:19 +02:00
Elias Naur 7da315eb2b app,app/internal/wm: release OpenGL context after use
Otherwise, making a context current on another thread may result in
an EGL_BAD_ACCESS error.

Fixes gio#248

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-07-27 09:42:34 +02:00
Elias Naur 060ae1cdf9 all: add //go:build lines
They're automatically added by Go 1.17 source formatters. This change
adds them all now.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-07-26 15:17:51 +02:00
Elias Naur ca5a05bb35 internal/d3d11,app/internal/wm: add Direct3D11 leak reporting
Updates gio#245

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-07-18 17:57:38 +01:00
Inkeliz ca722508ce app/internal/wm: refactor Samsung keyboard fix
Move the code from Java to Go.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-07-12 08:43:07 +02:00
Inkeliz 5b8da35a79 app/internal/wm: [android] fix Samsung keyboard
That change makes the Samsung Keyboard compatible with Gio, with minimal
changes.

Fixes gio#116

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-06-23 11:19:00 +02:00
Elias Naur f24232dac5 app/internal/wm: [X11] ignore zero-sized FrameEvents
Updates gio#235

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-06-16 12:01:42 +02:00
Elias Naur 3fc8f55350 app/internal/wm: [macOS] close display link after window close
The app.Window owner may run SetAnimating just before window close,
which in turn rely on an active display link. This change makes sure
the link is stopped after window close where no more driver calls
can occur.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-06-14 23:29:58 +02:00
Elias Naur 4c8aa4c3ca app/internal/wm: [macOS] make app emnu responsive on launch
The macOS app menu would respond to clicks, only to shotcuts (Cmd-Q,
Cmd-H). Moving setActivationPolicy to applicationDidFinishLaunching
seems to fix that, although I can't explain why.

Move a SetDriver call after initialization while here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-06-14 23:16:41 +02:00
Elias Naur e256d52409 app/internal/wm: reformat os_macos.m
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-06-13 15:39:48 +02:00
Elias Naur 0e592f8bc6 app,app/internal/wm: [macOS] refresh context on display change
The NSViewGlobalFrameDidChangeNotification notification is documented to
be fired every time [NSOpenGLContext update] needs to be called.
However, the notification fails to fire on my setup when a window is
moved to a display with a different pixel scale, which leads to
incorrectly sized output.

This change gets rid of the notification and updates the context before
every frame.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-06-12 20:07:52 +02:00
Inkeliz 39eeaaff94 app/internal/wm: [android] fix key.Event and key.EditEvent conflict
Fixes gio#224

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-06-10 11:37:12 +02:00
Inkeliz 910fa30edf app/internal/wm: [android] add Fullscreen support
Now, it's possible to use `app.Fullscreen` on Android devices. It uses
the "Fullscreen Sticky Immersive" mode.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-06-07 17:43:42 +02:00
Inkeliz c92a75948d internal/wm: [wasm] add Title support
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-06-07 17:07:31 +02:00
Elias Naur b0b469d540 app/internal/wm: [Android] set up view handle before callbacks
Fixes gio#230 (again)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-06-07 14:20:24 +02:00
Inkeliz 9b4b91fec0 app, io: [wasm, android] add support for numeric/email keyboard mode
Previously, the on-screen keyboard always displays the text keyboard,
(QWERTY or equivalent).

For optimal user experience, it's possible to specify the keyboard type
using `InputHint`. The on-screen keyboard will provide shortcuts or
restrict what the user can input.

Due to some limitations (gio#116), only numeric and text keyboards are
supported on Android.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-06-05 17:49:08 +02:00
Elias Naur 476d2269a6 gpu/internal/opengl,app/internal/wm: generalize desktop OpenGL support
This changes moves the macOS specific setup for desktop OpenGL to the
portable opengl package. The opengl package already takes care of the
desktop OpenGL setup for sRGB framebuffers, and by moving the code we
avoid calling the wrong OpenGL functions in case both OpenGL.framework
and ANGLE libGLESv2.dylib is linked into the program.

Remove the interface casting expressions for gl.Functions; it wasn't
worth the trouble to keep updated.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-06-01 18:26:11 +02:00
Elias Naur 5f631209ea app/internal/wm: merge os_android.c into os_android.go
The C functions can then be static, and we save a set of declarations.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-20 10:59:48 +02:00
Elias Naur df0e058ea6 app/internal/wm: [macOS] avoid deadlock in Window.Close
Native window callbacks now run in the same context as the event loop.
However, a call to Close immediately calls onClose which in turn wants
to send events. Break the deadlock by deferring the Close call.

Fixes gio#227

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-19 17:22:24 +02:00
Elias Naur 9ad492e93b app/internal/wm: [Android] make GioView delegate methods public
GioActivity is final to avoid the brittle base class problem. However,
to permit replacement of GioActivity the GioView delegate methods must
be public.

While here fix a function signature, rename lowMemory to onLowMemory and make it
static. Also move view specific setup to GioView, simplifying the host
activity further.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-19 15:30:42 +02:00
Elias Naur 8611894b4b app,app/internal/wm: introduce app.Window.Run and use it internally
app.Window implements a method for safely running functions against the
underlying native window through the driverFuncs channel. However, the
functions still run in a different goroutine than the one driving the
native event loop, which forces the implementations in package wm to do
complicated synchronization.

A previous change added a mechanism to run functions in the native event
loop thread. The macOS port needed this functionality, but with some
care it can be generalized. That's what this change does through the
new Run method.

The advantage is that the thread switch dance is now confined to
app.Window, with the help of a generic wm.Driver.Wakeup method. All
other Driver methods can then assume they run on their event loop
threads.

Run is exported because it is also needed for programs that use
Windows configured with CustomRenderer to control their own rendering.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-18 19:59:01 +01:00
Elias Naur c914935169 app/internal/wm: implement ViewEvent for Windows
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-18 14:27:51 +01:00
Elias Naur 1ec408280e app,app/internal/wm: implement ViewEvent for macOS
Move the deprecated setWantsBestResolutionOpenGLSurface to GL-specific
code while we're here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-18 14:26:46 +01:00
Elias Naur 413bff8766 app: implement CustomRenderer option
CustomRenderer disables the construction and binding of a GPU
context to the Window. Combined with ViewEvent and gpu.New, a Gio
client can mix Gio UI and custom rendering.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-18 14:26:45 +01:00
Elias Naur 03ee75fd72 gpu/internal/opengl: support sRGB emulation for desktop OpenGL
Desktop OpenGL implements a GL_FRAMEBUFFER_SRGB setting; query that instead
of the frambuffer color encoding.

With this change it is no longer necessary to enable FRAMEBUFFER_SRGB
in the macOS setup; remove it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-18 14:26:45 +01:00
Elias Naur b622412ac6 gpu: support forced OpenGL ES mode, for ANGLE on macOS
macOS is the only platform where desktop OpenGL is used. To support
foreign ANGLE contexts add a setting to override Gio's selection of
OpenGL implementation.

The bulk of this change is making all function pointers per-context
instead of global, and loading the OpenGL library dynamically. As a side
effect we're closer to Gio tolerating a platform without any OpenGL
implementation. For example, Apple has deprecated OpenGL and OpenGL ES
on its platforms and may remove them in the future.

Note that as a side-effect of this change, Gio needs Go 1.16 or newer to
run on iOS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-18 14:26:45 +01:00
Elias Naur 163be2ffd4 app/internal/wm: [Windows] handle WM_DESTROY properly
After handling WM_DESTROY, the system will destroy the window for us.
This change makes sure destroy events are sent and handled before the
window can no longer be used.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-18 14:25:12 +01:00
Elias Naur 06477be50f app/internal/wm: [iOS] use proper constructor for gl.Functions
We're about to load OpenGL function pointers into gl.Function structs.
Make sure iOS internally uses the NewFunctions constructor, not just
new(Functions).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-17 20:29:41 +02:00
Elias Naur 3a0583564b app/internal/wm: [macOS] avoid NSView.isFlipped
When using Gio with ANGLE, the isFlipped coordinate system flip will
apply to rendering as well. Fortunately we're no longer using NSOpenGLView
so isFlipped only applies to mouse events. Convert them manually to avoid
isFlipped and support ANGLE.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-17 10:51:10 +02:00
Elias Naur d5fc7fc8f6 app/internal/wm: [macOS] release context only if it was created
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-16 12:02:42 +02:00
Elias Naur 21c319ace5 gpu/internal/opengl,internal: move sRGB emulation to OpenGL driver
There is only one driver but several backends (EGL, WebGL).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-16 10:44:45 +02:00
Elias Naur 1d4bf04aa1 app/internal/wm: [macOS] use NSView+NSOpenGLContext, not NSOpenGLContextView
NSOpenGLContextView couples the window manager logic tightly with
OpenGL. Use generic NSViews, and attach NSOpenGLContext just like the
other platforms.

This change prepares for supporting GPU contexts created by clients as
well as a future Metal port.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-14 20:23:06 +02:00
Elias Naur fcca1c11ee app/internal/wm: [iOS] don't destroy context when MakeCurrent fails
The caller should ensure the proper destruction.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-14 16:22:56 +02:00
Inkeliz d51d8b46c3 app, app/internal: [wasm,android] new Option to set Orientation
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-04-25 21:32:54 +02:00
Inkeliz 9dae29844c app, app/internal: [wasm,android] new Option to change navigation/status color
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-04-22 12:15:26 +02:00
pierre 354f5b43d2 app: added missing handling of Options.Size for X11
Signed-off-by: pierre <pierre.curto@gmail.com>
2021-04-20 12:15:55 +02:00