void KeyboardLayoutView::_KeyChanged(const BMessage* message) { const uint8* state; ssize_t size; int32 key; if (message->FindData("states", B_UINT8_TYPE, (const void**)&state, &size) != B_OK || message->FindInt32("key", &key) != B_OK) return; // Update key state, and invalidate change keys bool checkSingle = true; if (message->what == B_KEY_DOWN || message->what == B_UNMAPPED_KEY_DOWN) { if (_HandleDeadKey(key, fModifiers)) checkSingle = false; if (_KeyForCode(key) == NULL) printf("no key for code %" B_PRId32 "\n", key); } for (int32 i = 0; i < 16; i++) { if (fKeyState[i] != state[i]) { uint8 diff = fKeyState[i] ^ state[i]; fKeyState[i] = state[i]; if (!checkSingle || !Window()->IsActive()) continue; for (int32 j = 7; diff != 0; j--, diff >>= 1) { if (diff & 1) { _InvalidateKey(i * 8 + j); } } } }
void KeyboardLayoutView::MouseUp(BPoint point) { Key* key = _KeyAt(fClickPoint); int32 buttons = 0; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) Looper()->CurrentMessage()->FindInt32("buttons", &buttons); if (key != NULL) { if ((fButtons & B_TERTIARY_MOUSE_BUTTON) != 0 && (buttons & B_TERTIARY_MOUSE_BUTTON) == 0) { _SetKeyState(key->code, false); _InvalidateKey(key); fButtons = buttons; } else { fButtons = buttons; // modifier keys are sticky when used with the mouse if (fKeymap != NULL && fKeymap->IsModifierKey(key->code)) return; _SetKeyState(key->code, false); if (_HandleDeadKey(key->code, fModifiers) && fDeadKey != 0) return; _InvalidateKey(key); if (fDragKey == NULL && fKeymap != NULL) { // Send fake key down message to target _SendFakeKeyDown(key); } } } fDragKey = NULL; }