Repository navigation
Conversation
1. Add a pure Go Wayland client with core bindings and opt-in protocol tracing. 2. Generate Go client bindings from protocol XML and replace output files atomically. 3. Add standalone CMake generation and cover wire interoperability and object lifecycle. Log: Add the Go Wayland client runtime and protocol scanner. Influence: Go clients can connect to Wayland compositors. feat(wayland): 新增 Go 客户端和协议生成器 1. 新增纯 Go Wayland 客户端,提供核心协议绑定和可选的协议日志。 2. 从协议 XML 生成 Go 客户端绑定,并原子替换输出文件。 3. 提供独立的 CMake 生成入口,覆盖协议互通和对象生命周期测试。 Log: 新增 Go Wayland 客户端运行时和协议生成器。 PMS: BUG-377251 Influence: Go 客户端可连接 Wayland 合成器。
Reviewer's GuideData structuresDefine the runtime’s protocol metadata, object and connection state, and wire encoder/decoder data structures that the client and generated bindings rely on.
APIExpose the Go client’s connection, object, dispatch, and wire APIs alongside the core protocol bindings and display helpers that clients call.
ImplementationImplement protocol XML parsing and binding generation, transport and object lifecycle behavior, and opt-in protocol tracing.
ConfigurationRegister the Wayland runtime and scanner in the project build and packaging, and add a standalone CMake entry point for generating protocol bindings.
DocumentationAdd the MIT license text needed by the imported Wayland core protocol copyright notice.
TestsCheck scanner input validation and atomic output replacement, and exercise runtime behavior and wire interoperability against a Wayland server.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 7 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="wayland/conn_linux.go" line_range="93" />
<code_context>
+}
+
+func Dial(ctx context.Context, display *Interface) (*Conn, *Object, error) {
+ name := os.Getenv("WAYLAND_DISPLAY")
+ if name == "" {
+ name = "wayland-0"
</code_context>
<issue_to_address>
**Inherited Wayland socket ignored**
When the client is launched with a connected compositor socket in `WAYLAND_SOCKET`, `Dial` ignores the inherited `WAYLAND_SOCKET` file descriptor and instead tries to connect to a socket path; clients launched with a pre-opened Wayland connection therefore fail to connect when that path is unavailable.
Have `Dial` detect and use the inherited socket descriptor before falling back to the `WAYLAND_DISPLAY` path.
</issue_to_address>
### Comment 2
<location path="wayland/conn_linux.go" line_range="102" />
<code_context>
+ if dir == "" {
+ return nil, nil, fmt.Errorf("XDG_RUNTIME_DIR is unset")
+ }
+ name = filepath.Join(dir, name)
+ }
+ var dialer net.Dialer
</code_context>
<issue_to_address>
**Abstract Wayland sockets cannot connect**
When `WAYLAND_DISPLAY` names an abstract Unix socket, such as `@wayland-0`, `Dial` joins the abstract socket name to `XDG_RUNTIME_DIR`, so `net.DialContext` looks for a filesystem socket and fails to connect.
Recognize abstract socket names and pass them to the Unix dialer without joining them to `XDG_RUNTIME_DIR`.
</issue_to_address>
### Comment 3
<location path="wayland/CMakeLists.txt" line_range="28" />
<code_context>
+
+set(core "${CMAKE_CURRENT_BINARY_DIR}/core/wayland-client-protocol.go")
+dde_generate_wayland_client("${core}" core "${WAYLAND_CORE_XML}"
+ -interfaces wl_display,wl_registry,wl_callback,wl_seat,wl_pointer,wl_keyboard,wl_touch)
+set(bindings "${core}")
+if(WAYLAND_PROTOCOL_XML)
</code_context>
<issue_to_address>
**Core input events reject surface references**
When a client using these core bindings receives a keyboard or pointer event referring to a surface it cannot create through the generated interfaces, `Decoder.Object` rejects the surface ID as unknown, so dispatch closes the connection before delivering the event. The generated keyboard and pointer bindings decode surface-bearing events, but the selected core bindings omit `wl_surface` and the interfaces needed to create one.
Include the required surface-creating interfaces and `wl_surface` in the core bindings, or otherwise ensure those surface objects are registered before such events are decoded.
</issue_to_address>
### Comment 4
<location path="cmd/go-wayland-scanner/main.go" line_range="217" />
<code_context>
+ }
+ }
+ fmt.Fprintf(&b, "\npackage %s\n\nimport wl \"github.com/linuxdeepin/dde-api/wayland\"\n\n", pkg)
+ fmt.Fprintln(&b, "func Register(c *wl.Conn) { c.Register(")
+ for _, i := range interfaces {
+ fmt.Fprintf(&b, "&%sInterface,\n", exported(i.Name))
</code_context>
<issue_to_address>
**Filtered bindings cannot create child objects**
When the `-interfaces` filter selects an interface with a typed `new_id` constructor but omits that constructor's target interface, `Register` registers only emitted interfaces, while generated constructor methods require the child interface to be registered. For example, generating only `wl_display` leaves `Sync` and `GetRegistry` unable to create their objects, so callers receive an “unregistered Wayland interface” error.
Include referenced constructor interfaces in the generated registration set, or reject filters that omit those dependencies.
</issue_to_address>
### Comment 5
<location path="Makefile" line_range="137" />
<code_context>
build-dev: prepare
- ${GOBUILD} $(addprefix ${GOPKG_PREFIX}/, ${LIBRARIES})
+ ${GOBUILD} $(addprefix ${GOPKG_PREFIX}/, ${LIBRARIES}) ${GOPKG_PREFIX}/wayland/core
install/lib/%:
</code_context>
<issue_to_address>
**Installed sources omit core bindings**
When a consumer installs the development sources through `install-dev`, `install-dev` derives its copy targets from `ININSTALLS`/`LIBRARIES`, which includes `wayland` but not `wayland/core`, so the installed source tree lacks the core bindings and downstream imports fail to build.
Include `wayland/core` in the source-copy targets used by `install-dev`.
</issue_to_address>
### Comment 6
<location path="wayland/core/client.go" line_range="27" />
<code_context>
+ }
+ Register(conn)
+ d := &Display{WlDisplay: WlDisplay{root}, Conn: conn}
+ d.OnError(func(_ *wayland.Object, code uint32, message string) {
+ d.protocolError = fmt.Errorf("Wayland protocol error %d: %s", code, message)
+ })
</code_context>
<issue_to_address>
**Custom listeners disable bookkeeping**
When a caller registers its own `OnDeleteId` or `OnError` handler after `Connect`, a caller registering its own `OnDeleteId` or `OnError` handler overwrites the handler installed by `Connect` because `Object.On` stores only one handler per opcode. Delete events then stop recycling object IDs, and error events stop setting `protocolError`, so `Dispatch` loses the protocol-error detail.
Keep required internal bookkeeping separate from user listeners, or chain the internal handler whenever a user registers one.
Also at `wayland/core/client.go:30`.
</issue_to_address>
### Comment 7
<location path="cmd/go-wayland-scanner/main.go" line_range="310-312" />
<code_context>
+ if a.Type == "new_id" {
+ result = "(*wl.Object, error)"
+ if a.Interface == "" {
+ params = append(params, "interfaceName string", "version uint32")
+ binding, version = "interfaceName", "version"
+ enc = append(enc, "e.String(interfaceName)", "e.Uint(version)")
+ } else {
+ binding = fmt.Sprintf("%q", a.Interface)
</code_context>
<issue_to_address>
**Generated bind requests duplicate arguments**
When the scanner generates `wl_registry.bind` or another untyped-`new_id` message with explicit interface and version XML arguments, `emitRequest` encodes the XML interface and version arguments in the ordinary loop, then appends them again before the ID, so the request has the wrong wire shape and the compositor rejects it; `debugMessage` also duplicates these fields in trace metadata.
Encode the interface and version only once, in the required wire order, and use that same argument list for trace metadata.
Also at `cmd/go-wayland-scanner/main.go:313-316`, `cmd/go-wayland-scanner/main.go:358-359`.
</issue_to_address>1. Keep protocol error reporting and object ID recycling when registering listeners. 2. Test that user listeners still run and bookkeeping is preserved. Log: Preserve internal display event handling when clients register listeners. Influence: Listeners retain error and ID handling. fix(wayland): 保留显示对象的内部事件处理 1. 注册监听器时保留协议错误上报与对象 ID 回收。 2. 验证用户回调和内部处理都能执行。 Log: 注册监听器时保留显示对象的内部事件处理。 PMS: BUG-377251 Influence: 监听器不会覆盖错误上报和 ID 回收。
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Cherry-pick of #210 for the develop/2500u3 packaging branch. Adds the pure Go Wayland client, protocol scanner, and standalone binding generation. The dde-api-dev package includes the Wayland runtime and core bindings required to build dde-daemon.
Validation: built dde-api and dde-api-dev 6.2.2 with dpkg-buildpackage; checked the packaged Go sources; built dde-session-daemon and ran inputdevices1 and inputmanager tests against the extracted development package. The libwayland interoperability test and REUSE lint passed.
PMS: BUG-377251
Summary by Sourcery
Provide a Go Wayland client and protocol binding generation for applications and package developers.
New Features:
Enhancements:
Build:
Tests:
Chores: