linuxmint / cinnamon-settings-daemon

The settings daemon for the Cinnamon desktop
GNU General Public License v2.0
58 stars 59 forks source link

Screen rotation does not rotate all input devices and needs custom settings #188

Open leigh123linux opened 7 years ago

leigh123linux commented 7 years ago

@evilphish commented on Wed Aug 23 2017

Issue Using cinnamon on a lenovo x1 yoga 2nd gen, while the automatic screen rotation with the help of iio-sensor-proxy works as expected, only the stylus gets rotated with the screen as well. Finger touch or any other pointing device still stays in normal orientation and is therefore unusable. The same happens if you do not use automatic rotation but rotate the display manually via the display settings or using xrandr from the command line.

In addition a "run on rotation" setting at least somewhere in dconf would be immensely helpful as it would allow toggling on or off the touchpad, launching other software, etc.

Steps to reproduce Start cinnamon, rotate your display (either automatically or manually via display settings or xrandr). That's it.

Expected behaviour All input pointing devices should rotate the same way as the display.

clefebvre commented 7 years ago

@leigh123linux can you see if porting https://github.com/GNOME/gnome-settings-daemon/commit/8e488c96f44c82238fb7d3260df67472014c2407#diff-fcb47d623300ed1b66fd6623f532a39a helps?

cajhne commented 5 years ago

Having this same issue with my ASUS Transformer Mini. I can confirm that it works properly with Ubuntu 18.10 in Gnome (GNOME Shell 3.30.1), but fails with Cinnamon desktop (Cinnamon 3.8.8).

cajhne commented 5 years ago

The command xinput set-prop "ELAN22A6:00 04F3:22A6" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1 Fixes the coords for right-rotated (clockwise) touchscreen coords.

cajhne commented 5 years ago

Likewise, if you have pen input, it needs to be rotated too: xinput set-prop "ELAN22A6:00 04F3:22A6 Pen Pen (0)" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1

cajhne commented 5 years ago

Note to those who want to diy fix, just type "xinput" into the command line, and use the name of your device in the command: xinput set-prop "YOURDEVICE" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1

If you're rotating COUNTER-clockwise (LEFT), the command is: xinput set-prop "YOURDEVICE" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1

ebrensi commented 5 years ago

Hey everyone! Check out my hacked fix for this problem, at https://gist.github.com/ebrensi/6d270bd84f04fbe0366fbbc3e5cf7054

It's a shell script that automatically rotates the Pen (Stylus) Device orientation, since Cinnamon appears not to do that by default. You will need to add it to your startup scripts.

It works on my HP Spectre x360 Convertible.

I modified an existing solution, so I don't know how efficient it is or if there are potential conflicts. Please let me know if there are potential problems with it.

elmosan commented 5 years ago

Hi, having the same issue with my ASUS VivoBook Flip 14. It works with gnome but not with cinnamon. The XInput set-property 'Coordinate Transformation Matrix' does not work, as it gets reverted immediately everytime. Trying to set the default value with 'libinput Calibration Matrix Default' gets the error "X Error of failed request: BadAccess (attempt to access private resource denied)". So how can I fix this permanently?

sphh commented 4 years ago

I have the same problem on two computers (Microsoft Surface Pro 3 and Microsoft Surface Pro 5 (2017)), both running Linux Mint 19.3 and Cinnamon 4.4.8.

On both the screen rotates and on both the pen does not rotate.

Here are some details:

Surface Pro 3

$ xinput
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Microsoft Surface Type Cover Mouse        id=9    [slave  pointer  (2)]
⎜   ↳ Microsoft Surface Type Cover Consumer Control id=10   [slave  pointer  (2)]
⎜   ↳ Microsoft Surface Type Cover Touchpad     id=11   [slave  pointer  (2)]
⎜   ↳ NTRG0001:01 1B96:1B05 Pen (0)             id=17   [slave  pointer  (2)]
⎜   ↳ NTRG0001:01 1B96:1B05                     id=15   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Video Bus                                 id=6    [slave  keyboard (3)]
    ↳ Surface Pro 3/4 Buttons                   id=7    [slave  keyboard (3)]
    ↳ Microsoft Surface Type Cover Keyboard     id=8    [slave  keyboard (3)]
    ↳ Microsoft LifeCam Front: Micros           id=12   [slave  keyboard (3)]
    ↳ Microsoft LifeCam Rear: Microso           id=13   [slave  keyboard (3)]
    ↳ NTRG0001:01 1B96:1B05                     id=14   [slave  keyboard (3)]
    ↳ Microsoft Surface Type Cover Consumer Control id=16   [slave  keyboard (3)]
    ↳ Surface Pen Keyboard                      id=18   [slave  keyboard (3)]

and

$ grep xrandr .xsession-errors
(csd-xrandr:1262): common-plugin-WARNING **: 19:17:25.298: Error in setting "Coordinate Transformation Matrix" for "NTRG0001:01 1B96:1B05"

The (finger) touchscreen rotates correctly.

I can rotate the pen and eraser with

$ xinput set-prop 17 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1

