Commit 1097260a authored by Anders Carlsson's avatar Anders Carlsson Committed by Anders Carlsson

Add quartz backend.

2005-11-21  Anders Carlsson  <andersca@imendio.com>

        * configure.in:
        * gtk/Makefile.am:
        * gdk/Makefile.am:
	* gdk/quartz/*:
	Add quartz backend.

        * docs/tools/Makefile.am:
	Only build docshooter when the X11 backend is used.

        * gtk/gtkplug-stub.c:
	Include gtkplug.h here.

        * gtk/gtksocket-stub.c:
	Include gtksocket.h here.
parent fbebb232
......@@ -38,7 +38,6 @@
(gtk_combo_box_child_show, gtk_combo_box_child_hide): Use
g_signal_emit, not g_signal_emit_by_name.
>>>>>>> 1.7265
2005-11-18 Matthias Clasen <mclasen@redhat.com>
Fix crashes in connection with pathbar scrolling (#321560,
......
......@@ -38,7 +38,6 @@
(gtk_combo_box_child_show, gtk_combo_box_child_hide): Use
g_signal_emit, not g_signal_emit_by_name.
>>>>>>> 1.7265
2005-11-18 Matthias Clasen <mclasen@redhat.com>
Fix crashes in connection with pathbar scrolling (#321560,
......
......@@ -224,13 +224,13 @@ else
gdktarget=x11
fi
AC_ARG_WITH(gdktarget, [ --with-gdktarget=[[x11/linux-fb/win32]] select non-default GDK target],
AC_ARG_WITH(gdktarget, [ --with-gdktarget=[[x11/linux-fb/win32/quartz]] select non-default GDK target],
gdktarget=$with_gdktarget)
AC_SUBST(gdktarget)
case $gdktarget in
x11|linux-fb|win32) ;;
*) AC_MSG_ERROR([Invalid target for GDK: use x11, linux-fb or win32.]);;
x11|linux-fb|win32|quartz) ;;
*) AC_MSG_ERROR([Invalid target for GDK: use x11, linux-fb, quartz or win32.]);;
esac
gdktargetlib=libgdk-$gdktarget-$GTK_API_VERSION.la
......@@ -1325,6 +1325,13 @@ else
AM_CONDITIONAL(USE_WIN32, false)
fi
if test "x$gdktarget" = "xquartz"; then
GDK_EXTRA_LIBS="$GDK_EXTRA_LIBS -framework Cocoa"
AM_CONDITIONAL(USE_QUARTZ, true)
else
AM_CONDITIONAL(USE_QUARTZ, false)
fi
GDK_PIXBUF_XLIB_DEP_LIBS="`$PKG_CONFIG --libs $GDK_PIXBUF_PACKAGES $GDK_PIXBUF_XLIB_PACKAGES` $GDK_PIXBUF_XLIB_EXTRA_LIBS $GDK_PIXBUF_EXTRA_LIBS"
GDK_PIXBUF_XLIB_DEP_CFLAGS="`$PKG_CONFIG --cflags gthread-2.0 $GDK_PIXBUF_PACKAGES $GDK_PIXBUF_XLIB_PACKAGES` $GDK_PIXBUF_EXTRA_CFLAGS $GDK_PIXBUF_XLIB_EXTRA_CFLAGS"
......@@ -1569,6 +1576,9 @@ elif test "x$gdktarget" = "xlinux-fb" ; then
gdk_windowing='
#define GDK_WINDOWING_FB
#define GDK_NATIVE_WINDOW_POINTER'
elif test "x$gdktarget" = "xquartz" ; then
gdk_windowing='
#define GDK_WINDOWING_QUARTZ'
fi
if test x$gdk_wchar_h = xyes; then
......@@ -1625,6 +1635,7 @@ gdk/win32/Makefile
gdk/win32/rc/Makefile
gdk/win32/rc/gdk.rc
gdk/linux-fb/Makefile
gdk/quartz/Makefile
gtk/Makefile
gtk/makefile.msc
gtk/gtkversion.h
......
......@@ -17,7 +17,7 @@ LDADDS = \
$(top_builddir)/gtk/$(gtktargetlib) \
$(GTK_DEP_LIBS)
if OS_UNIX
if USE_X11
noinst_PROGRAMS = \
doc-shooter
endif
......
## Makefile.am for gtk+/gdk
SUBDIRS = $(gdktarget)
DIST_SUBDIRS = linux-fb win32 x11
DIST_SUBDIRS = linux-fb win32 x11 quartz
EXTRA_DIST = \
keynames.txt \
......@@ -144,6 +144,11 @@ libgdk_linux_fb_2_0_la_LIBADD = linux-fb/libgdk-linux-fb.la $(GDK_DEP_LIBS) \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la
libgdk_linux_fb_2_0_la_LDFLAGS = $(LDADD)
libgdk_quartz_2_0_la_SOURCES = $(common_sources) gdkkeynames.c
libgdk_quartz_2_0_la_LIBADD = quartz/libgdk-quartz.la $(GDK_DEP_LIBS) \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la
libgdk_quartz_2_0_la_LDFLAGS = $(LDADD)
libgdk_win32_2_0_la_SOURCES = $(common_sources) gdkkeynames.c
libgdk_win32_2_0_la_LIBADD = win32/libgdk-win32.la $(GDK_DEP_LIBS) \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la
......@@ -198,7 +203,7 @@ endif
lib_LTLIBRARIES = $(gdktargetlib)
EXTRA_LTLIBRARIES = libgdk-x11-2.0.la libgdk-linux-fb-2.0.la libgdk-win32-2.0.la
EXTRA_LTLIBRARIES = libgdk-x11-2.0.la libgdk-linux-fb-2.0.la libgdk-win32-2.0.la libgdk-quartz-2.0.la
MAINTAINERCLEANFILES = gdkenumtypes.h stamp-gdkenumtypes.h gdkenumtypes.c \
gdkmarshalers.h gdkmarshalers.c
......
/* GdkQuartzView.m
*
* Copyright (C) 2005 Imendio AB
*
* 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.
*/
#import "GdkQuartzView.h"
#include "gdkwindow-quartz.h"
#include "gdkprivate-quartz.h"
@implementation GdkQuartzView
-(void)setGdkWindow:(GdkWindow *)window
{
gdk_window = window;
}
-(GdkWindow *)gdkWindow
{
return gdk_window;
}
-(BOOL)isFlipped
{
return YES;
}
-(BOOL)isOpaque
{
/* A view is opaque if its GdkWindow doesn't have the RGBA colormap */
return gdk_drawable_get_colormap (gdk_window) != gdk_screen_get_rgba_colormap (_gdk_screen);
}
-(void)drawRect:(NSRect)rect
{
NSRect bounds = [self bounds];
GdkRectangle gdk_rect;
GDK_QUARTZ_ALLOC_POOL;
/* Draw background */
if (GDK_WINDOW_OBJECT (gdk_window)->bg_pixmap == NULL)
{
CGContextRef context;
context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSaveGState (context);
_gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (gdk_window),
GDK_WINDOW_OBJECT (gdk_window)->bg_color.pixel);
CGContextFillRect (context, CGRectMake (bounds.origin.x, bounds.origin.y,
bounds.size.width, bounds.size.height));
CGContextRestoreGState (context);
}
gdk_rect.x = bounds.origin.x;
gdk_rect.y = bounds.origin.y;
gdk_rect.width = bounds.size.width;
gdk_rect.height = bounds.size.height;
gdk_window_invalidate_rect (gdk_window, &gdk_rect, FALSE);
gdk_window_process_updates (gdk_window, FALSE);
GDK_QUARTZ_RELEASE_POOL;
}
@end
/* GdkQuartzView.h
*
* Copyright (C) 2005 Imendio AB
*
* 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.
*/
#import <Quartz/Quartz.h>
#include "gdkwindow.h"
@interface GdkQuartzView : NSView {
GdkWindow *gdk_window;
}
-(void)setGdkWindow:(GdkWindow *)window;
-(GdkWindow *)gdkWindow;
@end
/* GdkQuartzWindow.m
*
* Copyright (C) 2005 Imendio AB
*
* 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.
*/
#import "GdkQuartzWindow.h"
#include "gdkwindow-quartz.h"
#include "gdkprivate-quartz.h"
@implementation GdkQuartzWindow
-(BOOL)windowShouldClose:(id)sender
{
GdkWindow *window = [[self contentView] gdkWindow];
GdkEvent *event;
event = gdk_event_new (GDK_DELETE);
event->any.window = g_object_ref (window);
event->any.send_event = FALSE;
_gdk_event_queue_append (gdk_display_get_default (), event);
return NO;
}
-(void)windowDidMiniaturize:(NSNotification *)aNotification
{
GdkWindow *window = [[self contentView] gdkWindow];
gdk_synthesize_window_state (window, 0,
GDK_WINDOW_STATE_ICONIFIED);
}
-(void)windowDidDeminiaturize:(NSNotification *)aNotification
{
GdkWindow *window = [[self contentView] gdkWindow];
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_ICONIFIED, 0);
}
-(void)windowDidBecomeKey:(NSNotification *)aNotification
{
GdkWindow *window = [[self contentView] gdkWindow];
_gdk_quartz_update_focus_window (window);
}
-(void)windowDidResize:(NSNotification *)aNotification
{
NSRect content_rect = [self contentRectForFrameRect:[self frame]];
GdkWindow *window = [[self contentView] gdkWindow];
GdkWindowObject *private = (GdkWindowObject *)window;
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
GdkEvent *event;
impl->width = content_rect.size.width;
impl->height = content_rect.size.height;
/* Synthesize a configure event */
event = gdk_event_new (GDK_CONFIGURE);
event->configure.window = g_object_ref (window);
event->configure.x = private->x;
event->configure.y = private->y;
event->configure.width = impl->width;
event->configure.height = impl->height;
_gdk_event_queue_append (gdk_display_get_default (), event);
/* Update tracking rectangle */
[[self contentView] removeTrackingRect:impl->tracking_rect];
impl->tracking_rect = [impl->view addTrackingRect:NSMakeRect(0, 0, impl->width, impl->height)
owner:impl->view
userData:nil
assumeInside:NO];
}
-(id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag
{
self = [super initWithContentRect:contentRect
styleMask:styleMask
backing:backingType
defer:flag];
/* A possible modification here would be to only accept mouse moved events
* if any of the child GdkWindows are interested in mouse moved events.
*/
[self setAcceptsMouseMovedEvents:YES];
[self setDelegate:self];
[self setReleasedWhenClosed:YES];
return self;
}
@end
/* GdkQuartzWindow.h
*
* Copyright (C) 2005 Imendio AB
*
* 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.
*/
#import <Quartz/Quartz.h>
#include "gdkwindow.h"
@interface GdkQuartzWindow : NSWindow {
}
@end
libgdkincludedir = $(includedir)/gtk-2.0/gdk
INCLUDES = \
-DG_LOG_DOMAIN=\"Gdk\" \
-DGDK_COMPILATION \
-I$(top_srcdir) \
-I$(top_srcdir)/gdk \
-I$(top_builddir)/gdk \
-DG_DISABLE_DEPRECATED \
-DGDK_PIXBUF_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
$(GTK_DEBUG_FLAGS) \
$(GDK_DEP_CFLAGS) \
"-xobjective-c"
LDADDS = $(GDK_DEP_LIBS)
noinst_LTLIBRARIES = libgdk-quartz.la
libgdk_quartz_la_SOURCES = \
GdkQuartzView.c \
GdkQuartzView.h \
GdkQuartzWindow.c \
GdkQuartzWindow.h \
gdkcolor-quartz.c \
gdkcursor-quartz.c \
gdkdisplay-quartz.c \
gdkdnd-quartz.c \
gdkdrawable-quartz.c \
gdkevents-quartz.c \
gdkfont-quartz.c \
gdkgc-quartz.c \
gdkgeometry-quartz.c \
gdkglobals-quartz.c \
gdkim-quartz.c \
gdkimage-quartz.c \
gdkinput.c \
gdkkeys-quartz.c \
gdkmain-quartz.c \
gdkpixmap-quartz.c \
gdkproperty-quartz.c \
gdkscreen-quartz.c \
gdkselection-quartz.c \
gdkvisual-quartz.c \
gdkwindow-quartz.c
/* gdkcolor-quartz.c
*
* Copyright (C) 2005 Imendio AB
*
* 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 "gdkcolor.h"
#include "gdkprivate-quartz.h"
GType
gdk_colormap_get_type (void)
{
static GType object_type = 0;
if (!object_type)
{
static const GTypeInfo object_info =
{
sizeof (GdkColormapClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) NULL,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkColormap),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
object_type = g_type_register_static (G_TYPE_OBJECT,
"GdkColormap",
&object_info,
0);
}
return object_type;
}
GdkColormap *
gdk_colormap_new (GdkVisual *visual,
gint private_cmap)
{
g_return_val_if_fail (visual != NULL, NULL);
/* FIXME: Implement */
return NULL;
}
GdkColormap *
gdk_screen_get_system_colormap (GdkScreen *screen)
{
static GdkColormap *colormap = NULL;
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
if (!colormap)
{
colormap = g_object_new (GDK_TYPE_COLORMAP, NULL);
colormap->visual = gdk_visual_get_system ();
colormap->size = colormap->visual->colormap_size;
}
return colormap;
}
GdkColormap *
gdk_screen_get_rgba_colormap (GdkScreen *screen)
{
static GdkColormap *colormap = NULL;
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
if (!colormap)
{
colormap = g_object_new (GDK_TYPE_COLORMAP, NULL);
colormap->visual = gdk_screen_get_rgba_visual (screen);
colormap->size = colormap->visual->colormap_size;
}
return colormap;
}
void
gdk_colormap_change (GdkColormap *colormap,
gint ncolors)
{
/* FIXME: Implement */
}
void
gdk_colormap_free_colors (GdkColormap *colormap,
GdkColor *colors,
gint ncolors)
{
/* This function shouldn't do anything since
* colors are neve allocated.
*/
}
gint
gdk_colormap_alloc_colors (GdkColormap *colormap,
GdkColor *colors,
gint ncolors,
gboolean writeable,
gboolean best_match,
gboolean *success)
{
int i;
for (i = 0; i < ncolors; i++)
{
colors[i].pixel = ((colors[i].red >> 8) & 0xff) << 16 |
((colors[i].green >> 8) & 0xff) << 8 |
((colors[i].blue >> 8) & 0xff);
}
return ncolors;
}
void
gdk_colormap_query_color (GdkColormap *colormap,
gulong pixel,
GdkColor *result)
{
result->red = pixel >> 16 & 0xff;
result->red += result->red << 8;
result->green = pixel >> 8 & 0xff;
result->green += result->green << 8;
result->blue = pixel & 0xff;
result->blue += result->blue << 8;
}
GdkScreen*
gdk_colormap_get_screen (GdkColormap *cmap)
{
g_return_val_if_fail (cmap != NULL, NULL);
return gdk_screen_get_default ();
}
void
_gdk_quartz_set_context_fill_color_from_pixel (CGContextRef context, GdkColormap *colormap, guint32 pixel)
{
float red, green, blue, alpha;
red = (pixel >> 16 & 0xff) / 255.0;
green = (pixel >> 8 & 0xff) / 255.0;
blue = (pixel & 0xff) / 255.0;
if (colormap && gdk_colormap_get_visual (colormap)->depth == 32)
alpha = (pixel >> 24 & 0xff) / 255.0;
else
alpha = 1.0;
CGContextSetRGBFillColor (context, red, green, blue, alpha);
}
void
_gdk_quartz_set_context_stroke_color_from_pixel (CGContextRef context, GdkColormap *colormap, guint32 pixel)
{
float red, green, blue, alpha;
red = (pixel >> 16 & 0xff) / 255.0;
green = (pixel >> 8 & 0xff) / 255.0;
blue = (pixel & 0xff) / 255.0;
if (colormap && gdk_colormap_get_visual (colormap)->depth == 32)
alpha = (pixel >> 24 & 0xff) / 255.0;
else
alpha = 1.0;
CGContextSetRGBStrokeColor (context, red, green, blue, 1.0);
}
/* gdkcursor-quartz.c
*
* Copyright (C) 2005 Imendio AB
*
* 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 "gdkdisplay.h"
#include "gdkcursor.h"
#include "gdkprivate-quartz.h"
static GdkCursor *
gdk_quartz_cursor_new_from_nscursor (NSCursor *nscursor, GdkCursorType cursor_type)
{
GdkCursorPrivate *private;
GdkCursor *cursor;
private = g_new (GdkCursorPrivate, 1);
private->nscursor = nscursor;
cursor = (GdkCursor *)private;
cursor->type = cursor_type;
cursor->ref_count = 1;
return cursor;
}
GdkCursor*
gdk_cursor_new_for_display (GdkDisplay *display,
GdkCursorType cursor_type)
{
NSCursor *nscursor;
g_return_val_if_fail (display == gdk_display_get_default (), NULL);
switch (cursor_type)
{
case GDK_XTERM:
nscursor = [NSCursor IBeamCursor];
break;
case GDK_SB_H_DOUBLE_ARROW:
nscursor = [NSCursor resizeLeftRightCursor];
break;
case GDK_SB_V_DOUBLE_ARROW:
nscursor = [NSCursor resizeUpDownCursor];
break;
default:
g_warning ("Unsupported cursor type %d, using default", cursor_type);
nscursor = [NSCursor arrowCursor];
}
[nscursor retain];
return gdk_quartz_cursor_new_from_nscursor (nscursor, cursor_type);
}
GdkCursor*
gdk_cursor_new_from_pixmap (GdkPixmap *source,
GdkPixmap *mask,
const GdkColor *fg,
const GdkColor *bg,
gint x,
gint y)
{
NSAutoreleasePool *pool;
NSBitmapImageRep *bitmap_rep;
NSImage *image;
NSCursor *nscursor;
GdkCursor *cursor;
gint width, height;
gint tmp_x, tmp_y;
guchar *dst_data, *mask_data, *src_data;
guchar *mask_start, *src_start;
int dst_stride;
gdk_drawable_get_size (source, &width, &height);
g_return_val_if_fail (GDK_IS_PIXMAP (source), NULL);
g_return_val_if_fail (GDK_IS_PIXMAP (mask), NULL);
g_return_val_if_fail (fg != NULL, NULL);
g_return_val_if_fail (bg != NULL, NULL);
pool = [[NSAutoreleasePool alloc] init];
bitmap_rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:width pixelsHigh:height
bitsPerSample:8 samplesPerPixel:4
hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace
bytesPerRow:0 bitsPerPixel:0];
dst_stride = [bitmap_rep bytesPerRow];
mask_start = GDK_PIXMAP_IMPL_QUARTZ (GDK_PIXMAP_OBJECT (mask)->impl)->data;
src_start = GDK_PIXMAP_IMPL_QUARTZ (GDK_PIXMAP_OBJECT (source)->impl)->data;
for (tmp_y = 0; tmp_y < height; tmp_y++)
{
dst_data = [bitmap_rep bitmapData] + tmp_y * dst_stride;
mask_data = mask_start + tmp_y * width;
src_data = src_start + tmp_y * width;
for (tmp_x = 0; tmp_x < width; tmp_x++)
{
if (*mask_data++)
{
const GdkColor *color;
if (*src_data++)
color = fg;
else