Skip to content

Commit 7c8f007

Browse files
simple refactor
1 parent 17c2016 commit 7c8f007

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/wayland/wlr_compositor.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,15 @@ set_default_cursor(WlrServer* server, wlr_output* output = nullptr)
222222
log_pointer_state(server, "default_cursor");
223223
}
224224

225+
bool isValidWaylandAppComponent(WlrServer* server, entt::entity entity) {
226+
return server->registry->valid(entity) &&
227+
server->registry->all_of<WaylandApp::Component>(entity);
228+
}
229+
225230
// Map the global pointer into surface-local coords assuming the surface is
226231
// centered in the output (matches render overlay) and clamp to surface size.
232+
//
233+
// TODO: Remove the clamp which is causing inputs that aren't on the window to be passed into the window.
227234
static std::pair<double, double>
228235
map_pointer_to_surface(WlrServer* server, wlr_surface* surf)
229236
{
@@ -236,9 +243,7 @@ map_pointer_to_surface(WlrServer* server, wlr_surface* surf)
236243
// top-left using the same math as renderWaylandPopup().
237244
if (server && surf && server->registry) {
238245
auto it = server->surface_map.find(surf);
239-
if (it != server->surface_map.end() &&
240-
server->registry->valid(it->second) &&
241-
server->registry->all_of<WaylandApp::Component>(it->second)) {
246+
if (it != server->surface_map.end() && isValidWaylandAppComponent(server, it->second)) {
242247
auto& comp = server->registry->get<WaylandApp::Component>(it->second);
243248
if (comp.accessory && !comp.layer_shell && comp.parent != entt::null &&
244249
server->registry->valid(comp.parent) &&

0 commit comments

Comments
 (0)