with 17 pointing to NTRG0001:01 1B96:1B05 Pen (0) and not NTRG0001:01 1B96:1B05 as mentioned in the error message.

Surface Pro 5 (2017)

$ xinput
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ IPTS Singletouch                          id=10   [slave  pointer  (2)]
⎜   ↳ Microsoft Surface Type Cover Consumer Control id=11   [slave  pointer  (2)]
⎜   ↳ Microsoft Surface Type Cover Touchpad     id=14   [slave  pointer  (2)]
⎜   ↳ Microsoft Surface Type Cover Mouse        id=15   [slave  pointer  (2)]
⎜   ↳ IPTS Stylus Eraser (0)                    id=16   [slave  pointer  (2)]
⎜   ↳ IPTS Stylus Pen (0)                       id=17   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Video Bus                                 id=6    [slave  keyboard (3)]
    ↳ gpio-keys                                 id=7    [slave  keyboard (3)]
    ↳ gpio-keys                                 id=8    [slave  keyboard (3)]
    ↳ IPTS Stylus                               id=9    [slave  keyboard (3)]
    ↳ Microsoft Surface Type Cover Consumer Control id=12   [slave  keyboard (3)]
    ↳ Microsoft Surface Type Cover Keyboard     id=13   [slave  keyboard (3)]

and

$ grep xrandr .xsession-errors
(csd-xrandr:5510): common-plugin-WARNING **: 15:24:12.868: Error in setting "Coordinate Transformation Matrix" for "IPTS Stylus"

On this computer the touchscreen does not work, because of the kernel used.

I can rotate both pen and eraser with

$ xinput set-prop 16 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
$ xinput set-prop 17 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1

with the numbers pointing to IPTS Stylus Eraser (0) and IPTS Stylus Pen (0) and not just IPTS Stylus as mentioned in the error message.

I also noticed that the pen and eraser with Pen (0) and Eraser (0) appended to their name only appears after they were used at least once. It looks to me, that csd-xrandr does not update the available devices, but I am no expert ...

Please note, that I use the patched libinput from https://gitlab.freedesktop.org/libinput/libinput. This is needed to get the eraser working.

Does this help to track down the problem? If you need any more information, I am happy to provide it.

sphh commented 4 years ago

Hi, I just tried to apply the patch mentioned by @clefebvre in https://github.com/linuxmint/cinnamon-settings-daemon/issues/188#issuecomment-338649029, but got the following compile errors even before applying the patch:

make[3]: Entering directory '/home/sphh/Software/git/cinnamon-settings-daemon/plugins/xrandr'
  CCLD     csd-xrandr
csd_xrandr-csd-xrandr-manager.o: In function `adjust_output_positions_for_scaling':
/home/sphh/Software/git/cinnamon-settings-daemon/plugins/xrandr/csd-xrandr-manager.c:1096: undefined reference to `gnome_rr_screen_calculate_best_global_scale'
/home/sphh/Software/git/cinnamon-settings-daemon/plugins/xrandr/csd-xrandr-manager.c:1098: undefined reference to `gnome_rr_output_info_set_scale'
/home/sphh/Software/git/cinnamon-settings-daemon/plugins/xrandr/csd-xrandr-manager.c:1104: undefined reference to `gnome_rr_config_set_base_scale'
csd_xrandr-csd-xrandr-manager.o: In function `use_stored_configuration_or_auto_configure_outputs':
/home/sphh/Software/git/cinnamon-settings-daemon/plugins/xrandr/csd-xrandr-manager.c:1806: undefined reference to `gnome_rr_config_get_legacy_filename'
csd_xrandr-csd-xrandr-manager.o: In function `apply_stored_configuration_at_startup':
/home/sphh/Software/git/cinnamon-settings-daemon/plugins/xrandr/csd-xrandr-manager.c:2002: undefined reference to `gnome_rr_config_get_legacy_filename'
collect2: error: ld returned 1 exit status
Makefile:558: recipe for target 'csd-xrandr' failed
make[3]: *** [csd-xrandr] Error 1
make[3]: Leaving directory '/home/sphh/Software/git/cinnamon-settings-daemon/plugins/xrandr'

Looks like a package is missing. But which one?

All other plugins up to this one compiled successfully.

What I did on my Linux Mint 19.3 Cinnamon system:

  1. I made a local copy of the repository: git clone https://github.com/linuxmint/cinnamon-settings-daemon.git
  2. I installed all Build-Depends mentioned in debian/control
  3. ./autogen.sh
  4. make

Any help how to compile the xrandr plugin is highly appreciated, so that I can test the xrandr plugin (and make a PR). Thanks.

icarter09 commented 4 years ago

@sphh are you still experiencing this issue?

sphh commented 4 years ago

Yes, since the daemon has not changed in recent time. From /usr/share/doc/cinnamon-settings-daemon/changelog.gz:

cinnamon-settings-daemon (4.4.0+tricia) tricia; urgency=medium
 -- Clement Lefebvre <root@linuxmint.com>  Sat, 16 Nov 2019 16:37:55 +0100

