#include <QCursor>
#include <QPixmap>
#include <QLinkedList>
+#include <QScreen>
#include <QtCompositor/waylandinput.h>
, m_renderScheduler(this)
, m_draggingWindow(0)
, m_dragKeyIsPressed(false)
+ , m_modifiers(Qt::NoModifier)
{
enableSubSurfaceExtension();
m_window->makeCurrent();
window->installEventFilter(this);
setRetainedSelectionEnabled(true);
+
+ setOutputGeometry(QRect(QPoint(0, 0), window->size()));
+ setOutputRefreshRate(qGuiApp->primaryScreen()->refreshRate());
}
QWindowCompositor::~QWindowCompositor()
m_textureBlitter->release();
frameFinished();
- glFinish();
-
+ // N.B. Never call glFinish() here as the busylooping with vsync 'feature' of the nvidia binary driver is not desirable.
m_window->swapBuffers();
}
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;
}
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();
WaylandSurface *targetSurface = input->keyboardFocus();
if (targetSurface)
input->sendKeyPressEvent(ke->nativeScanCode());
if (ke->key() == Qt::Key_Meta || ke->key() == Qt::Key_Super_L) {
m_dragKeyIsPressed = false;
}
+ m_modifiers = ke->modifiers();
WaylandSurface *targetSurface = input->keyboardFocus();
if (targetSurface)
input->sendKeyReleaseEvent(ke->nativeScanCode());