5#include <QuartzCore/QuartzCore.h>
19#include <QtCore/qfileinfo.h>
20#include <QtCore/private/qcore_mac_p.h>
22#include <private/qwindow_p.h>
23#include <qpa/qwindowsysteminterface.h>
24#include <qpa/qplatformscreen.h>
25#include <QtGui/private/qcoregraphics_p.h>
26#include <QtGui/private/qhighdpiscaling_p.h>
45 NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
53 if (!methodTag.
startsWith(notificationHandlerPrefix))
56 const QString notificationName = methodTag.
mid(notificationHandlerPrefix.
size());
57 [center addObserverForName:notificationName.toNSString()
object:nil
queue:nil
58 usingBlock:^(NSNotification *notification) {
61 if ([notification.object isKindOfClass:[NSWindow
class]]) {
62 NSWindow *nsWindow = notification.object;
65 if (cocoaWindow->nativeWindow() == nsWindow)
66 cocoaWindows += cocoaWindow;
68 }
else if ([notification.object isKindOfClass:[NSView
class]]) {
70 cocoaWindows += qnsView.platformWindow;
72 qCWarning(lcCocoaNotifications) <<
"Unhandled notification"
73 << notification.name <<
"for" << notification.object;
77 if (lcCocoaNotifications().isDebugEnabled() && !cocoaWindows.
isEmpty()) {
80 debugWindows += cocoaWindow;
89 qCWarning(lcQpaWindow) <<
"Failed to invoke NSNotification callback for"
90 << notification.name <<
"on" << cocoaWindow;
103 qCDebug(lcQpaWindow) <<
"QCocoaWindow::QCocoaWindow" <<
window();
106 m_view =
reinterpret_cast<NSView *
>(nativeHandle);
113 qCDebug(lcQpaWindow) <<
"QCocoaWindow::initialize" <<
window();
148 qCDebug(lcQpaWindow) <<
"QCocoaWindow::~QCocoaWindow" <<
window();
154 [
m_view removeFromSuperview];
159 [[NSNotificationCenter defaultCenter] removeObserver:
m_view];
163 auto vulcanInstance = cocoaIntegration->getCocoaVulkanInstance();
165 vulcanInstance->destroySurface(m_vulkanSurface);
172 [NSNotificationCenter.defaultCenter
183 return window()->requestedFormat();
188 qCDebug(lcQpaWindow) <<
"QCocoaWindow::setGeometry" <<
window() << rectIn;
217 NSPoint windowPoint = [
m_view convertPoint:NSMakePoint(0, 0) toView:nil];
218 NSRect screenRect = [[
m_view window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
219 NSPoint screenPoint = screenRect.origin;
221 QSize size = QRectF::fromCGRect(NSRectToCGRect([
m_view bounds])).toRect().size();
278 [
m_view.window setFrame:[
m_view.window frameRectForContentRect:bounds]
display:YES animate:NO];
288 switch (NSApp.currentEvent.type) {
289 case NSEventTypeLeftMouseDown:
290 case NSEventTypeRightMouseDown:
291 case NSEventTypeOtherMouseDown:
292 case NSEventTypeMouseMoved:
293 case NSEventTypeLeftMouseDragged:
294 case NSEventTypeRightMouseDragged:
295 case NSEventTypeOtherMouseDragged:
298 [
m_view.window performWindowDragWithEvent:NSApp.currentEvent];
307 qCDebug(lcQpaWindow) <<
"QCocoaWindow::setVisible" <<
window() << visible;
313 if (
window()->transientParent())
314 parentCocoaWindow =
static_cast<QCocoaWindow *
>(
window()->transientParent()->handle());
316 auto eventDispatcher = [] {
330 if (parentCocoaWindow) {
338 NSWindow *nativeParentWindow = parentCocoaWindow->
nativeWindow();
339 NSUInteger parentStyleMask = nativeParentWindow.styleMask;
341 && !(nativeParentWindow.styleMask & NSWindowStyleMaskFullScreen))
342 nativeParentWindow.styleMask &= ~NSWindowStyleMaskResizable;
360 NSWindow *nativeParentWindow = parentCocoaWindow->
nativeWindow();
361 if (!nativeParentWindow.attachedSheet)
362 [nativeParentWindow beginSheet:
m_view.window completionHandler:nil];
364 [nativeParentWindow beginCriticalSheet:
m_view.window completionHandler:nil];
367 eventDispatcher()->beginModalSession(
window());
368 }
else if (
m_view.window.canBecomeKeyWindow) {
369 bool shouldBecomeKeyNow = !NSApp.modalWindow
370 ||
m_view.window.worksWhenModal
371 || !NSApp.modalWindow.visible;
375 if ([
m_view.window isKindOfClass:[NSPanel
class]])
376 shouldBecomeKeyNow &= !(
static_cast<NSPanel*
>(
m_view.window).becomesKeyOnlyIfNeeded);
378 if (shouldBecomeKeyNow)
379 [
m_view.window makeKeyAndOrderFront:nil];
381 [
m_view.window orderFront:nil];
383 [
m_view.window orderFront:nil];
390 if (eventDispatcher()->hasModalSession()) {
391 eventDispatcher()->endModalSession(
window());
393 if ([
m_view.window isSheet]) {
394 Q_ASSERT_X(parentCocoaWindow,
"QCocoaWindow",
"Window modal dialog has no transient parent.");
404 [
m_view.window orderOut:nil];
406 if (
m_view.window == [NSApp keyWindow] && !eventDispatcher()->hasModalSession()) {
411 NSWindow *mainWindow = [NSApp mainWindow];
412 if (mainWindow && [mainWindow canBecomeKeyWindow])
413 [mainWindow makeKeyWindow];
420 NSWindow *nativeParentWindow = parentCocoaWindow->
nativeWindow();
422 && !(nativeParentWindow.styleMask & NSWindowStyleMaskFullScreen))
424 nativeParentWindow.styleMask |= NSWindowStyleMaskResizable;
447 auto *transientParent =
window()->transientParent();
448 if (transientParent && transientParent->handle()) {
468 auto *transientCocoaWindow =
static_cast<QCocoaWindow *
>(transientParent->handle());
492 return NSWindowStyleMaskBorderless;
496 return NSWindowStyleMaskBorderless;
502 ? NSWindowStyleMaskTitled
503 : NSWindowStyleMaskBorderless;
506 return NSWindowStyleMaskTitled;
515 styleMask |= NSWindowStyleMaskClosable
516 | NSWindowStyleMaskMiniaturizable;
519 styleMask |= NSWindowStyleMaskResizable;
522 styleMask |= NSWindowStyleMaskUtilityWindow;
526 styleMask |= NSWindowStyleMaskTexturedBackground;
529 if (
m_view.window.styleMask & NSWindowStyleMaskFullScreen)
530 styleMask |= NSWindowStyleMaskFullScreen;
531 if (
m_view.window.styleMask & NSWindowStyleMaskFullSizeContentView)
532 styleMask |= NSWindowStyleMaskFullSizeContentView;
548 static constexpr std::pair<NSWindowButton, Qt::WindowFlags> buttons[] = {
554 bool hideButtons =
true;
555 for (
const auto &[
button, buttonHint] : buttons) {
558 if (
button == NSWindowMiniaturizeButton)
563 enabled = windowFlags & buttonHint;
586 for (
const auto &[
button, buttonHint] : buttons)
587 [
m_view.window standardWindowButton:
button].hidden = hideButtons;
609 NSWindowCollectionBehavior behavior =
m_view.window.collectionBehavior;
610 const bool enableFullScreen =
m_view.window.qt_fullScreen
613 if (enableFullScreen) {
614 behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
615 behavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary;
617 behavior |= NSWindowCollectionBehaviorFullScreenAuxiliary;
618 behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
620 m_view.window.collectionBehavior = behavior;
642 if (
m_view.window.ignoresMouseEvents != ignoreMouse)
643 m_view.window.ignoresMouseEvents = ignoreMouse;
674 const NSSize contentSize =
m_view.frame.size;
675 if (contentSize.width <= 0 || contentSize.height <= 0) {
678 qWarning(
"invalid window content view size, check your window geometry");
683 const NSWindow *nsWindow =
m_view.window;
685 if (nsWindow.styleMask & NSWindowStyleMaskUtilityWindow
692 const id sender = nsWindow;
695 switch (currentState) {
697 [nsWindow deminiaturize:
sender];
724 [nsWindow miniaturize:
sender];
745 if (
window.qt_fullScreen) {
764 const bool wasResizable =
window.styleMask & NSWindowStyleMaskResizable;
765 window.styleMask |= NSWindowStyleMaskResizable;
771 window.styleMask &= ~NSWindowStyleMaskResizable;
786 window.collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
792void QCocoaWindow::windowWillEnterFullScreen()
802 m_view.window.styleMask |= NSWindowStyleMaskResizable;
808 return window.styleMask & NSWindowStyleMaskFullScreen && !
window.qt_fullScreen;
811void QCocoaWindow::windowDidEnterFullScreen()
817 "FullScreen category processes window notifications first");
825void QCocoaWindow::windowWillExitFullScreen()
832 m_view.window.styleMask |= NSWindowStyleMaskResizable;
835void QCocoaWindow::windowDidExitFullScreen()
841 "FullScreen category processes window notifications first");
858void QCocoaWindow::windowDidMiniaturize()
866void QCocoaWindow::windowDidDeminiaturize()
888 qCDebug(lcQpaWindow) <<
"QCocoaWindow::handleWindowStateChanged" <<
891 QWindowSystemInterface::handleWindowStateChanged<QWindowSystemInterface::SynchronousDelivery>(
920 [
m_view.window setTitleWithRepresentedFilename:filePath.toNSString()];
922 m_view.window.representedFilename = filePath.toNSString();
933 NSButton *iconButton = [
m_view.window standardWindowButton:NSWindowDocumentIconButton];
942 iconButton.image = [NSWorkspace.sharedWorkspace iconForFile:
m_view.window.representedFilename];
945 auto fallbackSize = iconButton.frame.size.height *
qGuiApp->devicePixelRatio();
946 iconButton.image = [NSImage imageFromQIcon:
icon withSize:fallbackSize];
971 if (
m_view.window.visible) {
981 static bool raiseProcess = qt_mac_resolveOption(
true,
"QT_MAC_SET_RAISE_PROCESS");
983 [NSApp activateIgnoringOtherApps:YES];
986 [
m_view.superview addSubview:
m_view positioned:NSWindowAbove relativeTo:nil];
995 if (
m_view.window.visible)
998 [
m_view.superview addSubview:
m_view positioned:NSWindowBelow relativeTo:nil];
1027 static GLint openglSourfaceOrder = qt_mac_resolveOption(1,
"QT_MAC_OPENGL_SURFACE_ORDER");
1033 return !translucent;
1042 qCDebug(lcQpaWindow) <<
"QCocoaWindow::propagateSizeHints" <<
window()
1052 minimumSize =
QSize(0, 0);
1053 window.contentMinSize = NSSizeFromCGSize(minimumSize.toCGSize());
1065 sizeIncrement =
QSize(1, 1);
1066 window.resizeIncrements = NSSizeFromCGSize(sizeIncrement.toCGSize());
1076 qCDebug(lcQpaWindow) <<
"QCocoaWindow::setOpacity" <<
level;
1085 qCDebug(lcQpaWindow) <<
"QCocoaWindow::setMask" <<
window() << region;
1089 for (
const QRect &
r : region)
1090 CGPathAddRect(maskPath,
nullptr,
r.toCGRect());
1091 CAShapeLayer *maskLayer = [CAShapeLayer
layer];
1092 maskLayer.path = maskPath;
1093 m_view.layer.mask = maskLayer;
1116 qCDebug(lcQpaWindow) <<
"QCocoaWindow::setParent" <<
window() << (parentWindow ? parentWindow->
window() : 0);
1143void QCocoaWindow::viewDidChangeFrame()
1160void QCocoaWindow::viewDidChangeGlobalFrame()
1162 [
m_view setNeedsDisplay:YES];
1172void QCocoaWindow::windowDidMove()
1183void QCocoaWindow::windowDidResize()
1190 if (!
m_view.inLiveResize)
1194void QCocoaWindow::windowDidEndLiveResize()
1202void QCocoaWindow::windowDidBecomeKey()
1210 QNSView *firstResponderView = qt_objc_cast<QNSView *>(
m_view.window.firstResponder);
1211 if (!firstResponderView)
1214 const QCocoaWindow *focusCocoaWindow = firstResponderView.platformWindow;
1219 QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(
1223void QCocoaWindow::windowDidResignKey()
1238 NSWindow *newKeyWindow = [NSApp keyWindow];
1239 if (newKeyWindow && newKeyWindow !=
m_view.window
1240 && [newKeyWindow conformsToProtocol:@protocol(QNSWindowProtocol)]) {
1246 QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(
1251void QCocoaWindow::windowDidOrderOnScreen()
1256 QWindowSystemInterface::handleLeaveEvent<QWindowSystemInterface::SynchronousDelivery>
1260 [
m_view setNeedsDisplay:YES];
1263void QCocoaWindow::windowDidOrderOffScreen()
1272 const auto windowPoint = windowUnderMouse->mapFromGlobal(screenPoint);
1274 QWindowSystemInterface::handleEnterEvent<QWindowSystemInterface::AsynchronousDelivery>
1275 (windowUnderMouse, windowPoint, screenPoint);
1281void QCocoaWindow::windowDidChangeOcclusionState()
1283 bool visible =
m_view.window.occlusionState & NSWindowOcclusionStateVisible;
1284 qCDebug(lcQpaWindow) <<
"QCocoaWindow::windowDidChangeOcclusionState" <<
window() <<
"is now" << (visible ?
"visible" :
"occluded");
1286 [
m_view setNeedsDisplay:YES];
1291void QCocoaWindow::windowDidChangeScreen()
1297 NSScreen *nsScreen =
m_view.window.screen;
1299 qCDebug(lcQpaWindow) <<
window() <<
"did change" << nsScreen;
1300 QCocoaScreen::updateScreens();
1305 qCDebug(lcQpaWindow) <<
"Screen changed for" <<
window() <<
"from" << previousScreen <<
"to" << currentScreen;
1318 QWindowSystemInterface::handleWindowScreenChanged<QWindowSystemInterface::SynchronousDelivery>(
1319 window(), currentScreen ? currentScreen->screen() :
nullptr);
1326 currentScreen->requestUpdate();
1334 qCDebug(lcQpaWindow) <<
"QCocoaWindow::windowShouldClose" <<
window();
1346 [[
m_view.window retain] autorelease];
1348 return QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(
window());
1370 CGRect contentRect = [
m_view.window contentRectForFrameRect:
m_view.window.frame];
1376 newGeometry = QRectF::fromCGRect(
m_view.frame).toRect();
1379 qCDebug(lcQpaWindow) <<
"QCocoaWindow::handleGeometryChange" <<
window()
1380 <<
"current" <<
geometry() <<
"new" << newGeometry;
1405 && !
m_view.hiddenOrHasHiddenAncestor) {
1411 qCDebug(lcQpaDrawing) <<
"QCocoaWindow::handleExposeEvent" <<
window() << region <<
"isExposed" <<
isExposed();
1412 QWindowSystemInterface::handleExposeEvent<QWindowSystemInterface::SynchronousDelivery>(
window(), region);
1455 qCDebug(lcQpaWindow) <<
"Skipping NSWindow management for foreign window" <<
this;
1466 oldParentCocoaWindow = qnsView.platformWindow;
1468 if (parentWindow != oldParentCocoaWindow)
1480 const bool shouldBeContentView = !parentWindow
1487 const bool shouldBePanel = shouldBeContentView &&
1490 if (isPanel != shouldBePanel)
1493 qCDebug(lcQpaWindow) <<
"QCocoaWindow::recreateWindowIfNeeded" <<
window() << recreateReason;
1510 m_view.window.contentView = nil;
1519 qCDebug(lcQpaWindow) <<
"Ensuring that" <<
m_view <<
"is content view for" << newWindow;
1520 [
m_view setPostsFrameChangedNotifications:NO];
1521 [newWindow setContentView:
m_view];
1522 [
m_view setPostsFrameChangedNotifications:YES];
1529 if (parentCocoaWindow) {
1537 qCDebug(lcQpaDrawing) <<
"QCocoaWindow::requestUpdate" <<
window()
1542 qCDebug(lcQpaDrawing) <<
"Falling back to timer-based update request";
1559 qCDebug(lcQpaDrawing) <<
"Delivering update request to" <<
window();
1567 [
m_view.window makeKeyWindow];
1601 constexpr NSEventMask mouseButtonMask = NSEventTypeLeftMouseDown | NSEventTypeLeftMouseUp
1602 | NSEventMaskRightMouseDown | NSEventMaskOtherMouseDown
1603 | NSEventMaskMouseMoved;
1605 handler:^(NSEvent *
e){
1617 const auto localPoint =
window->mapFromGlobal(globalPoint.toPoint());
1619 buttons,
button, eventType);
1631 addObserverForName:NSWorkspaceDidActivateApplicationNotification
1633 usingBlock:^(NSNotification *){
1648 QScreen *targetScreen =
nullptr;
1658 if (!targetScreen) {
1659 qCWarning(lcQpaWindow) <<
"Window position" <<
rect <<
"outside any known screen, using primary screen";
1664 styleMask = NSWindowStyleMaskBorderless;
1676 if (styleMask && (contentRect.origin.y + 24 > targetScreen->
geometry().
width())) {
1677 qCDebug(lcQpaWindow) <<
"Window positioned on portrait screen."
1678 <<
"Adjusting style mask during creation";
1679 styleMask = NSWindowStyleMaskBorderless;
1685 QCocoaNSWindow *nsWindow = [[windowClass alloc] initWithContentRect:contentRect
1690 backing:NSBackingStoreBuffered defer:NO
1691 screen:targetCocoaScreen->nativeScreen()
1692 platformWindow:
this];
1701 if (!resultingScreen)
1702 resultingScreen = targetCocoaScreen;
1711 nsWindow.delegate = sharedDelegate.
get();
1717 [nsWindow setReleasedWhenClosed:NO];
1720 static dispatch_once_t onceToken;
1721 dispatch_once(&onceToken, ^{
1722 NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
1723 [center addObserver:[
QNSWindow class]
selector:
@selector(applicationActivationChanged:)
1724 name:NSApplicationWillResignActiveNotification
object:nil];
1725 [center addObserver:[
QNSWindow class]
selector:
@selector(applicationActivationChanged:)
1726 name:NSApplicationWillBecomeActiveNotification
object:nil];
1730 nsWindow.restorable = NO;
1732 nsWindow.tabbingMode = NSWindowTabbingModeDisallowed;
1734 if (shouldBePanel) {
1739 nsWindow.collectionBehavior = NSWindowCollectionBehaviorFullScreenAuxiliary;
1742 nsWindow.hasShadow = YES;
1743 nsWindow.animationBehavior = NSWindowAnimationBehaviorUtilityWindow;
1755 NSData *iccData = colorSpace.iccProfile().toNSData();
1756 nsWindow.colorSpace = [[[NSColorSpace alloc] initWithICCProfileData:iccData] autorelease];
1757 qCDebug(lcQpaDrawing) <<
"Set" <<
this <<
"color space to" << nsWindow.colorSpace;
1765 return qt_mac_resolveOption(
false,
window(),
"_q_macAlwaysShowToolWindow",
"");
1773 m_view.window.documentEdited = modified;
1793 qCInfo(lcQpaMouse) <<
"Setting" <<
this <<
"cursor to" <<
cursor;
1812 auto locationInWindow =
m_view.window.mouseLocationOutsideOfEventStream;
1813 auto locationInSuperview = [
m_view.superview convertPoint:locationInWindow fromView:nil];
1814 bool mouseIsOverView = [
m_view hitTest:locationInSuperview] ==
m_view;
1815 auto utilityMask = NSWindowStyleMaskUtilityWindow | NSWindowStyleMaskTitled;
1816 bool isUtilityWindow = (
m_view.window.styleMask & utilityMask) == utilityMask;
1817 if (mouseIsOverView && (
m_view.window.keyWindow || isUtilityWindow)) {
1818 qCDebug(lcQpaMouse) <<
"Synthesizing cursor update";
1819 [
m_view cursorUpdate:[NSEvent enterExitEventWithType:NSEventTypeCursorUpdate
1820 location:locationInWindow modifierFlags:0 timestamp:0
1822 eventNumber:0 trackingNumber:0 userData:0]];
1830 m_view.allowedTouchTypes |= NSTouchTypeMaskIndirect;
1832 m_view.allowedTouchTypes &= ~NSTouchTypeMaskIndirect;
1862 window.styleMask =
window.styleMask & ~NSWindowStyleMaskTexturedBackground;
1863 [
window.contentView.superview setNeedsDisplay:YES];
1864 window.titlebarAppearsTransparent = NO;
1870 std::sort(ranges.begin(), ranges.end());
1871 int effectiveTopContentBorderThickness = 0;
1880 if (
range.upper <= (effectiveTopContentBorderThickness + 1))
1881 effectiveTopContentBorderThickness =
qMax(effectiveTopContentBorderThickness,
range.lower);
1886 int effectiveBottomContentBorderThickness = 0;
1888 [
window setStyleMask:[
window styleMask] | NSWindowStyleMaskTexturedBackground];
1889 window.titlebarAppearsTransparent = YES;
1894 const NSRect frameRect =
window.frame;
1895 const NSRect contentRect = [
window contentRectForFrameRect:frameRect];
1897 effectiveTopContentBorderThickness += titlebarHeight;
1899 [
window setContentBorderThickness:effectiveTopContentBorderThickness forEdge:NSMaxYEdge];
1900 [
window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];
1902 [
window setContentBorderThickness:effectiveBottomContentBorderThickness forEdge:NSMinYEdge];
1903 [
window setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge];
1905 [[[
window contentView] superview] setNeedsDisplay:YES];
1916 const int contentBorderThickness = [
m_view.window contentBorderThicknessForEdge:NSMaxYEdge];
1917 const NSRect frameRect =
m_view.window.frame;
1918 const NSRect contentRect = [
m_view.window contentRectForFrameRect:frameRect];
1919 const CGFloat titlebarHeight = frameRect.size.height - contentRect.size.height;
1920 return 0 <=
position &&
position < (contentBorderThickness - titlebarHeight);
1930 NSSize backingSize = [
m_view convertSizeToBacking:NSMakeSize(1.0, 1.0)];
1931 return backingSize.height;
1940 if (
handle->isExposed() && childWindow->geometry().contains(windowPoint))
1943 return targetWindow;
1959 if (showWithoutActivating.
isValid() && showWithoutActivating.
toBool())
1968 switch (
event->type()) {
1985 : NSMakePoint(0, 0);
1986 const NSRect visibleRect = [
m_view visibleRect];
1988 return QPoint(visibleRect.origin.x, -visibleRect.origin.y + (origin.y - visibleRect.size.height));
1996 NSRect frameW =
m_view.window.frame;
1997 NSRect frameC = [
m_view.window contentRectForFrameRect:frameW];
1999 return QMargins(frameW.origin.x - frameC.origin.x,
2000 (frameW.origin.y + frameW.size.height) - (frameC.origin.y + frameC.size.height),
2001 (frameW.origin.x + frameW.size.width) - (frameC.origin.x + frameC.size.width),
2002 frameC.origin.y - frameW.origin.y);
2010#ifndef QT_NO_DEBUG_STREAM
2025#include "moc_qcocoawindow.cpp"
static QCocoaIntegration * instance()
static CGPoint mapToNative(const QPointF &pos, QCocoaScreen *screen=QCocoaScreen::primaryScreen())
static QCocoaScreen * get(NSScreen *nsScreen)
static QPointF mapFromNative(CGPoint pos, QCocoaScreen *screen=QCocoaScreen::primaryScreen())
void handleWindowStateChanged(HandleFlags flags=NoHandleFlags)
static void setupPopupMonitor()
void setContentBorderAreaEnabled(quintptr identifier, bool enable)
bool alwaysShowToolWindow() const
void setMenubar(QCocoaMenuBar *mb)
QWindow * childWindowAt(QPoint windowPoint)
void setAlertState(bool enabled) override
Reimplement this method to set whether the window demands attention (for example, by flashing the tas...
Qt::WindowModality m_windowModality
void setWindowTitle(const QString &title) override
Reimplement to set the window title to title.
void setWindowCursor(NSCursor *cursor)
bool testContentBorderAreaPosition(int position) const
QRect normalGeometry() const override
the geometry of the window as it will appear when shown as a normal (not maximized or full screen) to...
bool updatesWithDisplayLink() const
WId winId() const override
Reimplement in subclasses to return a handle to the native window.
bool isForeignWindow() const override
bool setMouseGrabEnabled(bool grab) override
QCocoaNSWindow * m_nsWindow
void propagateSizeHints() override
Reimplement to propagate the size hints of the QWindow.
void setOpacity(qreal level) override
Reimplement to be able to let Qt set the opacity level of a window.
QCocoaNSWindow * createNSWindow(bool shouldBePanel)
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
static id s_globalMouseMonitor
void setMask(const QRegion ®ion) override
Reimplement to be able to let Qt set the mask of a window.
QHash< quintptr, bool > m_enabledContentBorderAreas
QCocoaWindow(QWindow *tlw, WId nativeHandle=0)
void setFrameStrutEventsEnabled(bool enabled) override
Reimplement this method to set whether frame strut events should be sent to enabled.
QCocoaMenuBar * menubar() const
void setWindowFilePath(const QString &filePath) override
Reimplement to set the window file path to filePath.
void setCocoaGeometry(const QRect &rect)
QRect geometry() const override
Returns the current geometry of a window.
NSInteger windowLevel(Qt::WindowFlags flags)
void setContentBorderEnabled(bool enable) override
void setParent(const QPlatformWindow *window) override
This function is called to enable native child window in QPA.
static void removePopupMonitor()
bool m_frameStrutEventsEnabled
bool setWindowModified(bool modified) override
Reimplement to be able to let Qt indicate that the window has been modified.
NSWindow * nativeWindow() const
void applyContentBorderThickness(NSWindow *window=nullptr)
void setWindowState(Qt::WindowStates state) override
Changes the state of the NSWindow, going in/out of minimize/zoomed/fullscreen.
void registerTouch(bool enable)
void updateTitleBarButtons(Qt::WindowFlags flags)
QMargins frameMargins() const override
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
void updateNormalGeometry()
bool isAlertState() const override
Reimplement this method return whether the window is in an alert state.
bool isExposed() const override
Returns if this window is exposed in the windowing system.
void deliverUpdateRequest() override
Delivers an QEvent::UpdateRequest event to the window.
bool isEmbedded() const override
Returns true if the window is a child of a non-Qt window.
void setWindowFlags(Qt::WindowFlags flags) override
Requests setting the window flags of this surface to flags.
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
bool shouldRefuseKeyWindowAndFirstResponder()
void requestUpdate() override
Requests an QEvent::UpdateRequest event.
static QPointer< QCocoaWindow > s_windowUnderMouse
static void closeAllPopups()
void setWindowIcon(const QIcon &icon) override
Reimplement to set the window icon to icon.
bool isContentView() const
Checks if the window is the content view of its immediate NSWindow.
void recreateWindowIfNeeded()
Recreates (or removes) the NSWindow for this QWindow, if needed.
void handleGeometryChange()
bool m_drawContentBorderGradient
bool m_resizableTransientParent
NSUInteger windowStyleMask(Qt::WindowFlags flags)
QCocoaMenuBar * m_menubar
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
bool startSystemMove() override
Reimplement this method to start a system move operation if the system supports it and return true to...
static const int NoAlertRequest
bool windowEvent(QEvent *event) override
Reimplement this method to be able to do any platform specific event handling.
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
bool setKeyboardGrabEnabled(bool grab) override
bool windowIsPopupType(Qt::WindowType type=Qt::Widget) const
void registerContentBorderArea(quintptr identifier, int upper, int lower)
void setEmbeddedInForeignView()
void applyWindowState(Qt::WindowStates newState)
QPoint bottomLeftClippedByNSWindowOffset() const override
bool isTransitioningToFullScreen() const
QHash< quintptr, BorderRange > m_contentBorderAreas
Qt::WindowStates windowState() const
qreal devicePixelRatio() const override
Reimplement this function in subclass to return the device pixel ratio for the window.
void initialize() override
Called as part of QWindow::create(), after constructing the window.
Qt::WindowStates m_lastReportedWindowState
QSurfaceFormat format() const override
Returns the actual surface format of the window.
static id s_applicationActivationObserver
void handleExposeEvent(const QRegion ®ion)
The QColorSpace class provides a color space abstraction.
virtual bool closeAllPopups()
static QGuiApplicationPrivate * instance()
static QWindow * currentMouseWindow
virtual bool popupActive()
static Qt::ApplicationState applicationState()
static QWindow * topLevelAt(const QPoint &pos)
Returns the top level window at the given position pos, if any.
static QWindowList allWindows()
Returns a list of all the windows in the application.
QScreen * primaryScreen
the primary (or default) screen of the application.
static QList< QScreen * > screens()
Returns a list of all the screens associated with the windowing system the application is connected t...
T value(const Key &key) const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
The QIcon class provides scalable icons in different modes and states.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
constexpr qsizetype size() const noexcept
constexpr int left() const noexcept
Returns the left margin.
constexpr int top() const noexcept
Returns the top margin.
static QObjectPrivate * get(QObject *o)
const QObjectList & children() const
Returns a list of child objects.
QObject * parent() const
Returns a pointer to the parent object.
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
QVariant property(const char *name) const
Returns the value of the object's name property.
\inmodule QtCore\reentrant
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr int width() const noexcept
Returns the width of the rectangle.
The QRegion class specifies a clip region for a painter.
QRect boundingRect() const noexcept
Returns the bounding rectangle of this region.
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
The QScreen class is used to query screen properties. \inmodule QtGui.
QRect geometry
the screen's geometry in pixels
Qt::ScreenOrientation primaryOrientation
the primary screen orientation
QPlatformScreen * handle() const
Get the platform screen handle.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr bool isNull() const noexcept
Returns true if both the width and height is 0; otherwise returns false.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
bool supportsOpenGL() const
Returns true if the surface is OpenGL compatible and can be used in conjunction with QOpenGLContext; ...
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
static QWindowPrivate * get(QWindow *window)
static Qt::WindowState effectiveState(Qt::WindowStates)
static bool flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Make Qt Gui process all events on the event queue immediately.
static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen)
static bool handleMouseEvent(QWindow *window, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
static void handleGeometryChange(QWindow *window, const QRect &newRect)
Qt::WindowFlags flags
the window flags of the window
QSurfaceFormat format() const override
Returns the actual format of this window.
QSize size() const override
Returns the size of the window excluding any window frame.
QString title
the window's title in the windowing system
Qt::WindowModality modality
the modality of the window
qreal opacity
The opacity of the window in the windowing system.
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
struct wl_display * display
QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *window)
Combined button and popup list for selecting options.
@ WindowDoesNotAcceptFocus
@ WindowFullscreenButtonHint
@ WindowMaximizeButtonHint
@ WindowMinimizeButtonHint
@ WindowTransparentForInput
@ ActiveWindowFocusReason
QNSView * qnsview_cast(NSView *view)
Returns the view cast to a QNSview if possible.
QEvent::Type cocoaEvent2QtMouseEvent(NSEvent *event)
Returns the QEvent::Type that corresponds to an NSEvent.type.
Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
Returns the Qt::Button that corresponds to an NSEvent.buttonNumber.
Qt::MouseButtons currentlyPressedMouseButtons()
Returns the Qt::MouseButtons that corresponds to an NSEvent.pressedMouseButtons.
#define Q_NOTIFICATION_PREFIX
const NSNotificationName QCocoaWindowWillReleaseQNSViewNotification
static void qRegisterNotificationCallbacks()
QDebug operator<<(QDebug debug, const QCocoaWindow *window)
const NSNotificationName QCocoaWindowWillReleaseQNSViewNotification
Q_CONSTRUCTOR_FUNCTION(initializeStandardUserDefaults)
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 * method
#define Q_LOGGING_CATEGORY(name,...)
#define qCInfo(category,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
constexpr const T & qMax(const T &a, const T &b)
typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program
GLuint64 GLenum void * handle
GLenum GLuint GLint level
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_ASSERT_X(cond, x, msg)
#define qPrintable(string)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
Q_GUI_EXPORT QWindowPrivate * qt_window_private(QWindow *window)
QWindow * qobject_cast< QWindow * >(QObject *o)
QFileSelector selector
[1]
obj metaObject() -> className()