コード例 #1
0
bool QxtGlobalShortcutPrivate::nativeEventFilter (const QByteArray& eventType, void *msg, long*)
{
	if (eventType != "xcb_generic_event_t")
		return false;

	const auto ev = static_cast<xcb_generic_event_t*> (msg);
	if ((ev->response_type & 127) != XCB_KEY_PRESS)
		return false;

	const auto kev = static_cast<xcb_key_press_event_t*> (msg);

	const auto keycode = kev->detail;
	uint keystate = 0;
	if (kev->state & XCB_MOD_MASK_1)
		keystate |= Mod1Mask;
	if (kev->state & XCB_MOD_MASK_CONTROL)
		keystate |= ControlMask;
	if (kev->state & XCB_MOD_MASK_4)
		keystate |= Mod4Mask;
	if (kev->state & XCB_MOD_MASK_SHIFT)
		keystate |= ShiftMask;

	activateShortcut (keycode, keystate & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask));

	return false;
}
コード例 #2
0
bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray &eventType,
                                                 void *message, long *result)
{
    Q_UNUSED(result);
    if (eventType != "xcb_generic_event_t")
        return false;

    xcb_generic_event_t *event = reinterpret_cast<xcb_generic_event_t*>(message);
    if ((event->response_type & ~0x80) != XCB_KEY_PRESS)
        return false;

    xcb_key_press_event_t *keyPressEvent = reinterpret_cast<xcb_key_press_event_t *>(event);

    // Avoid keyboard freeze
    xcb_connection_t *xcbConnection = QX11Info::connection();
    xcb_allow_events(xcbConnection, XCB_ALLOW_REPLAY_KEYBOARD, keyPressEvent->time);
    xcb_flush(xcbConnection);

    unsigned int keycode = keyPressEvent->detail;
    unsigned int keystate = 0;
    if (keyPressEvent->state & XCB_MOD_MASK_1)
        keystate |= XCB_MOD_MASK_1;
    if (keyPressEvent->state & XCB_MOD_MASK_CONTROL)
        keystate |= XCB_MOD_MASK_CONTROL;
    if (keyPressEvent->state & XCB_MOD_MASK_4)
        keystate |= XCB_MOD_MASK_4;
    if (keyPressEvent->state & XCB_MOD_MASK_SHIFT)
        keystate |= XCB_MOD_MASK_SHIFT;

    return activateShortcut(keycode, keystate);
}
コード例 #3
0
bool QxtGlobalShortcutPrivate::eventFilter(void* message)
{
    MSG* msg = static_cast<MSG*>(message);
    if (msg->message == WM_HOTKEY)
    {
        const quint32 keycode = HIWORD(msg->lParam);
        const quint32 modifiers = LOWORD(msg->lParam);
        activateShortcut(keycode, modifiers);
    }
    return false;
}
コード例 #4
0
bool QxtGlobalShortcutPrivate::eventFilter(void* message)
{
    XEvent* event = static_cast<XEvent*>(message);
    if (event->type == KeyPress)
    {
        XKeyEvent* key = (XKeyEvent*) event;
        activateShortcut(key->keycode, 
            // Mod1Mask == Alt, Mod4Mask == Meta
            key->state & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask));
    }
    return false;
}
コード例 #5
0
//static QxtGlobalShortcutPrivate::hotid;
bool QxtGlobalShortcutPrivate::eventFilter(void* message)
{
    gi_msg_t* event = static_cast<gi_msg_t*>(message);
    if (event->type == GI_MSG_KEY_DOWN && event->attribute_1)
    {
        //XKeyEvent* key = (XKeyEvent*) event;
        activateShortcut(event->params[3], 
            // Mod1Mask == Alt, Mod4Mask == Meta
            event->body.message[3]);
    }
    return false;
}
コード例 #6
0
bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray &, void *message, long *result)
#endif
{
    MSG* msg = static_cast<MSG*>(message);
    if (msg->message == WM_HOTKEY)
    {
        const quint32 keycode = HIWORD(msg->lParam);
        const quint32 modifiers = LOWORD(msg->lParam);
        activateShortcut(keycode, modifiers);
    }
    return false;
}
コード例 #7
0
bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray &, void *message, long *)
{
    EventRef event = (EventRef) message;
    if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed)
    {
        EventHotKeyID keyID;
        GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, nullptr, sizeof(keyID), nullptr, &keyID);
        Identifier id = keyIDs.key(keyID.id);
        activateShortcut(id.second, id.first);
    }
    return false;
}
コード例 #8
0
bool QxtGlobalShortcutPrivate::eventFilter(void* message)
//bool QxtGlobalShortcutPrivate::macEventFilter(EventHandlerCallRef caller, EventRef event)
{
    EventRef event = (EventRef) message;
    if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed)
    {
        EventHotKeyID keyID;
        GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID);
        Identifier id = keyIDs.key(keyID.id);
        activateShortcut(id.second, id.first);
    }
    return false;
}
コード例 #9
0
bool ShortcutManager::nativeEventFilter(const QByteArray & eventType,
    void * message, long * result)
{
    Q_UNUSED(eventType);
    Q_UNUSED(result);

    MSG* msg = static_cast<MSG*>(message);
        if (msg->message == WM_HOTKEY)
        {
            const quint32 keycode = HIWORD(msg->lParam);
            const quint32 modifiers = LOWORD(msg->lParam);
            activateShortcut(keycode, modifiers);
        }

        return false;
}
コード例 #10
0
bool QxtGlobalShortcutPrivate::eventFilter(void* message)
{
#else
bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType,
    void * message, long * result)
{
    Q_UNUSED(eventType);
    Q_UNUSED(result);
#endif
    MSG* msg = static_cast<MSG*>(message);
    if (msg->message == WM_HOTKEY)
    {
        const quint32 keycode = HIWORD(msg->lParam);
        const quint32 modifiers = LOWORD(msg->lParam);
        activateShortcut(keycode, modifiers);
    }

#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
    return prevEventFilter ? prevEventFilter(message) : false;
#else
	return false;
#endif
}