godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add option to disable middle-click paste in the GDScript Editor on Linux #6450

Open Leshy-YA opened 1 year ago

Leshy-YA commented 1 year ago

Describe the project you are working on

Procedural 3D RPG.

Describe the problem or limitation you are having in your project

Editing scripts in Godot and accidentally pasting random data, while trying to scroll is an extremely common occurrence.

The ancient behaviour on X11 is to have the middle mouse button work as paste. Usually for the currently selected text. Although a minority of users still want this behaviour, more and more find this not only cumbersome, but potentially a security vulnerability.

Because of that modern Linux distributions running on Wayland already have an option to disable that. However this does not apply to XWayland applications or anything still running pure X11. This affects the current X11/XWayland version of Godot.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add option to disable middle-click paste in the Godot editor. This will prevent frequent accidental pastes while editing scripts and shaders.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

There would be a checkbox in the editor settings. The text editor component already has a property that does that, this would just expose that to the editor settings.

If this enhancement will not be used often, can it be worked around with a few lines of script?

One workaround would be to use an external text editor, which beats the purpose of the many enhancements added in Godot 4 to the GDScript editor.

Second would be building a custom version of Godot with the aforementioned flag changed.

Is there a reason why this should be core and not an add-on in the asset library?

This will improve scripting workflow for most Linux users immediately.

KvaGram commented 1 year ago

The annoying middleclick paste is a core part of the X11 system. I think it is made optional in the Wayland system. I don't know if the Godot team can do much about this, is they can, I suppose they should. However, as a workaround, I would suggest switching to a Wayland-based desktop environment. Wayland still have some limitations compared to good (err bad?) old X11, so you should try and see if it fits with your workflow.

Leshy-YA commented 1 year ago

The annoying middleclick paste is a core part of the X11 system.

One of the plethora of reasons why X11 is being replaced.

I don't know if the Godot team can do much about this, is they can, I suppose they should.

As mentioned in the issue description, the Text Editor component in the engine already has the relevant configuration flag (when creating your own UI), it just needs to be exposed to the general editor settings.

However, as a workaround, I would suggest switching to a Wayland-based desktop environment. Wayland still have some limitations compared to good (err bad?) old X11, so you should try and see if it fits with your workflow.

As mentioned in the issue description this does not work. XWayland applications, such Godot ignore this Wayland setting. The setting is accessible on all distros running Gnome Shell and KDE over Wayland (such as Fedora).

Calinou commented 1 year ago

Not all applications running under X11 have to support middle mouse pasting, as it's generally implemented by the application itself. Godot didn't support middle click pasting until 3.5 or so, so it makes sense to add an editor setting to disable this. Mice with broken scroll wheels that send middle clicks for no good reason are quite common out there.

As mentioned in the issue description, the Text Editor component in the engine already has the relevant configuration flag (when creating your own UI), it just needs to be exposed to the general editor settings.

It should be possible to create an editor plugin to set this flag for now.