forked from joejulian/gio
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>
This commit is contained in:
+2
-2
@@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"gioui.org/app/internal/window"
|
||||
"gioui.org/app/internal/wm"
|
||||
)
|
||||
|
||||
// extraArgs contains extra arguments to append to
|
||||
@@ -44,5 +44,5 @@ func DataDir() (string, error) {
|
||||
// require control of the main thread of the program for
|
||||
// running windows.
|
||||
func Main() {
|
||||
window.Main()
|
||||
wm.Main()
|
||||
}
|
||||
|
||||
+4
-4
@@ -3,18 +3,18 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"gioui.org/app/internal/window"
|
||||
"gioui.org/app/internal/wm"
|
||||
)
|
||||
|
||||
type ViewEvent = window.ViewEvent
|
||||
type ViewEvent = wm.ViewEvent
|
||||
|
||||
// JavaVM returns the global JNI JavaVM.
|
||||
func JavaVM() uintptr {
|
||||
return window.JavaVM()
|
||||
return wm.JavaVM()
|
||||
}
|
||||
|
||||
// AppContext returns the global Application context as a JNI
|
||||
// jobject.
|
||||
func AppContext() uintptr {
|
||||
return window.AppContext()
|
||||
return wm.AppContext()
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"gioui.org/app/internal/window"
|
||||
"gioui.org/app/internal/wm"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -21,7 +21,7 @@ var (
|
||||
|
||||
func dataDir() (string, error) {
|
||||
dataDirOnce.Do(func() {
|
||||
dataPath = window.GetDataDir()
|
||||
dataPath = wm.GetDataDir()
|
||||
// Set XDG_CACHE_HOME to make os.UserCacheDir work.
|
||||
if _, exists := os.LookupEnv("XDG_CACHE_HOME"); !exists {
|
||||
cachePath := filepath.Join(dataPath, "cache")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
/*
|
||||
#include <EGL/egl.h>
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// +build linux,!android,!nowayland freebsd
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"gioui.org/internal/egl"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// +build linux,!android,!nox11 freebsd openbsd
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// +build darwin,ios
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
/*
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// +build darwin,!ios
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"gioui.org/gpu"
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -Werror
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
/*
|
||||
#include <Foundation/Foundation.h>
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// +build darwin,ios
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -DGLES_SILENCE_DEPRECATION -Werror -Wno-deprecated-declarations -fmodules -fobjc-arc -x objective-c
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"image"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// +build darwin,!ios
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// +build linux,!android freebsd openbsd
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// +build linux,!android,!nowayland freebsd
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// +build linux,!android,!nox11 freebsd openbsd
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
/*
|
||||
#cgo openbsd CFLAGS: -I/usr/X11R6/include -I/usr/local/include
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// +build android darwin,ios
|
||||
|
||||
package window
|
||||
package wm
|
||||
|
||||
// Android only supports non-Java programs as c-shared libraries.
|
||||
// Unfortunately, Go does not run a program's main function in
|
||||
@@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
// Package window implements platform specific windows
|
||||
// package wm implements platform specific windows
|
||||
// and GPU contexts.
|
||||
package window
|
||||
package wm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
+3
-3
@@ -7,7 +7,7 @@ import (
|
||||
"image/color"
|
||||
"runtime"
|
||||
|
||||
"gioui.org/app/internal/window"
|
||||
"gioui.org/app/internal/wm"
|
||||
"gioui.org/gpu"
|
||||
"gioui.org/op"
|
||||
)
|
||||
@@ -36,7 +36,7 @@ type frameResult struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func newLoop(ctx window.Context) (*renderLoop, error) {
|
||||
func newLoop(ctx wm.Context) (*renderLoop, error) {
|
||||
l := &renderLoop{
|
||||
frames: make(chan frame),
|
||||
results: make(chan frameResult),
|
||||
@@ -54,7 +54,7 @@ func newLoop(ctx window.Context) (*renderLoop, error) {
|
||||
return l, nil
|
||||
}
|
||||
|
||||
func (l *renderLoop) renderLoop(ctx window.Context) error {
|
||||
func (l *renderLoop) renderLoop(ctx wm.Context) error {
|
||||
// GL Operations must happen on a single OS thread, so
|
||||
// pass initialization result through a channel.
|
||||
initErr := make(chan error)
|
||||
|
||||
+25
-25
@@ -8,7 +8,6 @@ import (
|
||||
"image"
|
||||
"time"
|
||||
|
||||
"gioui.org/app/internal/window"
|
||||
"gioui.org/io/event"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/io/profile"
|
||||
@@ -18,15 +17,16 @@ import (
|
||||
"gioui.org/unit"
|
||||
|
||||
_ "gioui.org/app/internal/log"
|
||||
"gioui.org/app/internal/wm"
|
||||
)
|
||||
|
||||
// WindowOption configures a Window.
|
||||
type Option func(opts *window.Options)
|
||||
// WindowOption configures a wm.
|
||||
type Option func(opts *wm.Options)
|
||||
|
||||
// Window represents an operating system window.
|
||||
// Window represents an operating system wm.
|
||||
type Window struct {
|
||||
driver window.Driver
|
||||
ctx window.Context
|
||||
driver wm.Driver
|
||||
ctx wm.Context
|
||||
loop *renderLoop
|
||||
|
||||
// driverFuncs is a channel of functions to run when
|
||||
@@ -65,9 +65,9 @@ type queue struct {
|
||||
}
|
||||
|
||||
// driverEvent is sent when a new native driver
|
||||
// is available for the Window.
|
||||
// is available for the wm.
|
||||
type driverEvent struct {
|
||||
driver window.Driver
|
||||
driver wm.Driver
|
||||
}
|
||||
|
||||
// Pre-allocate the ack event to avoid garbage.
|
||||
@@ -84,7 +84,7 @@ var ackEvent event.Event
|
||||
// Calling NewWindow more than once is not supported on
|
||||
// iOS, Android, WebAssembly.
|
||||
func NewWindow(options ...Option) *Window {
|
||||
opts := &window.Options{
|
||||
opts := &wm.Options{
|
||||
Width: unit.Dp(800),
|
||||
Height: unit.Dp(600),
|
||||
Title: "Gio",
|
||||
@@ -114,7 +114,7 @@ func (w *Window) Events() <-chan event.Event {
|
||||
return w.out
|
||||
}
|
||||
|
||||
// update updates the Window. Paint operations updates the
|
||||
// update updates the wm. Paint operations updates the
|
||||
// window contents, input operations declare input handlers,
|
||||
// and so on. The supplied operations list completely replaces
|
||||
// the window state from previous calls.
|
||||
@@ -128,7 +128,7 @@ func (w *Window) validateAndProcess(frameStart time.Time, size image.Point, sync
|
||||
if w.loop != nil {
|
||||
if err := w.loop.Flush(); err != nil {
|
||||
w.destroyGPU()
|
||||
if err == window.ErrDeviceLost {
|
||||
if err == wm.ErrDeviceLost {
|
||||
continue
|
||||
}
|
||||
return err
|
||||
@@ -150,7 +150,7 @@ func (w *Window) validateAndProcess(frameStart time.Time, size image.Point, sync
|
||||
if sync {
|
||||
if err := w.loop.Flush(); err != nil {
|
||||
w.destroyGPU()
|
||||
if err == window.ErrDeviceLost {
|
||||
if err == wm.ErrDeviceLost {
|
||||
continue
|
||||
}
|
||||
return err
|
||||
@@ -235,7 +235,7 @@ func (w *Window) SetCursorName(name pointer.CursorName) {
|
||||
})
|
||||
}
|
||||
|
||||
// Close the window. The window's event loop should exit when it receives
|
||||
// Close the wm. The window's event loop should exit when it receives
|
||||
// system.DestroyEvent.
|
||||
//
|
||||
// Currently, only macOS, Windows and X11 drivers implement this functionality,
|
||||
@@ -281,7 +281,7 @@ func (w *Window) setNextFrame(at time.Time) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *callbacks) SetDriver(d window.Driver) {
|
||||
func (c *callbacks) SetDriver(d wm.Driver) {
|
||||
c.Event(driverEvent{d})
|
||||
}
|
||||
|
||||
@@ -341,10 +341,10 @@ func (w *Window) waitFrame() (*op.Ops, bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *Window) run(opts *window.Options) {
|
||||
func (w *Window) run(opts *wm.Options) {
|
||||
defer close(w.in)
|
||||
defer close(w.out)
|
||||
if err := window.NewWindow(&w.callbacks, opts); err != nil {
|
||||
if err := wm.NewWindow(&w.callbacks, opts); err != nil {
|
||||
w.out <- system.DestroyEvent{Err: err}
|
||||
return
|
||||
}
|
||||
@@ -380,7 +380,7 @@ func (w *Window) run(opts *window.Options) {
|
||||
w.updateAnimation()
|
||||
w.out <- e
|
||||
w.waitAck()
|
||||
case window.FrameEvent:
|
||||
case wm.FrameEvent:
|
||||
if e2.Size == (image.Point{}) {
|
||||
panic(errors.New("internal error: zero-sized Draw"))
|
||||
}
|
||||
@@ -444,14 +444,14 @@ func (q *queue) Events(k event.Tag) []event.Event {
|
||||
return q.q.Events(k)
|
||||
}
|
||||
|
||||
// Title sets the title of the window.
|
||||
// Title sets the title of the wm.
|
||||
func Title(t string) Option {
|
||||
return func(opts *window.Options) {
|
||||
return func(opts *wm.Options) {
|
||||
opts.Title = t
|
||||
}
|
||||
}
|
||||
|
||||
// Size sets the size of the window.
|
||||
// Size sets the size of the wm.
|
||||
func Size(w, h unit.Value) Option {
|
||||
if w.V <= 0 {
|
||||
panic("width must be larger than or equal to 0")
|
||||
@@ -459,13 +459,13 @@ func Size(w, h unit.Value) Option {
|
||||
if h.V <= 0 {
|
||||
panic("height must be larger than or equal to 0")
|
||||
}
|
||||
return func(opts *window.Options) {
|
||||
return func(opts *wm.Options) {
|
||||
opts.Width = w
|
||||
opts.Height = h
|
||||
}
|
||||
}
|
||||
|
||||
// MaxSize sets the maximum size of the window.
|
||||
// MaxSize sets the maximum size of the wm.
|
||||
func MaxSize(w, h unit.Value) Option {
|
||||
if w.V <= 0 {
|
||||
panic("width must be larger than or equal to 0")
|
||||
@@ -473,13 +473,13 @@ func MaxSize(w, h unit.Value) Option {
|
||||
if h.V <= 0 {
|
||||
panic("height must be larger than or equal to 0")
|
||||
}
|
||||
return func(opts *window.Options) {
|
||||
return func(opts *wm.Options) {
|
||||
opts.MaxWidth = w
|
||||
opts.MaxHeight = h
|
||||
}
|
||||
}
|
||||
|
||||
// MinSize sets the minimum size of the window.
|
||||
// MinSize sets the minimum size of the wm.
|
||||
func MinSize(w, h unit.Value) Option {
|
||||
if w.V <= 0 {
|
||||
panic("width must be larger than or equal to 0")
|
||||
@@ -487,7 +487,7 @@ func MinSize(w, h unit.Value) Option {
|
||||
if h.V <= 0 {
|
||||
panic("height must be larger than or equal to 0")
|
||||
}
|
||||
return func(opts *window.Options) {
|
||||
return func(opts *wm.Options) {
|
||||
opts.MinWidth = w
|
||||
opts.MinHeight = h
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ module gioui.org/cmd
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
gioui.org v0.0.0-20210225120118-f6fba7388544
|
||||
gioui.org v0.0.0-20210306132744-26d9e7fe5f05
|
||||
github.com/akavel/rsrc v0.10.1
|
||||
github.com/chromedp/cdproto v0.0.0-20191114225735-6626966fbae4
|
||||
github.com/chromedp/chromedp v0.5.2
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
gioui.org v0.0.0-20210225120118-f6fba7388544 h1:xQePGQEyaupU5lfPe3//VUVZLXNsjALGAppEVAEzRh8=
|
||||
gioui.org v0.0.0-20210225120118-f6fba7388544/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
|
||||
gioui.org v0.0.0-20210306132744-26d9e7fe5f05 h1:I/+JE+nIf5DjrJnkhtURZEfW3Yym0Uy3+zhKrnliYLM=
|
||||
gioui.org v0.0.0-20210306132744-26d9e7fe5f05/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/akavel/rsrc v0.10.1 h1:hCCPImjmFKVNGpeLZyTDRHEFC283DzyTXTo0cO0Rq9o=
|
||||
github.com/akavel/rsrc v0.10.1/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
|
||||
@@ -37,8 +37,8 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSfrPzImPoVxuomtbT2nk=
|
||||
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210304124612-50617c2ba197 h1:7+SpRyhoo46QjKkYInQXpcfxx3TYFEYkn131lwGE9/0=
|
||||
golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e h1:1xWUkZQQ9Z9UuZgNaIR6OQOE7rUFglXUUBZlO+dGg6I=
|
||||
|
||||
@@ -223,7 +223,7 @@ func compileAndroid(tmpDir string, tools *androidTools, bi *buildInfo) (err erro
|
||||
return err
|
||||
})
|
||||
}
|
||||
appDir, err := runCmd(exec.Command("go", "list", "-f", "{{.Dir}}", "gioui.org/app/internal/window"))
|
||||
appDir, err := runCmd(exec.Command("go", "list", "-f", "{{.Dir}}", "gioui.org/app/internal/wm"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ func archiveIOS(tmpDir, target, frameworkRoot string, bi *buildInfo) error {
|
||||
if _, err := runCmd(lipo); err != nil {
|
||||
return err
|
||||
}
|
||||
appDir, err := runCmd(exec.Command("go", "list", "-f", "{{.Dir}}", "gioui.org/app/internal/window"))
|
||||
appDir, err := runCmd(exec.Command("go", "list", "-f", "{{.Dir}}", "gioui.org/app/internal/wm"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user