I also just downloaded the beta version of Linux Mint 20 Cinnamon and there I observe the same phenomenon: The screen rotates, the touchscreen rotates but the pen input does not.

icarter09 commented 4 years ago

@sphh thanks for the update.

sphh commented 4 years ago

No worries. If you have any ideas, why my attempt to compile CSD failed, I am happy to compile and test it. I can also check out a compiled version if you need someone for testing.

sphh commented 4 years ago

I just re-installed Linux Mint 20 and experience the same issue:

$ xinput
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Microsoft Surface Type Cover Mouse        id=9    [slave  pointer  (2)]
⎜   ↳ Microsoft Surface Type Cover Consumer Control id=10   [slave  pointer  (2)]
⎜   ↳ Microsoft Surface Type Cover Touchpad     id=11   [slave  pointer  (2)]
⎜   ↳ NTRG0001:01 1B96:1B05                     id=15   [slave  pointer  (2)]
⎜   ↳ NTRG0001:01 1B96:1B05 Pen (0)             id=17   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Video Bus                                 id=6    [slave  keyboard (3)]
    ↳ Surface Pro 3/4 Buttons                   id=7    [slave  keyboard (3)]
    ↳ Microsoft Surface Type Cover Keyboard     id=8    [slave  keyboard (3)]
    ↳ Microsoft LifeCam Front: Micros           id=12   [slave  keyboard (3)]
    ↳ Microsoft LifeCam Rear: Microso           id=13   [slave  keyboard (3)]
    ↳ NTRG0001:01 1B96:1B05                     id=14   [slave  keyboard (3)]
    ↳ Microsoft Surface Type Cover Consumer Control id=16   [slave  keyboard (3)]
$ grep xrandr .xsession-errors
xrandr-plugin-Message: 10:03:46.986: Existing monitor config (/home/sph/.config/cinnamon-monitors.xml) not found at startup. Looking for legacy configuration (monitors.xml)
(csd-xrandr:1282): common-plugin-WARNING **: 16:04:07.407: Error in setting "Coordinate Transformation Matrix" for "NTRG0001:01 1B96:1B05"
(csd-xrandr:1282): common-plugin-WARNING **: 16:04:11.676: Error in setting "Coordinate Transformation Matrix" for "NTRG0001:01 1B96:1B05"
(csd-xrandr:1282): common-plugin-WARNING **: 16:04:20.822: Error in setting "Coordinate Transformation Matrix" for "NTRG0001:01 1B96:1B05"

Note, that the name has changed (maybe due to the fact, that I am currently not using the patched libinput, but the pattern is the same: It does not use the right input: It uses id=15 instead of id=16.

Note 2: The eraser (most likely id=16) is not set up yet.

sphh commented 4 years ago

@icarter: Is there any way that I can help?

ItzSwirlz commented 4 years ago

This is probably a regression and if GNOME fixed it I'm sure it should be fixed here.

But take the compilation warning that's the problem-it's a missing dependency or library, so can we try to get that tracked down? Maybe we are using a deprecated/old version.

sphh commented 4 years ago

@ItzSwirlz If you refer to my message https://github.com/linuxmint/cinnamon-settings-daemon/issues/188#issuecomment-627309034, I forgot to mention, that I could compile everything with apt-get --build source cinnamon-settings-daemon.

After checking that I can compile cinnamon-setting-daemon cleanly, I tried to apply the patches (by hand). This patch consists of three sets (see https://bugzilla.gnome.org/show_bug.cgi?id=709600):

  1. https://gitlab.gnome.org/GNOME/gnome-settings-daemon/commit/0810de0
  2. https://gitlab.gnome.org/GNOME/gnome-settings-daemon/commit/bf2f0d5
  3. https://gitlab.gnome.org/GNOME/gnome-settings-daemon/commit/8e488c9

I could apply patches 2. and 3. (well, not the whole of 2., because configure.ac changed) by hand, but not 1. Mind you, the patch is from 2014 and it looks like the branches have developed a bit.

Finally I wanted to check against the current gsd-xrandr-manager.c but was surprised, that the whole directory plugins/xrandr/ disappeared in the GNOME branch...

Since I am not fluent in gnome-settings-daemon, I unfortunately had to give up.

sphh commented 3 years ago

A further update, which is perhaps relevant: The manual setting of the transformation matrix works (as mentioned before). I currently use this script for rotating all input devices semi-automatically: https://github.com/linux-surface/linux-surface/tree/master/contrib/rotate-screen which uses the classical xinput set-prop command. This is run on all input devices it can find at that time, when the script is called. Sometimes neither the stylus nor the eraser are rotated, sometimes they are.

I tracked this down to the following:

  1. The stylus and the eraser are bluetooth devices. They connect automatically.
  2. If I have used them just before calling the script, they are rotated.
  3. If I have not used them before, they are not rotated (because they are not found by the script).

I wonder, if the same happens with csd-xrandr: If csd-xrandr does not automatically update the list of devices before rotating, it might work on an outdated list, which does not contain the stylus, which was not available, when csd-xrandr started.

I don't know, how to check this assumption, because I have no idea, how to connect the stylus before csd-xrandr is started …