Linux & Wayland

496 views
Skip to first unread message

Andy Robinson

unread,
Aug 22, 2016, 6:50:08 AM8/22/16
to wx-dev
I build on Xubuntu 14.04 which has Wayland compiled in by default, it seems.

I then distribute binaries, which means that on systems which do not
have Wayland compiled in by default (Gentoo, openSuse), my program won't
launch:
./transcribe: symbol lookup error: ./transcribe: undefined symbol:
gdk_wayland_display_get_type

So I looked for references to wayland in wx, there are very few, only in
src/gtk/toplevel.cpp, so I removed them - change
#ifdef GDK_WINDOWING_WAYLAND
to
#ifdef GDK_WINDOWING_WAYLANDxxx
and this fixes it.

My point is, I think there should be an option in configure where we can
choose whether to include any wayland code.

I don't know enough about how configure works to tackle this myself but
I just thought I'd mention it as a suggestion, and as a warning to
anyone who wants to build portable Linux binaries.

Also I don't know if what I have done is safe - please advise!

Regards,
Andy Robinson, Seventh String Software, www.seventhstring.com

Vadim Zeitlin

unread,
Aug 22, 2016, 8:11:38 AM8/22/16
to wx-...@googlegroups.com
On Mon, 22 Aug 2016 11:50:05 +0100 Andy Robinson wrote:

AR> I build on Xubuntu 14.04 which has Wayland compiled in by default, it seems.
AR>
AR> I then distribute binaries, which means that on systems which do not
AR> have Wayland compiled in by default (Gentoo, openSuse), my program won't
AR> launch:
AR> ./transcribe: symbol lookup error: ./transcribe: undefined symbol:
AR> gdk_wayland_display_get_type
AR>
AR> So I looked for references to wayland in wx, there are very few, only in
AR> src/gtk/toplevel.cpp, so I removed them - change
AR> #ifdef GDK_WINDOWING_WAYLAND
AR> to
AR> #ifdef GDK_WINDOWING_WAYLANDxxx
AR> and this fixes it.
AR>
AR> My point is, I think there should be an option in configure where we can
AR> choose whether to include any wayland code.

I could be wrong, but I don't think it's possible to avoid using it if
you're building using GTK+ based on Wayland. We need to have some way of
computing client decorations size and this is done in GTK+-backend-specific
way.

Looking at the code, we could provide some compile-time option saying to
default to using client decorations, but this definitely won't correctly on
systems using traditional X11 backend...

The only possibility to have a really portable binary I see is to compile
in all this code and determine during run-time which version of it to use,
but this is going to be pretty complicated.

Regards,
VZ

Andy Robinson

unread,
Aug 22, 2016, 11:00:39 AM8/22/16
to wx-...@googlegroups.com
I had never even heard of wayland until my users started reporting that
error message to me, so I apologise if I don't make sense...

Is a system with Wayland enabled, not capable of running a
non-wayland-aware program in some sort of legacy mode? And if I compile
my program without any reference to wayland (by removing the places in
toplevel.cpp where "#ifdef GDK_WINDOWING_WAYLAND" is used), am I not
producing a non-wayland-aware program?

What kind of problems might I expect to see? I have in fact removed the
"#ifdef GDK_WINDOWING_WAYLAND" sections from toplevel.cpp and my program
seems to look just the same on Xubuntu 14.04, which as I say does seem
to support wayland (GDK_WINDOWING_WAYLAND is defined).

If this is not a real solution (though as I say it seems to work for me)
then would it work if I switch to building on a platform that does not
support wayland? Or somehow disable wayland support in Xubuntu.

It would be unfortunate if it was impossible to build a wx app which
could run on Linux distros both with and without wayland.

Hans Mackowiak

unread,
Aug 22, 2016, 11:05:52 AM8/22/16
to wx-...@googlegroups.com
hey Andy Robinson, if i remember it correctly it was a bug in gdk that
it didn't export that gdk_wayland_display_get_type function.

but also you will always get the problem with dependencies.
so you might need to build extra packages for Gentoo & openSuse without
wayland. (some kind of build bots might help like launchpad)

adding a flag in wx widgets to disable wayland might not solve all your
problems.

Andy Robinson

unread,
Aug 22, 2016, 11:47:16 AM8/22/16
to wx-...@googlegroups.com
But after removing the "#ifdef GDK_WINDOWING_WAYLAND" parts from
toplevel.cpp, it does actually work - no dependency problem.

So, is this going to get me into trouble? What should I expect? It seems
to work ok.

Vadim Zeitlin

unread,
Aug 22, 2016, 12:52:57 PM8/22/16
to wx-...@googlegroups.com
On Mon, 22 Aug 2016 16:00:36 +0100 Andy Robinson wrote:

AR> Is a system with Wayland enabled, not capable of running a
AR> non-wayland-aware program in some sort of legacy mode? And if I compile
AR> my program without any reference to wayland (by removing the places in
AR> toplevel.cpp where "#ifdef GDK_WINDOWING_WAYLAND" is used), am I not
AR> producing a non-wayland-aware program?
AR>
AR> What kind of problems might I expect to see?

From reading the code, I think calling SetClientSize() and/or SetSize()
may not work correctly, e.g. calling SetClientSize(GetClientSize()) and/or
SetSize(GetSize()) would change the window size.

AR> It would be unfortunate if it was impossible to build a wx app which
AR> could run on Linux distros both with and without wayland.

I think it's possible because GTK Wayland and X backends should be
ABI-compatible. But wxGTK uses the underlying backend to get the size of
client decorations, that we need for our API. And this backend is
determined at compile-time currently. As I wrote in the previous reply, it
would be possible to determine it at run-time, but this is not trivial...

Regards,
VZ

Andy Robinson

unread,
Aug 23, 2016, 6:52:37 AM8/23/16
to wx-...@googlegroups.com
Thanks for this. It does seem to be working ok for me with the "#ifdef
GDK_WINDOWING_WAYLAND" parts removed so maybe I'll try releasing it and
see who complains. Attempting to support Linux is such a pain and
accounts for just 1.7% of my sales, I wouldn't bother except I use it
myself. Though I have to say the percentage is increasing. Over the last
3 years: 1.1%, 1.3%, 1.7% (the rest being split equally between Windows
& Mac, as it is a music app).

Andy Robinson

unread,
Aug 23, 2016, 6:57:53 AM8/23/16
to wx-...@googlegroups.com
On 22/08/16 17:52, Vadim Zeitlin wrote:
Another thought occurs to me. Now that I have removed the code in wx
that would recognize a wayland window, I presume that means that if my
app does have layout problems they would happen on a system with wayland
available. So, is there anything a user can do to disable wayland and
use plain X when running my app?
Reply all
Reply to author
Forward
0 new messages