HOWTO fix screen tearing
Screen tearing can be a problem on GNU/Linux with some combinations of graphics drivers and window-managers such as Xfce 4.12's xfwm4. Luckily, it's easily fixable by adding a minor snippet to Xorg's configuration file.
Create one of the following configuration files in
/etc/X11/xorg.conf.d/ (create that folder if it does not exist, there's no such folder on Ubuntu by default but it does look for it and read files in it) with
TearFree in a
Device section to avoid screen tearing.
Why Xorg Defaults To Screen Tearing
|Question: Why do you need to add this to X's configuration?
Imagine the setting Xorg
"The "TearFree" option isn't enabled by default because it has drawbacks (higher GPU memory consumption, performance overhead for unredirected fullscreen apps); also, it can be enabled at runtime with xrandr.
Maybe try barking up your DE's tree for not exposing a setting for that.
Don't like tearing? Use Wayland!"
Some rare Intel CPUs will additionally need
"AccelMethod" "uxa". That is usually not the case but that's what you need to add if the above configuration does not completely eliminate screen tearing on Intel GPUs:
Do not use
"AccelMethod" "uxa" unless you actually need it. That may be the case if your hardware is very old. It is not the case if it's new.
If you are using a not ancient AMD GPU you're using the "amdgpu" driver and you need this:
If you're using a very rather old AMD graphics card then you're using the "radeon" driver, not "amdgpu", and you will instead you need:
You can check the X log using grep if you are unsure what driver you are using by:
grep drivers /var/log/Xorg.0.log
That will produce a line such as:
[ 24.285] (II) Loading /usr/lib64/xorg/modules/drivers/amdgpu_drv.so
[ 24.285] (II) Loading /usr/lib64/xorg/modules/drivers/radeon_drv.so
or, if you are using an Intel (i)GPU:
[ 21.857] (II) Loading /usr/lib64/xorg/modules/drivers/intel_drv.so
Setting TearFree Using xrandr
You can change the TearFree in X using
xrandr --output DisplayPort-0 --set TearFree on
xrandr --verbose will show the TearFree status on the connected displays and
xrandr --verbose|grep TearFree will just list the
--output option is required and you can not use
all. You can also not specify multiple displays with
xrandr --output DisplayPort-0 --output DisplayPort-1 --output DisplayPort-2 --set TearFree on as that only applies it to the last
One possible "solution" is to ask xrandr what displays happen to be connected and use a loop to apply (or disable) TearFree with one command for each display:
xrandr |grep ' connected'|cut -f 1 -d ' '|while read display;do xrandr --output $display --set TearFree on;done
The above one-liner is not at all elegant, but it does work.