Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcocoaglcontext.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCOCOAGLCONTEXT_H
5#define QCOCOAGLCONTEXT_H
6
7#include <QtCore/QPointer>
8#include <QtCore/QVarLengthArray>
9#include <QtCore/private/qcore_mac_p.h>
10#include <qpa/qplatformopenglcontext.h>
11#include <QtGui/qopenglcontext.h>
12#include <QtGui/private/qopenglcontext_p.h>
13#include <QtGui/QWindow>
14
17
18QT_BEGIN_NAMESPACE
19
20class QCocoaWindow;
21
23{
24public:
25 QCocoaGLContext(QOpenGLContext *context);
26 QCocoaGLContext(NSOpenGLContext *context);
28
29 void initialize() override;
30
31 bool makeCurrent(QPlatformSurface *surface) override;
32 void swapBuffers(QPlatformSurface *surface) override;
33 void doneCurrent() override;
34
35 void update();
36
37 QSurfaceFormat format() const override;
38 bool isSharing() const override;
39 bool isValid() const override;
40
41 NSOpenGLContext *nativeContext() const override;
42
43 QFunctionPointer getProcAddress(const char *procName) override;
44
45private:
46 static NSOpenGLPixelFormat *pixelFormatForSurfaceFormat(const QSurfaceFormat &format);
47
48 bool setDrawable(QPlatformSurface *surface);
49 void updateSurfaceFormat();
50
51 NSOpenGLContext *m_context = nil;
52 NSOpenGLContext *m_shareContext = nil;
53 QSurfaceFormat m_format;
54 QVarLengthArray<QMacNotificationObserver, 3> m_updateObservers;
55 QAtomicInt m_needsUpdate = false;
56
57#ifndef QT_NO_DEBUG_STREAM
58 friend QDebug operator<<(QDebug debug, const QCocoaGLContext *screen);
59#endif
60};
61
62QT_END_NAMESPACE
63
64#endif // QCOCOAGLCONTEXT_H
static void clearCurrentThreadCocoaEventDispatcherInterruptFlag()
NSOpenGLContext * nativeContext() const override
void swapBuffers(QPlatformSurface *surface) override
Reimplement in subclass to native swap buffers calls.
void doneCurrent() override
friend QDebug operator<<(QDebug debug, const QCocoaGLContext *screen)
QSurfaceFormat format() const override
bool isSharing() const override
void initialize() override
Called after a new instance is constructed.
QFunctionPointer getProcAddress(const char *procName) override
Reimplement in subclass to allow dynamic querying of OpenGL symbols.
QCocoaGLContext(QOpenGLContext *context)
bool makeCurrent(QPlatformSurface *surface) override
bool isValid() const override
void * nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) override
NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) override
void handleWindowStateChanged(HandleFlags flags=NoHandleFlags)
static void setupPopupMonitor()
void setContentBorderAreaEnabled(quintptr identifier, bool enable)
bool alwaysShowToolWindow() const
void setMenubar(QCocoaMenuBar *mb)
void toggleMaximized()
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...
int m_registerTouchCount
Qt::WindowModality m_windowModality
QMargins safeAreaMargins() const override
The safe area margins of a window represent the area that is safe to place content within,...
void setWindowTitle(const QString &title) override
Reimplement to set the window title to title.
void setWindowCursor(NSCursor *cursor)
bool testContentBorderAreaPosition(int position) const
NSView * view() 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
bool m_inSetStyleMask
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 &region) override
Reimplement to be able to let Qt set the mask of a window.
QHash< quintptr, bool > m_enabledContentBorderAreas
void setFrameStrutEventsEnabled(bool enabled) override
Reimplement this method to set whether frame strut events should be sent to enabled.
void toggleFullScreen()
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
bool isOpaque() const
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.
bool windowShouldClose()
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 isFixedSize() const
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.
NSInteger m_alertRequest
QRect m_normalGeometry
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
QRect m_exposedRect
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.
void windowWillZoom()
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.
bool frameStrutEventsEnabled() const override
Reimplement this method to return whether frame strut events are enabled.
static id s_applicationActivationObserver
NSView * m_view
void handleExposeEvent(const QRegion &region)
QMargins m_lastReportedSafeAreaMargins
Combined button and popup list for selecting options.
Q_FORWARD_DECLARE_OBJC_CLASS(NSOpenGLPixelFormat)
Q_FORWARD_DECLARE_OBJC_CLASS(NSView)
Q_FORWARD_DECLARE_OBJC_CLASS(NSCursor)
const NSNotificationName QCocoaWindowWillReleaseQNSViewNotification
#define Q_NOTIFICATION_HANDLER(notification)
Q_FORWARD_DECLARE_OBJC_CLASS(NSObject)
bool operator<(BorderRange const &right) const
BorderRange(quintptr i, int u, int l)