diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-01-06 14:52:11 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-01-06 14:52:11 +0000 |
commit | 5652ab0a61d8741a6817dc93d9152537f4f3bf91 (patch) | |
tree | 2e142411f50cedf99e48c2c3522881eab449bd36 | |
parent | 2ff23b08bedde7f7e66bb204f31b236d8384f979 (diff) | |
parent | 0336af06f1281a4a294026296bd5b8e7575e11b3 (diff) | |
download | gtk+-5652ab0a61d8741a6817dc93d9152537f4f3bf91.tar.gz |
Merge branch 'macos-ci' into 'master'
Macos ci
See merge request GNOME/gtk!3032
-rw-r--r-- | .gitlab-ci.yml | 25 | ||||
-rwxr-xr-x | .gitlab-ci/show-execution-environment.sh | 8 | ||||
-rw-r--r-- | gdk/macos/GdkMacosWindow.c | 8 | ||||
-rw-r--r-- | gdk/macos/gdkmacosclipboard-private.h | 4 | ||||
-rw-r--r-- | gdk/macos/gdkmacosclipboard.c | 80 | ||||
-rw-r--r-- | gdk/macos/gdkmacosdisplay-translate.c | 4 | ||||
-rw-r--r-- | gdk/macos/gdkmacosutils-private.h | 31 | ||||
-rw-r--r-- | gtk/gtkapplication-quartz-menu.c | 4 | ||||
-rw-r--r-- | gtk/gtkcountingbloomfilterprivate.h | 2 | ||||
-rw-r--r-- | meson.build | 16 | ||||
-rw-r--r-- | modules/printbackends/meson.build | 13 | ||||
-rw-r--r-- | subprojects/cairo.wrap | 4 |
12 files changed, 158 insertions, 41 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 18565b2913..5b5ee631a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -144,6 +144,31 @@ msys2-mingw64: MSYSTEM: "MINGW64" CHERE_INVOKING: "yes" +macos: + stage: build + tags: + - macos + only: + - master + - merge_requests + needs: [] + before_script: + - bash .gitlab-ci/show-execution-environment.sh + - pip3 install --user meson==0.56 + - pip3 install --user ninja + - export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH + script: + - meson -Dx11-backend=false + -Dintrospection=disabled + -Dcpp_std=c++11 + -Dpixman:tests=disabled + _build + - ninja -C _build + artifacts: + when: always + paths: + - "${CI_PROJECT_DIR}/_build/meson-logs" + .flatpak-defaults: image: $FLATPAK_IMAGE stage: flatpak diff --git a/.gitlab-ci/show-execution-environment.sh b/.gitlab-ci/show-execution-environment.sh new file mode 100755 index 0000000000..cc1bfdb87d --- /dev/null +++ b/.gitlab-ci/show-execution-environment.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -eux -o pipefail + +xcodebuild -version || : +xcodebuild -showsdks || : + +system_profiler SPSoftwareDataType || : diff --git a/gdk/macos/GdkMacosWindow.c b/gdk/macos/GdkMacosWindow.c index e85ebf8805..3afcdeb826 100644 --- a/gdk/macos/GdkMacosWindow.c +++ b/gdk/macos/GdkMacosWindow.c @@ -38,6 +38,10 @@ #include "gdkmonitorprivate.h" #include "gdksurfaceprivate.h" +#ifndef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER +typedef NSString *CALayerContentsGravity; +#endif + @implementation GdkMacosWindow -(BOOL)windowShouldClose:(id)sender @@ -466,7 +470,7 @@ inTrackManualResize = YES; - mouse_location = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]]; + mouse_location = convert_nspoint_to_screen (self, [self mouseLocationOutsideOfEventStream]); mdx = initialResizeLocation.x - mouse_location.x; mdy = initialResizeLocation.y - mouse_location.y; @@ -588,7 +592,7 @@ } initialResizeFrame = [self frame]; - initialResizeLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]]; + initialResizeLocation = convert_nspoint_to_screen (self, [self mouseLocationOutsideOfEventStream]); } -(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender diff --git a/gdk/macos/gdkmacosclipboard-private.h b/gdk/macos/gdkmacosclipboard-private.h index ab37d707a5..01a562c2b8 100644 --- a/gdk/macos/gdkmacosclipboard-private.h +++ b/gdk/macos/gdkmacosclipboard-private.h @@ -27,6 +27,10 @@ G_BEGIN_DECLS +#ifndef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER +typedef NSString *NSPasteboardType; +#endif + #define GDK_TYPE_MACOS_CLIPBOARD (_gdk_macos_clipboard_get_type()) G_DECLARE_FINAL_TYPE (GdkMacosClipboard, _gdk_macos_clipboard, GDK, MACOS_CLIPBOARD, GdkClipboard) diff --git a/gdk/macos/gdkmacosclipboard.c b/gdk/macos/gdkmacosclipboard.c index 7297045b76..288a7c64d5 100644 --- a/gdk/macos/gdkmacosclipboard.c +++ b/gdk/macos/gdkmacosclipboard.c @@ -40,8 +40,56 @@ typedef struct guint done : 1; } WriteRequest; +enum { + TYPE_STRING, + TYPE_PBOARD, + TYPE_URL, + TYPE_FILE_URL, + TYPE_COLOR, + TYPE_TIFF, + TYPE_PNG, + TYPE_LAST +}; + +#define PTYPE(k) (get_pasteboard_type(TYPE_##k)) + +static NSPasteboardType pasteboard_types[TYPE_LAST]; + G_DEFINE_TYPE (GdkMacosClipboard, _gdk_macos_clipboard, GDK_TYPE_CLIPBOARD) +static NSPasteboardType +get_pasteboard_type (int type) +{ + static gsize initialized = FALSE; + + g_assert (type >= 0); + g_assert (type < TYPE_LAST); + + if (g_once_init_enter (&initialized)) + { + pasteboard_types[TYPE_PNG] = NSPasteboardTypePNG; + pasteboard_types[TYPE_STRING] = NSPasteboardTypeString; + pasteboard_types[TYPE_TIFF] = NSPasteboardTypeTIFF; + pasteboard_types[TYPE_COLOR] = NSPasteboardTypeColor; + + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + pasteboard_types[TYPE_PBOARD] = NSStringPboardType; + G_GNUC_END_IGNORE_DEPRECATIONS + +#ifdef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER + pasteboard_types[TYPE_URL] = NSPasteboardTypeURL; + pasteboard_types[TYPE_FILE_URL] = NSPasteboardTypeFileURL; +#else + pasteboard_types[TYPE_URL] = [[NSString alloc] initWithUTF8String:"public.url"]; + pasteboard_types[TYPE_FILE_URL] = [[NSString alloc] initWithUTF8String:"public.file-url"]; +#endif + + g_once_init_leave (&initialized, TRUE); + } + + return pasteboard_types[type]; +} + static void write_request_free (WriteRequest *wr) { @@ -56,17 +104,17 @@ _gdk_macos_clipboard_from_ns_type (NSPasteboardType type) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - if ([type isEqualToString:NSPasteboardTypeString] || - [type isEqualToString:NSStringPboardType]) + if ([type isEqualToString:PTYPE(STRING)] || + [type isEqualToString:PTYPE(PBOARD)]) return g_intern_string ("text/plain;charset=utf-8"); - else if ([type isEqualToString:NSPasteboardTypeURL] || - [type isEqualToString:NSPasteboardTypeFileURL]) + else if ([type isEqualToString:PTYPE(URL)] || + [type isEqualToString:PTYPE(FILE_URL)]) return g_intern_string ("text/uri-list"); - else if ([type isEqualToString:NSPasteboardTypeColor]) + else if ([type isEqualToString:PTYPE(COLOR)]) return g_intern_string ("application/x-color"); - else if ([type isEqualToString:NSPasteboardTypeTIFF]) + else if ([type isEqualToString:PTYPE(TIFF)]) return g_intern_string ("image/tiff"); - else if ([type isEqualToString:NSPasteboardTypePNG]) + else if ([type isEqualToString:PTYPE(PNG)]) return g_intern_string ("image/png"); G_GNUC_END_IGNORE_DEPRECATIONS; @@ -83,25 +131,25 @@ _gdk_macos_clipboard_to_ns_type (const char *mime_type, if (g_strcmp0 (mime_type, "text/plain;charset=utf-8") == 0) { - return NSPasteboardTypeString; + return PTYPE(STRING); } else if (g_strcmp0 (mime_type, "text/uri-list") == 0) { if (alternate) - *alternate = NSPasteboardTypeURL; - return NSPasteboardTypeFileURL; + *alternate = PTYPE(URL); + return PTYPE(FILE_URL); } else if (g_strcmp0 (mime_type, "application/x-color") == 0) { - return NSPasteboardTypeColor; + return PTYPE(COLOR); } else if (g_strcmp0 (mime_type, "image/tiff") == 0) { - return NSPasteboardTypeTIFF; + return PTYPE(TIFF); } else if (g_strcmp0 (mime_type, "image/png") == 0) { - return NSPasteboardTypePNG; + return PTYPE(PNG); } return nil; @@ -220,7 +268,7 @@ _gdk_macos_clipboard_read_async (GdkClipboard *clipboard, { G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - if ([[self->pasteboard types] containsObject:NSPasteboardTypeFileURL]) + if ([[self->pasteboard types] containsObject:PTYPE(FILE_URL)]) { GString *str = g_string_new (NULL); NSArray *files = [self->pasteboard propertyListForType:NSFilenamesPboardType]; @@ -267,12 +315,12 @@ _gdk_macos_clipboard_read_async (GdkClipboard *clipboard, } else if (strcmp (mime_type, "image/tiff") == 0) { - NSData *data = [self->pasteboard dataForType:NSPasteboardTypeTIFF]; + NSData *data = [self->pasteboard dataForType:PTYPE(TIFF)]; stream = create_stream_from_nsdata (data); } else if (strcmp (mime_type, "image/png") == 0) { - NSData *data = [self->pasteboard dataForType:NSPasteboardTypePNG]; + NSData *data = [self->pasteboard dataForType:PTYPE(PNG)]; stream = create_stream_from_nsdata (data); } diff --git a/gdk/macos/gdkmacosdisplay-translate.c b/gdk/macos/gdkmacosdisplay-translate.c index b638b87ab9..e6551581a2 100644 --- a/gdk/macos/gdkmacosdisplay-translate.c +++ b/gdk/macos/gdkmacosdisplay-translate.c @@ -700,7 +700,7 @@ get_surface_point_from_screen_point (GdkSurface *surface, NSPoint point; nswindow = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (surface)); - point = [nswindow convertPointFromScreen:screen_point]; + point = convert_nspoint_from_screen (nswindow, screen_point); *x = point.x; *y = surface->height - point.y; @@ -821,7 +821,7 @@ get_surface_from_ns_event (GdkMacosDisplay *self, } else { - *screen_point = [(GdkMacosWindow *)[nsevent window] convertPointToScreen:point]; + *screen_point = convert_nspoint_to_screen ([nsevent window], point); *x = point.x; *y = surface->height - point.y; } diff --git a/gdk/macos/gdkmacosutils-private.h b/gdk/macos/gdkmacosutils-private.h index 6b81fd28ac..dd8d3b296a 100644 --- a/gdk/macos/gdkmacosutils-private.h +++ b/gdk/macos/gdkmacosutils-private.h @@ -40,5 +40,36 @@ struct _GdkPoint }; typedef struct _GdkPoint GdkPoint; +static inline NSPoint +convert_nspoint_from_screen (NSWindow *window, + NSPoint point) +{ +#ifdef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER + return [window convertPointFromScreen:point]; +#else + /* Apple documentation claims that convertPointFromScreen is available + * on 10.12+. However, that doesn't seem to be the case when using it. + * Instead, we'll just use it on modern 10.15 systems and fallback to + * converting using rects on older systems. + */ + return [window convertRectFromScreen:NSMakeRect (point.x, point.y, 0, 0)].origin; +#endif +} + +static inline NSPoint +convert_nspoint_to_screen (NSWindow *window, + NSPoint point) +{ +#ifdef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER + return [window convertPointToScreen:point]; +#else + /* Apple documentation claims that convertPointToScreen is available + * on 10.12+. However, that doesn't seem to be the case when using it. + * Instead, we'll just use it on modern 10.15 systems and fallback to + * converting using rects on older systems. + */ + return [window convertRectToScreen:NSMakeRect (point.x, point.y, 0, 0)].origin; +#endif +} #endif /* __GDK_MACOS_UTILS_PRIVATE_H__ */ diff --git a/gtk/gtkapplication-quartz-menu.c b/gtk/gtkapplication-quartz-menu.c index 1de10dbd52..b9d27bd19f 100644 --- a/gtk/gtkapplication-quartz-menu.c +++ b/gtk/gtkapplication-quartz-menu.c @@ -324,7 +324,9 @@ icon_loaded (GObject *object, - (void)didChangeToggled { - [self setState:gtk_menu_tracker_item_get_toggled (trackerItem) ? NSControlStateValueOn : NSControlStateValueOff]; + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + [self setState:gtk_menu_tracker_item_get_toggled (trackerItem) ? NSOnState : NSOffState]; + G_GNUC_END_IGNORE_DEPRECATIONS } - (void)didChangeAccel diff --git a/gtk/gtkcountingbloomfilterprivate.h b/gtk/gtkcountingbloomfilterprivate.h index 9151901d75..78a3f54880 100644 --- a/gtk/gtkcountingbloomfilterprivate.h +++ b/gtk/gtkcountingbloomfilterprivate.h @@ -79,7 +79,7 @@ static inline gboolean gtk_counting_bloom_filter_may_contain (const GtkCounti * * The filter does not need to be freed. */ -#define GTK_COUNTING_BLOOM_FILTER_INIT { 0, } +#define GTK_COUNTING_BLOOM_FILTER_INIT {{0}} /* * gtk_counting_bloom_filter_add: diff --git a/meson.build b/meson.build index 60e7729a8e..8987a5d8fb 100644 --- a/meson.build +++ b/meson.build @@ -348,7 +348,8 @@ endif gmodule_dep = dependency('gmodule-2.0', version: glib_req, fallback : ['glib', 'libgmodule_dep']) cairo_dep = dependency('cairo', version: cairo_req, - fallback : ['cairo', 'libcairo_dep']) + fallback : ['cairo', 'libcairo_dep'], + default_options: ['zlib=enabled']) cairogobj_dep = dependency('cairo-gobject', version: cairo_req, fallback : ['cairo', 'libcairogobject_dep']) pango_dep = dependency('pango', version: pango_req, @@ -379,10 +380,17 @@ pixbuf_dep = dependency('gdk-pixbuf-2.0', version: gdk_pixbuf_req, epoxy_dep = dependency('epoxy', version: epoxy_req, fallback: ['libepoxy', 'libepoxy_dep']) harfbuzz_dep = dependency('harfbuzz', version: '>= 0.9', required: false, - fallback: ['harfbuzz', 'libharfbuzz_dep']) + fallback: ['harfbuzz', 'libharfbuzz_dep'], + default_options: ['coretext=enabled']) xkbdep = dependency('xkbcommon', version: xkbcommon_req, required: wayland_enabled) -graphene_dep = dependency('graphene-gobject-1.0', version: graphene_req, - fallback: ['graphene', 'graphene_dep']) +if os_darwin + graphene_dep = dependency('graphene-gobject-1.0', version: graphene_req, + fallback: ['graphene', 'graphene_dep'], + default_options: ['introspection=false']) +else + graphene_dep = dependency('graphene-gobject-1.0', version: graphene_req, + fallback: ['graphene', 'graphene_dep']) +endif iso_codes_dep = dependency('iso-codes', required: false) gtk_doc_dep = dependency('gtk-doc', version: '>=1.33', diff --git a/modules/printbackends/meson.build b/modules/printbackends/meson.build index c5d7b4cdaa..64d8a41974 100644 --- a/modules/printbackends/meson.build +++ b/modules/printbackends/meson.build @@ -1,18 +1,5 @@ print_backends = [] -if not cc.has_header('cairo-pdf.h', dependencies : cairo_dep) - error('Cannot find cairo-pdf.h. You must build Cairo with the pdf backend enabled.') -endif - -if os_unix - if not cc.has_header('cairo-ps.h', dependencies : cairo_dep) - error('Cannot find cairo-ps.h. You must build Cairo with the postscript backend enabled.') - endif - if not cc.has_header('cairo-svg.h', dependencies : cairo_dep) - error('Cannot find cairo-svg.h. You must build Cairo with the svg backend enabled.') - endif -endif - printbackends_subdir = 'gtk-4.0/@0@/printbackends'.format(gtk_binary_version) printbackends_install_dir = join_paths(get_option('libdir'), printbackends_subdir) diff --git a/subprojects/cairo.wrap b/subprojects/cairo.wrap index d09964e401..5e539239fe 100644 --- a/subprojects/cairo.wrap +++ b/subprojects/cairo.wrap @@ -1,6 +1,6 @@ [wrap-git] directory=cairo -url=https://gitlab.freedesktop.org/cairo/cairo.git +url=https://github.com/matthiasclasen/cairo.git push-url=ssh://git@gitlab.freedesktop.org:cairo/cairo.git -revision=master +revision=fix-osx-build depth=1 |