I've always grappled with one major issue when using lightweight DE's like XFCE or LXDE: Video tearing. For me there is nothing more annoying then seeing tearing when watching video in my local video player or in flash player, and seeing ugly tearing when scrolling in firefox. XFCE's built-in xrender based compositor does nothing but exacerbate the issue, and the intel driver's "TearFree" option performs rather poorly.

The obvious solution to this is using an opengl compositor. In the past I had been using compiz in XFCE, which worked but left a lot to be desired when it came to integrating with XFCE and general bugginess; and the last straw is that in 13.04 it seems rather unusable when used outside of unity (severe bugs such as unclickable window decorations), so I searched for another solution. I then found compton: https://github.com/chjj/compton. Compton is a very lightweight compositor that is based on xcompmgr (its a fork of xcompmgr-dana). Compton features a stable opengl backend and working vsync (It also has an xrender backend, but for the purpose of getting tear-free output the opengl backend is recommended). Compton is an excellent fit for XFCE or LXDE because it is very lightweight and it does not need to replace your window manager like compiz does, it purely provides compositing.

The first thing you will want to do is install compton. The compton maintainer has a ppa for compton here: https://launchpad.ne...archive/compton. To add the ppa to your system and install compton, open the terminal and enter the following commands: sudo apt-add-repository ppa:richardgv/compton and sudo apt-get update && sudo apt-get install compton

Next you will want to create your compton config file. Save the file as .compton.conf in your home directory. Here is the config file I use, I've added a few detailed comments explaining the most important things:

If you want to enable compton globally (for every user on the system), you can edit: /etc/xdg/lxsession/Lubuntu/autostart. Once the file is open in your text editor just add your startup command to it with an @ symbol in front of it, for example: @compton -b &

And there you have it, if all goes well you should not have quick and stable tear free rendering in XFCE (or the light DE/WM you prefer)

Alternate Method:

Some have commented that putting the opengl/vsync settings in their .compton.conf is not having any effect. If this happens you can pass them as command line switches instead. Create a file called compton.sh, make it executable with chmod +x compton.sh, and pass the settings as switches to the compton startup command like so: compton --backend glx --paint-on-overlay --glx-no-stencil --vsync opengl-swc -b &. Save the file, and in the XFCE application autostart settings click "add" and browse to where you saved the file.

For LXDE you can just follow the same instructions above to add it to autostart, just change the startup command accordingly.

5/6/13: edited with updated config file, added some more things to shadow exclusions.

Thanks for all of this info about compton. I just discovered it over the weekend, and this adds a lot to my knowledge. A couple of comments:

There is a way to start compton with the gui. Go to Settings Manager: Session and Startup: Application Autostart. Click add, and paste the start command in there, without the ampersand.

While you are in Settings Manager, you may want to turn off compositing in Window Manager Tweaks. :-)

The "man compton" or "compton -h" commands give a list of options.

...

In considering other window managers, did you try Openbox? It's interesting, maybe not worth the trouble if compton and xfce4wm solves your problem. One tip if you try this: Openbox conflicts with xfdesktop in a couple of areas. So the replacement is a bit more complicated than with gala. I disabled xfdesktop (along with xfwm4) and used nitrogen to set my desktop wallpaper.

Thanks for all of this info about compton. I just discovered it over the weekend, and this adds a lot to my knowledge. A couple of comments:

There is a way to start compton with the gui. Go to Settings Manager: Session and Startup: Application Autostart. Click add, and paste the start command in there, without the ampersand.

While you are in Settings Manager, you may want to turn off compositing in Window Manager Tweaks. :-)

The "man compton" or "compton -h" commands give a list of options.

...

In considering other window managers, did you try Openbox? It's interesting, maybe not worth the trouble if compton and xfce4wm solves your problem. One tip if you try this: Openbox conflicts with xfdesktop in a couple of areas. So the replacement is a bit more complicated than with gala. I disabled xfdesktop (along with xfwm4) and used nitrogen to set my desktop wallpaper.

Yeah I just put my startup command in a text file because I had been tweaking the command a lot, and that way all I had to do was edit the text file if I wanted to change it, instead of going into the settings manager every time. And thanks for the reminder about disabling xfwm's compositing, I've edited my OP to warn to make sure xfwm's compositing is set to disabled, otherwise compton won't start at all

