Commit Graph

905 Commits

Author SHA1 Message Date
John Ralls
33fd9eb472 [quartz] Convert frame_link, windows_awaiting_frame to GSList.
We were't using GList's prev member; worse, we weren't setting it
and that broke g_list_remove_link so that the link wasn't removed
in _gdk_quartz_display_remove_frame_callback.

Closes #5593
2023-03-23 11:44:33 -07:00
John Ralls
f931c73316 [quartz] Silence two compiler warnings.
One unused function, one return type mismatch.
2023-02-11 12:57:08 -08:00
John Ralls
312e5781f3 [quartz] Set the sRGB colorspace on the IOSurface.
Enables colorspace tranformation in Core Animation. This transform
is executed on the GPU and unlike the Core Graphics one has no
affect on performance.

Fixes #5579
2023-02-11 12:52:38 -08:00
John Ralls
f60359c183 [quartz] GdkWindow, GdkNSView frame and cairo surface same size.
The cairo surface must be padded to 4 pixels in order to
transfer correctly to the GPU. The GdkWindow and GdkNSView's
content frame must be the same width, otherwise there's a mismatch
that causes either the GdkWindow to draw wider than the frame or the
frame to be clipped narrower than the title bar.

Fixes #5535.
2023-01-19 10:37:55 -08:00
John Ralls
10689066e3 [quartz] Fix typo to call function. 2023-01-06 10:13:02 -08:00
Matthias Clasen
3b9531d3d3 Merge branch 'ebassi/no-more-autotools-redux' into 'gtk-3-24'
Drop the Autotools build

See merge request GNOME/gtk!5299
2022-12-13 12:10:34 +00:00
Matthias Clasen
efdc6b81e6 Merge branch 'issue5305' into 'gtk-3-24'
[quartz] Work around macOS 13 not sending trackingArea events.

See merge request GNOME/gtk!5280
2022-12-11 04:02:14 +00:00
John Ralls
5d91434f38 [quartz] Set GdkQuartzView wantsLayer.
Apparently wantsUpdateLayer by itself isn't sufficient.
Also #ifdef wantsUpdateLayer for macOS X 10.8 and later; earlier
versions don't provide it.

Fixes #5393
2022-12-08 10:04:56 -08:00
Emmanuele Bassi
2b0a605c5d build: Remove the Autotools build
CI and downstream packagers have been using the Meson build for a while
now, and we checked that it's idempotent to the Autotools build.

Having two build systems in tree doesn't make maintaining and releasing
GTK any easier, even if it's the stable/frozen branch.
2022-12-08 11:57:39 +00:00
John Ralls
7e1a3ffa37 [quartz] Work around macOS 13 not sending trackingArea events.
Fixes #5305
2022-11-29 11:58:17 -08:00
John Ralls
ce99b56f25 [quartz] Update known and latest macOS version to macOS 13 Ventura. 2022-11-29 11:45:39 -08:00
John Ralls
307945fbe4 [quartz]Use new (since 10.5) NSTrackingArea instead of older tracking rect. 2022-11-29 10:32:19 -08:00
John Ralls
cf53a34db4 [quartz] Fix some compile warnings. 2022-11-29 10:31:39 -08:00
John Ralls
7a56fa276b [quartz] find_toplevel_under_pointer should not return _gdk_root
The macOS WM has no root window. We fake one with a 1x1 window at the
origin that has no associated NSWindow. If the pointer is not on a
realized GdkWindow the hierarchical search will place it in the root
window even if it's nowhere near it. That's not valid, but returning it
from find_toplevel_under_pointer prevents Gdk from discovering when the
pointer is really over a GdkWindow. Return NULL instead so that the window
discovery is re-performed.
2022-08-22 08:58:08 -07:00
John Ralls
09dd73feeb [quartz] Remove extra reference on layer's cairo_surface. 2022-06-30 15:27:03 -07:00
John Ralls
f48bed22db [quartz] shouldInheritContentsScale from 10.7+ instead of 10.14+. 2022-06-30 15:25:50 -07:00
John Ralls
56d9dc95d9 [quartz] Fix build on macOS versions before 10.14.
shouldInheritContentScale was introduced in 10.14.
2022-06-20 17:15:49 -07:00
John Ralls
a2c54c739e [quartz] Ensure valid GdkWindowImplQuartz references.
In case of an offscreen window find its onscreen embedder, and NULL
any GdkWindowImpl that's not quartz, checking all return values.

