Repository: godotengine/godot
File: platform/linuxbsd/wayland/wayland_thread.cpp (C++)

Code before:
		} else if (p_constraint == PointerConstraint::CONFINED) {
			seat_state_confine_pointer(ss);
		}
	}

	pointer_constraint = p_constraint;
}

void WaylandThread::pointer_set_hint(const Point2i &p_hint) {
	SeatState *ss = wl_seat_get_seat_state(wl_seat_current);
	if (!ss) {
		return;
	}

	WindowState *ws = window_get_state(ss->pointer_data.pointed_id);
	if (!ws) {
		return;
	}

	// NOTE: It looks like it's not really recommended to convert from
	// "godot-space" to "wayland-space" and in general I received mixed feelings
	// discussing about this. I'm not really sure about the maths behind this but,
	// oh well, we're setting a cursor hint. ¯\_(ツ)_/¯
	// See: https://oftc.irclog.whitequark.org/wayland/2023-08-23#1692756914-1692816818
	int hint_x = std::round(p_hint.x / window_state_get_scale_factor(ws));
	int hint_y = std::round(p_hint.y / window_state_get_scale_factor(ws));

	if (ss) {
		seat_state_set_hint(ss, hint_x, hint_y);
	}
}

void WaylandThread::pointer_warp(const Point2i &p_to) {
	// NOTE: This is for compositors that don't support the pointer-warp protocol.
	// It's hacked together and not guaranteed to work.
	if (registry.wp_pointer_warp == nullptr) {
		PointerConstraint old_constraint = pointer_get_constraint();

		pointer_set_constraint(PointerConstraint::LOCKED);
		pointer_set_hint(p_to);

		pointer_set_constraint(old_constraint);

		return;
	}

	SeatState *ss = wl_seat_get_seat_state(wl_seat_current);
	if (!ss) {
		return;
	}


Review comment (suggestion):
```suggestion
	int hint_x = Math::round(p_hint.x / window_state_get_scale_factor(ws));
	int hint_y = Math::round(p_hint.y / window_state_get_scale_factor(ws));
```

Code after:
			}
#endif // LIBDECOR_ENABLED
		} break;
	}

	// Wait for a configure event and hope that something changed.
	wl_display_roundtrip(wl_display);

	if (ws.mode != DisplayServer::WINDOW_MODE_WINDOWED) {
		// The compositor refused our "normalization" request. It'd be useless or
		// unpredictable to attempt setting a new state. We're done.
		return;
	}

	// Ask the compositor to set the state indicated by the new mode.
	switch (p_window_mode) {
		case DisplayServer::WINDOW_MODE_WINDOWED: {
			// Do nothing. We're already windowed.
		} break;

		case DisplayServer::WINDOW_MODE_MINIMIZED: {
			if (!window_can_set_mode(p_window_id, p_window_mode)) {
				// Minimization is special (read below). Better not mess with it if the
				// compositor explicitly announces that it doesn't support it.
				break;
			}

			if (ws.xdg_toplevel) {
				xdg_toplevel_set_minimized(ws.xdg_toplevel);
			}

#ifdef LIBDECOR_ENABLED
			if (ws.libdecor_frame) {
				libdecor_frame_set_minimized(ws.libdecor_frame);
			}
#endif // LIBDECOR_ENABLED
	   // We have no way to actually detect this state, so we'll have to report it
	   // manually to the engine (hoping that it worked). In the worst case it'll
	   // get reset by the next configure event.
			ws.mode = DisplayServer::WINDOW_MODE_MINIMIZED;
		} break;

		case DisplayServer::WINDOW_MODE_MAXIMIZED: {
			if (ws.xdg_toplevel) {
				xdg_toplevel_set_maximized(ws.xdg_toplevel);
			}

#ifdef LIBDECOR_ENABLED
			if (ws.libdecor_frame) {
				libdecor_frame_set_maximized(ws.libdecor_frame);
			}