Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-67373

Drop Xlib / libXcurosr dependency from QXcbCursor



    • Task
    • Resolution: Done
    • P3: Somewhat important
    • 6.5.0 Beta1
    • None
    • QPA: X11/XCB
    • None
    • 012132c60d (qt/qtbase/dev) 012132c60d (qt/tqtc-qtbase/dev)


      XCB provides libxcb-cursor [1] as an replacement for Xlib's libXcurosr [2]. By looking at the source code it appears to be a full replacement with minor gap in API (particularly the API for explicitly setting a cursor theme), but functionality-wise it looks good. There are projects that already use libxcb-cursor:

      apt-cache rdepends libxcb-cursor0
      Reverse Depends:

      Kwin for example switched ~3 years ago:

      commit 0faf2fbcf8645b8affb9501e353dcdd61ad10644
      Author: Martin Gräßlin <mgraesslin@kde.org>
      Date:   Wed Jan 28 14:49:27 2015 +0100
          Use xcb_cursor library instead of Xlib based one in Cursor
          Straight forward port from XLib based XCursor library to the
          xcb variant which is considerably new. The xcb variant only allows
          to create xcb_cursor_t for the default theme and size. Which suits
          the needs in Cursor quite well, but means it's not a replacement for
          the usage in zoom effect.

      Very few changes have gone into [1] in recent years, from which I conclude that the library is stable.

      > The xcb variant only allows to create xcb_cursor_t for the default theme and size.

      mgraesslin I guess by the default you meant whatever is in the RESOURCE_MANAGER property? Thus, not having XcursorSet/GetTheme type of API?

      Current usages of libXcurosr APIs in QXcbCursor:

      XcursorGetDefaultSize (libXcurosr):

      We QLibrary::resolve() this function, but never use it, so it can be simply dropped. No replacement needed. It was added by [3].

      XcursorGetTheme and XcursorSetTheme (libXcurosr):

      Was added by [3] as a workaround to Gnome bug. The commit message did not elaborate on anything!!! but from looking around I see that it must have been gnome-settings-daemon [4] bug. See af8a40c2de0f1be5ca40ac851858f2fe8798a4ba [11] and 5852428ae909f8965c91bdddd02fbd21e9b6994e [12] in gnome-settings-daemon/plugins/xsettings/gsd-xsettings-manager.c

      Gnome uses xsettings [5], but did not update the RESOURCE_MANAGER property. Something that many libraries depend on, including libXcursor. The fixed gnome-settings-daemon is in Ubuntu 16.04, which is the minimal supported Ubuntu version. On Unity gnome-settings-daemon is named unity-settings-daemon, but the source code is about the same. Don't know what version is on RHEL 6, so the safest would be to keep the read-from-xsettings-fallback from [3]. But then we need to add API for setting/getting theme name in [1]. We can bundle the [1] and always fallback to the bundled version at configure time when libxcb-cursor on the system is not recent enough (for example see libxkbcommon, where we automatically fallback to bundled when version requirement is not satisfied).

      XcursorLibraryLoadCursor (libXcurosr):

      Can simply be replaced with xcb_cursor_load_cursor(). And from the initial testing this library swap appears to fix the bug reported in QTBUG-30016 - "But the bug reappears as soon as I restart Qt Creator." We need to add code for listening for property changes on RESOURCE_MANAGER. I have not looked into details why libXcursor's XcursorLibraryLoadCursor would not work as expected.

      XCreateFontCursor (Xlib):

      Is a total nonsense and can be dropped. No replacement needed. For details see https://bugreports.qt.io/browse/QTBUG-30016?focusedCommentId=397117&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-397117 It was added by [6], and again with no proper explanation!!!

      [1] https://cgit.freedesktop.org/xcb/util-cursor/
      [2] https://cgit.freedesktop.org/xorg/lib/libXcursor/
      [3] https://codereview.qt-project.org/#/c/54819/
      [4] https://github.com/GNOME/gnome-settings-daemon
      [5] http://standards.freedesktop.org/xsettings-spec/xsettings-0.5.html
      [6] https://codereview.qt-project.org/#/c/109570/

      [11] https://github.com/GNOME/gnome-settings-daemon/commit/af8a40c2de0f1be5ca40ac851858f2fe8798a4ba
      [12] https://github.com/GNOME/gnome-settings-daemon/commit/5852428ae909f8965c91bdddd02fbd21e9b6994e


        Issue Links

          For Gerrit Dashboard: QTBUG-67373
          # Subject Branch Project Status CR V



              liaqi Liang Qi
              paeglis Gatis Paeglis
              2 Vote for this issue
              8 Start watching this issue



                Gerrit Reviews

                  There are no open Gerrit changes