This replaces 16ded683, removing its unnecessary search_for_nearest
functions.

Any unchecked cast of a GdkWindowImpl to GdkWindowImplQuartz risks at
least getting an invalid member reference, not just the ones in
gdk_quartz_window_get_foo, and all calls to gdk_quartz_window_get_foo need
to be checked, not just Gtk's internal calls. The motivation was that
transient_for was getting set on a Gimp offscreen window and that caused a
crash in raise_transient.
2022-06-09 13:22:59 -07:00
John Ralls
749c863073 [quartz] Ensure GdkWindowQuartz members are either valid or NULL. 2022-06-09 13:22:59 -07:00
John Ralls
a5ad547b8b [quartz] ensure that the copy region is fully enclosed by the drawn surface. 2022-06-09 13:22:59 -07:00
John Ralls
8d4c4cdca4 [quartz] Handle scale changes using NSView::shouldInheritContentsScale.
Includes creating the CVPixelBuffer to supply the layer contents when
creating the cairo_image_surface, which reduces the number of them created
at the wrong scale.
2022-06-09 13:22:59 -07:00
Lukas Oberhuber
16ded6835c macos: Fix to offscreen window selections in Gimp 2.99 2022-05-27 21:26:50 +00:00
John Ralls
b94ed34f9c [quartz] Manage implementation surface lifetime.
To prevent leaking cairo surfaces while persisting the parts that
don't need to be redrawn.
2022-05-19 17:02:55 -07:00
John Ralls
df94d0168d Use a CVPixelBuffer instead of a CGImage. 2022-05-19 16:58:39 -07:00
John Ralls
be60902805 Draw window to image_surface and apply to CALayer. 2022-05-19 16:52:59 -07:00
John Ralls
2d3eb0c6a7 [quartz] Draw needs_display_region if available 2022-05-19 16:46:35 -07:00
John Ralls
8182c978db quartz: add CVDisplayLink based frame clock
This uses CVDisplayLink to drive the GdkFrameClock. A GdkWindow
can register a frame callback to thaw their frame clock as necessary
based on the next notification from CVDisplayLink.

CVDisplayLink notifies us on a high-priority thread. We use the same
NSEventas gdkeventloop-quartz.c to wakeup the main loop. This is done
so that we don’t pathologically wake up the select thread to then
continue notifying the main loop.

We use an embedded GList node in the GdkWindowImplQuartz so that we
can avoid allocating any lists or arrays for pending frame callbacks.
Compare this to the same design in GdkWindow for children.
2022-05-19 16:29:01 -07:00
John Ralls
3c721c5a80 quartz: drop beam sync penalty code
Now that we have a frame clock in place, we should be able to drop
the beam-sync penalty prevention code as we should be aligning our
draws with CVDisplayLink.
Originally by Christian Hergert <chergert@redhat.com>, flushWindow
corrections and improvements by John Ralls.
2022-05-05 16:19:02 -07:00
Christian Hergert
0c439e4b83 quartz: squash compiler warning about enums
We don’t care about the other enums, fine to squash the warning.
2022-05-05 16:08:54 -07:00
John Ralls
b72e4437a2 quartz: Clean up two macOS deprecation warnings. 2022-05-05 16:07:47 -07:00
John Ralls
acc1eb917b Quartz: Don't crash trying to release a NULL CGContext. 2022-05-05 16:04:42 -07:00
John Ralls
07d847d174 [quartz] Fix use-before-init.
Thanks to Lukas Oberhuber for the patch.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4726
2022-02-28 10:05:47 -08:00
Lukas Oberhuber
021cdf382d macos: correctly handle retina cursors
This change correctly sizes HiDPI curors on macOS.

