Commit Graph

77 Commits

Author SHA1 Message Date
Elias Naur 5cd5d49108 gpu/backend: move backend interface types to a separate package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur cf7d702a39 app/internal/window: remove unsafe cast
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 05485a79a6 app/internal/srgb: rename NewSRGBFBO to New and SRGBFBO to FBO
The srgb package was recently created to contain just the sRGB
emulation, but the names weren't shortened accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 94fdc26cb5 app,app/headless: expose Backends from window and headless contexts
This is a refactoring change to prepare for another gpu.Backend
implementations.

Notably, app/loop.go no longer imports gpu/gl.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:21 +01:00
Elias Naur e3f8d1a1af app/internal/window: (Windows) report pressed buttons for Move events
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-26 10:57:30 +01:00
Roy Lee ae6161dfb6 app/internal/wayland: Added header dir for wayland in openSUSE
Added a cflag -I to provide wayland header files in openSUSE.

Fixes gio#76

Signed-off-by: Roy Lee <royyhlee@gmail.com>
2020-02-16 21:44:29 +01:00
Elias Naur adb950cbf3 app/internal/srgb: move sRGB emulation to new internal package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-10 18:22:58 +01:00
Elias Naur 1f422ef960 all: gofmt
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-08 00:04:15 +01:00
Elias Naur 3b6646933d gpu: expose the rendering implementation
The rendering implementation is needed for using Gio UI with external
window libraries such as GLFW. Expose it in the new package gpu.

Updates #26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 21:21:38 +01:00
Elias Naur 251c075093 app/internal/gl/impl: extract platform dependent opengl bindings
We'd like to support Gio using a different renderer binding than
the builtin. A first step is to define the Functions interface
in package gl, and extract the concrete implementations to a
separate package.

Updates #26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 19:22:30 +01:00
Daniel Martí 54ed198cb0 app: don't discard android touch events of unknown tool type
This is the kind of event one gets when using 'adb shell input tap x y',
which I am trying to use for the end-to-end tests.

Right now, we only have two pointer source types: mouse and touch.
On Android, emulated touch events tend to simulate the touchscreen, not
a mouse, so let's go with that as a fallback.

Perhaps in the future we will have another special pointer source for
this kind of event, such as "unknown" or "virtual".

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-27 11:17:47 +01:00
Aaron Bieber fdaf891732 app: Enable building on OpenBSD
Currently the golang.org/x/sys package is missing the Pipe2 call for OpenBSD.
The call exists on OpenBSD, it just isn't exposed.

This diff was tested buy adding the Pipe2 call and setting:

   go mod edit -replace=golang.org/x/sys=/pat/to/modified/sys

Signed-off-by: Aaron Bieber <aaron@bolddaemon.com>
2020-01-24 14:32:54 +01:00
Elias Naur 95903aafda app/internal/window: add errno to wl_display_connect errors
Updates #40

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-03 11:28:53 +01:00
Elias Naur 06a2228798 app/internal/windows: split out Windows syscalls from package window
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 9b4176c475 app/internal/egl,app/internal/window: move Lock/Unlock methods
EGL contexts don't need locking, so their Lock and Unlock methods
are empty. Remove them and add them where necessary instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur f25f647a66 app/internal/window,app/internal/gl: move gl.Context to package window
Package gl now only defines opengl types and functions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 8cec7d1a40 app/internal/window: move context refresh to window
Instead of calling from the low level context into the window
for its surface and dimensions, add a Context.MakeCurrent method
that does it directly.

The result is simpler and clearer logic. For example, synchronization
is obviously no longer needed. It wasn't necessary before, but the
reason was unclear.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 3199ae7600 app/internal/window: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 99b6ad09e5 app/internal/egl: move EGL interface to its own package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur eb8745eb32 app/internal/window: remove redundant return
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 22:38:38 +01:00
Larry Clapp 0ddcee4ec6 app/internal/windows: modifiers & punctuation hotkeys
For Windows:
- Add shift/ctrl/etc modifiers to mouse events, so you can recognize the
  difference between "click" and "shift-click".
- Add several allowed punctuation characters as single key events, so
  you can (for example) use "." as a hotkey.

Signed-off-by: Larry Clapp <larry@theclapp.org>
2019-11-30 10:31:04 +01:00
Greg Pomerantz 2ca2e5462f app: add RegisterFragment method on *Window for Android
RegisterFragment creates an instance of a Java class and registers
it as a Fragment in the window's Context.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-11-26 18:52:43 +01:00
Elias Naur aca511f849 app/internal/window: (wasm) generate key.Events for all printable characters
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-24 19:41:11 +01:00
Larry Clapp 65bc7be256 app/internal/window: allow punctuation as keycode events
Allows things like "ctrl-{" and ".".

All punctuation is returned as-is, e.g. "!" is "!", not "shift-1", and
"{" is "{", not "shift-[".

Also add the Enter key as a known key (fn-return on my Mac).

