4#include <QtGui/qtguiglobal.h>
7#include <MetalKit/MetalKit.h>
16#include <qpa/qplatformintegration.h>
18#include <qpa/qwindowsysteminterface.h>
19#include <QtGui/QTextFormat>
20#include <QtCore/QDebug>
21#include <QtCore/QPointer>
23#include <QtCore/qsysinfo.h>
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>
39@interface QNSView (Drawing) <CALayerDelegate>
44- (instancetype)initWithView:(
QNSView *)theView;
45- (
void)mouseMoved:(NSEvent *)theEvent;
46- (
void)mouseEntered:(NSEvent *)theEvent;
47- (
void)mouseExited:(NSEvent *)theEvent;
48- (
void)cursorUpdate:(NSEvent *)theEvent;
53@interface QNSView (Mouse)
55- (NSPoint)screenMousePoint:(NSEvent *)theEvent;
56- (
void)mouseMovedImpl:(NSEvent *)theEvent;
57- (
void)mouseEnteredImpl:(NSEvent *)theEvent;
58- (
void)mouseExitedImpl:(NSEvent *)theEvent;
61@interface QNSView (Touch)
64@interface QNSView (Tablet)
65- (bool)handleTabletEvent:(NSEvent *)theEvent;
68@interface QNSView (Gestures)
71@interface QNSView (Dragging)
72-(
void)registerDragTypes;
75@interface QNSView (Keys)
78@interface QNSView (ComplexText) <NSTextInputClient>
83- (instancetype)initWithView:(
QNSView *)theView;
89- (BOOL)isTransparentForUserInput;
90@property (assign) NSView* previousSuperview;
91@property (assign) NSWindow* previousWindow;
122- (instancetype)initWithCocoaWindow:(
QCocoaWindow *)platformWindow
124 if ((
self = [super initWithFrame:NSZeroRect])) {
125 m_platformWindow = platformWindow;
134 self.focusRingType = NSFocusRingTypeNone;
136 self.previousSuperview = nil;
137 self.previousWindow = nil;
141 [
self registerDragTypes];
159 [[NSNotificationCenter defaultCenter] removeObserver:self];
160 [m_mouseMoveHelper release];
165- (NSString *)description
167 NSMutableString *description = [NSMutableString stringWithString:[
super description]];
169#ifndef QT_NO_DEBUG_STREAM
170 QString platformWindowDescription;
172 debug.nospace() <<
"; " << m_platformWindow <<
">";
174 NSRange lastCharacter = [description rangeOfComposedCharacterSequenceAtIndex:description.length - 1];
175 [description replaceCharactersInRange:lastCharacter withString:platformWindowDescription.toNSString()];
183- (
void)removeFromSuperview
186 [
super removeFromSuperview];
189- (
void)viewWillMoveToSuperview:(NSView *)newSuperview
192 self.previousSuperview =
self.superview;
194 if (newSuperview ==
self.superview)
195 qCDebug(lcQpaWindow) <<
"Re-ordering" <<
self <<
"inside" <<
self.superview;
197 qCDebug(lcQpaWindow) <<
"Re-parenting" <<
self <<
"from" <<
self.superview <<
"to" << newSuperview;
200- (
void)viewDidMoveToSuperview
204 if (
self.superview ==
self.previousSuperview) {
205 qCDebug(lcQpaWindow) <<
"Done re-ordering" <<
self <<
"new index:"
206 << [
self.superview.subviews indexOfObject:self];
210 qCDebug(lcQpaWindow) <<
"Done re-parenting" <<
self <<
"into" <<
self.superview;
215 if (!m_platformWindow)
218 if (!m_platformWindow->isEmbedded())
221 if ([self superview]) {
223 [
self setNeedsDisplay:YES];
228- (
void)viewWillMoveToWindow:(NSWindow *)newWindow
235 if (newWindow ==
self.window)
238 qCDebug(lcQpaWindow) <<
"Moving" <<
self <<
"from" <<
self.window <<
"to" << newWindow;
244- (
void)viewDidMoveToWindow
250 if (
self.window ==
self.previousWindow)
260 if (!m_platformWindow)
263 QWindow *focusWindow = m_platformWindow->window();
267 if (
qstrcmp(focusWindow->metaObject()->className(),
"QWidgetWindow") == 0) {
268 while (focusWindow->parent()) {
269 focusWindow = focusWindow->parent();
278 if (!m_platformWindow->isExposed())
281 m_platformWindow->handleExposeEvent(
QRegion());
287- (BOOL)isTransparentForUserInput
289 return m_platformWindow->window() &&
293- (BOOL)becomeFirstResponder
295 if (!m_platformWindow)
297 if ([self isTransparentForUserInput])
300 if (!m_platformWindow->windowIsPopupType()
301 && (!
self.window.canBecomeKeyWindow ||
self.window.keyWindow)) {
317 QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(
324- (BOOL)acceptsFirstResponder
326 if (!m_platformWindow)
328 if (m_platformWindow->shouldRefuseKeyWindowAndFirstResponder())
330 if ([self isTransparentForUserInput])
337- (NSView *)hitTest:(NSPoint)aPoint
339 NSView *candidate = [
super hitTest:aPoint];
340 if (candidate == self) {
341 if ([self isTransparentForUserInput])
347- (
void)convertFromScreen:(NSPoint)mouseLocation toWindowPoint:(
QPointF *)qtWindowPoint andScreenPoint:(
QPointF *)qtScreenPoint
367 NSWindow *
window = [
self window];
368 NSPoint nsWindowPoint;
369 NSRect windowRect = [window convertRectFromScreen:NSMakeRect(mouseLocation.x, mouseLocation.y, 1, 1)];
370 nsWindowPoint = windowRect.origin;
371 NSPoint nsViewPoint = [
self convertPoint: nsWindowPoint fromView: nil];
372 *qtWindowPoint =
QPointF(nsViewPoint.x, nsViewPoint.y);
387#if QT_CONFIG(accessibility)
393@implementation QNSView (QtExtras)
397 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]