feat(ports): add data drag and drop messages
- commit
- c2603da68e005266c0838fcbfdd3f8cbf87fedcf
- author
- brice · · 2026-10-17 14:10 UTC
- parent
- 458251f
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +67 -0
A internal/ports/dnd.go +67 -0
| @@ -0,0 +1,67 @@ | |||
| 1 | + | package ports | |
| 2 | + | ||
| 3 | + | import "time" | |
| 4 | + | ||
| 5 | + | // Data drag and drop (wl_data_device.start_drag). Wayland validates the | |
| 6 | + | // client's request and tells core; core owns the pointer during the drag: | |
| 7 | + | // it hit-tests, routes the drag to the surface under the pointer, drops on | |
| 8 | + | // the release and cancels on Escape. Wayland speaks the protocol to the | |
| 9 | + | // source and the targets. The icon is a client surface core draws over | |
| 10 | + | // everything at the cursor. | |
| 11 | + | ||
| 12 | + | // DataDragStarted carries wayland → core a client drag answering the | |
| 13 | + | // client's current press. Icon is the drag icon's ID (0: none); core | |
| 14 | + | // answers with DataDragCancel when it refuses the drag. | |
| 15 | + | type DataDragStarted struct { | |
| 16 | + | Icon WindowID | |
| 17 | + | } | |
| 18 | + | ||
| 19 | + | func (DataDragStarted) clientEvent() {} | |
| 20 | + | ||
| 21 | + | // DataDragIcon carries wayland → core the drag icon's geometry after a | |
| 22 | + | // commit: its top left corner relative to the cursor hotspot, and its | |
| 23 | + | // size, in logical pixels. W or H 0 hides it. | |
| 24 | + | type DataDragIcon struct { | |
| 25 | + | ID WindowID | |
| 26 | + | X, Y, W, H int | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | func (DataDragIcon) clientEvent() {} | |
| 30 | + | ||
| 31 | + | // DataDragEnded carries wayland → core the end of a drag core did not | |
| 32 | + | // end itself: the source died or the drag was cancelled. | |
| 33 | + | type DataDragEnded struct{} | |
| 34 | + | ||
| 35 | + | func (DataDragEnded) clientEvent() {} | |
| 36 | + | ||
| 37 | + | // DataDragFocus carries core → wayland the surface under the pointer | |
| 38 | + | // during a drag (0: none), at surface-local X, Y: the old target gets | |
| 39 | + | // leave, the new one enter with an offer. | |
| 40 | + | type DataDragFocus struct { | |
| 41 | + | ID WindowID | |
| 42 | + | X, Y float64 | |
| 43 | + | Time time.Duration | |
| 44 | + | } | |
| 45 | + | ||
| 46 | + | func (DataDragFocus) clientCommand() {} | |
| 47 | + | ||
| 48 | + | // DataDragMotion carries core → wayland the pointer over the drag target, | |
| 49 | + | // in its surface coordinates. | |
| 50 | + | type DataDragMotion struct { | |
| 51 | + | ID WindowID | |
| 52 | + | X, Y float64 | |
| 53 | + | Time time.Duration | |
| 54 | + | } | |
| 55 | + | ||
| 56 | + | func (DataDragMotion) clientCommand() {} | |
| 57 | + | ||
| 58 | + | // DataDragDrop carries core → wayland the release of the drag button: the | |
| 59 | + | // target gets drop when it accepted the offer, else the drag is cancelled. | |
| 60 | + | type DataDragDrop struct{} | |
| 61 | + | ||
| 62 | + | func (DataDragDrop) clientCommand() {} | |
| 63 | + | ||
| 64 | + | // DataDragCancel carries core → wayland a cancelled or refused drag. | |
| 65 | + | type DataDragCancel struct{} | |
| 66 | + | ||
| 67 | + | func (DataDragCancel) clientCommand() {} | |
| @@ -0,0 +1,67 @@ | |||||
| 1 | + | package ports | |||
| 2 | + | ||||
| 3 | + | import "time" | |||
| 4 | + | ||||
| 5 | + | // Data drag and drop (wl_data_device.start_drag). Wayland validates the | |||
| 6 | + | // client's request and tells core; core owns the pointer during the drag: | |||
| 7 | + | // it hit-tests, routes the drag to the surface under the pointer, drops on | |||
| 8 | + | // the release and cancels on Escape. Wayland speaks the protocol to the | |||
| 9 | + | // source and the targets. The icon is a client surface core draws over | |||
| 10 | + | // everything at the cursor. | |||
| 11 | + | ||||
| 12 | + | // DataDragStarted carries wayland → core a client drag answering the | |||
| 13 | + | // client's current press. Icon is the drag icon's ID (0: none); core | |||
| 14 | + | // answers with DataDragCancel when it refuses the drag. | |||
| 15 | + | type DataDragStarted struct { | |||
| 16 | + | Icon WindowID | |||
| 17 | + | } | |||
| 18 | + | ||||
| 19 | + | func (DataDragStarted) clientEvent() {} | |||
| 20 | + | ||||
| 21 | + | // DataDragIcon carries wayland → core the drag icon's geometry after a | |||
| 22 | + | // commit: its top left corner relative to the cursor hotspot, and its | |||
| 23 | + | // size, in logical pixels. W or H 0 hides it. | |||
| 24 | + | type DataDragIcon struct { | |||
| 25 | + | ID WindowID | |||
| 26 | + | X, Y, W, H int | |||
| 27 | + | } | |||
| 28 | + | ||||
| 29 | + | func (DataDragIcon) clientEvent() {} | |||
| 30 | + | ||||
| 31 | + | // DataDragEnded carries wayland → core the end of a drag core did not | |||
| 32 | + | // end itself: the source died or the drag was cancelled. | |||
| 33 | + | type DataDragEnded struct{} | |||
| 34 | + | ||||
| 35 | + | func (DataDragEnded) clientEvent() {} | |||
| 36 | + | ||||
| 37 | + | // DataDragFocus carries core → wayland the surface under the pointer | |||
| 38 | + | // during a drag (0: none), at surface-local X, Y: the old target gets | |||
| 39 | + | // leave, the new one enter with an offer. | |||
| 40 | + | type DataDragFocus struct { | |||
| 41 | + | ID WindowID | |||
| 42 | + | X, Y float64 | |||
| 43 | + | Time time.Duration | |||
| 44 | + | } | |||
| 45 | + | ||||
| 46 | + | func (DataDragFocus) clientCommand() {} | |||
| 47 | + | ||||
| 48 | + | // DataDragMotion carries core → wayland the pointer over the drag target, | |||
| 49 | + | // in its surface coordinates. | |||
| 50 | + | type DataDragMotion struct { | |||
| 51 | + | ID WindowID | |||
| 52 | + | X, Y float64 | |||
| 53 | + | Time time.Duration | |||
| 54 | + | } | |||
| 55 | + | ||||
| 56 | + | func (DataDragMotion) clientCommand() {} | |||
| 57 | + | ||||
| 58 | + | // DataDragDrop carries core → wayland the release of the drag button: the | |||
| 59 | + | // target gets drop when it accepted the offer, else the drag is cancelled. | |||
| 60 | + | type DataDragDrop struct{} | |||
| 61 | + | ||||
| 62 | + | func (DataDragDrop) clientCommand() {} | |||
| 63 | + | ||||
| 64 | + | // DataDragCancel carries core → wayland a cancelled or refused drag. | |||
| 65 | + | type DataDragCancel struct{} | |||
| 66 | + | ||||
| 67 | + | func (DataDragCancel) clientCommand() {} | |||