randr: Add some more debugging messages

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
randr: Round x monitor coordinates to a multiple of 8

We already do this when comparing new received monitor settings from the
client with the current ones, since the X-server rounds the width / x
coordinates to a multiple of 8 when we set them. Currently what happens is:
1) We get a monitor-config with a non multiple 8 width
2) We set the crtc to this width
3) We set the screen to this width
4) We configure the uinput tablet with this width
5) The X-server adjusts things to a multiple of 8
6) We re-configure the uinput tablet with the new width

By rounding the width and x coordinates before applying them we safe all
this back and forth to the X-server.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
randr: Move same_monitor_configs() call to after zero rooting the coordinates

If the client is sending non 0,0 rooted monitor coordinates these won't
match what we've configured in the X-server if we check them before having
called zero_base_monitors().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
randr: Call update_randr_res() from same_monitor_configs()

This is necessary because the randr settings may have been changed underneath
us (by gnome-settings-daemon for example).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
randr: Also compare screen width & height in same_monitor_configs()

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
randr: Properly update things if the number of monitors changes

If the number of monitors changes, and the remaining monitors are
the same as before, then same_monitor_configs() would wrongly return
true, causing monitor-reconfiguarion to be skipped.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
randr: Use XRRGetScreenResourcesCurrent (rhbz#888821)

Using XRRGetScreenResources, causes the X-server to actively check for
new monitors, which generates Xrandr events even if nothing is changed, which
causes gnome-setting-manager to muck with the settings, racing with the
agent doing the same.

XRRGetScreenResourcesCurrent OTOH simply returns the last known settings
without any polling of the hardware and matching events being involved.

So use XRRGetScreenResourcesCurrent instead of XRRGetScreenResources, with
one exception. When the number of monitors is changed, so some outputs are
enabled or disabled, then the hardware polling is necessary to properly
reflect the connected / disconnected state in xrandr.

This requires Xrandr >= 1.3, note that since 0.12.0 we already depended
on >= 1.2 anyways, this patch raises the requirement to 1.3 and makes
it explict.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
randr: Properly delete old mode in multi-monitor configs

Using x11->width and x11->height to delete the old mode is wrong, since
this contains the total screen width and height, not the per monitor
width and height.

And we must not only delete the mode when replacing it with a new one,
but also when disabling the output.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
randr: Limit searching mode by size to the current output

Otherwise we may end up using user-modes added for one output on another one,
messing up mode-deletion.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
vdagent-x11-randr: Fix building warning

This patch can be safely applied since it just deletes unused variables.

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
vdagentd: Fix building warning

Move some variable declarations to right place.

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
randr: Make all sizes and coordinates signed

Xrandr itself has monitor sizes and coordinates as signed, and so does
most of our code, but not all of it. Making it all signed fixes a compiler
warning, and allows us to properly deal with the client sending negative
monitor coordinates.

Note: Unfortunately this does require some pointer casts when dealing with
the agent monitor-config message, as width and height are unsigned there :|

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Buildsys: Add default CFLAGS to be used when no CFLAGS are specified

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Prepare for 0.12.1 release

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
randr: Add support for VD_AGENT_CAP_SPARSE_MONITORS_CONFIG (rhbz#881072)

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
vdagent-x11: Fix crash on vdagend restart (rhbz#894365)

vdagent_x11_destroy() cleans up clipboard state and will tell the client
it is releasing the clipboard if it owns it. But when the vdagentd is
restarted the unix socket is disconnected and x11->vdagentd points to
already free-ed memory, leading to a crash.

This patch fixes this by not trying to send messages to the client on
cleanup when the unix socket is disconnected.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
vdagentd-xorg-conf: Don't warn when there are too few qxl devices (rhbz#895004)

Since we now support more then 1 monitor / qxl device don't log a warning
when there are more monitors then qxl-devs. Note the warning does still
get written to the generated xorg.conf file, as that is intended for use with
xinerama setups, and there we do have a limit of 1 monitor / device.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>