Signed-off-by: Larry Clapp <larry@theclapp.org>
2019-11-24 19:41:11 +01:00
Elias Naur d5424ef7fc app/internal/window: replace X11 input handling with xkb
Unifies Wayland and X11 keyboard handling.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-24 19:41:11 +01:00
Elias Naur 72840d7b88 app/internal/window: delete redundant draw on WM_MAXIMIZE, WM_RESTORED
There's always a WM_PAINT after a restore or maximize message.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-20 15:19:26 +00:00
Larry Clapp f8de7545f4 several: add modifiers to mouse events and clicks
macOS only, for the os-specific bits.

Signed-off-by: Larry Clapp <larry@theclapp.org>
2019-11-18 15:38:09 +01:00
Konstantin Kulikov 101b65f4e5 app/internal/window: map window after defining WM protocols
ICCCM 4.1.2 says WMs will examine client properties every time
window is mapped. Because SetWMProtocols is called before MapWindow
some WMs (specifically taowm) never see them.

In other WMs this works because they check for WM_DELETE_WINDOW
when user tries to close window, not when window is mapped.

Signed-off-by: Konstantin Kulikov <k.kulikov2@gmail.com>
2019-11-14 10:56:49 +01:00
Denis Bernard 1bf2c7ef29 app/internal/window: (X11) Add support for UTF-8 window title.
Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-13 00:56:26 +01:00
Denis Bernard 2e0406802b app/internal/window: cleanup X11 initialization
Removed redundant XSelectInput and XChangeWindowAttributes as well as
obsolete screen parameter in x11DetectUIScale.

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-11 13:50:45 +01:00
Elias Naur d8c9cb426c example/gophers: update gio version
gofmt -w -s . as well.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 19:46:10 +01:00
Elias Naur b950aa71e1 app/internal/window: (X11) don't destroy window on EGL destroy
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 18:05:33 +01:00
Elias Naur 0cfcf5ca2d app/internal/window: (X11) implement right and middle mouse buttons
Updates gio#60

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 17:57:20 +01:00
Elias Naur dc7f9bab23 io/pointer,gesture: report right and middle mouse button events
Updates gio#60

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 17:41:39 +01:00
Denis Bernard a0050ab79b app/internal/window: x11: fix issue with space not sending key.EditEvent
This is a general fix where keys with names differing from their UTF8
representation could not be sent as EditEvents.

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-09 16:06:54 +01:00
Elias Naur dca25a7708 app/internal/window: map "Backtab" to Shift-Tab
Updates gio#62

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 15:47:06 +01:00
Elias Naur de7d6b28fa io/key: add support for the Tab and Space keys
Fixes gio#62

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 11:57:36 +01:00
Elias Naur cc43588aba io/key: switch Event.Name to be a string and add function keys
Function keys don't have a natural rune representation so switch
Event.Name to be a string to fit "F1"-"F12".

Fixes gio#59

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 22:20:17 +01:00
Elias Naur c833c98fd7 io/key: add ModAlt, ModSuper
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 18:39:21 +01:00
Elias Naur d293dfe604 key: add ModCtrl, ModShortcut
ModCtrl is the physical Ctrl key, ModShortcut is the virtual
"shortcut" modifier, which is Ctrl on most platforms, Command on
Apple platforms.

Updates #59

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 18:02:26 +01:00
Elias Naur 237a8dad8f app/internal/window: re-create EGL surface on resizing
This is effectively a revert of 60e4cca934, which
seems to have caused flickering problems on some versions of Windows.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 18:34:05 +01:00
Denis Bernard 75a58e42ef app/internal/window: remove direct pointer arithmetic in x11 driver.
Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-07 14:22:47 +01:00
Elias Naur 62da32be9c app/internal/gl: support Go 1.14 change to WebAssembly's js.Value
Gio programs will no longer build with Go 1.13; let's keep it at that
until someone complains.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 17:59:39 +01:00
Elias Naur 7256bdae38 app/internal/windows: don't draw window background on Windows
Avoids flickering between GPU content and the CPU drawn background
color.

gofmt -w -s . now we're here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 17:28:14 +01:00
Elias Naur 9c84b95f7d app/internal/window: specify None as the X11 window background
Avoids flickering on my Fedora 31 Gnome setup.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 17:13:03 +01:00
Elias Naur 0ad9bd9725 app/internal/window: finish GL commands before surface detruction
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 16:11:46 +01:00
Elias Naur 6287c1750f Revert "app/internal/window: finish GL commands before resizing"
This reverts commit 8e874e1afd.

Didn't fix flickering.
2019-11-06 16:09:21 +01:00
Denis Bernard 68063633f2 app/internal/window: Fix keyboard handling on X11
When the control key is pressed, clear event.state bits before calling
Xutf8LookupString in order to get the unmodified key name. This allows
proper handling of all keys in combination with ModCommand.

`key.Event.Name` is however layout dependent. Client code should be
careful about this when picking key shortcuts like CTRL-'+': on a QWERTY
keyboard, only CTRL-'=' and CTRL-SHIFT-'=' are generated when pressing
the '=' key of the top row. The keypad '+' key generates events with
`Name = '+'` as expected.

Fixes gio#57

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-06 15:16:47 +01:00
Elias Naur 8e874e1afd app/internal/window: finish GL commands before resizing
Perhaps fixes flickering during window resize.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 11:23:49 +01:00
Elias Naur ef78ba37f6 app/internal/window: implement GetDpiForMonitor fallback for < Win 8.1
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-05 18:20:36 +01:00