summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qnswindow.mm
Commit message (Collapse)AuthorAgeFilesLines
* macOS: Keep default NSWindow background unless window is framelessTor Arne Vestbø2019-09-141-2/+2
| | | | | | | | | | | | | | | | | | | | The logic was changed in ee82f8661 to only draw a window background when the window was textured, and otherwise ask for a clear window background. This has an unfortunate side-effect on macOS 10.15 that the window's title bar will be partially transparent and reflect the content under the window, with a blur effect. It also inadvertently broke the use-case of setting the NSWindow background color explicitly. With this patch we're back to the behavior before ee82f8661, and users who still want to have a non-borderless window with a clear background can still do this by setting the background color to the clear color manually. Task-number: QTBUG-77637 Change-Id: I8a11bc46e6393b29a37f002ea123a987048106b9 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Don't ask for a NSWindow background unless we need oneTor Arne Vestbø2019-08-221-12/+2
| | | | | | | | | | | | | This allow halfway transparent windows, even with a border, which is a bit of a weird use-case, but matches what we do on other platforms. We don't need the explicit call to NSDrawWindowBackground in the QNSWindowBackingStore implementation, as the NSThemeFrame will draw this background on our behalf. Fixes: QTBUG-77637 Change-Id: I012d845fa957c40aa713adaecbb1601a848e3534 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Set up platform window reference before initializing QNSWindow/PanelTor Arne Vestbø2019-02-181-22/+33
| | | | | | | | | Initializing the window will end up in [NSWindow _commonAwake], which calls many of the getters. We need to set up the platform window reference first, so we can properly reflect the window's state during initialization. Change-Id: I5349273b1930ee8a57dc518db74be90d2426f61c Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Implement QNSWindow/QNSPanel mixin using preprocessor includesTor Arne Vestbø2019-02-181-95/+75
| | | | | | | | | | | | | | We want to share the implementation between the two classes, but Objective-C doesn't natively have a mixin-feature. Instead of using dynamic super-calls at runtime (which worked fine, but added complexity), we now do the mixin at compile time using the preprocessor. The dynamic-super feature is left in, in case we need it in other areas in the future. Change-Id: I95dfa7f18cba86cc518e963dd018944ef113ac06 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Modernize worksWhenModal handlingTor Arne Vestbø2019-02-181-0/+13
| | | | | | | The code in QCocoaEventDispatcher was dead and could be removed. Change-Id: I0c57e64791045d65033376c096220983059028ba Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Improve logging during QNSView/QNSWindow deallocationTor Arne Vestbø2018-11-201-2/+2
| | | | | Change-Id: Ie6945f2a1f35db6d1259b77ee63137abcaf68318 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Use shared NSWindowDelegate instead of one per windowTor Arne Vestbø2018-11-201-1/+0
| | | | | | | | | | | All the delegate callbacks give us the relevant NSWindow, so we don't need one delegate per window just to be able to resolve the correct platform window. Change-Id: I8e44186da63bf01f029bb0b1fefcd8880f49dda6 Fixes: QTBUG-65693 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Ensure NSWindow delegate is released in sync with its NSWindowTor Arne Vestbø2018-11-201-4/+3
| | | | | | | | | | | | | | | Releasing it in [QNSWindow closeAndRelease] is wrong, as we only call that method from a few call sites, and can easily end up with a normal dealloc by means of e.g. the [m_nsWindow release] in ~QCocoaWindow. This still leaves Xcode thinking we have a single leaking delegate per active NSWindow, as it apparently doesn't realize we're calling release manually. This needs to be investigated further. Task-number: QTBUG-65693 Change-Id: I9105602274d8532465e5108aba2b05bf253268e9 Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Update all deprecated enums to their 10.12+ equivalentsTor Arne Vestbø2018-08-311-12/+12
| | | | | Change-Id: I3034258da95c9c70eb6758db92967f438617f6e9 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Remove codepaths and checks for unsupported Apple platformsTor Arne Vestbø2018-08-311-23/+14
| | | | | | | We no longer support macOS 10.11, iOS/tvOS 10, or watchOS 3. Change-Id: Ide03d8fac06185ef4162ba75ee54a0adf6916905 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Remove 'cocoa' infix in QPA logging categoriesTor Arne Vestbø2018-03-141-4/+4
| | | | | | | | Makes the naming of QPA logging categories the same across different platforms, which makes it easier to debug an unfamiliar platform. Change-Id: I60ed34892d154e86723c8e4bcff3c28fcab1f7a1 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* Clean up our Objective-C usageJake Petroules2018-02-201-4/+3
| | | | | | | | | | | | | | | | - Move ivars into @implementation - Use instancetype where applicable - Use dot notation for property access - Use subscript operator for dictionaries and arrays - Format selectors consistently - Use proper style for init methods - Use generics instead of void pointers where possible - Use "range for" loops instead of indexing - Replace or replace IBAction/IBOutlet with void Change-Id: I1667812a51d4dfe44ae80fe337cb1f4bc9699d92 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Copy QNSWindowProtocol without referencing it by nameTor Arne Vestbø2018-01-151-10/+17
| | | | | | | | | The protocol may be namespaced, in which case the string lookup would fail, so we iterate the protocols of QNSWindow instead (of which there is only one, QNSWindowProtocol). Change-Id: Ic45752c9e3a40f5d42ec82c4287402a3d7a47b09 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* macOS: Add categorized logging of event and notification forwardingTor Arne Vestbø2017-11-021-0/+20
| | | | | | | Useful for debugging issues in this area. Change-Id: Ic343ef790e20b66371028265efe2ec1816c954bd Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Retain NSWindow during event deliveryTor Arne Vestbø2017-11-021-0/+5
| | | | | | | | | | | | We have logic to deal with self.platformWindow and frame strut mouse events which happens after delivering the event to the NSWindow, but delivering it might dealloc the window, e.g. when closing it, so we need to explicitly retain it for the duration of [QNSWindow sendEvent:] Task-number: QTBUG-64023 Change-Id: I223fe3e3ac36a309da375522ba11f20f1ad6fc4f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* Clean up OS version checks for Apple platformsJake Petroules2017-09-291-1/+1
| | | | | | | | | | Convert QSysInfo/QOperatingSystemVersion to __builtin_available where required or possible, or to QOperatingSystemVersion where __builtin_available cannot be used and is not needed (such as negated conditions, which are not supported by that construct). Change-Id: I83c0e7e777605b99ff4d24598bfcccf22126fdda Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* macOS: Determine opaqueness and backgroundColor of NSWindow declarativelyTor Arne Vestbø2017-08-301-0/+22
| | | | | | | | | Instead of imperatively trying to keep the logic consistent in many different call sites. Task-number: QTBUG-61909 Change-Id: I8d647690c47656f34673555a8a8aa3ec6ffc73d1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Deduplicate QNSWindow/QNSPanel codeTor Arne Vestbø2017-08-241-167/+70
| | | | | | | | | | | | | | | | | | | | | | By sharing the implementations of the methods between QNSWindow and QNSPanel we don't need a helper, and can remove duplicated code. This duplication would expand in the future, as for each method added to the QNSWindowProtocol, we would have to add forwarding functions in both QNSWindow and QNSPanel, forwarding to QNSWindowHelper, and then two more functions in QNSWindow and QNSPanel in case we wanted to call super from the helper, similar to [QNSWindow superSendEvent]. The only snag is that calls to super are hard-coded to a specific superclass during complication, so we provide our wrapper for objc_msgSendSuper that resolves the superclass at runtime. The helper class QSendSuperHelper provides compile time implicit instantiation of the right template without having to provide the return type as a template argument, via operator T and a fallback for the case of no return type via the destructor. Change-Id: Iaf13f27675d90f884470f5005270ea0d9d0316f3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* macOS: Deliver native events to windows, as well as to event filtersTor Arne Vestbø2017-07-061-0/+7
| | | | | | | | | | | | | | | | | | | | | | Qt has two APIs to intercept native events today: - QAbstractEventDispatcher::installNativeEventFilter() - Q{Window|Widget}::nativeEvent() On macOS we only implemented one of them, the native event filter code path, by calling filterNativeEvent from the Cocoa event dispatcher. We now also propagate the native event to the corresponding QWindow, and QWidget if applicable. It would be nice if there was only one Qt API for this, or at least only one codepath for platform plugins to care about, but since the event filter might catch more event types than gets delivered to the window, we probably need both code paths going forward. Task-number: QTBUG-40116 Change-Id: I0796bd62a2b7c08b2eaaf6f15db8088e9703af02 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Don't deliver events via NSWindow for deleted QCococaWindowsTor Arne Vestbø2017-07-061-0/+8
| | | | | | Change-Id: Icb3794f37c929019de1e997e15f7d975492224c2 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Remove workaround for crash when closing window from title barTor Arne Vestbø2017-06-291-14/+0
| | | | | | | | | The platform window is now protected by a QPointer, so we don't need to juggle the NSWindow retain count. Task-number: QTBUG-37287 Change-Id: Id55ea311f0793370e248aa58cc8e383b574fbb40 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Remove unneeded Objective-C instance variable declarationsTor Arne Vestbø2017-06-291-2/+0
| | | | | | | | And their corresponding synthesizations. The compiler will take care of it for us. Change-Id: Ifa42e0732059008af6f3f65151bf203a1a19079d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Remove workaround for queued input events to stale windowsTor Arne Vestbø2017-06-291-9/+1
| | | | | | | | | | | | We now track the platform window with a QPointer, so the event callbacks can (and do) check the validity of the platform window before passing them on. The window property of the NSView is also nil at the point of even delivery, if we need another way to check if the event is still valid. Task-number: QTBUG-39211 Change-Id: I6179bdb3af9606cd0abf981c0fe6cacb9a2d98ab Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Remove workaround for grabbing child NSWindowsTor Arne Vestbø2017-06-281-20/+2
| | | | | | | | The code was introduced in 28c9c2ea50, but child NSWindows are no longer supported, so we can simplify the code by removing it. Change-Id: Ic98b8b0e0a84d5f2adba1840bd8318de2be031b6 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Remove support for child NSWindowsTor Arne Vestbø2017-06-211-21/+4
| | | | | | | | | | | | | | | The private feature was only used by QToolBar to solve QTBUG-33082, but the solution doesn't work, and complicates the macOS platform plugin quite a bit. A better solution is likely to use Core Animation layers, which is a direction we're going in anyways. To make it easier to modernize the macOS platform plugin, including moving to using layers, we remove the child NSWindows codepaths for now. Change-Id: I4b19464be3980fd84dd7af8316d4d5e85ba813b1 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* macOS: Move QNSWindow implementation into separate fileTor Arne Vestbø2017-06-211-0/+418
Change-Id: Ie75419c7ffb7a8fdf78d53e1ea14afee63ef1656 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>