4#include <QtGui/qtguiglobal.h>
7#include <MetalKit/MetalKit.h>
8#include <UniformTypeIdentifiers/UTCoreTypes.h>
17#include <qpa/qplatformintegration.h>
19#include <qpa/qwindowsysteminterface.h>
20#include <QtGui/QTextFormat>
21#include <QtCore/QDebug>
22#include <QtCore/QPointer>
24#include <QtCore/qsysinfo.h>
25#include <QtCore/private/qcore_mac_p.h>
26#include <QtGui/QAccessible>
27#include <QtGui/QImage>
28#include <private/qguiapplication_p.h>
29#include <private/qcoregraphics_p.h>
30#include <private/qwindow_p.h>
31#include <private/qpointingdevice_p.h>
32#include <private/qhighdpiscaling_p.h>
38#include <QtGui/private/qmacmimeregistry_p.h>
40@interface QNSView (Drawing) <CALayerDelegate>
45- (instancetype)initWithView:(
QNSView *)theView;
46- (
void)mouseMoved:(NSEvent *)theEvent;
47- (
void)mouseEntered:(NSEvent *)theEvent;
48- (
void)mouseExited:(NSEvent *)theEvent;
49- (
void)cursorUpdate:(NSEvent *)theEvent;
54@interface QNSView (Mouse)
56- (NSPoint)screenMousePoint:(NSEvent *)theEvent;
57- (
void)mouseMovedImpl:(NSEvent *)theEvent;
58- (
void)mouseEnteredImpl:(NSEvent *)theEvent;
59- (
void)mouseExitedImpl:(NSEvent *)theEvent;
62@interface QNSView (Touch)
65@interface QNSView (Tablet)
66- (bool)handleTabletEvent:(NSEvent *)theEvent;
69@interface QNSView (Gestures)
72@interface QNSView (Dragging)
73-(
void)registerDragTypes;
76@interface QNSView (Keys)
79@interface QNSView (ComplexText) <NSTextInputClient>
84- (instancetype)initWithView:(
QNSView *)theView;
90- (BOOL)isTransparentForUserInput;
91@property (assign) NSView* previousSuperview;
92@property (assign) NSWindow* previousWindow;
94@property (nonatomic, retain) NSColorSpace *colorSpace;
98 QPointer<QCocoaWindow> m_platformWindow;
124@synthesize colorSpace = m_colorSpace;
126- (instancetype)initWithCocoaWindow:(
QCocoaWindow *)platformWindow
128 if ((
self = [super initWithFrame:NSZeroRect])) {
129 m_platformWindow = platformWindow;
138 self.focusRingType = NSFocusRingTypeNone;
140 self.previousSuperview = nil;
141 self.previousWindow = nil;
145 [
self registerDragTypes];
163 [[NSNotificationCenter defaultCenter] removeObserver:self];
164 [m_mouseMoveHelper release];
169- (NSString *)description
171 NSMutableString *description = [NSMutableString stringWithString:[
super description]];
173#ifndef QT_NO_DEBUG_STREAM
174 QString platformWindowDescription;
176 debug.nospace() <<
"; " << m_platformWindow <<
">";
178 NSRange lastCharacter = [description rangeOfComposedCharacterSequenceAtIndex:description.length - 1];
179 [description replaceCharactersInRange:lastCharacter withString:platformWindowDescription.toNSString()];
187- (
void)removeFromSuperview
190 [
super removeFromSuperview];
193- (
void)viewWillMoveToSuperview:(NSView *)newSuperview
196 self.previousSuperview =
self.superview;
198 if (newSuperview ==
self.superview)
199 qCDebug(lcQpaWindow) <<
"Re-ordering" <<
self <<
"inside" <<
self.superview;
201 qCDebug(lcQpaWindow) <<
"Re-parenting" <<
self <<
"from" <<
self.superview <<
"to" << newSuperview;
204- (
void)viewDidMoveToSuperview
208 if (
self.superview ==
self.previousSuperview) {
209 qCDebug(lcQpaWindow) <<
"Done re-ordering" <<
self <<
"new index:"
210 << [
self.superview.subviews indexOfObject:self];
214 qCDebug(lcQpaWindow) <<
"Done re-parenting" <<
self <<
"into" <<
self.superview;
219 if (!m_platformWindow)
222 if (!m_platformWindow->isEmbedded())
225 if ([self superview]) {
227 [
self setNeedsDisplay:YES];
232- (
void)viewWillMoveToWindow:(NSWindow *)newWindow
239 if (newWindow ==
self.window)
242 qCDebug(lcQpaWindow) <<
"Moving" <<
self <<
"from" <<
self.window <<
"to" << newWindow;
248- (
void)viewDidMoveToWindow
254 if (
self.window ==
self.previousWindow)
264 if (!m_platformWindow)
267 QWindow *focusWindow = m_platformWindow->window();
271 if (
qstrcmp(focusWindow->metaObject()->className(),
"QWidgetWindow") == 0) {
272 while (focusWindow->parent()) {
273 focusWindow = focusWindow->parent();
288 if (!m_platformWindow->isExposed())
291 m_platformWindow->handleExposeEvent(
QRegion());
302 [
self setNeedsDisplay:YES];
305- (BOOL)isTransparentForUserInput
307 return m_platformWindow->window() &&
311- (BOOL)becomeFirstResponder
313 if (!m_platformWindow)
315 if ([self isTransparentForUserInput])
318 if (!m_platformWindow->windowIsPopupType()
319 && (!
self.window.canBecomeKeyWindow ||
self.window.keyWindow)) {
335 QWindowSystemInterface::handleFocusWindowChanged<QWindowSystemInterface::SynchronousDelivery>(
342- (BOOL)acceptsFirstResponder
344 if (!m_platformWindow)
346 if (m_platformWindow->shouldRefuseKeyWindowAndFirstResponder())
348 if ([self isTransparentForUserInput])
355- (NSView *)hitTest:(NSPoint)aPoint
357 NSView *candidate = [
super hitTest:aPoint];
358 if (candidate == self) {
359 if ([self isTransparentForUserInput])
365- (
void)convertFromScreen:(NSPoint)mouseLocation toWindowPoint:(
QPointF *)qtWindowPoint andScreenPoint:(
QPointF *)qtScreenPoint
385 NSWindow *
window = [
self window];
386 NSPoint nsWindowPoint;
387 NSRect windowRect = [window convertRectFromScreen:NSMakeRect(mouseLocation.x, mouseLocation.y, 1, 1)];
388 nsWindowPoint = windowRect.origin;
389 NSPoint nsViewPoint = [
self convertPoint: nsWindowPoint fromView: nil];
390 *qtWindowPoint =
QPointF(nsViewPoint.x, nsViewPoint.y);
405#if QT_CONFIG(accessibility)
411@implementation QNSView (QtExtras)
415 return m_platformWindow.data();;
static QPointF mapFromNative(CGPoint pos, QCocoaScreen *screen=QCocoaScreen::primaryScreen())
Native interface for QPlatformWindow on \macos. \inmodule QtGui.
\inmodule QtCore\reentrant
The QRegion class specifies a clip region for a painter.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static bool flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Make Qt Gui process all events on the event queue immediately.
static void handleGeometryChange(QWindow *window, const QRect &newRect)
@ WindowTransparentForInput
@ ActiveWindowFocusReason
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
#define QT_NAMESPACE_ALIAS_OBJC_CLASS(__KLASS__)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
#define qCDebug(category,...)
NSEvent * m_currentlyInterpretedKeyEvent
bool m_sendUpAsRightButton
Qt::MouseButtons m_buttons
bool m_dontOverrideCtrlLMB
QPointer< QObject > m_composingFocusObject
QNSViewMouseMoveHelper * m_mouseMoveHelper
QSet< quint32 > m_acceptedKeyDowns
bool m_sendKeyEventWithoutText
Qt::MouseButtons m_acceptedMouseDowns
Qt::MouseButtons m_frameStrutButtons
Qt::KeyboardModifiers m_currentWheelModifiers
NSDraggingContext m_lastSeenContext
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]