mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user