Commit Graph

441 Commits

Author SHA1 Message Date
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
Elias Naur a06a7a4b3c app: make Fullscreen, Windowed Options
Instead of

app.WindowMode(app.Fullscreen)

programs can now just use

app.Fullscreen

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-04-23 10:25:24 +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
aarzilli 495c690187 app: prevent default Windows event handler from running for WM_SYSKEYUP/DOWN
F10 has a special meaning on Windows, if the default handler runs the
first key press following F10 will not generate a key.Press event and
if the first key press after F10 is space the window menu will be
opened instead.

Fixes #213

Signed-off-by: aarzilli <alessandro.arzilli@gmail.com>
2021-04-10 11:40:05 +02:00
pierre abd6e8f9cd app: support changing Window options at runtime
A Window can now be requested to change its options after
it has been started via its Option method.

All options are supported on macOS, Windows and X11.
On Wayland, only the Size and Title options can be changed
at runtime.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-04-07 09:23:25 +02:00
Inkeliz 96840772c7 app/internal/wm: [js] avoid duplicated-paste
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-04-06 09:21:07 +02:00
pierre ce7f0da06e app/internal/wm: use Option method to initialize windows
Added (*w.window).Option methods to the backends and use them for setting the initial options passed into NewWindow.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-04-02 21:15:42 +02:00
pierre b77c1628f3 app/internal/wm: [macOS] run closure on main thread earlier if possible
Signed-off-by: pierre <pierre.curto@gmail.com>
2021-04-02 18:33:12 +02:00
Elias Naur 662cd2e97a app/internal/log: [Android] don't truncate log lines
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-04-02 16:13:35 +02:00
pierre 6330caad95 app/internal/wm: change Options fields from values to pointers
Switching to pointer values in Options, including using window manager defaults for size and title, in preparation for updating options on the fly.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-04-02 13:52:52 +02:00
Elias Naur 9d7b57f74a app/internal/wm: delete unused parameter
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-04-01 16:50:02 +02:00
Elias Naur f3d75f38a9 app/internal/wm: [macOS/iOS] don't release nil strings in nsstringToString
Fixes gio#210

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-29 09:20:24 +02:00
Inkeliz 07802569f7 app: [js] move redraw out of js.FuncOf
Currently, the redraw is called inside js.FuncOf. That PR moves the
redraw to the main function, using channels inside the FuncOf, instead.

The current method (of calling inside the FuncOf) seems to be responsable
to generate `deadlock` errors. It happens even when the wrapped in
goroutines.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-03-26 15:48:15 +01:00
Inkeliz 416094a82c app: [js] support for fullscreen mode
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-03-26 08:15:42 +01:00
pierre 238dd1aa86 app: added support for fullscreen mode
The option field WindowMode allows changing the window mode of an application in either Windowed or Fullscreen.
Only macOS, Windows and X11 platforms are currently supported.

Updates gio#89.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-03-23 23:26:46 +01:00
pierre e0262c20e3 io/key: add NameSpace, report it on Linux
Fixes gio#204.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-03-12 13:18:08 +01:00
Peter Sanford 2aa1cc8112 Add new permission: networkstate
For android this provides ACCESS_NETWORK_STATE

Signed-off-by: Peter Sanford <psanford@sanford.io>
2021-03-08 08:19:22 +01:00
Elias Naur 7059b6284a app/internal/wm: rename confusing app/internal/window
Package wm (for "window manager") is a better fit for the package, and
distinguishes it from the low-level package windows for the Windows API.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:28:57 +01:00
Elias Naur 91a14c7fa2 app/internal/window: rename "backends" to "drivers"
"driver" is the new more specific name for gpu backends.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:27:44 +01:00
Elias Naur 7bc0603d7e internal/gl: rename internal/glimpl
Now that the OpenGL driver package is named "opengl", we can finally get
rid of the ugly "glimpl" name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:27:44 +01:00
Elias Naur 2a66bfb2b4 gpu/headless: move package app/headless
Package headless is more about rendering that windows. Move it
accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur 18a6dcf571 gpu/internal/d3d11: make the Direct3D backend internal to package gpu
The package app/internal/d3d11 now contains only the GPU backend on
Direct3D. Move it below package gpu to reflect that.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur 5a9edc9af8 internal/cocoainit: move app/internal/cocoainit
We're about to move app/headless to gpu/headless, and it imports
cocoainit.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur 3af4e6accf internal/egl: move app/internal/egl
We're about to move package app/headless to gpu/headless, and it needs
the egl package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur 86d17efc2c internal/srgb: move app/internal/srgb
We're about to move app/headless to gpu/headless, and it imports
package srgb indirectly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur e17dd5bd30 internal/d3d11: extract Direct3D API to separate package
We're about the merge the Direct3D backend into package gpu. Extract the
raw Direct3D API to its own package, just like package glimpl.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:25 +01:00
Elias Naur 8ff6546285 gpu,gpu/backend: implement generic backend.NewDevice
NewDevice creates a Device given an API, which is the necessary GPU
resources for a backend.

Convert gpu.New to take an API instead of a backend.Device directly.

In turn, this frees us to later unexport the backend package along with
the backend implementations (for now just gioui.org/gpu/gl for OpenGL).
It also allows programs that embed Gio (such as gioui.org/example/glfw)
to freely choose a backend, not just OpenGL.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:24:09 +01:00
Elias Naur 0e723fa192 app/internal/d3d11: change NewBackend to only require a ID3D11Device
Completing the goal of allowing foreign Direct3D contexts for our
D3D backend, slim down the constructor to take only the device handle.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:23:45 +01:00
Elias Naur c3dde562df app/internal/d3d11: only use passed in ID3D11Device in NewBackend
We're about to enable drawing into foreign Direct3D contexts. In
preparation, NewBackend should only need a device handle.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:22:58 +01:00
Elias Naur 932465d891 app/internal/d3d11: move features from Device to Backend
Continuing the previous change to minimize Device, in preparation
for supporting foreign Direct3D contexts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:21:51 +01:00
Elias Naur 840b9ffa9b gpu/backend,gpu,app/internal/d3d11: move device state to backend
We'd like to allow Gio to share a Direct3D context with an embedding
program like the GLFW example does for OpenGL. To do that, d3d11.Device
needs to carry only the minimal information needed (ID3D11Device).

This change moves the caches of ID3D11DepthStencilState and
ID3D11BlendState from from d3d11.Device to d3d11.Backend. It also adds a
Release method for freeing them.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:21:51 +01:00
Elias Naur 44991f355c app/internal/d3d11: include depth buffer in current framebuffer query
Fixes rendering on Windows. Thanks to Egon Elbre for noticing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:21:15 +01:00
Elias Naur 3627df7efa app/internal/d3d11,gpu/gl: simplify BeginFrame implementations
BeginFrame returns the output framebuffer, and need not be as general
as the newly unexported currentFramebuffer methods.

No functional change.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-04 14:08:39 +01:00
Elias Naur be04dfae83 app/headless: bind output framebuffer at render, not creation
Bind the framebuffer as late as possible to lessen the risk of
confusing global state (current framebuffer). Commit
25a19481e3 removed the assumption
that the framebuffer current at gpu.New would always be the output
framebuffer

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-04 14:08:39 +01:00
Elias Naur b1dfc94a9b app/internal/window: use golang.org/x/window UTF-16 routines
Less code, no functional change.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-04 14:08:39 +01:00
Elias Naur ffb26b0e17 io/pointer: rename button names to reflect their meaning, not placement
For example, ButtonLeft may be the right-most button for a left-handed user.
Rename the button names to match their intended use.

This is an API change. Use the following commands to update your
projects:

    $ gofmt -r 'pointer.ButtonLeft -> pointer.ButtonPrimary' -w .
    $ gofmt -r 'pointer.ButtonRight -> pointer.ButtonSecondary' -w .
    $ gofmt -r 'pointer.ButtonMiddle -> pointer.ButtonTertiary' -w .

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-03 11:08:41 +01:00
Elias Naur f36ed04380 app/headless,app/internal/window: unexport embedded Device fields
There is no need for the fields to be embedded nor exported.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-02 20:51:28 +01:00
Elias Naur fc56d438f3 app/internal/d3d11: don't track the Backend for a Device
A previous commit removed the assumption that the output framebuffer
is constant across frames. Thus it is no longer necessary to track
and update a backend's current framebuffer when the window is resized.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-02 20:44:56 +01:00
Elias Naur 25a19481e3 gpu,gpu/backend: don't assume constant output framebuffer
Return the output framebuffer from BeginFrame, to make it clear that
it may change between frames. Delete CurrentFramebuffer which is no
longer needed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-02 20:43:59 +01:00
Elias Naur 3d3ff575e3 app/internal/windows,app/internal/d3d11: ensure error is returned
d3d11Context.Present would return a nil error if the underlying error
d3d11.ErrorCode.

While here, use defer for a resource cleanup.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-02 20:02:59 +01:00
Chris Waldon 54cddf5ca3 app/permission: update doc to reference app.ViewEvent
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2021-03-01 08:24:06 +01:00
Egon Elbre f6fba73885 internal/cmd/convertshaders: add Windows comp shader compilation
Use dxc (DirectXShaderCompiler) for compiling, which is newer than fxc
and doesn't not fail compilation with dynamically uniform flows with
barriers.

Currently requires -directcompute to enable generating the shaders.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-02-25 13:01:18 +01:00
Elias Naur 9d1e3370f4 app/internal/window: fix Wayland clipboard reading
The Wayland protocol implicitly dup(2)s the pipe write end descriptor passed to
wl_data_offer_receive. As long as we also have an open descriptor for the write
end, the pipe will not close and signal the completion of the clipboard read.

This change explicitly and immediately closes our write descriptor. Before this
change, reading the Wayland clipboard worked with some delay because the Go
garbage collector closed the write end of the transfer pipe after some time.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-21 14:36:36 +01:00
Paulo Melo 3987815469 app: change background for js
Default window background is white.
JS default background is transparent black.

Signed-off-by: Paulo Melo <paulo.durrer.melo@gmail.com>
2021-02-18 08:07:08 +01:00
pierre a581acf3fd io/pointer: added the grab cursor
Signed-off-by: pierre <pierre.curto@gmail.com>
2021-02-08 09:15:14 +01:00
pierre 1100e03c1e io/router: support cursor changes on Frame events
Add support to Router so that the cursor can be changed with CursorNameOp without any mouse movement.
Enter and Leave events are also delivered as areas change.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-01-27 22:21:27 +01:00
pierre d604455582 app: added windows.TRUE for Windows
Signed-off-by: pierre <pierre.curto@gmail.com>
2021-01-27 22:21:18 +01:00