MCPcopy
hub / github.com/mmulet/term.everything / XdgSurface_get_toplevel

Method XdgSurface_get_toplevel

wayland/xdg_surface.go:67–192  ·  view source on GitHub ↗
(
	s protocols.ClientState,
	xdgSurfaceObjectID protocols.ObjectID[protocols.XdgSurface],
	id protocols.ObjectID[protocols.XdgToplevel],
)

Source from the content-addressed store, hash-verified

65}
66
67func (x *XdgSurface) XdgSurface_get_toplevel(
68 s protocols.ClientState,
69 xdgSurfaceObjectID protocols.ObjectID[protocols.XdgSurface],
70 id protocols.ObjectID[protocols.XdgToplevel],
71) {
72 surface_id := GetSurfaceIDFromRole(s, xdgSurfaceObjectID)
73 if surface_id == nil {
74 SendError(s,
75 xdgSurfaceObjectID,
76 protocols.XdgSurfaceError_enum_not_constructed,
77 "surface not found",
78 )
79 return
80 }
81
82 surface := GetSurfaceFromRole(s, xdgSurfaceObjectID)
83 if surface == nil {
84 SendError(s,
85 xdgSurfaceObjectID,
86 protocols.XdgSurfaceError_enum_not_constructed,
87 "surface not found",
88 )
89 return
90 }
91
92 if surface.Role == nil {
93 surface.Role = &SurfaceRoleXdgToplevel{}
94 }
95
96 surfaceRole, surface_role_is_xdg_toplevel := surface.Role.(*SurfaceRoleXdgToplevel)
97 if !surface_role_is_xdg_toplevel {
98 SendError(s,
99 xdgSurfaceObjectID,
100 protocols.XdgSurfaceError_enum_defunct_role_object,
101 "surface not found",
102 )
103 return
104 }
105
106 if surfaceRole.Data != nil {
107 SendError(s,
108 xdgSurfaceObjectID,
109 protocols.XdgSurfaceError_enum_defunct_role_object,
110 "surface already has a role",
111 )
112 return
113 }
114
115 surfaceRole.Data = &id
116 AddObject(s, id, MakeXdgToplevel())
117
118 RegisterRoleToSurface(s, id, *surface_id)
119 s.TopLevelSurfaces()[id] = true
120
121 protocols.XdgToplevel_configure(
122 s,
123 id,
124 int32(VirtualMonitorSize.Width),

Callers

nothing calls this directly

Calls 11

GetGlobalWlOutputBindsFunction · 0.92
GetGlobalWlKeyboardBindsFunction · 0.92
GetGlobalWlPointerBindsFunction · 0.92
GetSurfaceIDFromRoleFunction · 0.85
SendErrorFunction · 0.85
GetSurfaceFromRoleFunction · 0.85
AddObjectFunction · 0.85
MakeXdgToplevelFunction · 0.85
RegisterRoleToSurfaceFunction · 0.85
ToBytesFunction · 0.85
TopLevelSurfacesMethod · 0.65

Tested by

no test coverage detected