void DesktopWindowLinux::sendKeyboardEventToNix(const XEvent& event) { if (XFilterEvent(const_cast<XEvent*>(&event), m_window)) return; NIXKeyEvent ev; memset(&ev, 0, sizeof(NIXKeyEvent)); char buf[20]; bool shouldUseUpperCase; const XKeyEvent* keyEvent = reinterpret_cast<const XKeyEvent*>(&event); KeySym symbol = chooseSymbolForXKeyEvent(keyEvent, &shouldUseUpperCase); ev = convertXKeyEventToNixKeyEvent(keyEvent, symbol, shouldUseUpperCase); Status status; int count = Xutf8LookupString(m_ic, const_cast<XKeyEvent*>(keyEvent), buf, 20, &symbol, &status); if (count) { buf[count] = '\0'; ev.text = buf; } if (ev.type == kNIXInputEventTypeKeyDown) m_client->onKeyPress(&ev); else m_client->onKeyRelease(&ev); }
void BrowserControl::sendKeyboardEventToNix(const XEvent& event) { if (XFilterEvent(const_cast<XEvent*>(&event), m_browserWindow->window())) return; NIXKeyEvent ev; char buf[20]; bool shouldUseUpperCase; const XKeyEvent* keyEvent = reinterpret_cast<const XKeyEvent*>(&event); int count = 0; KeySym keySym = 0; Status status; keySym = chooseSymbolForXKeyEvent(keyEvent, &shouldUseUpperCase); ev = convertXKeyEventToNixKeyEvent(keyEvent, keySym, shouldUseUpperCase); count = Xutf8LookupString(m_ic, const_cast<XKeyEvent*>(keyEvent), buf, 20, &keySym, &status); if (count) { buf[count] = '\0'; ev.text = buf; } if (ev.type == kNIXInputEventTypeKeyDown) m_client->handleKeyPress(&ev); else m_client->handleKeyRelease(&ev); }
void MiniBrowser::handleKeyReleaseEvent(const XKeyReleasedEvent& event) { if (!m_view) return; bool shouldUseUpperCase; KeySym symbol = chooseSymbolForXKeyEvent(event, &shouldUseUpperCase); if (checkNavigationCommand(symbol, event.state) != NoNavigation) return; NIXKeyEvent nixEvent = convertXKeyEventToNixKeyEvent(event, symbol, shouldUseUpperCase); if (m_touchMocker && m_touchMocker->handleKeyRelease(nixEvent)) { scheduleUpdateDisplay(); return; } NIXViewSendKeyEvent(m_view, &nixEvent); }
void MiniBrowser::handleKeyPressEvent(const XKeyPressedEvent& event) { if (!m_view) return; bool shouldUseUpperCase; KeySym symbol = chooseSymbolForXKeyEvent(event, &shouldUseUpperCase); NavigationCommand command = checkNavigationCommand(symbol, event.state); switch (command) { case BackNavigation: WKPageGoBack(pageRef()); return; case ForwardNavigation: WKPageGoForward(pageRef()); return; case ReloadNavigation: WKPageReload(pageRef()); return; default: NIXKeyEvent nixEvent = convertXKeyEventToNixKeyEvent(event, symbol, shouldUseUpperCase); NIXViewSendKeyEvent(m_view, &nixEvent); } }