<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 21, 2015 at 7:03 AM, Daniel P. Berrange <span dir="ltr"><<a href="mailto:berrange@redhat.com" target="_blank">berrange@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I'm trying to port GTK-VNC to work correctly under Wayland, both as<br>
a native client and as an Xwayland client. The only place we have<br>
any code that is specific to particular display servers is the keyboard<br>
handling. We can't use the GdkEventKey keyval directly because that<br>
results in having todo lossy keymap conversions in QEMU, so we need to<br>
translate the key event to get the values in terms of XT scancodes<br>
that we can send straight to QEMU. This involves a lossless translation<br>
of the values that GTK reports in the hardware_keycode field of<br>
GdkEventKey.<br>
<br>
Sadly there is no standard for what scancode values are reported in<br>
the hardware_keycode field, so we need to add a custom remapping for<br>
each display server.<br>
<br>
In traditional Xorg, the hardware_keycode is either reporting custom<br>
set of scancodes defined by xfree86 X11 keyboard driver, or with modern<br>
deployments using the Linux evdev scancodes with a simple offset-by-8<br>
applied.<br></blockquote><div><br></div><div>Do we see any widespread deployment with the xf86-input-keyboard driver? I think you can rely on seeing evdev + 8 codes everywhere.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
First I wanted to confirm what will be reported in hardware_keycode<br>
for both Wayland native and XWayland ? In my limited testing it<br>
appears that in both cases GTK is getting evdev scancodes with the<br>
same offset-by-8 applied as Xorg+evdev uses. Is this correct and is<br>
that guaranteed to stay with this mapping long term ?<br></blockquote><div><br></div><div>Yep, this is correct. To be more specific, Wayland uses evdev keycodes directly, and GDK adds the 8 to make them match the X11 scancodes as used in the XKB maps.<br><br><a href="https://git.gnome.org/browse/gtk+/tree/gdk/wayland/gdkdevice-wayland.c#n1304">https://git.gnome.org/browse/gtk+/tree/gdk/wayland/gdkdevice-wayland.c#n1304</a><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Detecting that we're a native Wayland client is easily done using<br>
GDK_IS_WAYLAND_DISPLAY(), but I'm less sure on the best way to<br>
detect that we're under XWayland. In fact ideally we'd not need<br>
to detect Xwayland, but rather directly query the keymap used.<br>
<br>
We have some existing code that uses the XkbGetKeyboard() call<br>
to query the keymap name[1], but this does not return any data when<br>
run under Xwayland.</blockquote><div><br></div><div>Hm, that's strange. We do set up an XKB keymap using the internal Xorg APIs. We should fix it so that XkbGetKeyboard(); works properly in Xwayland. I'm quite sure the XKB map we send across has the KcCGST, so we should be able to fill it in.<br><br><a href="http://cgit.freedesktop.org/xorg/xserver/tree/hw/xwayland/xwayland-input.c#n346">http://cgit.freedesktop.org/xorg/xserver/tree/hw/xwayland/xwayland-input.c#n346</a><br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The ServerVendor simply returns "Fedora"<br>
and not "XWayland", so that's out as a detection mechanism, and<br>
there's no obvious wayland specific extension loaded that I can<br>
use as a detection mechanism. I'm out of ideas of what aspect<br>
of the connected display I can use to detect presence of Xwayland.<br></blockquote><div><br></div><div>After we fix the XkbGetKeyboard(); bug, would you need to detect Xwayland?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
If there are any suggestions that'd be great, otherwise I'll go<br>
the somewhat sucky approach of seeing if the WAYLAND_DISPLAY env<br>
variable exists and infer that we're using Xwayland based on<br>
"GDK_IS_X11_DISPLAY && getenv(WAYLAND_DISPLAY) != NULL"<br>
<br>
Regards,<br>
Daniel<br>
<br>
[1] <a href="https://git.gnome.org/browse/gtk-vnc/tree/src/vncdisplaykeymap.c#n150" target="_blank">https://git.gnome.org/browse/gtk-vnc/tree/src/vncdisplaykeymap.c#n150</a><br>
<span class=""><font color="#888888">--<br>
|: <a href="http://berrange.com" target="_blank">http://berrange.com</a>      -o-    <a href="http://www.flickr.com/photos/dberrange/" target="_blank">http://www.flickr.com/photos/dberrange/</a> :|<br>
|: <a href="http://libvirt.org" target="_blank">http://libvirt.org</a>              -o-             <a href="http://virt-manager.org" target="_blank">http://virt-manager.org</a> :|<br>
|: <a href="http://autobuild.org" target="_blank">http://autobuild.org</a>       -o-         <a href="http://search.cpan.org/~danberr/" target="_blank">http://search.cpan.org/~danberr/</a> :|<br>
|: <a href="http://entangle-photo.org" target="_blank">http://entangle-photo.org</a>       -o-       <a href="http://live.gnome.org/gtk-vnc" target="_blank">http://live.gnome.org/gtk-vnc</a> :|<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">  Jasper<br></div>
</div></div>