Commit Graph

321 Commits

Author SHA1 Message Date
Elias Naur d572aa23ac op/clip: split Rect into pixel-aligned Rect and rounded RRect
The pixel-aligned Rect is more efficient and easier to use in the common case
of layout clipping.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-07-09 18:33:00 +02:00
Elias Naur 4818538ef8 op/clip: unexport Rect.Op
It wasn't used anywhere outside Rect.Add.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-07-09 17:29:31 +02:00
Elias Naur 96da6945a7 app/internal/window: [Wayland] initialize touchFoci map
Fixes gio#145 (I hope)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-07-08 16:16:44 +02:00
Elias Naur e2278b64c1 app/headless: avoid race between ReleaseCurrent and MakeCurrent
Release context on MakeCurrent failure paths as well.

Fixes gio#144

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-07-04 17:37:02 +02:00
Elias Naur 30ad63283b app/headless,internal/rendertest: report errors from headless renders
Updates gio#144

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-07-04 16:36:03 +02:00
Elias Naur d53c92791f app/headless: don't release context while it's current
Updates gio#144

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-07-04 16:35:58 +02:00
Elias Naur 1513348bf6 app/internal/egl: don't call eglTerminate
A single EGL display may be shared among several contexts. Don't
eglTerminate a context display when destroying the context.

Updates gio#144

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-07-04 16:26:16 +02:00
Elias Naur 958b19ae22 app/internal/window: [macOS] ignore result from CVDisplayLinkStart
Larry Clapp reported a panic from failing to start the display link.
Ignore the error and hope the error is transient.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-30 11:36:26 +02:00
Elias Naur 2f8833d985 app/internal/window: [X11] avoid -d=checkptr check failures
Casting a *XClientMessageEvent or *XSelectionEvent to *XEvent is
technically incorrect because the union XEvent is the larger structure.

Use an XEvent variable as the backing storage for the specialized
event types instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-27 15:29:42 +02:00
Sebastien Binet 6a9a870462 app{,/internal/window}: make app.Main blocking on desktop platforms
This CL implements the app.Main function as a blocking-forever function
for JS, Wayland, Windows and X11.
This works better for applications that can now programmatically close
windows.
2020-06-26 16:20:42 +02:00
Elias Naur 31e8339e1b app/internal/window: [Windows] fix min/max size
Fixes gio#141

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-26 16:14:41 +01:00
Elias Naur d97f7f9093 app/internal/window,cmd/gogio: [iOS] export GioViewController
The Gio GioAppDelegate created the GioViewController programmatically.
When using gogio's -buildmode=archive users may want to use a different
method (for example storyboards) but there can only be one app delegate.

Move the GioAppDelegate to gogio's exe buildmode, and export the
GioViewController for embedding use.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-26 15:47:00 +02:00
Elias Naur 79014a81d5 app/internal/window: [iOS] move logic out of GioAppDelegate
We'd like to remove GioAppDelegate when Gio is embedded with
gogio's -buildmode=archive. Minimize the code in GioAppDelegate.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-26 15:25:40 +02:00
Elias Naur db03b0898d app/internal/window: run main on main thread on Android and iOS
Before this change, Android and iOS were special for two reasons:
app.Main would return immediately, and the program main was invoked from
a goroutine. We can reduce that to one special case by either

- run the program main from the main thread,
- or make app.Main block.

Choose to run main on the main thread.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-25 16:21:28 +02:00
Sebastien Binet 59f07023d4 app/internal: [X11] implement Window.Close
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-06-22 17:21:39 +02:00
Jason 9cfbdafe14 app/window,app/internal/window: allow min/max window size
The app.MinSize and app.MaxSize options restricts the window size:

w := app.NewWindow(
	app.Size(unit.Dp(600), unit.Dp(596)),
	app.MinSize(unit.Dp(600), unit.Dp(596)),
	app.MaxSize(unit.Dp(600), unit.Dp(596)),
	app.Title(APPNAME),
)

Signed-off-by: Jason <sourcehut@sweatyballs.es>
2020-06-22 13:00:27 +02:00
Egon Elbre 0b713032fb app/internal: [Windows] support Window.Close
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-06-19 12:37:21 +02:00
Larry Clapp 602d54dc5e app,app/internal/window: [macOS] add app.Window.Close for closing a window
Recently support was added for multiple top-level windows. Add support
for closing those windows.

macOS only; all others stubbed out.

Signed-off-by: Larry Clapp <larry@theclapp.org>
2020-06-18 14:46:58 +02:00
Elias Naur 596e321610 all: make unit.Converter concrete and rename to Metric
An interface for scaling dp and sp is overkill, at least for all
current uses. Make it a concrete struct type, and rename it to the
shorter and more precise Metric.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-17 11:47:14 +02:00
Jason a3f7eaae08 app/internal/window: set WM_CLASS to binary name
WM_CLASS is used by Linux desktops to provide hints for window
grouping, icons to show and startup notifications.

https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s06.html

This patch set the WM_CLASS to the binary name.

