Remove Carbon API usage from tst_qmacnativeevents

These code paths are actually never exercised at all.

Change-Id: I95a5cfa0173e265573c30378ec2e03a2ddf954e4
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
bb10
Jake Petroules 2017-03-06 15:59:32 -08:00
parent a7b9a1f966
commit e0e956bfc2
3 changed files with 11 additions and 37 deletions

View File

@ -72,7 +72,7 @@ void QNativeInput::nativeEvent(QNativeEvent *event)
}
}
Qt::Native::Status QNativeInput::sendNativeEvent(const QNativeEvent &event, int pid)
Qt::Native::Status QNativeInput::sendNativeEvent(const QNativeEvent &event)
{
switch (event.id()){
case QNativeMouseMoveEvent::eventId:
@ -84,7 +84,7 @@ Qt::Native::Status QNativeInput::sendNativeEvent(const QNativeEvent &event, int
case QNativeMouseWheelEvent::eventId:
return sendNativeMouseWheelEvent(static_cast<const QNativeMouseWheelEvent &>(event));
case QNativeKeyEvent::eventId:
return sendNativeKeyEvent(static_cast<const QNativeKeyEvent &>(event), pid);
return sendNativeKeyEvent(static_cast<const QNativeKeyEvent &>(event));
case QNativeModifierEvent::eventId:
return sendNativeModifierEvent(static_cast<const QNativeModifierEvent &>(event));
case QNativeEvent::eventId:

View File

@ -204,10 +204,10 @@ class QNativeInput
static Qt::Native::Status sendNativeMouseMoveEvent(const QNativeMouseMoveEvent &event);
static Qt::Native::Status sendNativeMouseDragEvent(const QNativeMouseDragEvent &event);
static Qt::Native::Status sendNativeMouseWheelEvent(const QNativeMouseWheelEvent &event);
static Qt::Native::Status sendNativeKeyEvent(const QNativeKeyEvent &event, int pid = 0);
static Qt::Native::Status sendNativeKeyEvent(const QNativeKeyEvent &event);
static Qt::Native::Status sendNativeModifierEvent(const QNativeModifierEvent &event);
// sendNativeEvent will NOT differ from OS to OS.
static Qt::Native::Status sendNativeEvent(const QNativeEvent &event, int pid = 0);
static Qt::Native::Status sendNativeEvent(const QNativeEvent &event);
// The following methods will differ in implementation from OS to OS:
Qt::Native::Status subscribeForNativeEvents();

View File

@ -176,28 +176,18 @@ static CGEventRef EventHandler_Quartz(CGEventTapProxy proxy, CGEventType type, C
return inEvent;
}
Qt::Native::Status insertEventHandler_Quartz(QNativeInput *nativeInput, int pid = 0)
Qt::Native::Status insertEventHandler_Quartz(QNativeInput *nativeInput)
{
uid_t uid = geteuid();
if (uid != 0)
qWarning("MacNativeEvents: You must be root to listen for key events!");
CFMachPortRef port;
if (!pid){
port = CGEventTapCreate(kCGHIDEventTap,
kCGHeadInsertEventTap, kCGEventTapOptionListenOnly,
kCGEventMaskForAllEvents, EventHandler_Quartz, nativeInput);
} else {
ProcessSerialNumber psn;
GetProcessForPID(pid, &psn);
port = CGEventTapCreateForPSN(&psn,
kCGHeadInsertEventTap, kCGEventTapOptionListenOnly,
kCGEventMaskForAllEvents, EventHandler_Quartz, nativeInput);
}
CFMachPortRef port = CGEventTapCreate(kCGHIDEventTap,
kCGHeadInsertEventTap, kCGEventTapOptionListenOnly,
kCGEventMaskForAllEvents, EventHandler_Quartz, nativeInput);
CFRunLoopSourceRef eventSrc = CFMachPortCreateRunLoopSource(NULL, port, 0);
CFRunLoopAddSource((CFRunLoopRef) GetCFRunLoopFromEventLoop(GetMainEventLoop()),
eventSrc, kCFRunLoopCommonModes);
CFRunLoopAddSource(CFRunLoopGetMain(), eventSrc, kCFRunLoopCommonModes);
return Qt::Native::Success;
}
@ -207,19 +197,6 @@ Qt::Native::Status removeEventHandler_Quartz()
return Qt::Native::Success; // ToDo:
}
Qt::Native::Status sendNativeKeyEventToProcess_Quartz(const QNativeKeyEvent &event, int pid)
{
ProcessSerialNumber psn;
GetProcessForPID(pid, &psn);
CGEventRef e = CGEventCreateKeyboardEvent(0, (uint)event.nativeKeyCode, event.press);
setModifiersFromQNativeEvent(e, event);
SetFrontProcess(&psn);
CGEventPostToPSN(&psn, e);
CFRelease(e);
return Qt::Native::Success;
}
Qt::Native::Status sendNativeKeyEvent_Quartz(const QNativeKeyEvent &event)
{
CGEventRef e = CGEventCreateKeyboardEvent(0, (uint)event.nativeKeyCode, event.press);
@ -344,12 +321,9 @@ Qt::Native::Status QNativeInput::sendNativeMouseWheelEvent(const QNativeMouseWhe
return sendNativeMouseWheelEvent_Quartz(event);
}
Qt::Native::Status QNativeInput::sendNativeKeyEvent(const QNativeKeyEvent &event, int pid)
Qt::Native::Status QNativeInput::sendNativeKeyEvent(const QNativeKeyEvent &event)
{
if (!pid)
return sendNativeKeyEvent_Quartz(event);
else
return sendNativeKeyEventToProcess_Quartz(event, pid);
return sendNativeKeyEvent_Quartz(event);
}
Qt::Native::Status QNativeInput::sendNativeModifierEvent(const QNativeModifierEvent &event)