Exemple #1
0
void WindowSelector::start(std::function<void(KWin::Toplevel*)> callback, const QByteArray &cursorName)
{
    xcb_cursor_t cursor = createCursor(cursorName);
    if (m_active) {
        callback(nullptr);
        return;
    }

    xcb_connection_t *c = connection();
    ScopedCPointer<xcb_grab_pointer_reply_t> grabPointer(xcb_grab_pointer_reply(c, xcb_grab_pointer_unchecked(c, false, rootWindow(),
        XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
        XCB_EVENT_MASK_POINTER_MOTION |
        XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW,
        XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_WINDOW_NONE,
        cursor, XCB_TIME_CURRENT_TIME), NULL));
    if (grabPointer.isNull() || grabPointer->status != XCB_GRAB_STATUS_SUCCESS) {
        callback(nullptr);
        return;
    }
    m_active = grabXKeyboard();
    if (!m_active) {
        xcb_ungrab_pointer(connection(), XCB_TIME_CURRENT_TIME);
        callback(nullptr);
        return;
    }
    grabXServer();
    m_callback = callback;
}
QT_BEGIN_NAMESPACE

QQuickItem *QQuickTextUtil::createCursor(
    QQmlComponent *component, QQuickItem *parent, const QRectF &rectangle, const char *className)
{
    QQuickItem *item = 0;
    if (component->isReady()) {
        QQmlContext *creationContext = component->creationContext();

        if (QObject *object = component->beginCreate(creationContext
                              ? creationContext
                              : qmlContext(parent))) {
            if ((item = qobject_cast<QQuickItem *>(object))) {
                QQml_setParent_noEvent(item, parent);
                item->setParentItem(parent);
                item->setPosition(rectangle.topLeft());
                item->setHeight(rectangle.height());
            } else {
                qmlInfo(parent) << tr("%1 does not support loading non-visual cursor delegates.")
                                .arg(QString::fromUtf8(className));
            }
            component->completeCreate();
            return item;
        }
    } else if (component->isLoading()) {
        QObject::connect(component, SIGNAL(statusChanged(QQmlComponent::Status)),
                         parent, SLOT(createCursor()), Qt::UniqueConnection);
        return item;
    }
    qmlInfo(parent, component->errors()) << tr("Could not load cursor delegate");
    return item;
}
Exemple #3
0
//! ---|> Window
void WindowSDL::doHideCursor() {
	static std::unique_ptr<Cursor> hiddenCursor;
	if(hiddenCursor.get() == nullptr) {
		Reference<Bitmap> bitmap = new Bitmap(1, 1);
		bitmap->data()[0] = 0;
		bitmap->data()[1] = 0;
		bitmap->data()[2] = 0;
		bitmap->data()[3] = 0;
		hiddenCursor = createCursor(bitmap, 0, 0);
	}
	doSetCursor(hiddenCursor.get());
}
BlockInputStreamPtr MongoDBDictionarySource::loadKeys(
	const ConstColumnPlainPtrs & key_columns, const std::vector<std::size_t> & requested_rows)
{
	if (!dict_struct.key)
		throw Exception{"'key' is required for selective loading", ErrorCodes::UNSUPPORTED_METHOD};

	auto cursor = createCursor(db, collection, sample_block);

	Poco::MongoDB::Array::Ptr keys_array(new Poco::MongoDB::Array);
	for (const auto row_idx : requested_rows)
	{
		auto & key = keys_array->addNewDocument(DB::toString(row_idx));

		for (const auto attr : ext::enumerate(*dict_struct.key))
		{
			switch (attr.second.underlying_type)
			{
				case AttributeUnderlyingType::UInt8:
				case AttributeUnderlyingType::UInt16:
				case AttributeUnderlyingType::UInt32:
				case AttributeUnderlyingType::UInt64:
				case AttributeUnderlyingType::Int8:
				case AttributeUnderlyingType::Int16:
				case AttributeUnderlyingType::Int32:
				case AttributeUnderlyingType::Int64:
					key.add(attr.second.name, Int32(key_columns[attr.first]->get64(row_idx)));
					break;

				case AttributeUnderlyingType::Float32:
				case AttributeUnderlyingType::Float64:
					key.add(attr.second.name, applyVisitor(FieldVisitorConvertToNumber<Float64>(), (*key_columns[attr.first])[row_idx]));
					break;

				case AttributeUnderlyingType::String:
					key.add(attr.second.name, get<String>((*key_columns[attr.first])[row_idx]));
					break;
			}
		}
	}

	cursor->query().selector().add("$or", keys_array);

	return std::make_shared<MongoDBBlockInputStream>(
		connection, std::move(cursor), sample_block, max_block_size);
}
BlockInputStreamPtr MongoDBDictionarySource::loadIds(const std::vector<UInt64> & ids)
{
	if (!dict_struct.id)
		throw Exception{"'id' is required for selective loading", ErrorCodes::UNSUPPORTED_METHOD};

	auto cursor = createCursor(db, collection, sample_block);

	/** NOTE: While building array, Poco::MongoDB requires passing of different unused element names, along with values.
	  * In general, Poco::MongoDB is quite inefficient and bulky.
	  */

	Poco::MongoDB::Array::Ptr ids_array(new Poco::MongoDB::Array);
	for (const UInt64 id : ids)
		ids_array->add(DB::toString(id), Int32(id));

	cursor->query().selector().addNewDocument(dict_struct.id.value().name)
		.add("$in", ids_array);

	return std::make_shared<MongoDBBlockInputStream>(
		connection, std::move(cursor), sample_block, max_block_size);
}
int main() {
	auto armyEngine = ArmyEngine::getInstance();
	armyEngine->addEntity(createCursor());
	armyEngine->addEntity(createButton("Resume", 100, 100));
	/*armyEngine->addEntity(createButton("Restart", 100, 60));
	armyEngine->addEntity(createButton("Quit", 100, 110));
	armyEngine->addEntity(createButton("Other3", 100, 160));
	armyEngine->addEntity(createButton("Other1", 250, 10));
	armyEngine->addEntity(createButton("Other2", 250, 60));
	armyEngine->addEntity(createButton("Other3", 250, 110));
	armyEngine->addEntity(createButton("Other3", 250, 160));
	armyEngine->addEntity(createButton("Other1", 400, 10));
	armyEngine->addEntity(createButton("Other2", 400, 60));
	armyEngine->addEntity(createButton("Other3", 400, 110));
	armyEngine->addEntity(createButton("Other3", 400, 160));
	armyEngine->addEntity(createButton("Other1", 550, 10));
	armyEngine->addEntity(createButton("Other2", 550, 60));
	armyEngine->addEntity(createButton("Other3", 550, 110));
	armyEngine->addEntity(createButton("Other3", 550, 160));
	armyEngine->addEntity(createButton("Other1", 700, 10));
	armyEngine->addEntity(createButton("Other2", 700, 60));
	armyEngine->addEntity(createButton("Other3", 700, 110));
	armyEngine->addEntity(createButton("Other3", 700, 160));*/


	//create the close program event
	armyEngine->addEventCallback(EnumEventType::EVENT_CLOSED, [] (int eventIndex) {
		auto armyEngine = ArmyEngine::getInstance();
		auto window = armyEngine->getWindow();
		window->close();
		return 0;
	});


	armyEngine->runMainLoop();

	return 0;
}
void X11WindowedBackend::init()
{
    int screen = 0;
    xcb_connection_t *c = nullptr;
    Display *xDisplay = XOpenDisplay(deviceIdentifier().constData());
    if (xDisplay) {
        c = XGetXCBConnection(xDisplay);
        XSetEventQueueOwner(xDisplay, XCBOwnsEventQueue);
        screen = XDefaultScreen(xDisplay);
    }
    if (c && !xcb_connection_has_error(c)) {
        m_connection = c;
        m_screenNumber = screen;
        m_display = xDisplay;
        for (xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(m_connection));
            it.rem;
            --screen, xcb_screen_next(&it)) {
            if (screen == m_screenNumber) {
                m_screen = it.data;
            }
        }
        XRenderUtils::init(m_connection, m_screen->root);
        createWindow();
        startEventReading();
        connect(this, &X11WindowedBackend::cursorChanged, this,
            [this] {
                createCursor(softwareCursor(), softwareCursorHotspot());
            }
        );
        setReady(true);
        waylandServer()->seat()->setHasPointer(true);
        waylandServer()->seat()->setHasKeyboard(true);
        emit screensQueried();
    } else {
        emit initFailed();
    }
}
Exemple #8
0
BoardWidget::BoardWidget(Board& b, QWidget *parent)
    : PieceWidget(10,9,parent), board(b)
{
    pList =0;
    gettingMove = false;
    editMode = false;
    renderMode = false;

    /* setup cursors */

#define createCursor(bitmap,name) \
    static QBitmap bitmap = QBitmap::fromData(QSize(bitmap##_width, bitmap##_height), \
    (unsigned char *) bitmap##_bits);        \
    static QBitmap bitmap##Mask = QBitmap::fromData(QSize(bitmap##Mask_width, bitmap##Mask_height), \
    (unsigned char *) bitmap##Mask_bits);    \
    name = new QCursor(bitmap, bitmap##Mask, bitmap##_x_hot, bitmap##_y_hot);

    createCursor(Arrow1, arrow[1]);
    createCursor(Arrow2, arrow[2]);
    createCursor(Arrow3, arrow[3]);
    createCursor(Arrow4, arrow[4]);
    createCursor(Arrow5, arrow[5]);
    createCursor(Arrow6, arrow[6]);

    setCursor(Qt::CrossCursor);

    //  boardColor   = new QColor("lightblue");
    boardColor   = new QColor(palette().color(backgroundRole()));
    redColor     = new QColor("red");
    yellowColor  = new QColor("yellow");
    redHColor    = new QColor("orange");
    yellowHColor = new QColor("green");

    initPieces();
    updatePosition();
}
bool IMCursorManager::createCursor( const CursorType type, const sf::Texture* texture )
{ 
    return createCursor( type, texture, 0, 0 );
}
bool IMCursorManager::createCursor( const CursorType type, const sf::Texture* texture, const sf::Vector2i offset )
{
    return createCursor( type, texture, offset.x, offset.y );
}
bool IMCursorManager::createCursor( const CursorType type, const sf::Texture* texture, const sf::Rect<int> offsetAndSize )
{
    return createCursor( type, texture, offsetAndSize.left, offsetAndSize.top, offsetAndSize.width, offsetAndSize.height );
}
BlockInputStreamPtr MongoDBDictionarySource::loadAll()
{
	return std::make_shared<MongoDBBlockInputStream>(
		connection, createCursor(db, collection, sample_block), sample_block, max_block_size);
}