Signed-off-by: Jason <sourcehut@sweatyballs.es>
2020-06-16 16:15:36 +02:00
Elias Naur c2f99fb0e9 app/internal/egl: [Android] fix sRGB on Samsung S9
At least one Samsung S9 device ignores the sRGB setting if the context
wasn't created with alpha in its attributes.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-15 18:06:48 +02:00
Elias Naur 04e605c1b2 app/internal/window: [Android] implement scroll factor fallback for < API 26
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-15 13:40:13 +02:00
Elias Naur feacd1e2df app/internal/window: [Android] implement mouse scrolling
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-13 18:52:29 +02:00
Elias Naur 8688ed95c2 app/internal/window: [Android] replace RegisterFragment with Do
Do is a function for accessing the underlying Android View in a safe
context, the main thread. Do is

- more general than RegisterFragment and may be expanded to other platforms
- simpler to implement (from the Gio side)

and as a bonus, the Do implementation avoids a race condition where
a call to RegisterFragment during an Activity re-create would be ignored.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-13 17:47:58 +02:00
Elias Naur f36674ddb3 app/internal/window: [Android] make runOnThread independent of a valid GioView
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-13 17:47:58 +02:00
Elias Naur 2f521899c9 app/internal/window: [Android] use app context for clipboard access
The Activity context may not be available, so it's safer and simpler
to use the always available app context.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-13 16:41:28 +02:00
Elias Naur 65d9a9d1f1 app/internal/window: [Android] skip redraw for destroyed views
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-13 16:41:28 +02:00
Elias Naur fda6fbcf84 app: drop Go 1.12 support
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-13 16:41:28 +02:00
Elias Naur 1b944c8e65 app/internal/d3d11: tolerate padded row pitches from D3DDeviceContext::Map
Fixes gio#136 (I think)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-13 11:46:20 +02:00
Elias Naur 6d5fbcba3f app/internal/window: [Android] unregister focus listener on destroy
Updates github.com/tailscale/tailscale/issues/431

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-11 15:39:33 +02:00
Elias Naur 6380baacb6 all: move Now from system.Config to system.FrameEvent
Then, make layout.Context.Now a field, copied from FrameEvent.Now.

API change:

	gofmt -r 'gtx.Now() -> gtx.Now'

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-09 23:23:08 +02:00
Elias Naur 6f15275e22 app/internal/window: [macOS] retain NSWindow instance
Updates (maybe fixes) #130

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-08 17:54:44 +02:00
Elias Naur 98a603aed6 app/internal/window: [macOS] don't set callbacks before window is ready
Updates gio#130

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-08 16:34:10 +02:00
Elias Naur 504664e014 gpu: saturate instead of overflowing depth buffer
Use greater-than-or-equal test and saturate the z depth buffer
when more than 65k objects are drawn.

Fixes gio#127

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-08 16:28:56 +02:00
Elias Naur 64a516d7c9 app/internal/window: [Windows] avoid race between Main and window closes
While here, replace the window hwnd-to-window map with a sync.Map.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-08 11:39:40 +02:00
Elias Naur d86f96503f app/internal/window: [macOS] fix window sizes for unit.Px values
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 17:49:59 +02:00
Elias Naur f710bdf8e8 app: update NewWindow docs to reflect multi-window support
Fixes gio#19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 16:31:06 +02:00
Elias Naur c2c31a4d00 app/internal/window: [Windows] support multiple windows
Updates gio#19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 16:27:43 +02:00
Elias Naur 65078cdece app/internal/window: [macOS] simplify NewWindow
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 14:48:54 +02:00
Elias Naur 483084f4be app/internal/window: [macOS] delay window creation until ready
Fixes #128

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 08:42:36 +02:00
Elias Naur 144a5a9cf5 app/internal/window: [macOS] introduce serious cascading
This time without arbitrary offsets and with support for multiple
windows.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-06 19:27:25 +02:00
Elias Naur 4408c2a695 app/internal/window: [macOS] support more than one window
Updates #19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-06 19:09:02 +02:00
Elias Naur 476bf8d263 app/internal/window: [macOS] only terminate app when last window closes
Updates #19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 12:10:23 +02:00
Elias Naur 9efdc3409c app/internal/window: [macOS] remove window reference from app delegate
Updates #19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 12:10:23 +02:00
Elias Naur 7c22a888b1 app/internal/window: [macOS] make GioDelegate window-independent
Updates #19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 12:10:23 +02:00
Elias Naur 34c212d152 app/internal/window: [macOS] split out gio_createWindow
Updates #19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 12:10:23 +02:00
Elias Naur 2accb88381 app/internal/window: [macOS] fix zero-length clipboard reads
Fixes #126

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 10:09:17 +02:00
Elias Naur 278e9bc334 app/internal/window: [macOS] remove useless retain/release
The window and its view is guaranteed to outlast the display link.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-03 21:20:06 +02:00
Elias Naur c225daa845 app/internal/window: [macOS] use regular map for view-to-window lookups
All accesses to the view map now happens on the main thread, so
there is no need for a sync.Map anymore.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-03 21:20:02 +02:00
Elias Naur cb5cc02560 app/internal/window: [macOS] remove frivolous cascadeTopLeftFromPoint call
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-03 19:13:06 +02:00