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/private/qcore_mac_p.h>
25#include <QtGui/QAccessible>
26#include <QtGui/QImage>
27#include <private/qguiapplication_p.h>
28#include <private/qcoregraphics_p.h>
29#include <private/qwindow_p.h>
30#include <private/qpointingdevice_p.h>
31#include <private/qhighdpiscaling_p.h>
37#include <QtGui/private/qmacmimeregistry_p.h>
38#include <QtGui/private/qmetallayer_p.h>
40#include <QuartzCore/CATransaction.h>
42@interface QNSView (Drawing) <CALayerDelegate>
47- (instancetype)initWithView:(
QNSView *)theView;
48- (
void)mouseMoved:(NSEvent *)theEvent;
49- (
void)mouseEntered:(NSEvent *)theEvent;
50- (
void)mouseExited:(NSEvent *)theEvent;
51- (
void)cursorUpdate:(NSEvent *)theEvent;
56@interface QNSView (Mouse)
58- (NSPoint)screenMousePoint:(NSEvent *)theEvent;
59- (
void)mouseMovedImpl:(NSEvent *)theEvent;
60- (
void)mouseEnteredImpl:(NSEvent *)theEvent;
61- (
void)mouseExitedImpl:(NSEvent *)theEvent;
64@interface QNSView (Touch)
67@interface QNSView (Tablet)
68- (bool)handleTabletEvent:(NSEvent *)theEvent;
71@interface QNSView (Gestures)
74@interface QNSView (Dragging)
75-(
void)registerDragTypes;
78@interface QNSView (Keys)
81@interface QNSView (ComplexText) <NSTextInputClient>
86- (instancetype)initWithView:(
QNSView *)theView;
92- (BOOL)isTransparentForUserInput;
93@property (assign) NSView* previousSuperview;
94@property (assign) NSWindow* previousWindow;
96@property (nonatomic, retain) NSColorSpace *colorSpace;
100 QPointer<QCocoaWindow> m_platformWindow;
126@synthesize colorSpace = m_colorSpace;
128- (instancetype)initWithCocoaWindow:(
QCocoaWindow *)platformWindow
130 if ((
self = [super initWithFrame:NSZeroRect])) {
131 m_platformWindow = platformWindow;
140 self.focusRingType = NSFocusRingTypeNone;
142 self.previousSuperview = nil;
143 self.previousWindow = nil;
147 [
self registerDragTypes];
165 [[NSNotificationCenter defaultCenter] removeObserver:self];
166 [m_mouseMoveHelper release];
171- (NSString *)description
173 NSMutableString *description = [NSMutableString stringWithString:[
super description]];
175#ifndef QT_NO_DEBUG_STREAM
176 QString platformWindowDescription;
178 debug.nospace() <<
"; " << m_platformWindow <<
">";
180 NSRange lastCharacter = [description rangeOfComposedCharacterSequenceAtIndex:description.length - 1];
181 [description replaceCharactersInRange:lastCharacter withString:platformWindowDescription.toNSString()];
189- (
void)removeFromSuperview
192 [
super removeFromSuperview];
195- (
void)viewWillMoveToSuperview:(NSView *)newSuperview
198 self.previousSuperview =
self.superview;
200 if (newSuperview ==
self.superview)
201 qCDebug(lcQpaWindow) <<
"Re-ordering" <<
self <<
"inside" <<
self.superview;
203 qCDebug(lcQpaWindow) <<
"Re-parenting" <<
self <<
"from" <<
self.superview <<
"to" << newSuperview;
206- (
void)viewDidMoveToSuperview
210 if (
self.superview ==
self.previousSuperview) {
211 qCDebug(lcQpaWindow) <<
"Done re-ordering" <<
self <<
"new index:"
212 << [
self.superview.subviews indexOfObject:self];
216 qCDebug(lcQpaWindow) <<
"Done re-parenting" <<
self <<
"into" <<
self.superview;
221 if (!m_platformWindow)
224 if (!m_platformWindow->isEmbedded())
227 if ([self superview]) {
229 [
self setNeedsDisplay:YES];
234- (
void)viewWillMoveToWindow:(NSWindow *)newWindow
241 if (newWindow ==
self.window)
244 qCDebug(lcQpaWindow) <<
"Moving" <<
self <<
"from" <<
self.window <<
"to" << newWindow;
250- (
void)viewDidMoveToWindow
256 if (
self.window ==
self.previousWindow)
266 if (!m_platformWindow)
269 QWindow *focusWindow = m_platformWindow->window();
273 if (
qstrcmp(focusWindow->metaObject()->className(),
"QWidgetWindow") == 0) {
274 while (focusWindow->parent()) {
275 focusWindow = focusWindow->parent();
290 if (!m_platformWindow->isExposed())
293 m_platformWindow->handleExposeEvent(
QRegion());
304 [
self setNeedsDisplay:YES];
307- (BOOL)isTransparentForUserInput
309 return m_platformWindow->window() &&
313- (BOOL)becomeFirstResponder
315 if (!m_platformWindow)
317 if ([self isTransparentForUserInput])
320 if (!m_platformWindow->windowIsPopupType()
321 && (!
self.window.canBecomeKeyWindow ||
self.window.keyWindow)) {
337 QWindowSystemInterface::handleFocusWindowChanged<QWindowSystemInterface::SynchronousDelivery>(
344- (BOOL)acceptsFirstResponder
346 if (!m_platformWindow)
348 if (m_platformWindow->shouldRefuseKeyWindowAndFirstResponder())
350 if ([self isTransparentForUserInput])
357- (NSView *)hitTest:(NSPoint)aPoint
359 NSView *candidate = [
super hitTest:aPoint];
360 if (candidate == self) {
361 if ([self isTransparentForUserInput])
367- (
void)convertFromScreen:(NSPoint)mouseLocation toWindowPoint:(
QPointF *)qtWindowPoint andScreenPoint:(
QPointF *)qtScreenPoint
387 NSWindow *
window = [
self window];
388 NSPoint nsWindowPoint;
389 NSRect windowRect = [window convertRectFromScreen:NSMakeRect(mouseLocation.x, mouseLocation.y, 1, 1)];
390 nsWindowPoint = windowRect.origin;
391 NSPoint nsViewPoint = [
self convertPoint: nsWindowPoint fromView: nil];
392 *qtWindowPoint =
QPointF(nsViewPoint.x, nsViewPoint.y);
407#if QT_CONFIG(accessibility)
413@implementation QNSView (QtExtras)
417 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]