macOS: Replace category methods with functions
Objective-C category methods prohibit safe unloading of dynamic libraries / plugins statically linked to Qt. Although they can be called in convenient way they can be replaced with standalone functions without noticeable drawback. Remove unused qt_validModesForFontPanel category method. Remove empty NSStatusItem (Qt) category. Task-number: QTBUG-59884 Change-Id: I69503a115b1177623da91c67b62d72e56f43ffcf Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
parent
4c03f2b79e
commit
36ddfb6cc1
@ -83,23 +83,11 @@
|
|||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
/*
|
|
||||||
Cocoa Application Categories
|
|
||||||
*/
|
|
||||||
#include "qglobal.h"
|
#include "qglobal.h"
|
||||||
#include "private/qcore_mac_p.h"
|
#include "private/qcore_mac_p.h"
|
||||||
|
|
||||||
#import <AppKit/AppKit.h>
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
@class QT_MANGLE_NAMESPACE(QCocoaMenuLoader);
|
|
||||||
|
|
||||||
@interface NSApplication (QT_MANGLE_NAMESPACE(QApplicationIntegration))
|
|
||||||
- (void)QT_MANGLE_NAMESPACE(qt_setDockMenu):(NSMenu *)newMenu;
|
|
||||||
- (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel;
|
|
||||||
|
|
||||||
- (void)QT_MANGLE_NAMESPACE(qt_sendPostedMessage):(NSEvent *)event;
|
|
||||||
- (BOOL)QT_MANGLE_NAMESPACE(qt_filterEvent):(NSEvent *)event;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface QT_MANGLE_NAMESPACE(QNSApplication) : NSApplication {
|
@interface QT_MANGLE_NAMESPACE(QNSApplication) : NSApplication {
|
||||||
}
|
}
|
||||||
|
@ -82,25 +82,7 @@
|
|||||||
|
|
||||||
QT_USE_NAMESPACE
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
@implementation NSApplication (QT_MANGLE_NAMESPACE(QApplicationIntegration))
|
static void qt_sendPostedMessage(NSEvent *event)
|
||||||
|
|
||||||
- (void)QT_MANGLE_NAMESPACE(qt_setDockMenu):(NSMenu *)newMenu
|
|
||||||
{
|
|
||||||
[[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] setDockMenu:newMenu];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel
|
|
||||||
{
|
|
||||||
Q_UNUSED(fontPanel);
|
|
||||||
// only display those things that QFont can handle
|
|
||||||
return NSFontPanelFaceModeMask
|
|
||||||
| NSFontPanelSizeModeMask
|
|
||||||
| NSFontPanelCollectionModeMask
|
|
||||||
| NSFontPanelUnderlineEffectModeMask
|
|
||||||
| NSFontPanelStrikethroughEffectModeMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)QT_MANGLE_NAMESPACE(qt_sendPostedMessage):(NSEvent *)event
|
|
||||||
{
|
{
|
||||||
// WARNING: data1 and data2 is truncated to from 64-bit to 32-bit on OS 10.5!
|
// WARNING: data1 and data2 is truncated to from 64-bit to 32-bit on OS 10.5!
|
||||||
// That is why we need to split the address in two parts:
|
// That is why we need to split the address in two parts:
|
||||||
@ -128,7 +110,7 @@ QT_USE_NAMESPACE
|
|||||||
|
|
||||||
static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSEvent");
|
static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSEvent");
|
||||||
|
|
||||||
- (BOOL)QT_MANGLE_NAMESPACE(qt_filterEvent):(NSEvent *)event
|
static bool qt_filterEvent(NSEvent *event)
|
||||||
{
|
{
|
||||||
if (qApp && qApp->eventDispatcher()->
|
if (qApp && qApp->eventDispatcher()->
|
||||||
filterNativeEvent(q_macLocalEventType, static_cast<void*>(event), 0))
|
filterNativeEvent(q_macLocalEventType, static_cast<void*>(event), 0))
|
||||||
@ -137,7 +119,7 @@ static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSE
|
|||||||
if ([event type] == NSApplicationDefined) {
|
if ([event type] == NSApplicationDefined) {
|
||||||
switch (static_cast<short>([event subtype])) {
|
switch (static_cast<short>([event subtype])) {
|
||||||
case QtCocoaEventSubTypePostMessage:
|
case QtCocoaEventSubTypePostMessage:
|
||||||
[NSApp QT_MANGLE_NAMESPACE(qt_sendPostedMessage):event];
|
qt_sendPostedMessage(event);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -147,8 +129,6 @@ static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSE
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
static void qt_maybeSendKeyEquivalentUpEvent(NSEvent *event)
|
static void qt_maybeSendKeyEquivalentUpEvent(NSEvent *event)
|
||||||
{
|
{
|
||||||
// Cocoa is known for not sending key up events for key
|
// Cocoa is known for not sending key up events for key
|
||||||
@ -180,7 +160,7 @@ static void qt_maybeSendKeyEquivalentUpEvent(NSEvent *event)
|
|||||||
// be called instead of sendEvent if redirection occurs.
|
// be called instead of sendEvent if redirection occurs.
|
||||||
// 'self' will then be an instance of NSApplication
|
// 'self' will then be an instance of NSApplication
|
||||||
// (and not QNSApplication)
|
// (and not QNSApplication)
|
||||||
if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event]) {
|
if (!qt_filterEvent(event)) {
|
||||||
[self QT_MANGLE_NAMESPACE(qt_sendEvent_original):event];
|
[self QT_MANGLE_NAMESPACE(qt_sendEvent_original):event];
|
||||||
qt_maybeSendKeyEquivalentUpEvent(event);
|
qt_maybeSendKeyEquivalentUpEvent(event);
|
||||||
}
|
}
|
||||||
@ -190,7 +170,7 @@ static void qt_maybeSendKeyEquivalentUpEvent(NSEvent *event)
|
|||||||
{
|
{
|
||||||
// This method will be called if
|
// This method will be called if
|
||||||
// no redirection occurs
|
// no redirection occurs
|
||||||
if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event]) {
|
if (!qt_filterEvent(event)) {
|
||||||
[super sendEvent:event];
|
[super sendEvent:event];
|
||||||
qt_maybeSendKeyEquivalentUpEvent(event);
|
qt_maybeSendKeyEquivalentUpEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#include "qcocoamenu.h"
|
#include "qcocoamenu.h"
|
||||||
#include "qcocoamenubar.h"
|
#include "qcocoamenubar.h"
|
||||||
#include "qcocoahelpers.h"
|
#include "qcocoahelpers.h"
|
||||||
#include "qcocoaapplication.h"
|
#include "qcocoaapplicationdelegate.h"
|
||||||
#include "qcocoaintegration.h"
|
#include "qcocoaintegration.h"
|
||||||
#include "qcocoaeventdispatcher.h"
|
#include "qcocoaeventdispatcher.h"
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ void QCocoaNativeInterface::setDockMenu(QPlatformMenu *platformMenu)
|
|||||||
QMacAutoReleasePool pool;
|
QMacAutoReleasePool pool;
|
||||||
QCocoaMenu *cocoaPlatformMenu = static_cast<QCocoaMenu *>(platformMenu);
|
QCocoaMenu *cocoaPlatformMenu = static_cast<QCocoaMenu *>(platformMenu);
|
||||||
NSMenu *menu = cocoaPlatformMenu->nsMenu();
|
NSMenu *menu = cocoaPlatformMenu->nsMenu();
|
||||||
[NSApp QT_MANGLE_NAMESPACE(qt_setDockMenu): menu];
|
[[QCocoaApplicationDelegate sharedDelegate] setDockMenu:menu];
|
||||||
}
|
}
|
||||||
|
|
||||||
void *QCocoaNativeInterface::qMenuToNSMenu(QPlatformMenu *platformMenu)
|
void *QCocoaNativeInterface::qMenuToNSMenu(QPlatformMenu *platformMenu)
|
||||||
|
@ -289,9 +289,6 @@ void QCocoaSystemTrayIcon::showMessage(const QString &title, const QString &mess
|
|||||||
}
|
}
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
@implementation NSStatusItem (Qt)
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation QNSImageView
|
@implementation QNSImageView
|
||||||
-(id)initWithParent:(QNSStatusItem*)myParent {
|
-(id)initWithParent:(QNSStatusItem*)myParent {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user