Граф коммитов

332 Коммитов

Автор SHA1 Сообщение Дата
Bryan C. Mills c44159719b shiny/driver/gldriver: explicitly include needed X11 headers
x11.c refers to several types defined in Xlib headers, but did not
include those headers explicitly. As far as I can tell, it assumed
that they are indirectly included via egl.h — but that assumption
empirically does not always hold.

This fixes a build error on my machine. I'm not sure why it hasn't
shown up on the Go dashboard builders.

Change-Id: I70146c68ff7e4d32af63a5aa8d7a8e25445091c5
Reviewed-on: https://go-review.googlesource.com/c/exp/+/359695
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-10-29 17:01:13 +00:00
Nigel Tao 41231fe85c shiny/iconvg: add UpgradeToFileFormatVersion1
The iconvg Go implementation started at golang.org/x/exp/shiny/iconvg in
2016, speaking a file format retroactively named FFV0 (File Format
Version 0). The github.com/google/iconvg/src/go/* packages were created
more recently in 2021 and will speak a revised format, FFV1.

The long term plan is for the github.com/... packages to *only* speak
FFV1. The golang.org/... package (this package) will continue to speak
FFV0 directly and will additionally delegate decoding FFV1 to the
github.com/... packages. FFV0 will be considered a deprecated experiment
(it was marked EXPERIMENTAL ever since its inception). See
https://github.com/google/iconvg/issues/4

This commit, which decodes FFV0 and encodes FFV1, lives in the
golang.org/... packages, since it involves FFV0. Testing it (beyond the
basic consistency checks in upgrade_test.go) lives in the github.com/...
packages, since that involves decoding FFV1. For example, some outputs
of the UpgradeToFileFormatVersion1 function (added by this commit) were
checked in as https://github.com/google/iconvg/commit/c98b08c

Change-Id: Ib5861ae97928cf31faf207b915568532e2624f09
Reviewed-on: https://go-review.googlesource.com/c/exp/+/332989
Trust: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2021-09-03 01:35:09 +00:00
Nigel Tao 9e70acc10e shiny/iconvg: link to the canonical spec
Change-Id: Ib006cf872d79acf785fa5bffde9b8e32bcf5439b
Reviewed-on: https://go-review.googlesource.com/c/exp/+/323550
Reviewed-by: Rob Pike <r@golang.org>
Trust: Nigel Tao <nigeltao@golang.org>
2021-06-02 13:01:15 +00:00
Russ Cox 85be41e450 all: go fmt ./...
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Not strictly necessary but will avoid spurious changes
as files are edited.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: Id0f07c94a24a65e20ea98a91dc18965e17f1b0ff
Reviewed-on: https://go-review.googlesource.com/c/exp/+/294418
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-20 03:29:38 +00:00
Nigel Tao 62dc52270d shiny/iconvg: fix panic for out-of-range colors
Fixes golang/go#39526

Change-Id: I4ab207b24e424e92b2d8af86a64294db94631aa7
Reviewed-on: https://go-review.googlesource.com/c/exp/+/291150
Trust: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-02-12 05:37:07 +00:00
Dmitri Shuralyov eab1b5eb1a shiny/iconvg: add a decode + encode round-trip test
Given we promise deterministic encoding, and decoding is also
(trivially) deterministic, it's viable to add another test to
ensure that decoding and encoding an IconVG file gives us the
same bytes back.

Since the Encoder.HighResolutionCoordinates option is not a
part of the image metadata but needed for this test to work,
obtain it from the filename.

Also remove some comparisons of adj that can never be false
because no value of type uint8 is less than 0.

Change-Id: I356ec01c8dd582aaeff14b39bb0272ca93eb1d2a
Reviewed-on: https://go-review.googlesource.com/c/exp/+/279295
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Trust: Nigel Tao <nigeltao@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2020-12-29 01:16:36 +00:00
Dmitri Shuralyov e89b829e73 shiny/iconvg: make SetEllipticalGradient math deterministic
Add explicit rounding in Encoder.SetEllipticalGradient to disable
fused operations. This allows the TestEncodeElliptical case to pass
on GOARCH=arm64. Otherwise, fused multiply-sub instructions are
used on GOARCH=arm64 (but not GOARCH=amd64), which results in a
slightly different real value being computed for a "Set NREG"
instruction (with a tiny delta of 7.450581e-09), and then
encoded into non-identical bytes:

	 ac            Set NREG[NSEL-4] to a real number
	-00                0
	+03 00 00 b2       -7.450581e-09

Document the IconVG design decision that the encoder aims to
produce byte-identical output on all supported platforms per
suggestion in golang.org/issue/43219#issuecomment-748531069.
This should make it clear for the future—if another similar
problem is detected—that the encoder implementation should
be fixed (rather than relaxing Encode tests to allow for
non-deterministic encoding). It also allows package users
to be aware that the encoder is platform-agnostic and not
have to take additional measures themselves. (If this proves
to be truly unsustainable to maintain, it is still viable to
remove it given the "SUBJECT TO INCOMPATIBLE CHANGES" clause.)

Rename TestRasterizer to TestDecodeAndRasterize since it tests
both decoding and rasterizing. There isn't another test that
tests only the Decode function.

Fix some broken links to the material-design-icons repository.

Fixes golang/go#43219.
Updates golang/go#11811.

Change-Id: I5cf15541a4648e408c9c61689041c678c14441bf
Reviewed-on: https://go-review.googlesource.com/c/exp/+/279294
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2020-12-21 02:59:56 +00:00
Dmitri Shuralyov b63382b4d8 shiny/driver/gldriver: add darwin/arm64 (macOS) support
Remove build constraints for Intel architectures on macOS,
they're not needed. This fixes the build on M1 Macs.

Update to a newer version of the gl package with support
for darwin/arm64 that was added in CL 278779.

Fixes golang/go#43237.

Change-Id: I813d6ec9656463caafcd2daa08986c1bee62433f
Reviewed-on: https://go-review.googlesource.com/c/exp/+/278761
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2020-12-21 02:49:48 +00:00
Dmitri Shuralyov 660891f45e shiny/driver/mtldriver: add darwin/arm64 (macOS) support
The Objective-C BOOL type is defined as a signed char on on Intel-based
Mac computers, but on Apple silicon, it is defined as as a native bool.¹

This makes it hard to write portable Cgo code across darwin/amd64 and
darwin/arm64 ports. So, stop relying on it, and use the bool type from
<stdbool.h> instead.

Update to a newer version of the mtl package with a similar change.

¹ https://developer.apple.com/documentation/apple_silicon/addressing_architectural_differences_in_your_macos_code#3616879

Fixes golang/go#43221.

Change-Id: I63334dc646a8f9b74cd6a969eadf133cdbc84fb7
Reviewed-on: https://go-review.googlesource.com/c/exp/+/279293
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2020-12-21 02:44:58 +00:00
Dmitri Shuralyov 6cc2880d07 shiny/driver/mtldriver: update to GLFW 3.3.2
Update to a newer v3.3/glfw pseudo-version, which uses GLFW 3.3.2.

GLFW 3.3.2 includes a fix for glfw/glfw#1543 (go-gl/glfw#262),
which makes it possible to remove the workaround for it from mtldriver.

However, there is a new regression glfw/glfw#1649 (go-gl/glfw#272).
Fortunately, it's a smaller issue. Add a temporary workaround for it.

Also update comment in two internal packages. The upstream names were
modified in 11308bd612
to match the names used here.

Change-Id: I3199f16890efd539d62d8914b92260f8a614449a
Reviewed-on: https://go-review.googlesource.com/c/exp/+/220639
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
2020-02-24 16:26:31 +00:00
jopbrown 0405dc783f shiny/driver/x11driver: fallback to regular pixmaps if SHM is unavaiable
This PR implement the **TODO** in buffer.go:
```
// TODO: detect if the X11 server or connection cannot support SHM pixmaps,
// and fall back to regular pixmaps.
```
It fixes the issues:
[golang/go#15100](https://github.com/golang/go/issues/15100)
[aarzilli/gdlv#26](https://github.com/aarzilli/gdlv/issues/26)
[aarzilli/gdlv#5](https://github.com/aarzilli/gdlv/issues/5)
[oakmound/shiny#8](https://github.com/oakmound/shiny/issues/8)

@sbinet
@aarzilli
@200sc

Change-Id: I7f157c95928ca5fde015935ea5fe1d1f8b03ea43
GitHub-Last-Rev: 0a5d514a6c
GitHub-Pull-Request: golang/exp#9
Reviewed-on: https://go-review.googlesource.com/c/exp/+/213199
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2020-01-19 23:39:11 +00:00
Green Lightning da58074b42 shiny/driver/internal/win32: handle syskey messages
Under certain circumstances Windows sends `_WM_SYSKEYDOWN` and `_WM_SYSKEYUP` messages instead of `_WM_KEYDOWN` and `_WM_KEYUP` messages.

This handles the `SYSKEY` messages in the same way as the other messages, to be able to forward all key events to the application.

The exact circumstances are when the key is F10 or when the ALT key is currently pressed while another key is pressed. This behavior is documented in the Windows documentation [here](https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-syskeydown).

Fixes golang/go#36213.

Change-Id: I12ef1b45110a2e02ce319b12c1e6d93a011e5fab
GitHub-Last-Rev: 60a04482b2
GitHub-Pull-Request: golang/exp#8
Reviewed-on: https://go-review.googlesource.com/c/exp/+/212403
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-12-27 19:53:50 +00:00
Dmitri Shuralyov 1fea468a75 shiny/driver/gldriver: revert "update the open gl context after making it current"
This reverts CL 154461.

[NSOpenGLContext update] must be called from the main thread if the
context has a view. The makeCurrentContext function is not called from
the main thread, so it is not thread safe to make a direct [ctx update];
call in it. Doing so causes gldriver to crash with a SIGILL signal when
compiled with Xcode 11.1 or newer on macOS Catalina.

Fixes golang/go#35177

Change-Id: I566c9526cddf31ed981312466f8843c2030d6692
Reviewed-on: https://go-review.googlesource.com/c/exp/+/212245
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2019-12-24 04:42:20 +00:00
Dmitri Shuralyov b0642c6635 shiny/driver/mtldriver: select on receiving from newWindowCh
This is a fixup to CL 208877. The intention there was to select
between receiving a value from the newWindowCh or done channels.
Instead, it was receiving only on the newWindowCh channel,
before proceeding to select between sending to newWindowCh
and receiving from done. That means a shiny program that doesn't
open a window could never exit. This change fixes that.

Change-Id: I1c09ea5f7bec6c9714f20428fdd90d1b756f515d
Reviewed-on: https://go-review.googlesource.com/c/exp/+/209257
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-11-29 03:04:59 +00:00
Dmitri Shuralyov 9964a5a804 shiny/driver/mtldriver: update to GLFW v3.3
GLFW v3.2 was old and started generating some warnings on macOS 10.15
Catalina (and warnings get upgraded to errors on builders). Update to
GLFW v3.3 that was recently released to resolve the problem.

There is a small regression affecting the newer version of GLFW that is
being tracked in issues https://github.com/glfw/glfw/issues/1543 and
https://github.com/go-gl/glfw/issues/262. It causes the application to
crash when glfwWaitEvents is called before the first window is opened:

	$ go run -tags='example metal' .../shiny/example/basic
	2019-11-25 22:19:24.715 basic[9412:69556] *** Assertion failure in -[NSApplication run], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1894.10.126/AppKit.subproj/NSApplication.m:3313
	2019-11-25 22:19:24.715 basic[9412:69556] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSApp with wrong _running count'
	*** First throw call stack:
	(
		0   CoreFoundation                      0x00007fff30503f53 __exceptionPreprocess + 250
		1   libobjc.A.dylib                     0x00007fff665c9835 objc_exception_throw + 48
		2   CoreFoundation                      0x00007fff3051f810 +[NSException raise:format:arguments:] + 88
		3   Foundation                          0x00007fff32bff5d1 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
		4   AppKit                              0x00007fff2d657ed3 -[NSApplication run] + 1007
		5   basic                               0x00000000040d473d _glfwPlatformCreateWindow + 77
		6   basic                               0x00000000040cd945 glfwCreateWindow + 485
		7   basic                               0x00000000040da71b _cgo_78603e0816ec_Cfunc_glfwCreateWindow + 43
		8   basic                               0x0000000004058430 runtime.asmcgocall + 112
	)
	libc++abi.dylib: terminating with uncaught exception of type NSException
	SIGABRT: abort
	PC=0x7fff67a7b49a m=0 sigcode=0
	signal arrived during cgo execution
	[...]

Work around it by waiting for the first window open request before
entering the main loop. That way, glfwWaitEvents is not called
before a window has been created, and the crash does not occur.
This temporary workaround can be removed after the bug is fixed.

Fixes golang/go#35766
Updates go-gl/glfw#256
Updates glfw/glfw#1543
Updates go-gl/glfw#262

Change-Id: Ie9b15ab6632af39871d94993a3e3097ea798a7e2
Reviewed-on: https://go-review.googlesource.com/c/exp/+/208877
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-11-27 03:53:08 +00:00
Dmitri Shuralyov 81c71964d7 shiny/driver/mtldriver: add start of a Metal API-based driver
The OpenGL API has been deprecated on macOS as of version 10.14.¹
The replacement for OpenGL on macOS is the Metal API.² This change adds
the start of a Metal API-based shiny driver. It can be activated by
specifying the -tags=metal build tag on macOS 10.13+. For example:

	go run -tags='example metal' golang.org/x/exp/shiny/example/icongallery

The goal of this CL has been to create an MVP. As a result, the focus is
on simplicity and correctness. Performance optimizations can come later.

The Metal API is currently used only to present the final pixels to
the screen. All rendering is performed on the CPU via the image/draw
algorithms (see https://blog.golang.org/go-imagedraw-package).
Future work is to use mtl.Buffer, mtl.Texture, etc., to do more of
the rendering work on the GPU.

From what I've observed so far, the Metal API is looking to be a great
fit for implementing the screen.Screen interface. But we'll learn more
when it's used to a greater extent of its full performance potential.

GLFW v3.2.1 is used for window creation, receiving input events, etc.
Package dmitri.shuralyov.com/gpu/mtl is used for Metal API access.
Helper packages for Apple's Core Animation and AppKit APIs are copied.

References:

¹ https://developer.apple.com/documentation/macos_release_notes/macos_mojave_10_14_release_notes?language=objc#3035786
² https://developer.apple.com/metal/

Change-Id: I0e02d660b776820ca499bfe7d67e47a9866d530c
Reviewed-on: https://go-review.googlesource.com/c/exp/+/171025
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2019-09-19 03:57:09 +00:00
aarzilli ac5d2bfcbf shiny: support AltGr under X11
Supports key combinations involving AltGr.

Change-Id: Ib431d31dad9493b7ced7192e4b5157b6a2dfcd40
Reviewed-on: https://go-review.googlesource.com/c/exp/+/192778
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2019-09-12 06:37:10 +00:00
aarzilli efb12f957e shiny: handle changes to x11 keyboard mapping
Handle MappingNotifyEvent and reload the keyboard configuration as
needed. This will keep the x11 driver updated when the user changes the
keyboard layout (for example with setxkbmap).

Change-Id: I466d9c221f8e742b813634be429df710cb46aaac
Reviewed-on: https://go-review.googlesource.com/c/exp/+/192777
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2019-09-12 06:30:29 +00:00
Bryan C. Mills 63fe5bdad1 shiny/driver/gldriver: fix build with CGO_ENABLED=0
Fixes golang/go#32837

Change-Id: I2787bba8ee35eb150dfb8cfcfb3854b43fe611a4
Reviewed-on: https://go-review.googlesource.com/c/exp/+/192319
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-08-29 15:01:08 +00:00
smasher164 ec7cb31e5a shiny/driver/gldriver: add missing modifier key codes on cocoa
key.ControlRight and kVK_RightCommand were found by looking in
HIToolbox/Events.h as well as experimenting with Karabiner-Elements.

Fixes golang/go#32131.

Change-Id: I90c76a3983109cdc2d0a645d7955b631d94ee2ee
Reviewed-on: https://go-review.googlesource.com/c/exp/+/188378
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2019-07-31 23:59:08 +00:00
aarzilli 0e2d8f6bf8 shiny: handle numpad keys correctly in x11driver
Figure out which modifier is the numlock modifier, use the correct
keysym when the numlock modifier is set and map numpad keysyms to their
runes and key.Codes.

Change-Id: If8bb28cc10564aa0ecaf4a45753993496f288d6e
Reviewed-on: https://go-review.googlesource.com/c/exp/+/175084
Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2019-05-10 05:17:28 +00:00
aarzilli ec0fef3eb6 shiny: handle capslock correctly in x11driver
Turn rune returned by x11key.Lookup to upper case if the capslock bit
is set in the state.

Change-Id: Ie9ad67ce7f80a669cbf34194f563dfb1845efa21
Reviewed-on: https://go-review.googlesource.com/c/exp/+/175083
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2019-05-09 00:56:04 +00:00
aarzilli d394625e5b shiny: map capslock, numlock and help keys in x11driver
Change-Id: I740ea812911755352d0264287512e9b6d6f3d603
Reviewed-on: https://go-review.googlesource.com/c/exp/+/175082
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-05-09 00:54:30 +00:00
aarzilli 199475d767 exp/shiny: support unicode-but-not-ASCII keysyms
Change-Id: I48a6e35693152848ad9cf01b1ef57de09328117c
Reviewed-on: https://go-review.googlesource.com/c/exp/+/171940
Run-TryBot: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2019-04-26 04:52:26 +00:00
Mirko Hansen 7f338f5710 shiny/driver/internal/win32: Close window correctly to be able to re-open one after closing
This is an additional commit to
https://github.com/golang/exp/pull/6
https://go-review.googlesource.com/c/exp/+/171697

I forgot to add the modification of the syscall_windows.go that generates the zsyscall_windows.go. This is the missed change.

Change-Id: Ib22037f5c51d3185dbc88cda12df9c2da55a895b
GitHub-Last-Rev: 393f2689f0
GitHub-Pull-Request: golang/exp#7
Reviewed-on: https://go-review.googlesource.com/c/exp/+/171998
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-13 19:28:49 +00:00
Mirko Hansen 0480eff6dd shiny/driver/internal/win32: Close window correctly to be able to re-open one after closing
Closing and re-opening a window caused an error at RegisterClassW call (class already registered). This fixes the problem by correctly unregistering the class.

Change-Id: Ie6e45354096bc1245776264bec9be0c86f53d79c
GitHub-Last-Rev: 34780c2735
GitHub-Pull-Request: golang/exp#6
Reviewed-on: https://go-review.googlesource.com/c/exp/+/171697
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-11 19:33:53 +00:00
Dmitri Shuralyov 56b785ea58 shiny/driver/gldriver: fix 2 warnings on macOS 10.14
This CL iterates upon CL 171033 and resolves two remaining C compiler
warnings when building on macOS 10.14:

	# golang.org/x/exp/shiny/driver/gldriver
	cocoa.m:63:39: warning: 'NSOpenGLCPSwapInterval' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
	/Applications/Xcode.app/.../NSOpenGL.h:281:39: note: 'NSOpenGLCPSwapInterval' has been explicitly marked deprecated here
	cocoa.m:72:1: warning: method possibly missing a [super prepareOpenGL] call [-Wobjc-missing-super-calls]

NSOpenGLContextParameterSwapInterval is the less-deprecated version of
NSOpenGLCPSwapInterval and respects the GL_SILENCE_DEPRECATION define.
However, we can't use it because it's available only in macOS 10.12+,
but Go currently supports older macOS versions (e.g., Go 1.12 requires
macOS 10.10+). Use a targeted #pragma clang diagnostic ignored instead.

Add a [super prepareOpenGL] call to ScreenGLView.prepareOpenGL method.
I can't quite tell if it was omitted intentionally, but based on its
documentation¹, it seems reasonable to have it. I didn't notice problems
in local testing. If it turns out it shouldn't be there, then it can be
removed in a way that doesn't generate a compiler warning.

¹ https://developer.apple.com/documentation/appkit/nsopenglview/1414940-prepareopengl

Updates golang/go#11811

Change-Id: I10b6522a7af64eadeb6586fad44ef4c1ece40ab2
Reviewed-on: https://go-review.googlesource.com/c/exp/+/171034
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-09 04:48:07 +00:00
Dmitri Shuralyov eba85a11b6 shiny/driver/gldriver: define GL_SILENCE_DEPRECATION
The OpenGL API has been deprecated on macOS as of version 10.14.¹
Building gldriver on macOS 10.14 produces warnings such as:

	# golang.org/x/exp/shiny/driver/gldriver
	cgo-gcc-prolog:117:2: warning: 'glBindVertexArray' is deprecated: first deprecated in macOS 10.14 - OpenGL API deprecated. (Define GL_SILENCE_DEPRECATION to silence these warnings) [-Wdeprecated-declarations]
	/Applications/Xcode.app/.../gl3.h:2360:21: note: 'glBindVertexArray' has been explicitly marked deprecated here
	cocoa.m:35:2: warning: 'NSOpenGLContext' is deprecated: first deprecated in macOS 10.14 - Please use Metal or MetalKit. [-Wdeprecated-declarations]
	/Applications/Xcode.app/.../NSOpenGL.h:202:12: note: 'NSOpenGLContext' has been explicitly marked deprecated here
	...

The package is named gldriver, so it would be too drastic of a change
for it to stop using OpenGL. Also, OpenGL is not deprecated on all
other platforms that package gldriver supports.

Despite being deprecated, OpenGL is not removed from macOS 10.14 at this
time. It's not helpful for the warnings to be shown to users who are
building and using the package on macOS, so, simply acknowledge the
deprecation notice by defining GL_SILENCE_DEPRECATION and silence the
warnings.

It should also help with x/exp builds passing on https://build.golang.org,
because warnings are promoted to errors in trybots (to help catch issues
such as this one).

References:

¹ https://developer.apple.com/documentation/macos_release_notes/macos_mojave_10_14_release_notes?language=objc#3035786

Updates golang/go#11811

Change-Id: Ie86d03a44c3cdb7aca3ff255bbf7a71926d14025
Reviewed-on: https://go-review.googlesource.com/c/exp/+/171033
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-09 01:48:42 +00:00
Elias Naur a1d7652674 shiny/driver/gldriver: skip on GOOS=android
gldriver doesn't build on android.

Change-Id: Ifc5d9e54b196e82cd958e773b93ad01a38f028e4
Reviewed-on: https://go-review.googlesource.com/c/exp/+/165658
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-06 15:27:37 +00:00
Ethan Burns 46ee236611 shiny/driver/gldriver: update the open gl context after making it current
This seems necessary (at least on Mojave). Otherwise, the window seems to have the wrong viewport until it is moved or resized.

Change-Id: I0efd372e875e37056974a9d1ae99ba47896f69d5
GitHub-Last-Rev: bc6b239087
GitHub-Pull-Request: golang/exp#5
Reviewed-on: https://go-review.googlesource.com/c/154461
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2018-12-20 20:31:36 +00:00
Elias Naur e88728d35e exp/shiny: fix usage of TexImage2D after breaking change
CL 133155 adds the internalFormat parameter to TexImage2D. Fix
the two usages of TexImage2D in this repository.

Change-Id: Id529c755f47202d10f8aeec0f85f8f4e0d6fcfd1
Reviewed-on: https://go-review.googlesource.com/133175
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2018-09-07 22:42:06 +00:00
unknown f5f3468356 shiny/driver/internal/win32: send WM_CLOSE on Release
Calling DestroyWindow in Release is not allowed when
running on a different thread than the message pump.
This sends a WM_CLOSE message instead, that is handled by
the message pump itself.

Fixes golang/go#25671

Change-Id: Ie8610a8385faa2746dc7eabac11edc1106e8bb6e
Reviewed-on: https://go-review.googlesource.com/115998
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-04 04:07:59 +00:00
elmar d20ef58a6d shiny: windriver: close client windows
After receiving a close request from the window manager,
DestroyWindow must be called to actually close the window.
This is done by DefWindowProc.

Fixes golang/go#25587

Change-Id: I05c95046ce4572fec0cba67eba2d313f318e36ba
Reviewed-on: https://go-review.googlesource.com/115515
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-31 14:57:32 +00:00
Giovanni Bajo 8460e604b9 exp/shiny: fix a typo that prevented correct rounding
Change-Id: Id1c01d4e4b5c69fde195f1e56ccbd6760a8dbccc
Reviewed-on: https://go-review.googlesource.com/100936
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2018-03-21 21:57:51 +00:00
Bryan C. Mills 83bc9a11ae shiny/driver/internal/event: factor out initalization boilerplate into a method
Change-Id: Ia89c7d9cb122dd33d29d6b443d16b895f021032f
Reviewed-on: https://go-review.googlesource.com/94136
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-14 20:50:18 +00:00
Bryan C. Mills 50a1031d8e shiny/driver/internal/event: do not over-retain references to events
The garbage collector considers slice elements past len to be
reachable, since the slice may be resliced to those elements at any
time. That means that elements past len(q.front) will remain reachable
until the next time len(q.front) again reaches its largest value.

Since we don't actually know when that will occur, nil out consumed
entries to allow their events to be collected as soon as possible.

Change-Id: I7bc914eebfd7dec42933b9fa5ad256d4db3701ab
Reviewed-on: https://go-review.googlesource.com/94135
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-14 20:49:43 +00:00
tomheng 0729911652 shiny/driver: use __MAC_OS_X_VERSION_MAX_ALLOWED for conditional compilation
__MAC_OS_X_VERSION_MAX_ALLOWED is official way to do conditional compilation
according to documentation in: https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/cross_development/Using/using.html#//apple_ref/doc/uid/20002000-SW5

Fixes golang/go#22634

Change-Id: I916403149ed6a1ede5d8dcb554d152784c302fcb
Reviewed-on: https://go-review.googlesource.com/31546
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-12-09 01:20:58 +00:00
Sergiusz Bazanski a05f2c1e93 shiny: add OpenBSD support
We mostly re-use existing X11/Linux or X11/Dragonfly code.

Notes:
 - in OpenBSD, all X11 headers are in /usr/X11R6, thus we need to add this to the linker and include paths
 - in OpenBSD, we seem to need to open MIT-SHM segments with 0666 rights - this could be fixed by passing the SHM segment by file descriptor instead, via X_ShmAttachFd & co.

Change-Id: I2c2d50b5f8d9f1ee2c9c64d131b556d5e337be6f
Reviewed-on: https://go-review.googlesource.com/79917
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-26 19:28:22 +00:00
aarzilli be79676510 shiny/driver/gldriver: disable forced OpenGL acceleration on macOS
Fixes golang/go#19191

Change-Id: I932119963f5ea46166d741c9427a6941ed700ee5
Reviewed-on: https://go-review.googlesource.com/44379
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2017-06-02 04:28:42 +00:00
Alex Brainman cf79bb083a shiny/driver/windriver: fix destination rectangle formula
Fixes golang/go#19902

Change-Id: Iaa1218775830699865dc9c5613abf2e81362ed4d
Reviewed-on: https://go-review.googlesource.com/40891
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2017-04-21 01:47:03 +00:00
Alex Brainman e9c3453fc7 shiny/driver/internal/win32: introduce and use ResizeClientRect
This CL makes screen.NewWindowOptions.Width and
screen.NewWindowOptions.Height parameters of screen.NewWindow
set window's client area of the specified window, instead of
setting dimensions of the bounding rectangle.

Fixes golang/go#19704.

Change-Id: Ic8a819e8127b89cc2734ed26dff6be06d2446ab1
Reviewed-on: https://go-review.googlesource.com/39111
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2017-04-02 07:31:29 +00:00
Nigel Tao 47ce6ee20a shiny/driver/gldriver: be less racy wrt size events.
Set the windowImpl.sz cached value on the receiver side of the channel
communication, not spawned by a goroutine 'soon' after the send.

This CL only affects x11. The same change applies in principle to cocoa
and win32, but I have not (manually) tested it there yet.

Change-Id: Ibe4bad965fe0c059378daef2f535dcae362447a9
Reviewed-on: https://go-review.googlesource.com/37918
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-15 23:27:40 +00:00
Nigel Tao c6698df92a shiny/driver/gldriver: implement Texture.Fill.
Change-Id: I651fc5a8770c6902d89cf01bf445f88afe2c0134
Reviewed-on: https://go-review.googlesource.com/37415
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-10 09:37:14 +00:00
Nigel Tao 397dac334b shiny/driver: s/WM_NAME/_NET_WM_NAME/ for X11.
https://specifications.freedesktop.org/wm-spec/latest/ar01s05.html#idm139870830016992
says that modern window managers should prefer the latter to the former.
The former might also have difficulties with non-ASCII UTF-8.

Also fix a recently introduce build breakage.

Change-Id: Id6da9aa23ad356d7e485925734c28d891be0f2fc
Reviewed-on: https://go-review.googlesource.com/37413
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-02-24 09:13:59 +00:00
Nigel Tao 7c75da1031 shiny/example: add window title strings.
Change-Id: I8f90b4a638a45dc53aab36c66ccca81ce2727acb
Reviewed-on: https://go-review.googlesource.com/37412
Reviewed-by: Fabian Zaremba <fabian@youremail.eu>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-02-24 09:07:49 +00:00
Nigel Tao 8c92c4dca8 shiny/screen: sanitize NewWindowOptions.Title.
Its bytes are passed to C libraries, so we sanitize as a precaution.

Change-Id: I6ecdd5388be40c4067815ba0484112bea6c55270
Reviewed-on: https://go-review.googlesource.com/37414
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-02-24 09:06:53 +00:00
Fabian Zaremba 35a3e9890c shiny: add window title support
Titles are UTF-8 compatible on all platforms; drivers
default to an empty string.

Change-Id: I4cf1a16ceb4e9641b2e1fc78dcff0501aac7dedb
Reviewed-on: https://go-review.googlesource.com/37200
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2017-02-23 23:12:47 +00:00
Dave MacFarlane 1451a5b113 shiny/driver/x11driver: add support for DragonflyBSD
DragonflyBSD supports all the functionality needed, but was excluded
by build tags.

Change-Id: If7fb237ad0b652686f8e32d11fc1f721b455bb91
Reviewed-on: https://go-review.googlesource.com/36475
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-02-07 03:18:45 +00:00
elmar f2073adf91 shiny/driver/internal/win32: use relative coordinates for mouse wheel events
Windows mouse wheel events report the cursor position in
absolute screen coordinates, while other mouse event's positions
are relative to the window.
This adds ScreenToClient to syscall_windows.go and converts the
event's position for mouse wheel events.

Fixes golang/go#18695

Change-Id: Ic086033e435cf4699c7ff0aad90e1a1ce233bb02
Reviewed-on: https://go-review.googlesource.com/35412
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-01-20 06:22:47 +00:00
Nigel Tao f43f8d06a5 shiny/driver/gldriver: initialize glctx fields earlier.
A *windowImpl's glctx and worker fields should really be set on
construction (and never modified afterwards), as fields in the
&windowImpl{ etc } literal during screenImpl.NewWindow. However, the
initialization values are platform specific, so they are initialized in
a separate function call.

Until now, that function call was showWindow, as it is called
conveniently soon after newWindow returns. showWindow's primary purpose
is mostly unrelated: to show the freshly created window on the screen.

Soon isn't soon enough, though. The (implemented in C) message pump
happens in another thread, which can trigger callbacks like onConfigure,
which (racily) reads the w.glctx field with lines like:

w.lifecycler.SendEvent(w, w.glctx)

This commit fixes the race, originally reported at
https://github.com/golang/exp/pull/3

Change-Id: I69d50b037ec4c4f021ca60f570f86723c17d7bb7
Reviewed-on: https://go-review.googlesource.com/34873
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-01-12 00:45:35 +00:00