Re: [PATCH]: Make virt-viewer ungrab the mouse and keyboard on un-focus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 20, 2008 at 01:39:49PM -0600, Pat Campbell wrote:
> Chris Lalancette wrote:
> > Daniel P. Berrange wrote:
> >   
> >> I struggle to understand how/what you managed todo here. If the keyboard
> >> grab is active nothing should be able to steal keyboard input focus, since
> >> this is the whole point of keyboard grab. If something did manage to steal
> >> keyboard input while grab was active, then this is a bug in the window
> >> manager and not something we should hack in virt-viewer - inded if this
> >> is possible, then every single app which uses grabs needs your patch which
> >> is clearly non-scalable
> >>     
> >
> > This arguably is some sort of window manager bug, or possibly a bug in the way
> > keyboard grab is currently working.  In any case, it is very easy to reproduce.
> >  Just do something like:
> >
> > # virt-viewer guest1 & sleep 10 ; virt-viewer guest2
> >
> > And make sure to click inside the guest1 virt-viewer window right after it pops
> > up.  Assuming your keyboard is grabbed there, and that your window manager
> > placed the guest2 window on top of the guest1 window, you will be unable to
> > escape (with Ctrl-Alt) from the guest1 window.
> >
> > Chris Lalancette
> >
> >   
> It is not a Window Manager bug, it is a virt-viewer bug.  The Window
> Manager is not responsible for releasing keyboard or pointer grabs when
> a window looses focus.  It is the applications job.
> 
> Take a look at xorg/xc/Xserver/dix/event.c: ProcUngrabPointer(ClientPtr
> client)   This function checks that the releasing client is the client
> that owns the grab.  This behavior makes sense, would be a huge security
> hole otherwise.

Ok, that makes a little more sense, though I'm still surprised its possible
to loose keyboard focus while grabbed, and I'm fairly sure we always grab
keyboard whenever the mouse is grabbed.

> Not sure this will apply cleanly but I would suggest something like
> below to gtk-vnc/vncdisplay.c:

Looks reasonable to me - CC'ing the GTK-VNC mailing list..
 
> --- vncdisplay.c.orig   2008-05-20 13:32:24.000000000 -0600
> +++ vncdisplay.c        2008-05-20 13:33:22.000000000 -0600
> @@ -492,6 +492,9 @@ static gboolean leave_event(GtkWidget *w
>          if (priv->grab_keyboard)
>                  do_keyboard_ungrab(VNC_DISPLAY(widget), FALSE);
> 
> +        if (priv->grab_pointer)
> +                do_pointer_ungrab(VNC_DISPLAY(widget), FALSE);
> +
>          return TRUE;
>  }

Dan
-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux