If automaticSocketNaming is enabled, it will use wl_display_add_socket_auto
to allocate the next free socket. The resulting name can be retrieved using
socketName after a successful start afterwards.
Details
- Reviewers
romangg - Group Reviewers
KWin Plasma - Commits
- R127:d671fcd0c09d: Add option to use wl_display_add_socket_auto
Ran the new autotest, passes. kwin_wayland still uses the old behaviour.
Diff Detail
- Repository
- R127 KWayland
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
I don't think we need a second variable effectiveSocketName. Just test if socketName is empty. If it is call wl_display_add_socket_auto, otherwise call wl_display_add_socket.
According to description some autotest fails. Which one exactly?
If socketName is overwritten after using wl_display_add_socket_auto, it's not possible to call start twice without resetting socketName again.
If the actual socket's name is not written to any variable, it's impossible to set WAYLAND_DISPLAY correctly in KWin.
The new variable is used to be fully API compatible except if socketName was explicitly set to an empty string.
According to description some autotest fails. Which one exactly?
testSocketName as the default value of socketName changed.
FAIL! : TestWaylandServerDisplay::testSocketName() Compared values are not the same Actual (display.socketName()) : "" Expected (QStringLiteral("wayland-0")): "wayland-0" Loc: [/home/fabian/kderepos/kwayland/autotests/server/test_display.cpp(54)]
Is a Display object meant to be started and terminated more than once? But ok, let's make sure.
According to description some autotest fails. Which one exactly?
testSocketName as the default value of socketName changed.
FAIL! : TestWaylandServerDisplay::testSocketName() Compared values are not the same Actual (display.socketName()) : "" Expected (QStringLiteral("wayland-0")): "wayland-0" Loc: [/home/fabian/kderepos/kwayland/autotests/server/test_display.cpp(54)]
Is there an argument against just checking on empty string at this location? Since the socket name is not yet set in line 54, there shouldn't be one.
Not sure, but it's technically possible and I don't see anything discouraging it.
According to description some autotest fails. Which one exactly?
testSocketName as the default value of socketName changed.
FAIL! : TestWaylandServerDisplay::testSocketName() Compared values are not the same Actual (display.socketName()) : "" Expected (QStringLiteral("wayland-0")): "wayland-0" Loc: [/home/fabian/kderepos/kwayland/autotests/server/test_display.cpp(54)]Is there an argument against just checking on empty string at this location? Since the socket name is not yet set in line 54, there shouldn't be one.
The argument is that the default value changed, which is technically an ABI break - that's why this is an RFC. If you say that it's fine, I'll do the change and remove the RFC.
Hmm, maybe then add another setter setAutomaticSocketNaming instead to switch to automatic socket name query instead. When it's not called before start it would fall back to old behavior.
Hmm, maybe then add another setter setAutomaticSocketNaming instead to switch to automatic socket name query instead. When it's not called before start it would fall back to old behavior.
That would need changes in KWin though so Plasma 5.16 only :-(
I've been using a patched kwayland locally for several months now already, so I'd need to continue doing that for a another couple months. That's all though.
I'll do the change and remove the RFC.
src/server/display.cpp | ||
---|---|---|
86–88 |
src/server/display.cpp | ||
---|---|---|
87 | bool running = false; bool automaticSocketNaming = false; |
autotests/server/test_display.cpp | ||
---|---|---|
223 | This fails when one tries to run the test inside another Wayland session, which already uses the wayland-0 socket name. What you could do here is loop until you find the first non-existing wayland-x in the runtime dir. Then do it one more time from there until you find the second wayland-y. Remember x,y and compare these below against the created socket names. |
autotests/server/test_display.cpp | ||
---|---|---|
223 | That won't work reliably either though - if wayland-0 is free, but wayland-1 is used, it would pick wayland-0 and wayland-2. Maybe it should just check that starting both displays at the same time succeeds and that their socket names are not equal. |
autotests/server/test_display.cpp | ||
---|---|---|
223 | I would suggest changing the XDG_RUNTIME_DIR for the duration of the test. |
autotests/server/test_display.cpp | ||
---|---|---|
223 | That's why I said "do it one more time from there until you find the second wayland-y". QString name1, name2; int cnt = -1; while(true) { cnt++; const QString name = "wayland-" + str(cnt); if (!runtimeDir.exists(name)) { name1 = name; break; } } while(true) { cnt++; const QString name = "wayland-" + str(cnt); if (!runtimeDir.exists(name)) { name2 = name; break; } } David's solution is nicer though. |