summaryrefslogtreecommitdiff
path: root/gdk/quartz
diff options
context:
space:
mode:
authorKristian Rietveld <kris@gtk.org>2010-12-23 13:14:49 +0100
committerKristian Rietveld <kris@gtk.org>2010-12-23 14:17:41 +0100
commitfb8717f722ad11d83672dbfd233c73f429ec9b14 (patch)
tree1643f0a36f0bd71d26c5ac2f876a635dcfa0944f /gdk/quartz
parentf15934bd6697d02f0af20560027a08989d3187ab (diff)
downloadgtk+-fb8717f722ad11d83672dbfd233c73f429ec9b14.tar.gz
quartz: move utils to gdkutils-quartz.c
Diffstat (limited to 'gdk/quartz')
-rw-r--r--gdk/quartz/Makefile.am1
-rw-r--r--gdk/quartz/gdkcursor-quartz.c72
-rw-r--r--gdk/quartz/gdkevents-quartz.c7
-rw-r--r--gdk/quartz/gdkutils-quartz.c99
4 files changed, 101 insertions, 78 deletions
diff --git a/gdk/quartz/Makefile.am b/gdk/quartz/Makefile.am
index cfbe55d9cb..b9c5b464fa 100644
--- a/gdk/quartz/Makefile.am
+++ b/gdk/quartz/Makefile.am
@@ -42,6 +42,7 @@ libgdk_quartz_la_SOURCES = \
gdkscreen-quartz.h \
gdkselection-quartz.c \
gdktestutils-quartz.c \
+ gdkutils-quartz.c \
gdkvisual-quartz.c \
gdkwindow-quartz.c \
gdkwindow-quartz.h \
diff --git a/gdk/quartz/gdkcursor-quartz.c b/gdk/quartz/gdkcursor-quartz.c
index 7f3e142833..22b7676acb 100644
--- a/gdk/quartz/gdkcursor-quartz.c
+++ b/gdk/quartz/gdkcursor-quartz.c
@@ -250,70 +250,6 @@ _gdk_quartz_display_get_cursor_for_type (GdkDisplay *display,
return gdk_quartz_cursor_new_from_nscursor (nscursor, cursor_type);
}
-static NSImage *
-_gdk_quartz_pixbuf_to_ns_image (GdkPixbuf *pixbuf)
-{
- NSBitmapImageRep *bitmap_rep;
- NSImage *image;
- gboolean has_alpha;
-
- has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
-
- /* Create a bitmap image rep */
- bitmap_rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
- pixelsWide:gdk_pixbuf_get_width (pixbuf)
- pixelsHigh:gdk_pixbuf_get_height (pixbuf)
- bitsPerSample:8 samplesPerPixel:has_alpha ? 4 : 3
- hasAlpha:has_alpha isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace
- bytesPerRow:0 bitsPerPixel:0];
-
- {
- /* Add pixel data to bitmap rep */
- guchar *src, *dst;
- int src_stride, dst_stride;
- int x, y;
-
- src_stride = gdk_pixbuf_get_rowstride (pixbuf);
- dst_stride = [bitmap_rep bytesPerRow];
-
- for (y = 0; y < gdk_pixbuf_get_height (pixbuf); y++)
- {
- src = gdk_pixbuf_get_pixels (pixbuf) + y * src_stride;
- dst = [bitmap_rep bitmapData] + y * dst_stride;
-
- for (x = 0; x < gdk_pixbuf_get_width (pixbuf); x++)
- {
- if (has_alpha)
- {
- guchar red, green, blue, alpha;
-
- red = *src++;
- green = *src++;
- blue = *src++;
- alpha = *src++;
-
- *dst++ = (red * alpha) / 255;
- *dst++ = (green * alpha) / 255;
- *dst++ = (blue * alpha) / 255;
- *dst++ = alpha;
- }
- else
- {
- *dst++ = *src++;
- *dst++ = *src++;
- *dst++ = *src++;
- }
- }
- }
- }
-
- image = [[NSImage alloc] init];
- [image addRepresentation:bitmap_rep];
- [bitmap_rep release];
- [image autorelease];
-
- return image;
-}
GdkCursor *
_gdk_quartz_display_get_cursor_for_pixbuf (GdkDisplay *display,
@@ -330,7 +266,7 @@ _gdk_quartz_display_get_cursor_for_pixbuf (GdkDisplay *display,
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
- image = _gdk_quartz_pixbuf_to_ns_image (pixbuf);
+ image = gdk_quartz_pixbuf_to_ns_image_libgtk_only (pixbuf);
nscursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(x, y)];
cursor = gdk_quartz_cursor_new_from_nscursor (nscursor, GDK_CURSOR_IS_PIXMAP);
@@ -432,9 +368,3 @@ gdk_quartz_cursor_get_image (GdkCursor *cursor)
/* FIXME: Implement */
return NULL;
}
-
-NSImage *
-gdk_quartz_pixbuf_to_ns_image_libgtk_only (GdkPixbuf *pixbuf)
-{
- return _gdk_quartz_pixbuf_to_ns_image (pixbuf);
-}
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index 3b20df2886..227cdbdb94 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -55,13 +55,6 @@ static int current_button_state;
static void append_event (GdkEvent *event,
gboolean windowing);
-NSEvent *
-gdk_quartz_event_get_nsevent (GdkEvent *event)
-{
- /* FIXME: If the event here is unallocated, we crash. */
- return ((GdkEventPrivate *) event)->windowing_data;
-}
-
void
_gdk_quartz_events_init (void)
{
diff --git a/gdk/quartz/gdkutils-quartz.c b/gdk/quartz/gdkutils-quartz.c
new file mode 100644
index 0000000000..122a31cb07
--- /dev/null
+++ b/gdk/quartz/gdkutils-quartz.c
@@ -0,0 +1,99 @@
+/* gdkutils-quartz.c
+ *
+ * Copyright (C) 2005 Imendio AB
+ * Copyright (C) 2010 Kristian Rietveld <kris@gtk.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <AppKit/AppKit.h>
+
+#include <gdkquartzutils.h>
+#include "gdkprivate-quartz.h"
+
+NSImage *
+gdk_quartz_pixbuf_to_ns_image_libgtk_only (GdkPixbuf *pixbuf)
+{
+ NSBitmapImageRep *bitmap_rep;
+ NSImage *image;
+ gboolean has_alpha;
+
+ has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
+
+ /* Create a bitmap image rep */
+ bitmap_rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
+ pixelsWide:gdk_pixbuf_get_width (pixbuf)
+ pixelsHigh:gdk_pixbuf_get_height (pixbuf)
+ bitsPerSample:8 samplesPerPixel:has_alpha ? 4 : 3
+ hasAlpha:has_alpha isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace
+ bytesPerRow:0 bitsPerPixel:0];
+
+ {
+ /* Add pixel data to bitmap rep */
+ guchar *src, *dst;
+ int src_stride, dst_stride;
+ int x, y;
+
+ src_stride = gdk_pixbuf_get_rowstride (pixbuf);
+ dst_stride = [bitmap_rep bytesPerRow];
+
+ for (y = 0; y < gdk_pixbuf_get_height (pixbuf); y++)
+ {
+ src = gdk_pixbuf_get_pixels (pixbuf) + y * src_stride;
+ dst = [bitmap_rep bitmapData] + y * dst_stride;
+
+ for (x = 0; x < gdk_pixbuf_get_width (pixbuf); x++)
+ {
+ if (has_alpha)
+ {
+ guchar red, green, blue, alpha;
+
+ red = *src++;
+ green = *src++;
+ blue = *src++;
+ alpha = *src++;
+
+ *dst++ = (red * alpha) / 255;
+ *dst++ = (green * alpha) / 255;
+ *dst++ = (blue * alpha) / 255;
+ *dst++ = alpha;
+ }
+ else
+ {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ *dst++ = *src++;
+ }
+ }
+ }
+ }
+
+ image = [[NSImage alloc] init];
+ [image addRepresentation:bitmap_rep];
+ [bitmap_rep release];
+ [image autorelease];
+
+ return image;
+}
+
+NSEvent *
+gdk_quartz_event_get_nsevent (GdkEvent *event)
+{
+ /* FIXME: If the event here is unallocated, we crash. */
+ return ((GdkEventPrivate *) event)->windowing_data;
+}