I switched to Linux about 1.5 years ago now when replacing my old Macbook Pro with a Tuxedo Infinity Book. I am super happy with the transition, and for the most part my digital life has severely improved as a result of it. There’s one thing in particular though that I haven’t fully grasped or understood despite all the talk about it, and that really has mostly caused confusion on my part, and that is Xorg/X11 (I don’t know the difference…) vs. Wayland.

I started out with Tuxedo OS 1 and 2 running KDE Plasma 5.x.x, and thus have been on X11 for the most part since switching to Linux. I never dared switching to Wayland myself. However, they somewhat recently started offering optional upgrades to Tuxedo OS 3 running KDE Plasma 6 where Wayland is the default, and I took the plunge. The only real difference I noticed was small annoyances that I had to fix. Glitching windows running on XWayland and having to configure some .desktop-files to force apps to launch natively in Wayland. Apps not showing the correct desktop icons but the generic Wayland logo instead, making Alt+Tabbing a bit more difficult because it is harder to tell applications apart. Annoying smooth scrolling (I don’t want scrolling to have as much friction as polished ice) activated in all kinds of applications that I seem to have to turn off individually. Nothing breaking (though I haven’t dared booting with my Nvidia dGPU yet in fear of breaking something irreversibly…), but I haven’t noticed any improvements either, and I find it a bit frustrating not knowing where to make the necessary changes and always having to search for it seemingly on a case by case basis.

