Might be a dumb question, but I've achieved partial-functionality with this. I'm working in Godot 3.1 and am attempting to be able to click-and-drag the window from the title bar. My tree looks like
Node2D
-|Control
---|Title Bar
-----|Panel
---|[App contents]
I've implemented your code almost exactly as-is (providing a different name for the title bar and using [event] instead of [ev]), but functionality should be the same.
Problem is, [Node2D] doesn't offer a guiinput(), placing guiinput() on [Control] or [Title Bar] does nothing, and placing guiinput() on [Panel] allows me to move the contents of the window, uh... inside the window. Without the window moving. Placing a Panel as a direct child of [Node2D] before [Control] in the heirarchy and hooking a guiinput() on that up to the script provided does nothing.
I suspect it's a hierarchy problem. That'd explain why the current [Panel], being the object "closest" to the user does it while nothing else does. However, that doesn't explain for me how that moves everything within the window (including the entirety of [App contents]), but not the window itself.
I don't know if anybody's still tracking this question and it's probably a dunderheaded overlook on my part, but any assistance would be appreciated.