Regarding openbox, I didn't have any particular interesting in trying it because it wouldn't do anything to solve my tearing problem, because like xfwm it does not have any opengl compositing (so i'd be using compton either way). With intel graphics I get tearing with any window manager that does not have opengl compositing, its really the only way to get full tear-free output with modern intel graphics.

Recent intel hardware is actually designed with only a compositor in mind (quote from an intel developer):

First note that all Intel hardware up to SandyBridge has functional vsync support with no greater cost than stalling the GPU until the blit can proceed.The problem is that with the agressive powersaving of SandyBridge and the greater decoupling between the display engine and the GPU, the ability to delay rendering until a particular scanline had passed was assumed to be a legacy feature and the GPU commands to do so were removed. By presuming that all updates would then be through a compositor using pageflipping (i.e. their primary target, Windows Vista/7/8), they were then able to make further power savings. If you use an OpenGL (really DRI2) compositor that only pageflips (i.e. doesn't try to take "advantage" of MESA_copy_sub_buffer), you will not see any tearing, suffer very little jitter, and maximise the power savings of the GPU.The TearFree option (still in its infancy, and really only a proof-of-principle at this stage) is to make sure that even a bare X only ever pageflips. This is primarily because future hardware will have even more widespread aggressive power savings that assume a compositor, and worst case scenario, the display engine will only be functional with a pageflipping compositor.

Yeah I just put my startup command in a text file because I had been tweaking the command a lot, and that way all I had to do was edit the text file if I wanted to change it, instead of going into the settings manager every time.

...

Regarding openbox, I didn't have any particular interesting in trying it because it wouldn't do anything to solve my tearing problem...

I think the config file for compton makes a lot of sense, for the reason you mentioned. I believe you could call compton.sh from Application Autostart in the GUI though. Not a big deal, but some readers might prefer to do it that way.

I'm mostly a Linux hobbyist, running an old HP laptop with an AMD processor. I try things for the learning experience, and because I'm always looking for a good combination of performance, convenience, and ease of use. I find xfce delivers a pleasing balance of those things, but it's fun to try different modifications.

In my testing, Openbox used slightly less memory than xfwm. But since I just upgraded RAM from 1Gb to 2 Gb, I can afford the extra 10 Mb. :-)

Please put back the old instructions, as these new ones produce tearing at the very top of the screen. They are luckily still available through Google cache.

Basically by copying what Crunchbangs settings are you are also reproducing the tearing that Crunchbang has on Intel at the very top of the screen. Your old .sh instructions do not produce any tearing at the top of the screen or anywhere else on Intel.

While I did like gala, it was very quick with some very nice looking effects, it did seem to be a little on the buggy side when used with XFCE (keyboard shortcuts would randomly stop working) and the integration left a little to be desired.

I recently discovered that the lightweight compton compositor now has a decent opengl backend and can do tear-free rendering with most drivers: https://github.com/chjj/compton

This is now by far my favorite compositor to use with XFCE (Its ideal for any lightweight DE really, and probably also good for those that just use a WM) because compton does not need to replace the XFCE window manager, it only provides the compositing and I can retain the native XFCE window management and window decorations, so integration-wise its basically perfect. Compton only has some very simple shadows and effects, but it is enough for me, I mainly just want that wonderful tear-free output

It does take a little tweaking to initially setup, so here is a quick guide:

1. Obviously, install compton. For ubuntu there is a PPA available here and it is maintained by the compton maintainer: https://launchpad.ne...archive/compton. For arch it is in the AUR as compton-git. Not sure about other distros.

2. You will want to take a look at: https://github.com/c...pton.1.asciidoc for a good overview of the options available to you, compton is very customizable. You may also want to take a look at this to tweak compton for optimal performance, certain options may perform better on certain hardware/drivers: https://github.com/c...wiki/perf-guide

3. You will need a way to start compton. What I did was make a file called compton.sh in my home dir (don't forget to make it executable!), and added it to my XFCE autostart (Settings Manager > Session and startup> application autostart > add > browse to compton.sh), this way I can easily tweak my compton launch options in the text file.

--backend glx enables the opengl backend of compton, by default it uses xrender. You will definitely want to use the opengl backend if you want tear-free output.

--paint-on-overlay and --glx-no-stencil are not required, they can effect performance a bit. on my intel card/driver they happened to perform well.

--vsync opengl-swc This is the important part, it enables one of the opengl backend's vsync methods. This method should work with intel and nvidia. If it does not work take a look at the other vsync options on the compton documentation, there should be one that works for your driver.

--config ~/.compton.conf This tells compton the location of the config file I want it to read from, you can specify any location or config file name you wish. The config file is important for fine tuning things like shadows and effects.

-b & forks compton and makes it run in the background as a daemon.

note: make sure xfwm's compositing is disabled before attempting to start compton, otherwise compton will not start.

4. You will want to make your compton config file, in my case its .compton.conf. I've optimized mine to have some simple shadows and fade effects, and to work well with XFCE (I've removed shadows on tooltips and xfce's notifications, it also has tweaks to fix shadows on synapse and conky):

# Shadow

shadow = true; # Enabled client-side shadows on windows.

no-dock-shadow = true; # Avoid drawing shadows on dock/panel windows.

no-dnd-shadow = true; # Don't draw shadows on DND windows.

clear-shadow = true; # Zero the part of the shadow's mask behind the window (experimental).

All the compton opengl/vsync settings in the updated instructions are exactly the same as they were in the old ones, I just moved them into the config file instead of having them in the compton startup command...

Before I was using these in my startup command: --backend glx --paint-on-overlay --glx-no-stencil --glx-no-rebind-pixmap --vsync opengl-swc

And now I am starting compton with just compton -b and just have them in the top of my config file instead:

I copied the config file in my updated post directly into my own .compton.config just to make sure and it works totally fine here; no tearing anywhere, and it is behaving just as it was before when I had the opengl settings in the startup command.

I would double-check the name and location of your config file, maybe compton isn't seeing your config file for some reason so its just launching with default settings? It should be .compton.conf in your home directory (unless you specified another location for it in your compton startup command).

The config and location are fine on my end. It appears that for some reason my PC is not seeing the new switches in the .config like it was with the .sh file.

The tearing is at the absolute top of the screen. Have you tried having no panel at the top or auto hiding it to see if when you move a window at the very top edge of the screen that there is no tearing?

The config and location are fine on my end. It appears that for some reason my PC is not seeing the new switches in the .config like it was with the .sh file.

The tearing is at the absolute top of the screen. Have you tried having no panel at the top or auto hiding it to see if when you move a window at the very top edge of the screen that there is no tearing?

Yes, and I tried fullscreen video, no tearing anywhere just as expected. Not sure why yours is not parsing those options in the config file, it seems to work fine for everyone else