Beispiel #1
0
 void QXcbCursor::cursorThemePropertyChanged(QXcbScreen *screen, const QByteArray &name, const QVariant &property, void *handle)
{
    Q_UNUSED(screen);
    Q_UNUSED(name);
    QXcbCursor *self = static_cast<QXcbCursor *>(handle);
    updateCursorTheme(self->connection()->xlib_display(),property.toByteArray());
}
Beispiel #2
0
xcb_cursor_t QXcbCursor::createFontCursor(int cshape)
{
    xcb_connection_t *conn = xcb_connection();
    int cursorId = cursorIdForShape(cshape);
    xcb_cursor_t cursor = XCB_NONE;

    // Try Xcursor first
#ifdef XCB_USE_XLIB
    if (cshape >= 0 && cshape <= Qt::LastCursor) {
        void *dpy = connection()->xlib_display();
        // special case for non-standard dnd-* cursors
        cursor = loadCursor(dpy, cshape);
        if (!cursor && !m_gtkCursorThemeInitialized && m_screen->xSettings()->initialized()) {
            QByteArray gtkCursorTheme = m_screen->xSettings()->setting("Gtk/CursorThemeName").toByteArray();
            m_screen->xSettings()->registerCallbackForProperty("Gtk/CursorThemeName",cursorThemePropertyChanged,this);
            if (updateCursorTheme(dpy,gtkCursorTheme)) {
                cursor = loadCursor(dpy, cshape);
            }
            m_gtkCursorThemeInitialized = true;
        }
    }
    if (cursor)
        return cursor;
    if (!cursor && cursorId) {
        cursor = XCreateFontCursor(DISPLAY_FROM_XCB(this), cursorId);
        if (cursor)
            return cursor;
    }

#endif

    // Non-standard X11 cursors are created from bitmaps
    cursor = createNonStandardCursor(cshape);

    // Create a glpyh cursor if everything else failed
    if (!cursor && cursorId) {
        cursor = xcb_generate_id(conn);
        xcb_create_glyph_cursor(conn, cursor, cursorFont, cursorFont,
                                cursorId, cursorId + 1,
                                0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0);
    }

    if (cursor && cshape >= 0 && cshape < Qt::LastCursor && connection()->hasXFixes()) {
        const char *name = cursorNames[cshape];
        xcb_xfixes_set_cursor_name(conn, cursor, strlen(name), name);
    }

    return cursor;
}