Straight line brush mask

there was a recent discussion about the lack of a way to draw straight lines with the brush mask in ART, and how awesome and important this feature would be to bring the tool “out of the narrow FOSS loop”. I said that it would be a good idea but I wasn’t interested in doing this myself, but never say never. Well, today I had some free time, so I thought about this a bit more, and it turned out that it can be done in exactly 5 lines of code:

diff --git a/rtgui/ b/rtgui/
--- a/rtgui/
+++ b/rtgui/
@@ -461,13 +461,17 @@
         bool ctrl = modifierKey & GDK_CONTROL_MASK;
         bool shift = modifierKey & GDK_SHIFT_MASK;
+        bool alt = modifierKey & GDK_MOD1_MASK;
+        bool dragging = alt && !mask_->strokes.empty();
         if (ctrl && !shift) {
+            dragging = false;
         } else if ((!ctrl && shift) != prev_erase_) {
             prev_erase_ = !ctrl && shift;
+            dragging = false;
-        add_stroke(false);
+        add_stroke(dragging);
         return true;

So, I just added that: now, you can draw straight lines by holding the Alt key. And as promised, since this was @Eigil_Skovgaard’s idea, I’ve added his name to the AUTHORS.txt file, under the contributors section. I hope now we are ready to dethrone Adobe :stuck_out_tongue_winking_eye:

Here’s a little demo:


Well, now you’re just showing off :wink:
Doing this in five lines of code means you had very clean code in the first place, impressive!

Well, I’m just trying to live up to my “annoying arrogance” reputation :slight_smile: Though if I really wanted to show off, I would have sacrificed some readability and done it in one line :wink:


“Poke the bear” :slight_smile:

I got a transparency effect when using the Alt key !
I just compiled the version as usual. All other keys behave as usual

I am sorry, because don’t understand your problem… Are you sure it’s not the window manager that gets in the way?

It may be the case, for the moment I don’t find any redundant key. I will dig into the problem.

Don’t worry! It only has to work on Windows to dethrone Adobe. :grin:

@agriggio :+100:

i can eliminate the transparency issue, but i don’t get the colored spots on the screen

Maybe the procedure is not clear… Let me try to explain. First you click normally to define the starting point (without holding Alt), then you move the mouse to the end point (without clicking anything, i.e. without “dragging”), then you click again while holding the Alt key, and now you should have your line … Can you confirm this is what you were doing? Thanks!

I carefully followed your scheme, I got the first yellow point only, as if holding the Alt key was inactive and prevent setting a second point.


I just build the latest development version (1.9.3-16-g9140a11d0) and this new feature works as advertised/shown for me.

I’m on Linux (Debian 10.10/Buster).

@srgmro : Are you on the latest development version? Never mind, just noticed the version in your window.

Exactly, furthermore I translated the new lines in french. Are you on kde desktop ?

Nope, Xfce.

Hi, I have the same behaviour as @srgmro under Archlinux KDE.
I’ve tried it on my arch laptop under i3wm, it works!
The problem is with KDE

Hmm, I’m on Xfce as well but it does not work for me.
Xubuntu 20.04.2 LTS, Art Version: 1.9.3-16-g9140a11d0
Branch: master
Commit: 9140a11d0
Commit date: 2021-08-08.

My impression was that after clicking the Alt key to make that straight line, Xfce is waiting for a second key to do something. Using left Alt, I can move a window with mouse left-click and resize a window with Alt + right click. But no straight line in Art.

@jllailes / @paulmatth

I think @agriggio’s initial idea about this being a WM problem might be correct. I have run into alt/meta/super key problems in the past and WMs do tend to “steal” some of them for their own uses.

About Xfce: Have a look at the Window Manager Tweaks, specifically the Accessibility tab. The top entry, Key used to grab and move windows is set to Super in my case, I’m assuming yours is set to Alt (not sure if that is the default setting). I changed that back when I started using Krita and ran into the alt key being needed by some of the tools.

EDIT: Fixed typos.

If the control and shift keys do not pose a problem, would it be an option to let the straight line functionality work if you press both of them at the same time, instead of alt?

That’s it Jacques, thanks!