mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
Compare commits
6 Commits
v0.10.0
...
a8fe27488f
| Author | SHA1 | Date | |
|---|---|---|---|
| a8fe27488f | |||
| 06307313cd | |||
| 15335a2b37 | |||
| acf5635575 | |||
| caccb608a5 | |||
| d52632b475 |
+28
-30
@@ -369,8 +369,7 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
|
|||||||
w.update()
|
w.update()
|
||||||
case windows.WM_WINDOWPOSCHANGED:
|
case windows.WM_WINDOWPOSCHANGED:
|
||||||
w.update()
|
w.update()
|
||||||
case windows.WM_SIZE:
|
return 0
|
||||||
w.update()
|
|
||||||
case windows.WM_GETMINMAXINFO:
|
case windows.WM_GETMINMAXINFO:
|
||||||
mm := (*windows.MinMaxInfo)(unsafe.Pointer(lParam))
|
mm := (*windows.MinMaxInfo)(unsafe.Pointer(lParam))
|
||||||
|
|
||||||
@@ -413,6 +412,7 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
|
|||||||
icaret := image.Pt(int(caret.X+.5), int(caret.Y+.5))
|
icaret := image.Pt(int(caret.X+.5), int(caret.Y+.5))
|
||||||
windows.ImmSetCompositionWindow(imc, icaret.X, icaret.Y)
|
windows.ImmSetCompositionWindow(imc, icaret.X, icaret.Y)
|
||||||
windows.ImmSetCandidateWindow(imc, icaret.X, icaret.Y)
|
windows.ImmSetCandidateWindow(imc, icaret.X, icaret.Y)
|
||||||
|
return windows.TRUE
|
||||||
case windows.WM_IME_COMPOSITION:
|
case windows.WM_IME_COMPOSITION:
|
||||||
imc := windows.ImmGetContext(w.hwnd)
|
imc := windows.ImmGetContext(w.hwnd)
|
||||||
if imc == 0 {
|
if imc == 0 {
|
||||||
@@ -495,34 +495,32 @@ func getModifiers() key.Modifiers {
|
|||||||
// hitTest returns the non-client area hit by the point, needed to
|
// hitTest returns the non-client area hit by the point, needed to
|
||||||
// process WM_NCHITTEST.
|
// process WM_NCHITTEST.
|
||||||
func (w *window) hitTest(x, y int) uintptr {
|
func (w *window) hitTest(x, y int) uintptr {
|
||||||
if w.config.Mode != Windowed {
|
if w.config.Mode == Windowed {
|
||||||
// Only windowed mode should allow resizing.
|
// Check for resize handle before system actions; otherwise it can be impossible to
|
||||||
return windows.HTCLIENT
|
// resize a custom-decorations window when the system move area is flush with the
|
||||||
}
|
// edge of the window.
|
||||||
// Check for resize handle before system actions; otherwise it can be impossible to
|
top := y <= w.borderSize.Y
|
||||||
// resize a custom-decorations window when the system move area is flush with the
|
bottom := y >= w.config.Size.Y-w.borderSize.Y
|
||||||
// edge of the window.
|
left := x <= w.borderSize.X
|
||||||
top := y <= w.borderSize.Y
|
right := x >= w.config.Size.X-w.borderSize.X
|
||||||
bottom := y >= w.config.Size.Y-w.borderSize.Y
|
switch {
|
||||||
left := x <= w.borderSize.X
|
case top && left:
|
||||||
right := x >= w.config.Size.X-w.borderSize.X
|
return windows.HTTOPLEFT
|
||||||
switch {
|
case top && right:
|
||||||
case top && left:
|
return windows.HTTOPRIGHT
|
||||||
return windows.HTTOPLEFT
|
case bottom && left:
|
||||||
case top && right:
|
return windows.HTBOTTOMLEFT
|
||||||
return windows.HTTOPRIGHT
|
case bottom && right:
|
||||||
case bottom && left:
|
return windows.HTBOTTOMRIGHT
|
||||||
return windows.HTBOTTOMLEFT
|
case top:
|
||||||
case bottom && right:
|
return windows.HTTOP
|
||||||
return windows.HTBOTTOMRIGHT
|
case bottom:
|
||||||
case top:
|
return windows.HTBOTTOM
|
||||||
return windows.HTTOP
|
case left:
|
||||||
case bottom:
|
return windows.HTLEFT
|
||||||
return windows.HTBOTTOM
|
case right:
|
||||||
case left:
|
return windows.HTRIGHT
|
||||||
return windows.HTLEFT
|
}
|
||||||
case right:
|
|
||||||
return windows.HTRIGHT
|
|
||||||
}
|
}
|
||||||
p := f32.Pt(float32(x), float32(y))
|
p := f32.Pt(float32(x), float32(y))
|
||||||
if a, ok := w.w.ActionAt(p); ok && a == system.ActionMove {
|
if a, ok := w.w.ActionAt(p); ok && a == system.ActionMove {
|
||||||
|
|||||||
@@ -41,14 +41,10 @@ var (
|
|||||||
_eglWaitClient *syscall.Proc
|
_eglWaitClient *syscall.Proc
|
||||||
)
|
)
|
||||||
|
|
||||||
var loadOnce sync.Once
|
var loadOnce = sync.OnceValue(loadDLLs)
|
||||||
|
|
||||||
func loadEGL() error {
|
func loadEGL() error {
|
||||||
var err error
|
return loadOnce()
|
||||||
loadOnce.Do(func() {
|
|
||||||
err = loadDLLs()
|
|
||||||
})
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadDLLs() error {
|
func loadDLLs() error {
|
||||||
|
|||||||
+3
-1
@@ -760,6 +760,8 @@ func (q *pointerQueue) Push(handlers map[event.Tag]*handler, state pointerState,
|
|||||||
if p.pressed {
|
if p.pressed {
|
||||||
p, evts = q.deliverDragEvent(handlers, p, evts)
|
p, evts = q.deliverDragEvent(handlers, p, evts)
|
||||||
}
|
}
|
||||||
|
case pointer.Leave:
|
||||||
|
p, evts, state.cursor, _ = q.deliverEnterLeaveEvents(handlers, state.cursor, p, evts, e)
|
||||||
case pointer.Release:
|
case pointer.Release:
|
||||||
evts = q.deliverEvent(handlers, p, evts, e)
|
evts = q.deliverEvent(handlers, p, evts, e)
|
||||||
p.pressed = false
|
p.pressed = false
|
||||||
@@ -823,7 +825,7 @@ func (q *pointerQueue) deliverEvent(handlers map[event.Tag]*handler, p pointerIn
|
|||||||
func (q *pointerQueue) deliverEnterLeaveEvents(handlers map[event.Tag]*handler, cursor pointer.Cursor, p pointerInfo, evts []taggedEvent, e pointer.Event) (pointerInfo, []taggedEvent, pointer.Cursor, bool) {
|
func (q *pointerQueue) deliverEnterLeaveEvents(handlers map[event.Tag]*handler, cursor pointer.Cursor, p pointerInfo, evts []taggedEvent, e pointer.Event) (pointerInfo, []taggedEvent, pointer.Cursor, bool) {
|
||||||
changed := false
|
changed := false
|
||||||
var hits []event.Tag
|
var hits []event.Tag
|
||||||
if e.Source != pointer.Mouse && !p.pressed && e.Kind != pointer.Press {
|
if e.Kind == pointer.Leave || e.Source != pointer.Mouse && !p.pressed && e.Kind != pointer.Press {
|
||||||
// Consider non-mouse pointers leaving when they're released.
|
// Consider non-mouse pointers leaving when they're released.
|
||||||
} else {
|
} else {
|
||||||
var transSrc *pointerFilter
|
var transSrc *pointerFilter
|
||||||
|
|||||||
@@ -255,6 +255,45 @@ func TestPointerMove(t *testing.T) {
|
|||||||
assertEventPointerTypeSequence(t, events(&r, -1, filter(handler2)), pointer.Enter, pointer.Move, pointer.Leave, pointer.Cancel)
|
assertEventPointerTypeSequence(t, events(&r, -1, filter(handler2)), pointer.Enter, pointer.Move, pointer.Leave, pointer.Cancel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPointerLeave(t *testing.T) {
|
||||||
|
handler := new(int)
|
||||||
|
var ops op.Ops
|
||||||
|
|
||||||
|
filter := pointer.Filter{
|
||||||
|
Target: handler,
|
||||||
|
Kinds: pointer.Move | pointer.Enter | pointer.Leave | pointer.Cancel,
|
||||||
|
}
|
||||||
|
defer clip.Rect(image.Rect(0, 0, 100, 100)).Push(&ops).Pop()
|
||||||
|
event.Op(&ops, handler)
|
||||||
|
|
||||||
|
var r Router
|
||||||
|
events(&r, -1, filter)
|
||||||
|
r.Frame(&ops)
|
||||||
|
r.Queue(
|
||||||
|
pointer.Event{
|
||||||
|
Kind: pointer.Move,
|
||||||
|
Source: pointer.Mouse,
|
||||||
|
PointerID: 1,
|
||||||
|
Position: f32.Pt(50, 50),
|
||||||
|
},
|
||||||
|
pointer.Event{
|
||||||
|
Kind: pointer.Leave,
|
||||||
|
Source: pointer.Mouse,
|
||||||
|
PointerID: 1,
|
||||||
|
Position: f32.Pt(50, 50),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assertEventPointerTypeSequence(t, events(&r, -1, filter), pointer.Enter, pointer.Move, pointer.Leave)
|
||||||
|
|
||||||
|
r.Queue(pointer.Event{
|
||||||
|
Kind: pointer.Move,
|
||||||
|
Source: pointer.Mouse,
|
||||||
|
PointerID: 1,
|
||||||
|
Position: f32.Pt(50, 50),
|
||||||
|
})
|
||||||
|
assertEventPointerTypeSequence(t, events(&r, -1, filter), pointer.Enter, pointer.Move)
|
||||||
|
}
|
||||||
|
|
||||||
func TestPointerTypes(t *testing.T) {
|
func TestPointerTypes(t *testing.T) {
|
||||||
handler := new(int)
|
handler := new(int)
|
||||||
var ops op.Ops
|
var ops op.Ops
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"image/color"
|
"image/color"
|
||||||
|
|
||||||
"gioui.org/f32"
|
"gioui.org/f32"
|
||||||
"gioui.org/io/semantic"
|
|
||||||
"gioui.org/io/system"
|
"gioui.org/io/system"
|
||||||
"gioui.org/layout"
|
"gioui.org/layout"
|
||||||
"gioui.org/op"
|
"gioui.org/op"
|
||||||
@@ -86,21 +85,10 @@ func (d DecorationsStyle) layoutDecorations(gtx layout.Context) layout.Dimension
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
cl := d.Decorations.Clickable(a)
|
cl := d.Decorations.Clickable(a)
|
||||||
dims := cl.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
dims := Clickable(gtx, cl, func(gtx layout.Context) layout.Dimensions {
|
||||||
semantic.Button.Add(gtx.Ops)
|
system.ActionInputOp(a).Add(gtx.Ops)
|
||||||
return layout.Background{}.Layout(gtx,
|
paint.ColorOp{Color: d.Foreground}.Add(gtx.Ops)
|
||||||
func(gtx layout.Context) layout.Dimensions {
|
return inset.Layout(gtx, w)
|
||||||
defer clip.Rect{Max: gtx.Constraints.Min}.Push(gtx.Ops).Pop()
|
|
||||||
for _, c := range cl.History() {
|
|
||||||
drawInk(gtx, c)
|
|
||||||
}
|
|
||||||
return layout.Dimensions{Size: gtx.Constraints.Min}
|
|
||||||
},
|
|
||||||
func(gtx layout.Context) layout.Dimensions {
|
|
||||||
paint.ColorOp{Color: d.Foreground}.Add(gtx.Ops)
|
|
||||||
return inset.Layout(gtx, w)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
size.X += dims.Size.X
|
size.X += dims.Size.X
|
||||||
if size.Y < dims.Size.Y {
|
if size.Y < dims.Size.Y {
|
||||||
|
|||||||
Reference in New Issue
Block a user