Now for instance I was updating FreeTube to a new version, and the flags I previously added to the ́.desktop’-file suddenly doesn’t work anymore (--enable-features=UseOzonePlatform,WaylandWindowDecorations --ozone-platform-hint=auto). The application won’t launch unless I remove them, but then it launches under XWayland instead. Not that I have any issues so far running it like that, but I guess I would prefer to run everything natively in Wayland if I can.

  • Ramin Honary@lemmy.ml
    link
    fedilink
    English
    arrow-up
    91
    arrow-down
    1
    ·
    edit-2
    2 months ago

    I can explain the difference between X11 and Xorg with an analogy to the web and web browsers: X11 is like HTTP, Xorg is like the Chrome browser. X11 is the protocol, Xorg is software that implements that protocol.

    X11 is old, it was designed back in the 1980s and includes messages for drawing lines and circles and fonts on the screen. Also, back then there were a lot of “thin clients”, computers that were basically nothing but a browser, since graphics were computationally expensive and could not be done on the client computer, graphics rendering was done server side. There are lots of messages in the protocol for handling screen updates over a computer network.

    Nowadays, all personal computers are powerful enough to render their own graphics, and no one needs the display server to draw individual lines or circles on screen. Vector graphics and fonts are done at the application level, not over the network. So these these messages specified in the X11 protocol are hardly ever used. Really, most of X11 (let’s say 90% of it) is not used at all, only the parts where the keyboard and mouse are defined, and how you can allocate memory to buffer a graphic and copy that buffer to the display. But you still need to maintain the Xorg software to handle everything that X11 specifies, and this is just a waste of code, and a waste of time for the code maintainers.

    So basically, they decided about 10-15 years ago that since no one uses most of X11, let’s just define a new protocol (called Wayland) that only has the parts of X11 that everyone still uses, and get rid of the 90% of it that no one ever uses. Also, the protocol design takes into account the fact that most modern computers do all of their own rendering rather than calling out to a server to render for them. Also the Wayland protocol design takes into account that a lot of computers have graphics cards for accelerated graphics rendering.

    Since the Wayland protocol is much simpler, it is easier for anyone to write their own software which implements the protocol, these software are called “compositors.” Finally, 10 years after some of the first implementations of Wayland, the protocol and compositors are becoming mature enough that they can be used in ordinary consumer PCs.

    • 8adger@lemmy.world
      link
      fedilink
      English
      arrow-up
      36
      arrow-down
      2
      ·
      2 months ago

      Don’t forget Wayland and security into the mix as well. That seems to have caused some of the biggest issues with apps. Don’t get me wrong though, security was desperately needed. X11 had no concept of security.

      • cyberwolfie@lemmy.mlOP
        link
        fedilink
        arrow-up
        14
        ·
        2 months ago

        Do you mean that Wayland has had its own security issues, or that enhanced security has caused additional issues for apps to run correctly?

        • spacemanspiffy@lemmy.world
          link
          fedilink
          English
          arrow-up
          34
          arrow-down
          1
          ·
          2 months ago

          My understanding is that due to X11’s design, all running GUI apps can “see” all the other apps. If you’re running a malicious program in X11, it can easily snoop what else you are doing, log your keystrokes, etc.

          Wayland solves this through better design.

        • unknowing8343@discuss.tchncs.de
          link
          fedilink
          arrow-up
          23
          ·
          2 months ago

          The second one. Some apps were taking advantage of the fact that X allowed any program access to EVERYTHING on your screen, shortcuts, etc. Wayland ensures more control, which is excellent news, but definitely the change requires programs to adapt, and some have not (AnyDesk, for example).

        • TheGrandNagus@lemmy.world
          link
          fedilink
          English
          arrow-up
          19
          ·
          2 months ago

          The addition of security has caused issues.

          E.g. apps not being able to see other apps by default has caused issues for some screen recorders or screen-sharing software. Or screen readers from seeing inside apps.

          Or apps not being able to see keystrokes when the app isn’t active, impacting global shortcuts (say, for example, you’re a streamer who uses a hotkey to change cameras in OBS)

          A lot of Linux stuff was written with the expectation of there being zero security safeguards. With Wayland, that has changed and it’s causing issues.

      • TimeSquirrel@kbin.melroy.org
        link
        fedilink
        arrow-up
        11
        arrow-down
        2
        ·
        edit-2
        2 months ago

        It was created in a time when physical restrictions on access to the machine was enough. If you weren’t meant to be in the lab, somebody found out real quick.

        Wasn’t just that, it was everything. DOS, early Windows, etc all didn’t give a rat’s ass about security. In 1986 you could just go over to your friends house and turn on their machine and just go through all their shit laid bare. I don’t even think we had BIOS passwords at the time. At least the machines I used didn’t. It was a wild time.

    • cyberwolfie@lemmy.mlOP
      link
      fedilink
      arrow-up
      13
      arrow-down
      1
      ·
      2 months ago

      Thanks for such a detailed account - it really makes sense to move on from X11 based on what you write.

      When I first heard about what X11 and Wayland was and how long the transition has been in the making, I found it a bit hard to believe that it should take so long. I am still not fully sure why it would take so long time to mature… is it a chicken-and-egg kind of situation where it cannot mature properly before it is more widely used, but it has not been more widely used because it was not mature enough? Or is it such a difficult task to get this right and that the development time reflects that?

      And why would for instance NVIDIA GPUs continue to have issues with Wayland (and what kind of issues would actually be caused by this?)? Is that a matter of closed source drivers and lack of support from NVIDIA’s side to implement required changes? Or are such issues on a more fundamental level (i.e. architectural differences that somehow factors into this - I have no idea what I’m talking about now, I’ll stop writing…)?

      • nous@programming.dev
        link
        fedilink
        English
        arrow-up
        12
        arrow-down
        2
        ·
        2 months ago

        Closed source drivers are not really the issue. But competing graphics APIs are. With the move to Wayland open graphics drivers were updated to support the GBM graphics API which if one window manager wants to support then it gains support for all graphics drivers that use that api. But nvidia created its own api, eglstreams that to support required all window managers to write extra code for. Some refused to do that or took a long time to do.which gave shoddy nvidia support.

        Some did support nvidia slowly, but then nvidia also switched to support the same api as everyone else (poorly at first but I assume it has improved over the years). Nvidia have also partly released their drivers as open source which has also helped.

        • cyberwolfie@lemmy.mlOP
          link
          fedilink
          arrow-up
          4
          ·
          2 months ago

          Ah, OK. I wasn’t aware of those APIs, only things like OpenGL and Vulkan, but those are perhaps specific to 3D graphics rendering?

          And windows managers in the context of Wayland are the same as Wayland compositors? Which compositor would I be using through KDE Plasma 6?

          • jayandp@sh.itjust.works
            link
            fedilink
            arrow-up
            1
            ·
            2 months ago

            Which compositor would I be using through KDE Plasma 6?

            KDE uses KWin by default, which can do both X11 and Wayland currently.

      • lilbluntwrap@beehaw.org
        link
        fedilink
        arrow-up
        6
        ·
        2 months ago

        Re: maturity - I think it is the latter where the problem is very complex and the dev time reflects that, it takes a long time to implement all the features people need and are used to in X11 (or, used to when coming from windows/macOS). For instance, screensharing is still not widely solved across all wayland compositors. In Gnome or KDE Plasma, it works as you’d expect. But a smaller project like river (tiling window manager that I daily drive rn) does not handle screensharing out of the box and takes some extra configuration - and even then it’s got some oddities that I didnt have in KDE.

        As for your issues with NVIDIA gpus under Wayland, yes I think it comes down to driver support from NVIDIA (or the open source drivers just need to mature some more)

  • azvasKvklenko@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    21
    ·
    2 months ago

    At the very beginning in early 90’s Linux adopted X11 implementation that was XFree86. It was obvious and pragmatic move, because Linux was UNIX clone with full POSIX standard compatibility, and X11 was already there for almost a decade. Porting it allowed for having graphical interface very early on (Linux started in 1991, X11 support was added one year later) and allowed all the contemporary UNIX software to be easily ported to Linux.

    X11 however was designed with completely different needs in mind, as UNIX machines were mostly mainframes or powerful workstations and not home computers. It was about a lot of features that make no sense in this day and age (like network transparency, drawing primitives, printing capabilities, font rendering etc) and its design aged like milk. Xorg (that was fork of XFree86 started after license change) was implemented in a way that allows keeping compatibility for the time being with many issues being worked around and the old solution being effectively forcefully framed into modern use. It’s basically huge

    Wayland started as an idea on how to do graphics on Linux (and other UNIX systems) without X, but it was never meant to be drop-in replacement. That being said, it’s vastly incompatible and the shape towards having Wayland desktops is long process of gradual implementation of new protocols to make it complete eventually.

    Making Wayland possible took redesign of the OS itself. In old days, Linux didn’t think much about graphics and it was the monolithic X server that took responsibility of things like loading video drivers, setting screen modes or pushing stuff to video memory. Wayland was all about split of X’s features outside of X to gradually remove the dependency, so now the kernel has native system interfaces like kernel mode setting, direct rendering manager and so on. It’s not only Wayland taking advantage of it, as the same infrastructure is now used under X too.

    Your experience wasn’t much different because it wasn’t meant to be. Desktops that are ported to Wayland are very good at abstracting things that are specific to both (otherwise completely different) display systems. You can gradually find about some things being different over time as you dive deeper.

    There are certain limitations of X that Wayland doesn’t have:

    • X cannot handle multiple DPI settings, so it is only possible to set one scaling factor globally for all monitors no matter their size/pixel density
    • X could never properly handle multiple refresh rates for different monitors
    • No way for proper HDR support on X
    • VR is not really a good idea on X

    On the other hand, X is very open to the user and applications, providing all sorts of information about opened windows and sniffing input globally by any client (focused or not) is a feature. In 1984 no one really thought cybersecurity will be important factor. So on Wayland:

    • App can’t keylog keyboard presses or mouse movements unless its window is focused (global shortcuts are still unsolved issue, WIP)
    • App can’t directly control its window position and size as it is only controlled by compositor (the idea is to introduce protocol for asking compositor on window positions relative to some area, it’s WIP)
    • App cannot get image of screen or window (this is solved via PipeWire video capabilities and xdg-desktop-portal)
    • Any GUI automation is compositor-specific, at least for now.

    For those and other reasons (like availability of desktop environments and window managers), some still prefer Xserver.

  • atzanteol@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    20
    ·
    edit-2
    2 months ago

    The biggest benefits of Wayland over Xorg are to the developers maintaining it, not to the end user.

    The Xorg project has become difficult to modify for new features and fixes and so they’ve decided to rewrite it.

    As a result users will eventually see some benefits as Wayland implements features that were difficult to do in Xorg over time. But in the meantime it’s causing everything to be rewritten to support the new standard. And it’s a pain in the ass.

    If your application works as you want on Xwayland there’s no reason to try to get it to work on Wayland native. Xwayland won’t be going away anytime soon. Eventually those applications will just switch over to Wayland and you shouldn’t need to think about it.

    • Telorand@reddthat.com
      link
      fedilink
      arrow-up
      7
      arrow-down
      1
      ·
      2 months ago

      My department is rewriting a lot of its codebase, and we only have 15yrs to deal with vs Xorg’s 20. Pain in the ass, indeed.

  • flamingo_pinyata@sopuli.xyz
    link
    fedilink
    arrow-up
    9
    ·
    2 months ago

    It’s not something that you can really experience directly as the end user. It’s a base on which other features can be built. Most obvious would be fractional scaling.

  • Bobby Turkalino@lemmy.yachts
    link
    fedilink
    English
    arrow-up
    5
    ·
    2 months ago

    I can name one improvement: global scaling works SO much better in Wayland

    But obviously if you don’t have a high DPI monitor, this won’t matter to you

  • boredsquirrel@slrpnk.net
    link
    fedilink
    arrow-up
    1
    arrow-down
    3
    ·
    edit-2
    2 months ago

    Wayland should be faster. What would you expect to happen? It should just work, while in the background EVERYTHING is changing.

    For Freetube, it should automatically detect running on Wayland and use that. But I had one bug on Freetube only on Wayland, may be an Electron issue.

    • cyberwolfie@lemmy.mlOP
      link
      fedilink
      arrow-up
      5
      ·
      2 months ago

      Wayland should be faster. What would you expect to happen? It should just work, while in the background EVERYTHING is changing.

      I had assumed that I would get a somehow smoother experience (such as speed, for instance) or some other perceivable benefit, but I think Ramin Honary nicely highlighted the necessity of the change on the backend side. So your point is good, maybe I should just expect a smooth transition where I don’t notice anything.

      For Freetube, it should automatically detect running on Wayland and use that. But I had one bug on Freetube only on Wayland, may be an Electron issue.

      If I run the executable after downloading from the GitHub repo directly, it launches in XWayland. The additional parameters I mentioned in the post used to work to launch it in Wayland, but not anymore.