[Spice-devel] [vdagent-linux v2] randr: handle XRRScreenChangeNotifyEvent

Christophe Fergeau cfergeau at redhat.com
Wed Oct 8 05:07:18 PDT 2014


On Wed, Aug 27, 2014 at 08:51:10PM +0200, Marc-André Lureau wrote:
> From: Marc-Andre Lureau <marcandre.lureau at redhat.com>
> 
> Make sure vdagent follows the current monitor configuration.  This
> solves a number of issue where the pointer input is off, because the
> uinput tablet isn't reconfigured.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1086657
> ---
>  src/vdagent-x11-priv.h  |  4 +++-
>  src/vdagent-x11-randr.c | 34 +++++++++++++++++++++++++++++++++-
>  src/vdagent-x11.c       |  4 +++-
>  3 files changed, 39 insertions(+), 3 deletions(-)
> 
> diff --git a/src/vdagent-x11-priv.h b/src/vdagent-x11-priv.h
> index 38f852e..d60cc07 100644
> --- a/src/vdagent-x11-priv.h
> +++ b/src/vdagent-x11-priv.h
> @@ -95,6 +95,7 @@ struct vdagent_x11 {
>      int height[MAX_SCREENS];
>      int has_xfixes;
>      int xfixes_event_base;
> +    int xrandr_event_base;
>      int max_prop_size;
>      int expected_targets_notifies[256];
>      int clipboard_owner[256];
> @@ -145,7 +146,8 @@ void vdagent_x11_send_daemon_guest_xorg_res(struct vdagent_x11 *x11,
>                                              int update);
>  void vdagent_x11_randr_handle_root_size_change(struct vdagent_x11 *x11,
>                                              int screen, int width, int height);
> -
> +int vdagent_x11_randr_handle_event(struct vdagent_x11 *x11,
> +    XEvent event);
>  void vdagent_x11_set_error_handler(struct vdagent_x11 *x11,
>      int (*handler)(Display *, XErrorEvent *));
>  int vdagent_x11_restore_error_handler(struct vdagent_x11 *x11);
> diff --git a/src/vdagent-x11-randr.c b/src/vdagent-x11-randr.c
> index 5faaee6..c6f790e 100644
> --- a/src/vdagent-x11-randr.c
> +++ b/src/vdagent-x11-randr.c
> @@ -132,12 +132,15 @@ void vdagent_x11_randr_init(struct vdagent_x11 *x11)
>          return;
>      }
>  
> -    if (XRRQueryExtension(x11->display, &i, &i)) {
> +    if (XRRQueryExtension(x11->display, &x11->xrandr_event_base, &i)) {
>          XRRQueryVersion(x11->display, &x11->xrandr_major, &x11->xrandr_minor);
>          if (x11->xrandr_major == 1 && x11->xrandr_minor >= 3)
>              x11->has_xrandr = 1;
>      }
>  
> +    XRRSelectInput(x11->display, x11->root_window[0],
> +        RRScreenChangeNotifyMask | RRCrtcChangeNotifyMask);
> +

Enabling this on just root_window[0] will still allow us to get events
for changes on any screen regardless of their root window?


>      if (x11->has_xrandr) {
>          update_randr_res(x11, 0);
>      } else {
> @@ -466,6 +469,8 @@ static int set_screen_to_best_size(struct vdagent_x11 *x11, int width, int heigh
>  void vdagent_x11_randr_handle_root_size_change(struct vdagent_x11 *x11,
>      int screen, int width, int height)
>  {
> +    update_randr_res(x11, 0);
> +
>      if (width == x11->width[screen] && height == x11->height[screen]) {
>          return;
>      }
> @@ -481,6 +486,33 @@ void vdagent_x11_randr_handle_root_size_change(struct vdagent_x11 *x11,
>      }
>  }
>  
> +int vdagent_x11_randr_handle_event(struct vdagent_x11 *x11,
> +    XEvent event)
> +{
> +    int handled = TRUE;
> +
> +    switch (event.type - x11->xrandr_event_base) {
> +        case RRScreenChangeNotify: {
> +            XRRScreenChangeNotifyEvent *sce =
> +                (XRRScreenChangeNotifyEvent *) &event;
> +            vdagent_x11_randr_handle_root_size_change(x11, 0,
> +                sce->width, sce->height);

I think '0' is not good enough here and that the index of sce->window
should be used (see ConfigureNotify handling in
vdagent_x11_handle_event)

> +            break;
> +        }
> +        case RRNotify: {

'case RRCrtcChangeNotify' as this is what was selected earlier?

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20141008/aba88d01/attachment.sig>


More information about the Spice-devel mailing list