I'm working on a small project and I need to disable the border to achieve the desired effect. However, this makes the game screen unmovable. So I wrote the following code to enable dragging the screen with mouse:

func _input(event):
	if event is InputEventMouseButton:
		if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
			dragging = true
			mouse_in_pos = get_viewport().get_mouse_position()
	else:
		dragging = false
		
	if event is InputEventMouseMotion and dragging:
		mouse_pos = get_viewport().get_mouse_position()
		get_tree().get_root().position = Vector2(get_tree().get_root().position) + mouse_pos - mouse_in_pos

The game can now detect mouse drag behavior, but the screen still cannot be dragged. How can I improve this code?

I don't think it's possible as far as I know. You'd need a way to tell the operating system where to move the window itself. The way you're doing it here, I'm pretty sure it's just moving the entire root node, which, I think, effectively does nothing.

If you're on Windows, it looks like you could do ALT+SPACEBAR and when a menu shows up, hit M and the window enters some kind of move state.

I'm on Linux with Openbox, so I've got it configured to move windows the same way by just holding the Windows key and dragging the window. Doesn't matter where on the window I click, it just works.

I think MacOS is ctrl+cmd. I'm not sure, the help I could find for that was vague(I didn't look very hard)

7 days later

there is a video about how to make a borderless window in Godot:

You can do it, I've tested this before. Using the function DisplayServer.window_set_position()

However, I have noticed it can be choppy depending on the monitor and resolution, it is not as smooth as when the OS does it native.