void QWindowCompositor::surfaceMapped() { QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender()); QPoint pos; if (!m_surfaces.contains(surface)) { uint px = 0; uint py = 0; if (!QCoreApplication::arguments().contains(QLatin1String("-stickytopleft"))) { px = 1 + (qrand() % (m_window->width() - surface->size().width() - 2)); py = 1 + (qrand() % (m_window->height() - surface->size().height() - 2)); } pos = QPoint(px, py); surface->setPos(pos); } else { m_surfaces.removeOne(surface); } //Sometimes surfaces dont have shell_surfaces, so don't render them if (surface->hasShellSurface()) { m_surfaces.append(surface); defaultInputDevice()->setKeyboardFocus(surface); } m_renderScheduler.start(0); }
static void parse_device(ca_dev *cadev, const char *name) { char buf[256], deviceId[128]; char *input, *output, *tmp, *buffer = buf; strncpy(buffer, name, sizeof(buf)); DBG_DYNA_AUDIO_DRV("**CoreAudio: parsing %s\n", name); if (strncasecmp(buffer, "ca:", 3) == 0) { buffer += 3; } if ((input = strcasestr(buffer, IN_PREFIX)) && (tmp = strchr(input + 3, ' '))) { strncpy(cadev->inputID, input + 3, tmp - (input + 3)); } if (strlen(cadev->inputID) < 6) { /* 6 because minimum string can be: "1:0:2\0" */ memset(deviceId, 0, sizeof(deviceId)); defaultInputDevice(deviceId); strncpy(cadev->inputID, deviceId, sizeof(cadev->inputID)); } if ((output = strcasestr(buffer, OUT_PREFIX))) { strncpy(cadev->outputID, output + 4, strlen(output + 4)); } if (strlen(cadev->outputID) < 6) { memset(deviceId, 0, sizeof(deviceId)); defaultOutputDevice(deviceId); strncpy(cadev->outputID, deviceId, sizeof(cadev->inputID)); } DBG_DYNA_AUDIO_DRV("**CoreAudio: using devices in=%s out=%s\n", cadev->inputID, cadev->outputID); }
QAbstractAudioInput* QAudioDeviceFactory::createDefaultInputDevice(QAudioFormat const &format) { return createInputDevice(defaultInputDevice(), format); }
bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) { if (obj != m_window) return false; QWaylandInputDevice *input = defaultInputDevice(); switch (event->type()) { case QEvent::Expose: m_renderScheduler.start(0); if (m_window->isExposed()) { // Alt-tabbing away normally results in the alt remaining in // pressed state in the clients xkb state. Prevent this by sending // a release. This is not an issue in a "real" compositor but // is very annoying when running in a regular window on xcb. Qt::KeyboardModifiers mods = QGuiApplication::queryKeyboardModifiers(); if (m_modifiers != mods && input->keyboardFocus()) { Qt::KeyboardModifiers stuckMods = m_modifiers ^ mods; if (stuckMods & Qt::AltModifier) input->sendKeyReleaseEvent(64); // native scancode for left alt m_modifiers = mods; } } break; case QEvent::MouseButtonPress: { QPointF local; QMouseEvent *me = static_cast<QMouseEvent *>(event); QWaylandSurface *targetSurface = surfaceAt(me->localPos(), &local); if (m_dragKeyIsPressed && targetSurface) { m_draggingWindow = targetSurface; m_drag_diff = local; } else { if (targetSurface && input->keyboardFocus() != targetSurface) { input->setKeyboardFocus(targetSurface); m_surfaces.removeOne(targetSurface); m_surfaces.append(targetSurface); m_renderScheduler.start(0); } input->sendMousePressEvent(me->button(), local, me->localPos()); } return true; } case QEvent::MouseButtonRelease: { QWaylandSurface *targetSurface = input->mouseFocus(); if (m_draggingWindow) { m_draggingWindow = 0; m_drag_diff = QPointF(); } else { QMouseEvent *me = static_cast<QMouseEvent *>(event); QPointF localPos; if (targetSurface) localPos = toSurface(targetSurface, me->localPos()); input->sendMouseReleaseEvent(me->button(), localPos, me->localPos()); } return true; } case QEvent::MouseMove: { QMouseEvent *me = static_cast<QMouseEvent *>(event); if (m_draggingWindow) { m_draggingWindow->setPos(me->localPos() - m_drag_diff); m_renderScheduler.start(0); } else { QPointF local; QWaylandSurface *targetSurface = surfaceAt(me->localPos(), &local); input->sendMouseMoveEvent(targetSurface, local, me->localPos()); } break; } case QEvent::Wheel: { QWheelEvent *we = static_cast<QWheelEvent *>(event); input->sendMouseWheelEvent(we->orientation(), we->delta()); break; } case QEvent::KeyPress: { QKeyEvent *ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_Meta || ke->key() == Qt::Key_Super_L) { m_dragKeyIsPressed = true; } m_modifiers = ke->modifiers(); QWaylandSurface *targetSurface = input->keyboardFocus(); if (targetSurface) input->sendKeyPressEvent(ke->nativeScanCode()); break; } case QEvent::KeyRelease: { QKeyEvent *ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_Meta || ke->key() == Qt::Key_Super_L) { m_dragKeyIsPressed = false; } m_modifiers = ke->modifiers(); QWaylandSurface *targetSurface = input->keyboardFocus(); if (targetSurface) input->sendKeyReleaseEvent(ke->nativeScanCode()); break; } case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: { QWaylandSurface *targetSurface = 0; QTouchEvent *te = static_cast<QTouchEvent *>(event); QList<QTouchEvent::TouchPoint> points = te->touchPoints(); QPoint pointPos; if (!points.isEmpty()) { pointPos = points.at(0).pos().toPoint(); targetSurface = surfaceAt(pointPos); } if (targetSurface && targetSurface != input->mouseFocus()) input->setMouseFocus(targetSurface, pointPos, pointPos); if (input->mouseFocus()) input->sendFullTouchEvent(te); break; } default: break; } return false; }
void QWindowCompositor::ensureKeyboardFocusSurface(QWaylandSurface *oldSurface) { QWaylandSurface *kbdFocus = defaultInputDevice()->keyboardFocus(); if (kbdFocus == oldSurface || !kbdFocus) defaultInputDevice()->setKeyboardFocus(m_surfaces.isEmpty() ? 0 : m_surfaces.last()); }
void LipstickCompositor::clearKeyboardFocus() { defaultInputDevice()->setKeyboardFocus(0); }