mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
Compare commits
5 Commits
v0.10.0
...
0bf9626a58
| Author | SHA1 | Date | |
|---|---|---|---|
| 0bf9626a58 | |||
| 15335a2b37 | |||
| acf5635575 | |||
| caccb608a5 | |||
| d52632b475 |
+27
-30
@@ -369,8 +369,7 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
|
||||
w.update()
|
||||
case windows.WM_WINDOWPOSCHANGED:
|
||||
w.update()
|
||||
case windows.WM_SIZE:
|
||||
w.update()
|
||||
return 0
|
||||
case windows.WM_GETMINMAXINFO:
|
||||
mm := (*windows.MinMaxInfo)(unsafe.Pointer(lParam))
|
||||
|
||||
@@ -495,34 +494,32 @@ func getModifiers() key.Modifiers {
|
||||
// hitTest returns the non-client area hit by the point, needed to
|
||||
// process WM_NCHITTEST.
|
||||
func (w *window) hitTest(x, y int) uintptr {
|
||||
if w.config.Mode != Windowed {
|
||||
// Only windowed mode should allow resizing.
|
||||
return windows.HTCLIENT
|
||||
}
|
||||
// Check for resize handle before system actions; otherwise it can be impossible to
|
||||
// resize a custom-decorations window when the system move area is flush with the
|
||||
// edge of the window.
|
||||
top := y <= w.borderSize.Y
|
||||
bottom := y >= w.config.Size.Y-w.borderSize.Y
|
||||
left := x <= w.borderSize.X
|
||||
right := x >= w.config.Size.X-w.borderSize.X
|
||||
switch {
|
||||
case top && left:
|
||||
return windows.HTTOPLEFT
|
||||
case top && right:
|
||||
return windows.HTTOPRIGHT
|
||||
case bottom && left:
|
||||
return windows.HTBOTTOMLEFT
|
||||
case bottom && right:
|
||||
return windows.HTBOTTOMRIGHT
|
||||
case top:
|
||||
return windows.HTTOP
|
||||
case bottom:
|
||||
return windows.HTBOTTOM
|
||||
case left:
|
||||
return windows.HTLEFT
|
||||
case right:
|
||||
return windows.HTRIGHT
|
||||
if w.config.Mode == Windowed {
|
||||
// Check for resize handle before system actions; otherwise it can be impossible to
|
||||
// resize a custom-decorations window when the system move area is flush with the
|
||||
// edge of the window.
|
||||
top := y <= w.borderSize.Y
|
||||
bottom := y >= w.config.Size.Y-w.borderSize.Y
|
||||
left := x <= w.borderSize.X
|
||||
right := x >= w.config.Size.X-w.borderSize.X
|
||||
switch {
|
||||
case top && left:
|
||||
return windows.HTTOPLEFT
|
||||
case top && right:
|
||||
return windows.HTTOPRIGHT
|
||||
case bottom && left:
|
||||
return windows.HTBOTTOMLEFT
|
||||
case bottom && right:
|
||||
return windows.HTBOTTOMRIGHT
|
||||
case top:
|
||||
return windows.HTTOP
|
||||
case bottom:
|
||||
return windows.HTBOTTOM
|
||||
case left:
|
||||
return windows.HTLEFT
|
||||
case right:
|
||||
return windows.HTRIGHT
|
||||
}
|
||||
}
|
||||
p := f32.Pt(float32(x), float32(y))
|
||||
if a, ok := w.w.ActionAt(p); ok && a == system.ActionMove {
|
||||
|
||||
@@ -41,14 +41,10 @@ var (
|
||||
_eglWaitClient *syscall.Proc
|
||||
)
|
||||
|
||||
var loadOnce sync.Once
|
||||
var loadOnce = sync.OnceValue(loadDLLs)
|
||||
|
||||
func loadEGL() error {
|
||||
var err error
|
||||
loadOnce.Do(func() {
|
||||
err = loadDLLs()
|
||||
})
|
||||
return err
|
||||
return loadOnce()
|
||||
}
|
||||
|
||||
func loadDLLs() error {
|
||||
|
||||
+3
-1
@@ -760,6 +760,8 @@ func (q *pointerQueue) Push(handlers map[event.Tag]*handler, state pointerState,
|
||||
if p.pressed {
|
||||
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:
|
||||
evts = q.deliverEvent(handlers, p, evts, e)
|
||||
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) {
|
||||
changed := false
|
||||
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.
|
||||
} else {
|
||||
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)
|
||||
}
|
||||
|
||||
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) {
|
||||
handler := new(int)
|
||||
var ops op.Ops
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"image/color"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/io/semantic"
|
||||
"gioui.org/io/system"
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op"
|
||||
@@ -86,21 +85,10 @@ func (d DecorationsStyle) layoutDecorations(gtx layout.Context) layout.Dimension
|
||||
continue
|
||||
}
|
||||
cl := d.Decorations.Clickable(a)
|
||||
dims := cl.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||
semantic.Button.Add(gtx.Ops)
|
||||
return layout.Background{}.Layout(gtx,
|
||||
func(gtx layout.Context) layout.Dimensions {
|
||||
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)
|
||||
},
|
||||
)
|
||||
dims := Clickable(gtx, cl, func(gtx layout.Context) layout.Dimensions {
|
||||
system.ActionInputOp(a).Add(gtx.Ops)
|
||||
paint.ColorOp{Color: d.Foreground}.Add(gtx.Ops)
|
||||
return inset.Layout(gtx, w)
|
||||
})
|
||||
size.X += dims.Size.X
|
||||
if size.Y < dims.Size.Y {
|
||||
|
||||
Reference in New Issue
Block a user