Handle QEventLoop::ExcludeUserInputEvents in QWindowSystemInterface.
Add a flag indicating user input events to the event type and leave those events in the queue if QEventLoop::ExcludeUserInputEvents is set. Task-number: QTBUG-27595 Change-Id: Ib41b826ef3be19253cd582d9894dd7c87953711f Reviewed-by: Oliver Wolff <oliver.wolff@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
parent
31c6d55445
commit
9b49c0561e
@ -344,6 +344,11 @@ QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate
|
||||
return windowSystemEventQueue.takeFirstOrReturnNull();
|
||||
}
|
||||
|
||||
QWindowSystemInterfacePrivate::WindowSystemEvent *QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent()
|
||||
{
|
||||
return windowSystemEventQueue.takeFirstNonUserInputOrReturnNull();
|
||||
}
|
||||
|
||||
QWindowSystemInterfacePrivate::WindowSystemEvent *QWindowSystemInterfacePrivate::peekWindowSystemEvent(EventType t)
|
||||
{
|
||||
return windowSystemEventQueue.peekAtFirstOfType(t);
|
||||
@ -520,20 +525,14 @@ bool QWindowSystemInterface::sendWindowSystemEventsImplementation(QEventLoop::Pr
|
||||
{
|
||||
int nevents = 0;
|
||||
|
||||
while (true) {
|
||||
QWindowSystemInterfacePrivate::WindowSystemEvent *event;
|
||||
if (!(flags & QEventLoop::ExcludeUserInputEvents)
|
||||
&& QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0) {
|
||||
// process a pending user input event
|
||||
event = QWindowSystemInterfacePrivate::getWindowSystemEvent();
|
||||
if (!event)
|
||||
break;
|
||||
} else {
|
||||
while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) {
|
||||
QWindowSystemInterfacePrivate::WindowSystemEvent *event =
|
||||
(flags & QEventLoop::ExcludeUserInputEvents) ?
|
||||
QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent() :
|
||||
QWindowSystemInterfacePrivate::getWindowSystemEvent();
|
||||
if (!event)
|
||||
break;
|
||||
}
|
||||
|
||||
nevents++;
|
||||
|
||||
QGuiApplicationPrivate::processWindowSystemEvent(event);
|
||||
delete event;
|
||||
}
|
||||
|
@ -66,30 +66,31 @@ QT_BEGIN_NAMESPACE
|
||||
class Q_GUI_EXPORT QWindowSystemInterfacePrivate {
|
||||
public:
|
||||
enum EventType {
|
||||
Close,
|
||||
GeometryChange,
|
||||
Enter,
|
||||
Leave,
|
||||
ActivatedWindow,
|
||||
WindowStateChanged,
|
||||
Mouse,
|
||||
FrameStrutMouse,
|
||||
Wheel,
|
||||
Key,
|
||||
Touch,
|
||||
ScreenOrientation,
|
||||
ScreenGeometry,
|
||||
ScreenAvailableGeometry,
|
||||
ScreenLogicalDotsPerInch,
|
||||
ScreenRefreshRate,
|
||||
ThemeChange,
|
||||
Expose,
|
||||
FileOpen,
|
||||
Tablet,
|
||||
TabletEnterProximity,
|
||||
TabletLeaveProximity,
|
||||
PlatformPanel,
|
||||
ContextMenu
|
||||
UserInputEvent = 0x100,
|
||||
Close = UserInputEvent | 0x01,
|
||||
GeometryChange = 0x02,
|
||||
Enter = UserInputEvent | 0x03,
|
||||
Leave = UserInputEvent | 0x04,
|
||||
ActivatedWindow = 0x05,
|
||||
WindowStateChanged = 0x06,
|
||||
Mouse = UserInputEvent | 0x07,
|
||||
FrameStrutMouse = UserInputEvent | 0x08,
|
||||
Wheel = UserInputEvent | 0x09,
|
||||
Key = UserInputEvent | 0x0a,
|
||||
Touch = UserInputEvent | 0x0b,
|
||||
ScreenOrientation = 0x0c,
|
||||
ScreenGeometry = 0x0d,
|
||||
ScreenAvailableGeometry = 0x0e,
|
||||
ScreenLogicalDotsPerInch = 0x0f,
|
||||
ScreenRefreshRate = 0x10,
|
||||
ThemeChange = 0x11,
|
||||
Expose = 0x12,
|
||||
FileOpen = UserInputEvent | 0x13,
|
||||
Tablet = UserInputEvent | 0x14,
|
||||
TabletEnterProximity = UserInputEvent | 0x15,
|
||||
TabletLeaveProximity = UserInputEvent | 0x16,
|
||||
PlatformPanel = UserInputEvent | 0x17,
|
||||
ContextMenu = UserInputEvent | 0x18
|
||||
};
|
||||
|
||||
class WindowSystemEvent {
|
||||
@ -374,6 +375,14 @@ public:
|
||||
{ const QMutexLocker locker(&mutex); impl.prepend(e); }
|
||||
WindowSystemEvent *takeFirstOrReturnNull()
|
||||
{ const QMutexLocker locker(&mutex); return impl.empty() ? 0 : impl.takeFirst(); }
|
||||
WindowSystemEvent *takeFirstNonUserInputOrReturnNull()
|
||||
{
|
||||
const QMutexLocker locker(&mutex);
|
||||
for (int i = 0; i < impl.size(); ++i)
|
||||
if (!(impl.at(i)->type & QWindowSystemInterfacePrivate::UserInputEvent))
|
||||
return impl.takeAt(i);
|
||||
return 0;
|
||||
}
|
||||
void append(WindowSystemEvent *e)
|
||||
{ const QMutexLocker locker(&mutex); impl.append(e); }
|
||||
int count() const
|
||||
@ -405,6 +414,7 @@ public:
|
||||
|
||||
static int windowSystemEventsQueued();
|
||||
static WindowSystemEvent *getWindowSystemEvent();
|
||||
static WindowSystemEvent *getNonUserInputWindowSystemEvent();
|
||||
static WindowSystemEvent *peekWindowSystemEvent(EventType t);
|
||||
static void removeWindowSystemEvent(WindowSystemEvent *event);
|
||||
static void handleWindowSystemEvent(WindowSystemEvent *ev);
|
||||
|
Loading…
x
Reference in New Issue
Block a user