Repository: AvaloniaUI/Avalonia
File: src/Avalonia.X11/XI2Manager.cs (C#)

Code before:
                // https://www.kernel.org/doc/html/latest/input/multi-touch-protocol.html
                var touchMajorAtom = XInternAtom(_x11.Display, "Abs MT Touch Major", false);
                var touchMinorAtom = XInternAtom(_x11.Display, "Abs MT Touch Minor", false);

                var pressureAtom = XInternAtom(_x11.Display, "Abs MT Pressure", false);
                var pressureAtomPen = XInternAtom(_x11.Display, "Abs Pressure", false);
                var absTiltXAtom = XInternAtom(_x11.Display, "Abs Tilt X", false);
                var absTiltYAtom = XInternAtom(_x11.Display, "Abs Tilt Y", false);

                PressureXIValuatorClassInfo = null;
                TouchMajorXIValuatorClassInfo = null;
                TouchMinorXIValuatorClassInfo = null;

                foreach (var xiValuatorClassInfo in Valuators)
                {
                    if (xiValuatorClassInfo.Label == pressureAtom ||
                        xiValuatorClassInfo.Label == pressureAtomPen)
                    {
                        PressureXIValuatorClassInfo = xiValuatorClassInfo;
                    }
                    else if (xiValuatorClassInfo.Label == touchMajorAtom)
                    {
                        TouchMajorXIValuatorClassInfo = xiValuatorClassInfo;
                    }
                    else if (xiValuatorClassInfo.Label == touchMinorAtom)
                    {
                        TouchMinorXIValuatorClassInfo = xiValuatorClassInfo;
                    }
                    else if (xiValuatorClassInfo.Label == absTiltXAtom)
                    {
                        TiltXXIValuatorClassInfo = xiValuatorClassInfo;
                    }
                    else if (xiValuatorClassInfo.Label == absTiltYAtom)
                    {
                        TiltYXIValuatorClassInfo = xiValuatorClassInfo;
                    }
                }
            }

            public override void Update(XIAnyClassInfo** classes, int num)
            {
                base.Update(classes, num);
                UpdateKnownValuator();
            }

            public bool HasPenEvaluators()
            {
                return PressureXIValuatorClassInfo is not null;
            }

            public bool HasScroll(ParsedDeviceEvent ev)

Review comment (suggestion):
Is it possible for a device to have both `Abs Pressure` and `Abs MT Pressure`? I don't think so, but if that's the case we should probably prefer the second one.

Code after:

                UpdateKnownValuator();
            }
            
            private readonly X11Info _x11;

            private void UpdateKnownValuator()
            {
                // ABS_MT_TOUCH_MAJOR ABS_MT_TOUCH_MINOR
                // https://www.kernel.org/doc/html/latest/input/multi-touch-protocol.html
                var touchMajorAtom = XInternAtom(_x11.Display, "Abs MT Touch Major", false);
                var touchMinorAtom = XInternAtom(_x11.Display, "Abs MT Touch Minor", false);

                var pressureAtom = XInternAtom(_x11.Display, "Abs MT Pressure", false);
                var pressureAtomPen = XInternAtom(_x11.Display, "Abs Pressure", false);
                var absTiltXAtom = XInternAtom(_x11.Display, "Abs Tilt X", false);
                var absTiltYAtom = XInternAtom(_x11.Display, "Abs Tilt Y", false);

                PressureXIValuatorClassInfo = null;
                TouchMajorXIValuatorClassInfo = null;
                TouchMinorXIValuatorClassInfo = null;

                foreach (var xiValuatorClassInfo in Valuators)
                {
                    if (xiValuatorClassInfo.Label == pressureAtom ||
                        xiValuatorClassInfo.Label == pressureAtomPen)
                    {
                        PressureXIValuatorClassInfo = xiValuatorClassInfo;
                    }
                    else if (xiValuatorClassInfo.Label == touchMajorAtom)
                    {
                        TouchMajorXIValuatorClassInfo = xiValuatorClassInfo;
                    }
                    else if (xiValuatorClassInfo.Label == touchMinorAtom)
                    {
                        TouchMinorXIValuatorClassInfo = xiValuatorClassInfo;
                    }
                    else if (xiValuatorClassInfo.Label == absTiltXAtom)
                    {
                        TiltXXIValuatorClassInfo = xiValuatorClassInfo;
                    }
                    else if (xiValuatorClassInfo.Label == absTiltYAtom)
                    {
                        TiltYXIValuatorClassInfo = xiValuatorClassInfo;
                    }
                }
            }

            public override void Update(XIAnyClassInfo** classes, int num, int? slaveId)
            {
                base.Update(classes, num, slaveId);