Before this, the cursors would appear double the size of normal cursors
on non HiDPI screens.
Based in part on this comment:
https://gitlab.gnome.org/GNOME/gtk/-/issues/613#note_687914
2022-01-14 00:10:15 +00:00
Thomas Holder
0ac6144369 macOS: Fix QuartzCore linking and compiling with 10.11
Follow-up on 10b5f8a0d6

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4573
2021-12-29 11:33:50 +01:00
Lukas Oberhuber
10b5f8a0d6 macOS: Big Sur performance patch
One of 4 that were applied on Gimp 2.99. Original authorship
@DesMcGuiness and adapted to Gtk3 by @lukaso
2021-12-18 22:59:58 +00:00
Lukas Oberhuber
71e2821578 gdkquartz: fix crash on uninitialized attribute
`gdk_quartz_display_get_monitor_at_window` crashes when it tries to access the NSWindow on
an offscreen window. The attribute `toplevel` of `impl` is uninitialized and
causes a segfault.

This partially fixes: https://gitlab.gnome.org/GNOME/gimp/-/issues/7608
2021-12-16 13:00:02 +00:00
Luca Bacci
78a0cdde83
Quartz: Fix keyboard layout notification
Register for notifications before initializing keymaps
2021-11-24 16:20:02 +01:00
John Ralls
36315cbe2b [quartz]Use the absolute value of Scale values for CGContextScaleSCM
In macOS-12.sdk CGContextConverSizeToDeviceSpace returns a negative
height and passing that to CGContextScaleCTM in turn causes the cairo
surface to draw outside the window where it can't be seen. Passing the
absolute values of the scale factors fixes the display on macOS 12 without
affecting earlier macOS versions.
2021-10-14 12:45:48 -07:00
John Ralls
a752e33838 Update Quartz version detection for macOS 12. 2021-09-08 18:01:50 -07:00
John Ralls
e9d4b0dda0 Move includes of gdkinternal-quartz.h from headers to impl files.
gdkinternal-quartz.h isn't installed but the headers that included
it are, which which would cause the build to fail if an external
project included one of them.

Also changed the includes in gdkinteral-quartz.h to local for
faster loading.
2021-09-07 11:08:11 -07:00
John Ralls
7e732caa1e Let gdkquartz-cocoa-access.h find gdkquartz.h during build.
gdkquartz.h is installed in $PREFIX/include/gdk but is in gdk/quartz
in the source tree. Use "gdkquartz.h" to find it in both places.
2021-09-07 10:39:37 -07:00
Hiroyuki Ito
ec4d27a4fc accepts NSPasteboardTypeFileURL as "text/uri-list". 2021-08-14 09:38:36 +09:00
John Ralls
6128492cc0 [quartz] Fix incorrect include path for gdkquartz.h 2021-07-10 13:57:11 -07:00
Tom Schoonjans
66b533408d quartz: fix compilation on macOS 10.10 2021-06-12 06:10:54 +01:00
Mosè Giordano
0e14822a22 Fix value of MAC_OS_X_VERSION_MAX_ALLOWED 2021-05-07 11:46:47 +01:00
John Ralls
a6c3887736 Ensure gdk_quartz_drag_source freed on all paths.
New release function _gdk_quartz_drag_source_context_destroy_gtk_only
gets called when drag fails to start or is cancelled as well as
when it successfully completes.
2021-05-04 08:33:56 -07:00
John Ralls
242b76a771 Add a public header for Cocoa access functions.
Some applications need to access gdk_quartz_window_get_nsview,
gdk_quartz_window_get_nswindow, and gdk_quartz_event_get_nsevent
so move these from the private gdkquartz-gtk-only.h to a new
header gdkquartz-cocoa-access.h. Don't include this header in
gdkquartz.h so that user code that doesn't need to access these
functins isn't required to compile with Objective C/C++.

Closes https://gitlab.gnome.org/GNOME/gtk/-/issues/1737
2021-04-16 16:56:55 -07:00
René de Hesselle
8627a9a569 Fix building on OS X El Capitan 10.11
The preprocessor directives for proper OS version support are missing
their last digit, rendering the checks defunct.

Improves on https://gitlab.gnome.org/GNOME/gtk/-/issues/3592 but does
not fully fix as other issues have surfaced down the line.
2021-04-05 22:20:25 +02:00
Cédric Krier
238bb38249 Keep window without decoration miniaturizable
Closes #2345
2021-03-10 16:08:14 +01:00
John Ralls
d0b09a8823 [imquartz] Set the filter key to passthrough regardless of selector.
Remove all of the selectors. They just set the passthrough anyway so
there's not much point to maintaining them and they weren't the
complete set of possible selectors.
2020-10-13 14:36:12 -07:00