Refactor: Make uri_to_remote_recorder more declarative

The function was getting rather long so I decided to refactor it mistaking
it for `uri_to_remote` which I'd planned to modify.  Arguably this is
still an improvement reducing the number of lines by 14.
Refactor: Make `uri_to_remote` more declarative

The function was getting rather long so I decided to refactor it before
adding the new remote type `X11Remote`.  This is more declarative.
Remotes: Add support for sending keys to X11

Can be used with GStreamer's ximagesrc for desktop automation, testing
applications, websites and set-top-box UIs written in HTML5.
test_x11_remote: Tear down Xorg & xterm in event of test failure

Otherwise the next time you run the tests it says "Skipped: There is
already a display server running on :99".
test_x11_remote: Fix finding xterm on Mac OS X

Running this test on OS X requires installing XQuartz[1], which installs
xterm into /opt/X11/bin. (You'll also have to install xdotool using
macports or similar.)

[1]: http://xquartz.macosforge.org/
Merge pull request #173 from wmanley/control-xdotool

Add support for sending keypresses to X11
README.rst: Update copyright
API: Include the region of the match, not just the position

`MatchResult.region` contains all the information that `position` does,
plus indicating the size of the matched area.  This can be useful for OCR
which takes a region to read from.  So with this change it's easy and
convenient to read the text next to a matching icon for instance:

    text = ocr(region=wait_for_match('icon.png').region.extend(right=200))

This changes the arguments `MatchResult` constructor.  This would be a
backwards compatibility break but `MatchResult`s should only be being
created by core stbt code and not by user code.  Still this is something
to watch out for.

Users can still write `pos = match_result.position` so the user facing API
has not been broken.
Fix display of `Region` documentation in web page

Unlike the man page (generated by rst2man), the web version at
http://stb-tester.com/stbt.html is generated by pandoc. Pandoc
requires that each line in an indented code block be indented
at least as much as the first line.
Use pylint 1.1.0 on Travis CI

This should minimise differences between `make check` on developer's
machines and Travis CI. 1.1.0 is the same version as in Ubuntu 14.04.

Pylint 1.x knows about namedtuple members[1] so we no longer have to
ignore E1101 errors regarding stbt.Position, stbt._Rect, stbt._Size,
and stbt.Region.

[1] http://www.logilab.org/revision/148201
Ignore pylint error on Travis CI

The error was:

    stbt.py:1680: [E1120(no-value-for-parameter), Display.teardown] No
    value for argument 'self' in unbound method call

referring to `Gst.Event.new_eos()`, which is a static method, but I
guess that pylint doesn't know that.

There are 2 very odd things about this:

1. This error doesn't happen on my own machine running the same version
   of pylint (1.1.0).
2. extra/pylint.conf says `ignored-classes=Event`, so pylint should be
   ignoring any errors related to `Event`.

Note that E1120 exists on pylint 0.28, so users of that version
shouldn't get an error due to the newly-introduced "pylint: disable"
annotation.

Other things I tried before settling on this solution:

* Upgrading Travis CI to pylint 1.2.0 (same error happens; I decided to
  stay on 1.1.0 because that's the version on Ubuntu 14.04).
* Changing extra/pylint.conf to say `ignored-classed=Gst.Event` (same
  error happens).
Merge pull request #179 from wmanley/api-matchresult-region

API: Include the region of the match, not just the position
Tidy up and fix unreliable test `test_x11_remote`

It was failing intermittently on Travis due to not knowing when xterm
is ready to accept key events.  Instead we keep sending key events until
we can see that they are having an effect.

This also tidies up the test somewhat.  By pulling the starting/stopping
of the X server out into a context manager it is clearer exactly what
`test_x11_remote` is intended to test, and how it tries to test it.

The broken test was introduced in a64e7ac7.
Merge pull request #180 from wmanley/fix-test-x11-remote

Tidy up and fix unreliable test `test_x11_remote`
test_detect_match_nonexistent_template: Make it check the right behaviour

`detect_match` should (and does) throw if the template name its given is
wrong, but the test looked like it just returned a non-matching
`MatchResult`.

This commit fixes this test to actually test the expected behaviour.
API: Allow treating `MatchResult` as a boolean

This is part of an effort to make the stbt match API more composible.
For instance with the addition of a `match()` method you will be able
to write something like:

    if match('template.png') or match('template2.png'):
        do_stuff()

The tests are updated to reflect the recommended way of expressing testing
for matches.
Merge pull request #183 from wmanley/api-matchresult-boolean

API: Allow treating `MatchResult` as a boolean
stbt control: Allow specifying keymap file in stbt config

With this change the keymap file will default to the value stored in
"control.keymap" rather than and falling back to
`~/.config/stbt/control.conf`.  This makes it easier for the use-case
where you have a config file per device under test and you want to be
able to easily switch between them using the `STBT_CONFIG_FILE`
environment variable.
Merge pull request #181 from wmanley/config-control-conf

stbt control: Allow specifying keymap file in stbt config
tests: Run (no of cores +4) tests in parallel

If available `make check` uses GNU parallel to run tests in parallel.  By
default it will run (no of cores) tasks in parallel.  This commit boosts
this number by 4 as on Travis we only have a single core to play with, but
our tests aren't CPU bound so we can further parallelize and further
reduce test run time.

On @drothlis's dual-core laptop the time is reduced from 2m to 1m30s and
on my 4 core laptop it is reduced from 1m2s to 51s.