dasher-project / dasher

Dasher
http://www.inference.phy.cam.ac.uk/dasher/
GNU General Public License v2.0
159 stars 45 forks source link

Seems not to work in Wayland #103

Open paumard opened 7 years ago

paumard commented 7 years ago

Hi,

I have just tried Dasher 5.0.0~beta in Debian Stretch (the release in preparation). While it works with the default GNOME X11 session, the Dasher window looks frozen (i.e. it simply does not sense the hovering mouse) in the GNOME Wayland session.

Kind regards, Thibaut.

paumard commented 7 years ago

Also reported as: https://bugzilla.gnome.org/show_bug.cgi?id=778151 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=852699

cagdasgerede commented 7 years ago

First I need to set up a virtual box image with Debian Stretch. In the mean time, if there are any log files, error messages, stack traces you can share with me, that would be great (Although I am not sure where the log files are stored in Dasher, if there are any)

paumard commented 7 years ago

Hi,

I'm afraid there is no backtrace I can send you. However you don't necessarily need to setup a stretch image, you should be able to reproduce this in any Linux distro recent enough to ship wayland. The problem also appears when running weston as your compositor (you will need to activate the xwayland component in weston for dasher to run at all). A good starting point is: https://fedoraproject.org/wiki/How_to_debug_Wayland_problems

If you look at the report I have also sent to the GNOME bug tracker (I opened it so I could mark this bug as blocking WaylandRelated), you will notice that there is a work-around, which is to bypass Wayland, but if you do that, there remains two problems:

This is clearly because of the "security" features of wayland, which normally does not allow applications to read or write any information outside of their own window. There are applications that are able to do this sort of things (such as GNOME Screenshot), but they need to be part of the compositor as far as I understand.

So there is something deep in the Wayland design that makes it difficult for Dasher to operate as it should in this environment. I'm not a specialist of Wayland, but it's clear that, for Dasher to work in Wayland (which seems to be what everyone will be running in a few years), you will need to avoid any gdkx.h call, and call only gdk.h functions.

It is possible that you will not be able to read the cursor position outside of the dasher window, or that you will not be able to use direct mode, unless dasher integrates closer into the compositor. I see rumors that this sort of special needs (screenshot etc) at the moment need to be reimplemented for each compositor. I hope this is not the case, or rather I hope that the Wayland developers will design some sort of authorization mechanism such as in android to allow development of third party tools to read and write in other applications. After all Dasher for android is perfectly able to write in any application, Wayland needs to have this sort of mechanism.

Perhaps a way forward would be to inject the keyboard events at the kernel level rather than at the display server level? I have not looked in details at what dasher is doing, but I expect it uses some X11 interface to send events. If this is the case, you could look at e.g. TermKeyboard and see how they proceed?

Kind regards, Thibaut.

paumard commented 6 years ago

Hi,

I have added the following patch to the Debian package

--- a/Src/main.cc
+++ b/Src/main.cc
@@ -147,6 +147,12 @@
   bind_textdomain_codeset(PACKAGE, "UTF-8");
   textdomain(PACKAGE);

+  // Disallow the wayland backend as Dasher does not work well, if at
+  // all, with this backend. TODO: check which other backends are
+  // needed for other platforms than Linux. This line needs to come
+  // before Gdk is initialized which occurs in g_option_context_parse().
+  gdk_set_allowed_backends ("x11");
+
   //  gchar *szOptionAppstyle = NULL;

   SCommandLine sCommandLine;

This is enough to make Dasher work in Wayland, to the extent that Direct mode only works for X11 windows.

As noted as comment in the patch, it remains to be checked which other backends should be allowed for other platforms.

raininja commented 1 month ago

As this issue is still evident, let's look into drawing directly into GTK3 windows in wayland, which can be accomplished with this library.