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. REVIEW: 122290
This commit is contained in:
parent
45519677b2
commit
0faf2fbcf8
4 changed files with 31 additions and 11 deletions
|
@ -173,6 +173,7 @@ find_package(XCB
|
|||
GLX
|
||||
OPTIONAL_COMPONENTS
|
||||
ICCCM
|
||||
CURSOR
|
||||
)
|
||||
set_package_properties(XCB PROPERTIES TYPE REQUIRED)
|
||||
|
||||
|
@ -181,6 +182,7 @@ if (XCB_ICCCM_VERSION VERSION_LESS "0.4")
|
|||
set(XCB_ICCCM_FOUND FALSE)
|
||||
endif()
|
||||
add_feature_info("XCB-ICCCM" XCB_ICCCM_FOUND "Required for building test applications for KWin")
|
||||
add_feature_info("XCB-CURSOR" XCB_CURSOR_FOUND "Required for XCursor support")
|
||||
|
||||
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
||||
|
@ -260,6 +262,12 @@ else()
|
|||
set(HAVE_WAYLAND_EGL FALSE)
|
||||
endif()
|
||||
|
||||
if(XCB_CURSOR_FOUND)
|
||||
set(HAVE_XCB_CURSOR ${XCB_CURSOR_FOUND})
|
||||
else()
|
||||
set(HAVE_XCB_CURSOR FALSE)
|
||||
endif()
|
||||
|
||||
include(CheckIncludeFiles)
|
||||
check_include_files(unistd.h HAVE_UNISTD_H)
|
||||
check_include_files(malloc.h HAVE_MALLOC_H)
|
||||
|
@ -464,7 +472,6 @@ set(kwin_KDE_LIBS
|
|||
set(kwin_XLIB_LIBS
|
||||
${X11_X11_LIB}
|
||||
${X11_Xext_LIB}
|
||||
${X11_Xcursor_LIB}
|
||||
${X11_ICE_LIB}
|
||||
${X11_SM_LIB}
|
||||
)
|
||||
|
@ -500,6 +507,10 @@ if(KWIN_BUILD_ACTIVITIES)
|
|||
set(kwin_KDE_LIBS ${kwin_KDE_LIBS} KF5::Activities)
|
||||
endif()
|
||||
|
||||
if(HAVE_XCB_CURSOR)
|
||||
set(kwin_XCB_LIBS ${kwin_XCB_LIBS} XCB::CURSOR)
|
||||
endif()
|
||||
|
||||
set(kwinLibs
|
||||
${kwin_OWN_LIBS}
|
||||
${kwin_QT_LIBS}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#cmakedefine01 HAVE_WAYLAND_EGL
|
||||
#cmakedefine01 HAVE_XKB
|
||||
#cmakedefine01 HAVE_INPUT
|
||||
#cmakedefine01 HAVE_XCB_CURSOR
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#cmakedefine HAVE_UNISTD_H 1
|
||||
|
|
23
cursor.cpp
23
cursor.cpp
|
@ -33,11 +33,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <QDBusConnection>
|
||||
#include <QScreen>
|
||||
#include <QTimer>
|
||||
// Xlib
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
#include <fixx11h.h>
|
||||
// xcb
|
||||
#include <xcb/xfixes.h>
|
||||
#if HAVE_XCB_CURSOR
|
||||
#include <xcb/xcb_cursor.h>
|
||||
#endif
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -353,15 +353,20 @@ xcb_cursor_t X11Cursor::createCursor(const QByteArray &name)
|
|||
if (name.isEmpty()) {
|
||||
return XCB_CURSOR_NONE;
|
||||
}
|
||||
// XCursor is an XLib only lib
|
||||
XcursorImage *ximg = XcursorLibraryLoadImage(name.constData(), themeName().toUtf8().constData(), themeSize());
|
||||
if (!ximg) {
|
||||
#if HAVE_XCB_CURSOR
|
||||
xcb_cursor_context_t *ctx;
|
||||
if (xcb_cursor_context_new(connection(), defaultScreen(), &ctx) < 0) {
|
||||
return XCB_CURSOR_NONE;
|
||||
}
|
||||
xcb_cursor_t cursor = XcursorImageLoadCursor(display(), ximg);
|
||||
XcursorImageDestroy(ximg);
|
||||
m_cursors.insert(name, cursor);
|
||||
const xcb_cursor_t cursor = xcb_cursor_load_cursor(ctx, name.constData());
|
||||
if (cursor != XCB_CURSOR_NONE) {
|
||||
m_cursors.insert(name, cursor);
|
||||
}
|
||||
xcb_cursor_context_free(ctx);
|
||||
return cursor;
|
||||
#else
|
||||
return XCB_CURSOR_NONE;
|
||||
#endif
|
||||
}
|
||||
|
||||
QByteArray Cursor::cursorName(Qt::CursorShape shape) const
|
||||
|
|
|
@ -16,7 +16,6 @@ kf5_add_kdeinit_executable( kwin_rules_dialog ${kwin_rules_dialog_KDEINIT_SRCS})
|
|||
set(kwin_kcm_rules_XCB_LIBS
|
||||
XCB::XCB
|
||||
XCB::XFIXES
|
||||
${X11_Xcursor_LIB}
|
||||
)
|
||||
|
||||
set(kcm_libs
|
||||
|
@ -35,6 +34,10 @@ if(KWIN_BUILD_ACTIVITIES)
|
|||
set(kcm_libs ${kcm_libs} KF5::Activities)
|
||||
endif()
|
||||
|
||||
if(HAVE_XCB_CURSOR)
|
||||
set(kwin_kcm_rules_XCB_LIBS ${kwin_kcm_rules_XCB_LIBS} XCB::CURSOR)
|
||||
endif()
|
||||
|
||||
target_link_libraries(kdeinit_kwin_rules_dialog ${kcm_libs} ${kwin_kcm_rules_XCB_LIBS})
|
||||
|
||||
install(TARGETS kdeinit_kwin_rules_dialog ${INSTALL_TARGETS_DEFAULT_ARGS} )
|
||||
|
|
Loading…
Reference in a new issue