beginning of a MacOS X port

This commit is contained in:
Hubert Figuiere
2005-06-14 02:25:58 +00:00
parent d9441df224
commit 01f5b89802
20 changed files with 11404 additions and 6 deletions

View File

@@ -111,6 +111,17 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE")
AC_CANONICAL_HOST
MATH_LIB=-lm
AC_MSG_CHECKING([for native MacOS X])
case "$host" in
*-*-darwin*)
os_macosx=yes
;;
*)
os_macosx=no
;;
esac
AC_MSG_RESULT([$os_macosx])
AC_MSG_CHECKING([for native Win32])
case "$host" in
*-*-mingw*)
@@ -130,6 +141,7 @@ case $host in
esac
dnl Initialize libtool
AC_PROG_CC
AM_DISABLE_STATIC
if test "$os_win32" = "yes"; then
@@ -166,7 +178,22 @@ esac
AC_MSG_RESULT([$platform_win32])
AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
AC_MSG_CHECKING([for some MacOS X platform])
case "$host" in
*-*-darwin*|*-*-darwin*)
platform_macosx=yes
;;
*)
platform_macosx=no
;;
esac
AC_MSG_RESULT([$platform_macosx])
AM_CONDITIONAL(PLATFORM_MACOSX, test "$platform_macosx" = "yes")
AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
AM_CONDITIONAL(OS_MACOSX, test "$os_macosx" = "yes")
AM_CONDITIONAL(OS_UNIX, test "$os_win32" != "yes")
AM_CONDITIONAL(OS_LINUX, test "$os_linux" = "yes")
@@ -217,18 +244,29 @@ AC_ARG_WITH(ie55,
GLIB_AC_DIVERT_BEFORE_HELP([
if test "$platform_win32" = yes; then
gdktarget=win32
elif test "$platform_macosx" = yes; then
gdktarget=macosx
else
gdktarget=x11
fi
])
# this because the macro above is broken.... and doesn't work.
if test "$platform_win32" = yes; then
gdktarget=win32
elif test "$platform_macosx" = yes; then
gdktarget=macosx
else
gdktarget=x11
fi
AC_ARG_WITH(gdktarget, [ --with-gdktarget=[[x11/linux-fb/win32]] select GDK target [default=$gdktarget]],
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|macosx) ;;
*) AC_MSG_ERROR([Invalid target for GDK: use x11, linux-fb, win32 or macosx.]);;
esac
gdktargetlib=libgdk-$gdktarget-$GTK_API_VERSION.la
@@ -331,6 +369,15 @@ if test x"$os_win32" = xyes; then
fi
fi
# objective-C
OBJC="gcc"
OBJCFLAGS=""
AC_SUBST(OBJC)
AC_SUBST(OBJCFLAGS)
dnl Make Objective-C work with automake 1.7.x
dnl see http://lists.gnu.org/archive/html/automake/2003-05/msg00027.html
AM_CONDITIONAL([am__fastdepOBJC], false)
# Honor aclocal flags
ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
@@ -1343,6 +1390,13 @@ else
AM_CONDITIONAL(USE_WIN32, false)
fi
if test "x$gdktarget" = "xmacosx"; then
GDK_EXTRA_LIBS="$GDK_EXTRA_LIBS -framework Cocoa -framework ApplicationServices"
AM_CONDITIONAL(USE_MACOSX, true)
else
AM_CONDITIONAL(USE_MACOSX, false)
fi
GDK_PIXBUF_XLIB_PACKAGES=
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"
@@ -1401,6 +1455,8 @@ if test "x$gdktarget" = "xx11"; then
if $PKG_CONFIG --exists pangox ; then
PANGO_PACKAGES="$PANGO_PACKAGES pangox"
fi
elif test "x$gdktarget" = "xmacosx"; then
PANGO_PACKAGES=pangoft2
elif test "x$gdktarget" = "xwin32"; then
PANGO_PACKAGES=pangowin32
elif test "x$gdktarget" = "xlinux-fb"; then
@@ -1614,6 +1670,10 @@ elif test "x$gdktarget" = "xlinux-fb" ; then
gdk_windowing='
#define GDK_WINDOWING_FB
#define GDK_NATIVE_WINDOW_POINTER'
elif test "x$gdktarget" = "xmacosx" ; then
gdk_windowing='
#define GDK_WINDOWING_MACOSX
#define GDK_NATIVE_WINDOW_POINTER'
fi
if test x$gdk_wchar_h = xyes; then
@@ -1673,6 +1733,8 @@ gdk/win32/Makefile
gdk/win32/rc/Makefile
gdk/win32/rc/gdk.rc
gdk/linux-fb/Makefile
gdk/macosx/Makefile
gdk/test/Makefile
gtk/Makefile
gtk/makefile.msc
gtk/gtkversion.h

View File

@@ -1,7 +1,8 @@
## Makefile.am for gtk+/gdk
SUBDIRS = $(gdktarget)
DIST_SUBDIRS = linux-fb win32 x11
SUBDIRS = $(gdktarget) test
DIST_SUBDIRS = linux-fb win32 x11 macosx
check_SUBDIRS = test
EXTRA_DIST = \
gdkconfig.h.win32 \
@@ -138,6 +139,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_macosx_2_0_la_SOURCES = $(common_sources)
libgdk_macosx_2_0_la_LIBADD = macosx/libgdk-macosx.la $(GDK_DEP_LIBS) \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la
libgdk_macosx_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
@@ -192,7 +198,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-macosx-2.0.la
MAINTAINERCLEANFILES = gdkenumtypes.h stamp-gdkenumtypes.h gdkenumtypes.c \
gdkmarshalers.h gdkmarshalers.c gdkalias.h gdkaliasdef.c

37
gdk/macosx/Makefile.am Normal file
View File

@@ -0,0 +1,37 @@
## Process this file with automake to produce Makefile.in
libgdkincludedir = $(includedir)/gtk-2.0/gdk
AUTOMAKE_OPTIONS = no-dependencies
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)
LDADDS = $(GDK_DEP_LIBS)
noinst_LTLIBRARIES = libgdk-macosx.la
libgdk_macosx_la_SOURCES = gdkpango-macosx.c \
gdkevents-macosx.m \
gdkdisplay-macosx.m \
gdkgc-macosx.m \
gdkmain-macosx.m \
gdknsview-macosx.m \
gdkscreen-macosx.m \
gdkwindow-macosx.m
libgdkinclude_HEADERS =
# We need to include all these C files here since the conditionals
# don't seem to be correctly expanded for the dist files.
EXTRA_DIST =

View File

@@ -0,0 +1,71 @@
/*
* gdkdisplay-macosx.h
*
* Copyright 2001 Sun Microsystems Inc.
*
* Erwann Chenede <erwann.chenede@sun.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library 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.
*/
#ifndef __GDK_DISPLAY_MACOSX__
#define __GDK_DISPLAY_MACOSX__
#include <glib.h>
#include <gdk/gdkdisplay.h>
#include <gdk/gdkkeys.h>
#include <gdk/gdkwindow.h>
#include <gdk/gdk.h> /* For gdk_get_program_class() */
G_BEGIN_DECLS
typedef struct _GdkDisplayMacOSX GdkDisplayMacOSX;
typedef struct _GdkDisplayMacOSXClass GdkDisplayMacOSXClass;
#define GDK_TYPE_DISPLAY_MACOSX (_gdk_display_macosx_get_type())
#define GDK_DISPLAY_MACOSX(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_MACOSX, GdkDisplayMacOSX))
#define GDK_DISPLAY_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY_MACOSX, GdkDisplayMacOSXClass))
#define GDK_IS_DISPLAY_MACOSX(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DISPLAY_MACOSX))
#define GDK_IS_DISPLAY_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY_MACOSX))
#define GDK_DISPLAY_MACOSX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY_MACOSX, GdkDisplayMacOSXClass))
typedef enum
{
GDK_UNKNOWN,
GDK_NO,
GDK_YES
} GdkTristate;
struct _GdkDisplayMacOSX
{
GdkDisplay parent_instance;
GdkScreen *default_screen;
GdkScreen **screens;
int num_screens;
/* NSView to GdkWindow pointers */
GHashTable *nsview_ht;
};
struct _GdkDisplayMacOSXClass
{
GdkDisplayClass parent_class;
};
GType _gdk_display_macosx_get_type (void);
G_END_DECLS
#endif /* __GDK_DISPLAY_MacOSX__ */

View File

@@ -0,0 +1,547 @@
/* GDK - The GIMP Drawing Kit
* gdkdisplay-macosx.c
*
* Copyright 2001 Sun Microsystems Inc.
* Copyright (C) 2004 Nokia Corporation
* Copyright (C) 2005 Hubert Figuiere
*
* Hubert Figuiere <hub@figuiere.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library 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.
*/
/*
* derived from GdkDisplay-X11....
*/
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <glib.h>
#include "gdkalias.h"
#include "gdkdisplay.h"
#include "gdkdisplay-macosx.h"
#include "gdkscreen.h"
#include "gdkscreen-macosx.h"
#include "gdkinternals.h"
#include <Cocoa/Cocoa.h>
static void gdk_display_macosx_class_init (GdkDisplayMacOSXClass *class);
static void gdk_display_macosx_dispose (GObject *object);
static void gdk_display_macosx_finalize (GObject *object);
static gpointer parent_class = NULL;
GType
_gdk_display_macosx_get_type (void)
{
static GType object_type = 0;
if (!object_type)
{
static const GTypeInfo object_info =
{
sizeof (GdkDisplayMacOSXClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gdk_display_macosx_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkDisplayMacOSX),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
object_type = g_type_register_static (GDK_TYPE_DISPLAY,
"GdkDisplayMacOSX",
&object_info, 0);
}
return object_type;
}
static void
gdk_display_macosx_class_init (GdkDisplayMacOSXClass * class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = gdk_display_macosx_dispose;
object_class->finalize = gdk_display_macosx_finalize;
parent_class = g_type_class_peek_parent (class);
}
/**
* gdk_display_open:
* @display_name: the name of the display to open
* @returns: a #GdkDisplay, or %NULL if the display
* could not be opened.
*
* Opens a display.
*
* Since: 2.2
*/
GdkDisplay *
gdk_display_open (const gchar *display_name)
{
GdkDisplay *display;
GdkDisplayMacOSX *display_macosx;
GdkWindowAttr attr;
NSArray *screens;
NSScreen *current_screen;
NSScreen *default_screen;
NSEnumerator *iter;
int screen_count, i;
display = g_object_new (GDK_TYPE_DISPLAY_MACOSX, NULL);
display_macosx = GDK_DISPLAY_MACOSX (display);
/* initialize the display's screens */
screens = [NSScreen screens];
screen_count = [screens count];
display_macosx->screens = g_new (GdkScreen *, screen_count);
default_screen = [NSScreen mainScreen];
iter = [screens objectEnumerator];
i = 0;
while (current_screen = [iter nextObject]) {
display_macosx->screens[i] = _gdk_macosx_screen_new (display, current_screen);
if (current_screen == default_screen) {
display_macosx->default_screen = display_macosx->screens[i];
}
i++;
if(i == screen_count) {
g_warning("screen count changes\n");
/* FIXME don't leake */
return NULL;
}
}
display_macosx->num_screens = i;
display_macosx->nsview_ht = NULL;
/* just make sure we have a NSApplication created */
[NSApplication sharedApplication];
/* FIXME make all of this is OK */
/*
_gdk_windowing_image_init (display);
_gdk_events_init (display);
_gdk_input_init (display);
_gdk_dnd_init (display);
*/
g_signal_emit_by_name (gdk_display_manager_get(),
"display_opened", display);
return display;
}
/**
* gdk_display_get_name:
* @display: a #GdkDisplay
*
* Gets the name of the display.
*
* Returns: a string representing the display name. This string is owned
* by GDK and should not be modified or freed.
*
* Since: 2.2
*/
G_CONST_RETURN gchar *
gdk_display_get_name (GdkDisplay * display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return "";
}
/**
* gdk_display_get_n_screens:
* @display: a #GdkDisplay
*
* Gets the number of screen managed by the @display.
*
* Returns: number of screens.
*
* Since: 2.2
*/
gint
gdk_display_get_n_screens (GdkDisplay * display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
return [[NSScreen screens] count];
}
/**
* gdk_display_get_screen:
* @display: a #GdkDisplay
* @screen_num: the screen number
*
* Returns a screen object for one of the screens of the display.
*
* Returns: the #GdkScreen object
*
* Since: 2.2
*/
GdkScreen *
gdk_display_get_screen (GdkDisplay * display, gint screen_num)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail ((GDK_DISPLAY_MACOSX (display)->num_screens) > screen_num, NULL);
return GDK_DISPLAY_MACOSX (display)->screens[screen_num];
}
/**
* gdk_display_get_default_screen:
* @display: a #GdkDisplay
*
* Get the default #GdkScreen for @display.
*
* Returns: the default #GdkScreen object for @display
*
* Since: 2.2
*/
GdkScreen *
gdk_display_get_default_screen (GdkDisplay * display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return GDK_DISPLAY_MACOSX (display)->default_screen;
}
/**
* gdk_display_pointer_ungrab:
* @display: a #GdkDisplay.
* @time_: a timestap (e.g. GDK_CURRENT_TIME).
*
* Release any pointer grab.
*
* Since: 2.2
*/
void
gdk_display_pointer_ungrab (GdkDisplay *display,
guint32 time)
{
// FIXME nothing to do
}
/**
* gdk_display_pointer_is_grabbed:
* @display: a #GdkDisplay
*
* Test if the pointer is grabbed.
*
* Returns: %TRUE if an active X pointer grab is in effect
*
* Since: 2.2
*/
gboolean
gdk_display_pointer_is_grabbed (GdkDisplay * display)
{
// FIXME I don't think we have grabs. Maybe should we
// store that state in the GdkDisplay....
return false;
}
/**
* gdk_display_keyboard_ungrab:
* @display: a #GdkDisplay.
* @time_: a timestap (e.g #GDK_CURRENT_TIME).
*
* Release any keyboard grab
*
* Since: 2.2
*/
void
gdk_display_keyboard_ungrab (GdkDisplay *display,
guint32 time)
{
}
/**
* gdk_display_beep:
* @display: a #GdkDisplay
*
* Emits a short beep on @display
*
* Since: 2.2
*/
void
gdk_display_beep (GdkDisplay * display)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
NSBeep();
}
/**
* gdk_display_sync:
* @display: a #GdkDisplay
*
* Flushes any requests queued for the windowing system and waits until all
* requests have been handled. This is often used for making sure that the
* display is synchronized with the current state of the program. Calling
* gdk_display_sync() before gdk_error_trap_pop() makes sure that any errors
* generated from earlier requests are handled before the error trap is
* removed.
*
* This is most useful for X11. On windowing systems where requests are
* handled synchronously, this function will do nothing.
*
* Since: 2.2
*/
void
gdk_display_sync (GdkDisplay * display)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
/* FIXME see if we can do something with CoreGraphics */
}
/**
* gdk_display_flush:
* @display: a #GdkDisplay
*
* Flushes any requests queued for the windowing system; this happens automatically
* when the main loop blocks waiting for new events, but if your application
* is drawing without returning control to the main loop, you may need
* to call this function explicitely. A common case where this function
* needs to be called is when an application is executing drawing commands
* from a thread other than the thread where the main loop is running.
*
* This is most useful for X11. On windowing systems where requests are
* handled synchronously, this function will do nothing.
*
* Since: 2.4
*/
void
gdk_display_flush (GdkDisplay *display)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
/* FIXME see if we can do something with CoreGraphics */
}
/**
* gdk_display_get_default_group:
* @display: a #GdkDisplay
*
* Returns the default group leader window for all toplevel windows
* on @display. This window is implicitly created by GDK.
* See gdk_window_set_group().
*
* Return value: The default group leader window for @display
*
* Since: 2.4
**/
GdkWindow *gdk_display_get_default_group (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_warning ("gdk_display_get_default_group not yet implemented");
return NULL;
}
/**
* gdk_macosx_display_grab:
* @display: a #GdkDisplay
*
* Call XGrabServer() on @display.
* To ungrab the display again, use gdk_macosx_display_ungrab().
*
* gdk_macosx_display_grab()/gdk_macosx_display_ungrab() calls can be nested.
*
* Since: 2.2
**/
void
gdk_macosx_display_grab (GdkDisplay * display)
{
}
/**
* gdk_macosx_display_ungrab:
* @display: a #GdkDisplay
*
* Ungrab @display after it has been grabbed with
* gdk_macosx_display_grab().
*
* Since: 2.2
**/
void
gdk_macosx_display_ungrab (GdkDisplay * display)
{
}
static void
gdk_display_macosx_dispose (GObject *object)
{
GdkDisplayMacOSX *display_macosx;
gint i;
display_macosx = GDK_DISPLAY_MACOSX (object);
for (i = 0; i < display_macosx->num_screens; i++) {
_gdk_screen_close (display_macosx->screens[i]);
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gdk_display_macosx_finalize (GObject *object)
{
GdkDisplayMacOSX *display_macosx = GDK_DISPLAY_MACOSX (object);
g_free (display_macosx->screens);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
void
_gdk_windowing_set_default_display (GdkDisplay *display)
{
/* FIXME */
g_warning ("_gdk_windowing_set_default_display() not implemented on MacOS X\n");
}
/**
* gdk_notify_startup_complete:
*
* Indicates to the GUI environment that the application has finished
* loading. If the applications opens windows, this function is
* normally called after opening the application's initial set of
* windows.
*
* GTK+ will call this function automatically after opening the first
* #GtkWindow unless gtk_window_set_auto_startup_notification() is called
* to disable that feature.
*
* Since: 2.2
**/
void
gdk_notify_startup_complete (void)
{
/* FIXME */
g_warning ("gdk_notify_startup_complete () not implemented on MacOS X\n");
}
/**
* gdk_display_supports_selection_notification:
* @display: a #GdkDisplay
*
* Returns whether #GdkEventOwnerChange events will be
* sent when the owner of a selection changes.
*
* Return value: whether #GdkEventOwnerChange events will
* be sent.
*
* Since: 2.6
**/
gboolean
gdk_display_supports_selection_notification (GdkDisplay *display)
{
/* FIXME I'm not sure we support that */
return FALSE;
}
/**
* gdk_display_request_selection_notification:
* @display: a #GdkDisplay
* @selection: the #GdkAtom naming the selection for which
* ownership change notification is requested
*
* Request #GdkEventOwnerChange events for ownership changes
* of the selection named by the given atom.
*
* Return value: whether #GdkEventOwnerChange events will
* be sent.
*
* Since: 2.6
**/
gboolean gdk_display_request_selection_notification (GdkDisplay *display,
GdkAtom selection)
{
/* FIXME I'm not sure we support that */
return FALSE;
}
/**
* gdk_display_supports_clipboard_persistence
* @display: a #GdkDisplay
*
* Returns whether the speicifed display supports clipboard
* persistance; i.e. if it's possible to store the clipboard data after an
* application has quit. On MacOSX this checks if a clipboard daemon is
* running.
*
* Returns: %TRUE if the display supports clipboard persistance.
*
* Since: 2.6
*/
gboolean
gdk_display_supports_clipboard_persistence (GdkDisplay *display)
{
/* It might make sense to cache this */
return TRUE;
}
/**
* gdk_display_store_clipboard
* @display: a #GdkDisplay
* @clipboard_window: a #GdkWindow belonging to the clipboard owner
* @time_: a timestamp
* @targets: an array of targets that should be saved, or %NULL
* if all available targets should be saved.
* @n_targets: length of the @targets array
*
* Issues a request to the clipboard manager to store the
* clipboard data.
*
* Since: 2.6
*/
void
gdk_display_store_clipboard (GdkDisplay *display,
GdkWindow *clipboard_window,
guint32 time_,
GdkAtom *targets,
gint n_targets)
{
/* FIXME */
g_warning ("gdk_display_store_clipboard() not implemented on MacOS X\n");
}

View File

@@ -0,0 +1,103 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_DRAWABLE_MACOSX_H__
#define __GDK_DRAWABLE_MACOSX_H__
#include <config.h>
#include <gdk/gdkdrawable.h>
#include <ApplicationServices/ApplicationServices.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Drawable implementation for MacOSX
*/
typedef enum
{
GDK_MACOSX_FORMAT_NONE,
GDK_MACOSX_FORMAT_EXACT_MASK,
GDK_MACOSX_FORMAT_ARGB_MASK,
GDK_MACOSX_FORMAT_ARGB
} GdkMacOSXFormatType;
typedef struct _GdkDrawableImplMacOSX GdkDrawableImplMacOSX;
typedef struct _GdkDrawableImplMacOSXClass GdkDrawableImplMacOSXClass;
#define GDK_TYPE_DRAWABLE_IMPL_MACOSX (_gdk_drawable_impl_macosx_get_type ())
#define GDK_DRAWABLE_IMPL_MACOSX(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAWABLE_IMPL_MACOSX, GdkDrawableImplMacOSX))
#define GDK_DRAWABLE_IMPL_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAWABLE_IMPL_MACOSX, GdkDrawableImplMacOSXClass))
#define GDK_IS_DRAWABLE_IMPL_MACOSX(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAWABLE_IMPL_MACOSX))
#define GDK_IS_DRAWABLE_IMPL_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAWABLE_IMPL_MACOSX))
#define GDK_DRAWABLE_IMPL_MACOSX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAWABLE_IMPL_MACOSX, GdkDrawableImplMacOSXClass))
struct _GdkDrawableImplMacOSX
{
GdkDrawable parent_instance;
GdkDrawable *wrapper;
GdkColormap *colormap;
CGContextRef cg;
};
struct _GdkDrawableImplMacOSXClass
{
GdkDrawableClass parent_class;
};
GType _gdk_drawable_impl_macosx_get_type (void);
void _gdk_macosx_convert_to_format (guchar *src_buf,
gint src_rowstride,
guchar *dest_buf,
gint dest_rowstride,
GdkMacOSXFormatType dest_format,
GdkByteOrder dest_byteorder,
gint width,
gint height);
/* Note that the following take GdkDrawableImplMacOSX, not the wrapper drawable */
/*
void _gdk_macosx_drawable_draw_xtrapezoids (GdkDrawable *drawable,
GdkGC *gc,
XTrapezoid *xtrapezoids,
int n_trapezoids);
void _gdk_macosx_drawable_draw_xft_glyphs (GdkDrawable *drawable,
GdkGC *gc,
XftFont *xft_font,
XftGlyphSpec *glyphs,
gint n_glyphs);
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GDK_DRAWABLE_MacOSX_H__ */

View File

@@ -0,0 +1,88 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
* Copyright (C) 2005 Hubert Figuiere
*
* 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
/*
* MacOS X port by Hubert Figuiere
*/
#include <config.h>
#include "gdk.h"
#include "gdkinternals.h"
#include <Carbon/Carbon.h>
/*
* Currently does nothing
*/
void
gdk_flush (void)
{
}
/**
* gdk_event_send_client_message_for_display:
* @display: the #GdkDisplay for the window where the message is to be sent.
* @event: the #GdkEvent to send, which should be a #GdkEventClient.
* @winid: the window to send the client message to.
*
* On X11, sends an X ClientMessage event to a given window. On
* Windows, sends a message registered with the name
* GDK_WIN32_CLIENT_MESSAGE.
*
* This could be used for communicating between different
* applications, though the amount of data is limited to 20 bytes on
* X11, and to just four bytes on Windows.
*
* Returns: non-zero on success.
*
* Since: 2.2
*/
gboolean
gdk_event_send_client_message_for_display (GdkDisplay *display,
GdkEvent *event,
GdkNativeWindow winid)
{
/* FIXME */
g_assert(false);
return false;
}
void
_gdk_events_queue (GdkDisplay *display)
{
while (!_gdk_event_queue_find_first(display))
{
/* FIXME */
}
}

File diff suppressed because it is too large Load Diff

1306
gdk/macosx/gdkgc-macosx.m Normal file

File diff suppressed because it is too large Load Diff

55
gdk/macosx/gdkmacosx.h Normal file
View File

@@ -0,0 +1,55 @@
#ifndef __GDK_MACOSX_H__
#define __GDK_MACOSX_H__
#include <gdk/gdk.h>
#include <Cocoa/Cocoa.h>
#define GDK_WINDOW_NSVIEW(win) (GDK_WINDOW_IMPL_MACOSX(win)->v)
GdkWindow *gdk_nsview_table_lookup_for_display(GdkDisplay *display,
GdkNativeWindow anid);
void _gdk_nsview_table_insert (GdkDisplay *display,
GdkNativeWindow anid,
GdkWindow *window);
inline static GdkRectangle ns_to_gdkrect(NSRect r)
{
GdkRectangle dest;
dest.x = r.origin.x;
dest.y = r.origin.y;
dest.width = r.size.width;
dest.height = r.size.height;
return dest;
}
inline static GdkModifierType ns_to_gdk_modifier(int modifier)
{
GdkModifierType dest = 0;
if (modifier & NSAlphaShiftKeyMask) {
dest |= GDK_LOCK_MASK;
}
if (modifier & NSShiftKeyMask) {
dest |= GDK_SHIFT_MASK;
}
if (modifier & NSControlKeyMask) {
dest |= GDK_CONTROL_MASK;
}
if (modifier & NSAlternateKeyMask) {
dest |= GDK_MOD1_MASK;
}
if (modifier & NSCommandKeyMask) {
dest != GDK_MOD2_MASK;
}
return dest;
}
#endif

View File

@@ -0,0 +1,42 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
* Copyright (C) 1998-2002 Tor Lillqvist
* Copyright (C) 2005 Hubert Figuiere
*
* 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 "gdk.h"
void
_gdk_windowing_display_set_sm_client_id (GdkDisplay *display,
const gchar *sm_client_id)
{
g_warning("gdk_set_sm_client_id %s", sm_client_id ? sm_client_id : "NULL");
}

View File

@@ -0,0 +1,127 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include <config.h>
#include "gdkalias.h"
#include "gdkprivate-macosx.h"
#include "gdkdisplay-macosx.h"
#include <stdio.h>
@class NSView;
static guint gdk_nsview_hash (NSView **v);
static gboolean gdk_nsview_equal (NSView **a, NSView **b);
void
_gdk_nsview_table_insert (GdkDisplay *display,
NSView *v,
gpointer data)
{
GdkDisplayMacOSX *display_macosx;
g_return_if_fail (v != NULL);
g_return_if_fail (GDK_IS_DISPLAY (display));
display_macosx = GDK_DISPLAY_MACOSX (display);
if (!display_macosx->nsview_ht)
display_macosx->nsview_ht = g_hash_table_new ((GHashFunc) gdk_nsview_hash,
(GEqualFunc) gdk_nsview_equal);
g_hash_table_insert (display_macosx->nsview_ht, v, data);
}
void
_gdk_xid_table_remove (GdkDisplay *display,
NSView *v)
{
GdkDisplayMacOSX *display_macosx;
g_return_if_fail (GDK_IS_DISPLAY(display));
display_macosx = GDK_DISPLAY_MACOSX(display);
if (display_macosx->nsview_ht)
g_hash_table_remove (display_macosx->nsview_ht, &v);
}
/**
* gdk_xid_table_lookup_for_display:
* @display: the #GdkDisplay.
* @xid: an X id.
*
* Returns the GDK object associated with the given X id.
*
* Returns: a GDK object associated with the given X id.
*
* Since: 2.2
*/
gpointer
gdk_nsview_table_lookup_for_display (GdkDisplay *display,
NSView *v)
{
GdkDisplayMacOSX *display_macosx;
gpointer data = NULL;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
display_macosx = GDK_DISPLAY_MACOSX (display);
if (display_macosx->nsview_ht)
data = g_hash_table_lookup (display_macosx->nsview_ht, &v);
return data;
}
/**
* gdk_xid_table_lookup:
* @xid: an X id.
*
* Returns the Gdk object associated with the given X id.
*
* Return value: the associated Gdk object, which may be a #GdkPixmap,
* a #GdkWindow or a #GdkFont.
**/
gpointer
gdk_nsview_table_lookup (NSView *v)
{
return gdk_nsview_table_lookup_for_display (gdk_display_get_default (), v);
}
static guint
gdk_nsview_hash (NSView **v)
{
return (guint)*v;
}
static gboolean
gdk_nsview_equal (NSView **a,
NSView **b)
{
return (*a == *b);
}

View File

@@ -0,0 +1,11 @@
#include <config.h>
#include <glib.h>
#include "gdkpango.h"
#include <pango/pangoft2.h>
PangoContext *
gdk_pango_context_get_for_screen (GdkScreen *screen)
{
return pango_ft2_get_context (75.0, 75.0);
}

View File

@@ -0,0 +1,70 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_PIXMAP_MACOSX_H__
#define __GDK_PIXMAP_MACOSX_H__
#include <gdk/macosx/gdkdrawable-macosx.h>
#include <gdk/gdkpixmap.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Pixmap implementation for MacOSX
*/
typedef struct _GdkPixmapImplMacOSX GdkPixmapImplMacOSX;
typedef struct _GdkPixmapImplMacOSXClass GdkPixmapImplMacOSXClass;
#define GDK_TYPE_PIXMAP_IMPL_MacOSX (gdk_pixmap_impl_macosx_get_type ())
#define GDK_PIXMAP_IMPL_MACOSX(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXMAP_IMPL_MacOSX, GdkPixmapImplMacOSX))
#define GDK_PIXMAP_IMPL_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXMAP_IMPL_MACOSX, GdkPixmapImplMacOSXClass))
#define GDK_IS_PIXMAP_IMPL_MACOSX(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXMAP_IMPL_MacOSX))
#define GDK_IS_PIXMAP_IMPL_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXMAP_IMPL_MACOSX))
#define GDK_PIXMAP_IMPL_MACOSX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXMAP_IMPL_MACOSX, GdkPixmapImplMacOSXClass))
struct _GdkPixmapImplMacOSX
{
GdkDrawableImplMacOSX parent_instance;
gint width;
gint height;
guint is_foreign : 1;
};
struct _GdkPixmapImplMacOSXClass
{
GdkDrawableImplMacOSXClass parent_class;
};
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GDK_PIXMAP_MacOSX_H__ */

View File

@@ -0,0 +1,217 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
/*
* Private uninstalled header defining things local to X windowing code
*/
#ifndef __GDK_PRIVATE_MacOSX_H__
#define __GDK_PRIVATE_MacOSX_H__
#include <gdk/gdkcursor.h>
#include <gdk/gdkprivate.h>
#include <gdk/macosx/gdkwindow-macosx.h>
#include <gdk/macosx/gdkpixmap-macosx.h>
#include <gdk/macosx/gdkdisplay-macosx.h>
#include <ApplicationServices/ApplicationServices.h>
#include "gdkinternals.h"
#include <config.h>
#define GDK_TYPE_GC_MACOSX (_gdk_gc_macosx_get_type ())
#define GDK_GC_MACOSX(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_MACOSX, GdkGCMacOSX))
#define GDK_GC_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GC_MACOSX, GdkGCMacOSXClass))
#define GDK_IS_GC_MACOSX(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GC_MACOSX))
#define GDK_IS_GC_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GC_MACOSX))
#define GDK_GC_MACOSX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GC_MACOSX, GdkGCMacOSXClass))
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkVisualPrivate GdkVisualPrivate;
typedef struct _GdkGCMacOSX GdkGCMacOSX;
typedef struct _GdkGCMacOSXClass GdkGCMacOSXClass;
struct _GdkGCMacOSX
{
GdkGC parent_instance;
CGContextRef cggc;
GdkScreen *screen;
GdkRegion *clip_region;
guint16 dirty_mask;
guint have_clip_mask : 1;
guint depth : 8;
GdkFill fill;
GdkBitmap *stipple;
GdkPixmap *tile;
//cture fg_picture;
//enderColor fg_picture_color;
CGColorRef stroke_color;
CGColorRef fill_color;
};
struct _GdkGCMacOSXClass
{
GdkGCClass parent_class;
};
struct _GdkCursorPrivate
{
GdkCursor cursor;
Cursor xcursor;
GdkDisplay *display;
};
struct _GdkVisualPrivate
{
GdkVisual visual;
//Visual *xvisual;
GdkScreen *screen;
};
/*
void _gdk_xid_table_insert (GdkDisplay *display,
XID *xid,
gpointer data);
void _gdk_xid_table_remove (GdkDisplay *display,
XID xid);
gint _gdk_send_xevent (GdkDisplay *display,
Window window,
gboolean propagate,
glong event_mask,
XEvent *event_send);
*/
GType _gdk_gc_macosx_get_type (void);
gboolean _gdk_macosx_have_render (GdkDisplay *display);
gboolean _gdk_macosx_have_render_with_trapezoids (GdkDisplay *display);
/*
Picture _gdk_macosx_gc_get_fg_picture (GdkGC *gc);
void _gdk_gc_macosx_get_fg_xft_color (GdkGC *gc,
XftColor *xftcolor);
*/
GdkGC *_gdk_macosx_gc_new (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask values_mask);
GdkImage *_gdk_macosx_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height);
//Pixmap _gdk_macosx_image_get_shm_pixmap (GdkImage *image);
/* Routines from gdkgeometry-macosx.c */
void _gdk_window_init_position (GdkWindow *window);
void _gdk_window_move_resize_child (GdkWindow *window,
gint x,
gint y,
gint width,
gint height);
void _gdk_window_process_expose (GdkWindow *window,
gulong serial,
GdkRectangle *area);
void _gdk_selection_window_destroyed (GdkWindow *window);
//gboolean _gdk_selection_filter_clear_event (XSelectionClearEvent *event);
/*
void _gdk_region_get_xrectangles (GdkRegion *region,
gint x_offset,
gint y_offset,
XRectangle **rects,
gint *n_rects);
*/
//gboolean _gdk_moveresize_handle_event (XEvent *event);
gboolean _gdk_moveresize_configure_done (GdkDisplay *display,
GdkWindow *window);
void _gdk_keymap_state_changed (GdkDisplay *display);
void _gdk_keymap_keys_changed (GdkDisplay *display);
gint _gdk_macosx_get_group_for_state (GdkDisplay *display,
GdkModifierType state);
CGContextRef _gdk_macosx_gc_flush (GdkGC *gc);
void _gdk_macosx_initialize_locale (void);
/*
void _gdk_xgrab_check_unmap (GdkWindow *window,
gulong serial);
void _gdk_xgrab_check_destroy (GdkWindow *window);
gboolean _gdk_macosx_display_is_root_window (GdkDisplay *display,
Window xroot_window);
void _gdk_macosx_precache_atoms (GdkDisplay *display,
const gchar * const *atom_names,
gint n_atoms);
*/
void _gdk_macosx_events_init_screen (GdkScreen *screen);
void _gdk_macosx_events_uninit_screen (GdkScreen *screen);
void _gdk_events_init (GdkDisplay *display);
void _gdk_windowing_window_init (GdkScreen *screen);
void _gdk_visual_init (GdkScreen *screen);
void _gdk_dnd_init (GdkDisplay *display);
void _gdk_windowing_image_init (GdkDisplay *display);
void _gdk_input_init (GdkDisplay *display);
/*
PangoRenderer *_gdk_macosx_renderer_get (GdkDrawable *drawable,
GdkGC *gc);
*/
extern GdkDrawableClass _gdk_macosx_drawable_class;
extern gboolean _gdk_use_xshm;
extern const int _gdk_nenvent_masks;
extern const int _gdk_event_mask_table[];
extern GdkAtom _gdk_selection_property;
extern gboolean _gdk_synchronize;
#define GDK_PIXMAP_SCREEN(pix) (GDK_DRAWABLE_IMPL_MACOSX (((GdkPixmapObject *)pix)->impl)->screen)
#define GDK_PIXMAP_DISPLAY(pix) (GDK_SCREEN_MACOSX (GDK_PIXMAP_SCREEN (pix))->display)
#define GDK_PIXMAP_XROOTWIN(pix) (GDK_SCREEN_MACOSX (GDK_PIXMAP_SCREEN (pix))->xroot_window)
#define GDK_DRAWABLE_DISPLAY(win) (GDK_IS_WINDOW (win) ? GDK_WINDOW_DISPLAY (win) : GDK_PIXMAP_DISPLAY (win))
#define GDK_DRAWABLE_SCREEN(win) (GDK_IS_WINDOW (win) ? GDK_WINDOW_SCREEN (win) : GDK_PIXMAP_SCREEN (win))
#define GDK_DRAWABLE_XROOTWIN(win) (GDK_IS_WINDOW (win) ? GDK_WINDOW_XROOTWIN (win) : GDK_PIXMAP_XROOTWIN (win))
#define GDK_SCREEN_DISPLAY(screen) (GDK_SCREEN_MACOSX (screen)->display)
#define GDK_SCREEN_XROOTWIN(screen) (GDK_SCREEN_MACOSX (screen)->xroot_window)
#define GDK_WINDOW_SCREEN(win) (GDK_DRAWABLE_IMPL_MACOSX (((GdkWindowObject *)win)->impl)->screen)
#define GDK_WINDOW_DISPLAY(win) (GDK_SCREEN_MACOSX (GDK_WINDOW_SCREEN (win))->display)
#define GDK_WINDOW_XROOTWIN(win) (GDK_SCREEN_MACOSX (GDK_WINDOW_SCREEN (win))->xroot_window)
#define GDK_GC_DISPLAY(gc) (GDK_SCREEN_DISPLAY (GDK_GC_MACOSX(gc)->screen))
#endif /* __GDK_PRIVATE_MACOSX_H__ */

View File

@@ -0,0 +1,70 @@
/*
* gdkscreen-macosx.h
*
* Copyright 2001 Sun Microsystems Inc.
*
* Erwann Chenede <erwann.chenede@sun.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library 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.
*/
#ifndef __GDK_SCREEN_MACOSX_H__
#define __GDK_SCREEN_MACOSX_H__
#include "gdkprivate-macosx.h"
//#include "xsettings-client.h"
#include <gdk/gdkscreen.h>
#include <gdk/gdkvisual.h>
G_BEGIN_DECLS
typedef struct _GdkScreenMacOSX GdkScreenMacOSX;
typedef struct _GdkScreenMacOSXClass GdkScreenMacOSXClass;
#define GDK_TYPE_SCREEN_MACOSX (_gdk_screen_macosx_get_type ())
#define GDK_SCREEN_MACOSX(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_SCREEN_MACOSX, GdkScreenMacOSX))
#define GDK_SCREEN_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_SCREEN_MACOSX, GdkScreenMacOSXClass))
#define GDK_IS_SCREEN_MACOSX(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_SCREEN_MACOSX))
#define GDK_IS_SCREEN_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_SCREEN_MACOSX))
#define GDK_SCREEN_MACOSX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_SCREEN_MACOSX, GdkScreenMacOSXClass))
@class NSEvent;
@class NSScreen;
struct _GdkScreenMacOSX
{
GdkScreen parent_instance;
GdkDisplay *display;
GdkWindow *root_window;
GdkColormap *default_colormap;
};
struct _GdkScreenMacOSXClass
{
GdkScreenClass parent_class;
};
GType _gdk_screen_macosx_get_type (void);
GdkScreen * _gdk_macosx_screen_new (GdkDisplay *display,
NSScreen *screen);
void _gdk_macosx_screen_size_changed (GdkScreen *screen,
NSEvent *event);
G_END_DECLS
#endif /* __GDK_SCREEN_MacOSX_H__ */

View File

@@ -0,0 +1,452 @@
/*
* gdkscreen-macosx.c
*
* Copyright 2001 Sun Microsystems Inc.
* Copyright 2005 Hubert Figuiere
*
* Hubert Figuiere <hub@figuiere.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library 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 <stdlib.h>
#include <string.h>
#include <Cocoa/Cocoa.h>
#include <glib.h>
#include "gdkmacosx.h"
#include "gdkalias.h"
#include "gdkscreen.h"
#include "gdkscreen-macosx.h"
#include "gdkdisplay.h"
#include "gdkdisplay-macosx.h"
static void gdk_screen_macosx_class_init (GdkScreenMacOSXClass *klass);
static void gdk_screen_macosx_dispose (GObject *object);
static void gdk_screen_macosx_finalize (GObject *object);
static void init_xinerama_support (GdkScreen *screen);
static void init_randr_support (GdkScreen *screen);
enum
{
WINDOW_MANAGER_CHANGED,
LAST_SIGNAL
};
static gpointer parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
GType
_gdk_screen_macosx_get_type (void)
{
static GType object_type = 0;
if (!object_type)
{
static const GTypeInfo object_info =
{
sizeof (GdkScreenMacOSXClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gdk_screen_macosx_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkScreenMacOSX),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
object_type = g_type_register_static (GDK_TYPE_SCREEN,
"GdkScreenMacOSX",
&object_info, 0);
}
return object_type;
}
static void
gdk_screen_macosx_class_init (GdkScreenMacOSXClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gdk_screen_macosx_dispose;
object_class->finalize = gdk_screen_macosx_finalize;
parent_class = g_type_class_peek_parent (klass);
}
/**
* gdk_screen_get_display:
* @screen: a #GdkScreen
*
* Gets the display to which the @screen belongs.
*
* Returns: the display to which @screen belongs
*
* Since: 2.2
**/
GdkDisplay *
gdk_screen_get_display (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
return GDK_SCREEN_MACOSX (screen)->display;
}
/**
* gdk_screen_get_width:
* @screen: a #GdkScreen
*
* Gets the width of @screen in pixels
*
* Returns: the width of @screen in pixels.
*
* Since: 2.2
**/
gint
gdk_screen_get_width (GdkScreen *screen)
{
NSArray *all_screens;
NSRect frame;
NSScreen *ns_screen;
NSEnumerator *iter;
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
frame = NSMakeRect(0,0,0,0);
all_screens = [NSScreen screens];
iter = [all_screens objectEnumerator];
while(ns_screen = [iter nextObject])
{
frame = NSUnionRect(frame, [ns_screen frame]);
}
return frame.size.width;
}
/**
* gdk_screen_get_height:
* @screen: a #GdkScreen
*
* Gets the height of @screen in pixels
*
* Returns: the height of @screen in pixels.
*
* Since: 2.2
**/
gint
gdk_screen_get_height (GdkScreen *screen)
{
NSArray *all_screens;
NSRect frame;
NSScreen *ns_screen;
NSEnumerator *iter;
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
frame = NSMakeRect(0,0,0,0);
all_screens = [NSScreen screens];
iter = [all_screens objectEnumerator];
while(ns_screen = [iter nextObject])
{
frame = NSUnionRect(frame, [ns_screen frame]);
}
return frame.size.height;
}
static NSSize
_gdk_screen_get_dpi(GdkScreen *screen)
{
NSSize s;
NSScreen *ns_screen = [NSScreen mainScreen];
NSDictionary *props = [ns_screen deviceDescription];
s = [[props objectForKey:NSDeviceResolution] size];
return s;
}
/*
@"NSScreenNumber"
*/
/**
* gdk_screen_get_width_mm:
* @screen: a #GdkScreen
*
* Gets the width of @screen in millimeters.
* Note that on some X servers this value will not be correct.
*
* Returns: the width of @screen in pixels.
*
* Since: 2.2
**/
gint
gdk_screen_get_width_mm (GdkScreen *screen)
{
NSSize s;
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
s = _gdk_screen_get_dpi(screen);
return gdk_screen_get_width(screen) / (s.width / 25.4);
}
/**
* gdk_screen_get_height_mm:
* @screen: a #GdkScreen
*
* Returns the height of @screen in millimeters.
* Note that on some X servers this value will not be correct.
*
* Returns: the heigth of @screen in pixels.
*
* Since: 2.2
**/
gint
gdk_screen_get_height_mm (GdkScreen *screen)
{
NSSize s;
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
s = _gdk_screen_get_dpi(screen);
return gdk_screen_get_height(screen) / (s.height / 25.4);
}
/**
* gdk_screen_get_number:
* @screen: a #GdkScreen
*
* Gets the index of @screen among the screens in the display
* to which it belongs. (See gdk_screen_get_display())
*
* Returns: the index
*
* Since: 2.2
**/
gint
gdk_screen_get_number (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return 0;
}
/**
* gdk_screen_get_root_window:
* @screen: a #GdkScreen
*
* Gets the root window of @screen.
*
* Returns: the root window
*
* Since: 2.2
**/
GdkWindow *
gdk_screen_get_root_window (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
// FIXME
return NULL;
}
/**
* gdk_screen_get_default_colormap:
* @screen: a #GdkScreen
*
* Gets the default colormap for @screen.
*
* Returns: the default #GdkColormap.
*
* Since: 2.2
**/
GdkColormap *
gdk_screen_get_default_colormap (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
return GDK_SCREEN_MACOSX (screen)->default_colormap;
}
/**
* gdk_screen_set_default_colormap:
* @screen: a #GdkScreen
* @colormap: a #GdkColormap
*
* Sets the default @colormap for @screen.
*
* Since: 2.2
**/
void
gdk_screen_set_default_colormap (GdkScreen *screen,
GdkColormap *colormap)
{
GdkColormap *old_colormap;
g_return_if_fail (GDK_IS_SCREEN (screen));
g_return_if_fail (GDK_IS_COLORMAP (colormap));
old_colormap = GDK_SCREEN_MACOSX (screen)->default_colormap;
GDK_SCREEN_MACOSX (screen)->default_colormap = g_object_ref (colormap);
if (old_colormap)
g_object_unref (old_colormap);
}
static void
gdk_screen_macosx_dispose (GObject *object)
{
GdkScreenMacOSX *screen_macosx = GDK_SCREEN_MACOSX (object);
//_gdk_macosx_events_uninit_screen (GDK_SCREEN (object));
g_object_unref (screen_macosx->default_colormap);
screen_macosx->default_colormap = NULL;
screen_macosx->root_window = NULL;
screen_macosx->display = NULL;
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gdk_screen_macosx_finalize (GObject *object)
{
GdkScreenMacOSX *screen_macosx = GDK_SCREEN_MACOSX (object);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
* gdk_screen_get_n_monitors:
* @screen: a #GdkScreen.
*
* Returns the number of monitors which @screen consists of.
*
* Returns: number of monitors which @screen consists of.
*
* Since: 2.2
**/
gint
gdk_screen_get_n_monitors (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return [[NSScreen screens] count];
}
/**
* gdk_screen_get_monitor_geometry:
* @screen : a #GdkScreen.
* @monitor_num: the monitor number.
* @dest : a #GdkRectangle to be filled with the monitor geometry
*
* Retrieves the #GdkRectangle representing the size and position of
* the individual monitor within the entire screen area.
*
* Note that the size of the entire screen area can be retrieved via
* gdk_screen_get_width() and gdk_screen_get_height().
*
* Since: 2.2
**/
void
gdk_screen_get_monitor_geometry (GdkScreen *screen,
gint monitor_num,
GdkRectangle *dest)
{
NSRect rect;
g_return_if_fail (GDK_IS_SCREEN (screen));
/* g_return_if_fail (monitor_num < GDK_SCREEN_MACOSX (screen)->num_monitors);
g_return_if_fail (monitor_num >= 0);*/
rect = [[[NSScreen screens] objectAtIndex:monitor_num] frame];
*dest = ns_to_gdkrect(rect);
}
GdkScreen *
_gdk_macosx_screen_new (GdkDisplay *display,
NSScreen *screen)
{
GdkScreen *gscreen;
GdkScreenMacOSX *screen_macosx;
GdkDisplayMacOSX *display_macosx = GDK_DISPLAY_MACOSX (display);
gscreen = g_object_new (GDK_TYPE_SCREEN_MACOSX, NULL);
screen_macosx = GDK_SCREEN_MACOSX (gscreen);
screen_macosx->display = display;
screen_macosx->default_colormap = NULL;
// screen_macosx->xroot_window = RootWindow (display_macosx->xdisplay,screen_number);
_gdk_visual_init (gscreen);
_gdk_windowing_window_init (gscreen);
return gscreen;
}
/**
* _gdk_windowing_substitute_screen_number:
* @display_name : The name of a display, in the form used by
* gdk_display_open (). If %NULL a default value
* will be used. On MacOSX, this is derived from the DISPLAY
* environment variable.
* @screen_number : The number of a screen within the display
* referred to by @display_name.
*
* Modifies a @display_name to make @screen_number the default
* screen when the display is opened.
*
* Return value: a newly allocated string holding the resulting
* display name. Free with g_free().
*/
gchar *
_gdk_windowing_substitute_screen_number (const gchar *display_name,
gint screen_number)
{
return g_strdup (display_name);
}
/**
* gdk_screen_make_display_name:
* @screen: a #GdkScreen
*
* Determines the name to pass to gdk_display_open() to get
* a #GdkDisplay with this screen as the default screen.
*
* Return value: a newly allocated string, free with g_free()
*
* Since: 2.2
**/
gchar *
gdk_screen_make_display_name (GdkScreen *screen)
{
return g_strdup ("");
}

View File

@@ -0,0 +1,106 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_WINDOW_MACOSX_H__
#define __GDK_WINDOW_MACOSX_H__
#include <gdk/macosx/gdkdrawable-macosx.h>
G_BEGIN_DECLS
typedef struct _GdkToplevelMacOSX GdkToplevelMacOSX;
typedef struct _GdkWindowImplMacOSX GdkWindowImplMacOSX;
typedef struct _GdkWindowImplMacOSXClass GdkWindowImplMacOSXClass;
typedef struct _GdkMacPositionInfo GdkMacPositionInfo;
struct _GdkMacPositionInfo
{
gint x;
gint y;
gint width;
gint height;
gint x_offset; /* Offsets to add to X coordinates within window */
gint y_offset; /* to get GDK coodinates within window */
guint big : 1;
guint mapped : 1;
guint no_bg : 1; /* Set when the window background is temporarily
* unset during resizing and scaling */
GdkRectangle clip_rect; /* visible rectangle of window */
};
/* Window implementation for MacOSX
*/
#define GDK_TYPE_WINDOW_IMPL_MACOSX (gdk_window_impl_macosx_get_type ())
#define GDK_WINDOW_IMPL_MACOSX(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL_MACOSX, GdkWindowImplMacOSX))
#define GDK_WINDOW_IMPL_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_IMPL_MACOSX, GdkWindowImplMacOSXClass))
#define GDK_IS_WINDOW_IMPL_MACOSX(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_IMPL_MACOSX))
#define GDK_IS_WINDOW_IMPL_MACOSX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL_MACOSX))
#define GDK_WINDOW_IMPL_MACOSX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL_MACOSX, GdkWindowImplMacOSXClass))
@class NSWindow;
@class NSView;
struct _GdkWindowImplMacOSX
{
GdkDrawableImplMacOSX parent_instance;
gint width;
gint height;
GdkMacPositionInfo position_info;
GdkToplevelMacOSX *toplevel; /* Toplevel-specific information */
gint8 toplevel_window_type;
NSView *v;
};
struct _GdkWindowImplMacOSXClass
{
GdkDrawableImplMacOSXClass parent_class;
};
struct _GdkToplevelMacOSX
{
NSWindow *w;
};
GType gdk_window_impl_macosx_get_type (void);
void gdk_macosx_window_set_user_time (GdkWindow *window,
guint32 timestamp);
GdkToplevelMacOSX *_gdk_macosx_window_get_toplevel (GdkWindow *window);
void _gdk_macosx_window_tmp_unset_bg (GdkWindow *window,
gboolean recurse);
void _gdk_macosx_window_tmp_reset_bg (GdkWindow *window,
gboolean recurse);
G_END_DECLS
#endif /* __GDK_WINDOW_MACOSX_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -658,20 +658,23 @@ gtkinclude_HEADERS = $(gtk_public_h_sources) $(gtk_semi_private_h_sources) $(gtk
libgtk_x11_2_0_la_SOURCES = $(gtk_c_sources) $(gtk_plug_c_sources)
libgtk_linux_fb_2_0_la_SOURCES = $(gtk_c_sources)
libgtk_win32_2_0_la_SOURCES = $(gtk_c_sources)
libgtk_macosx_2_0_la_SOURCES = $(gtk_c_sources)
libgtk_x11_2_0_la_LDFLAGS = $(libtool_opts)
libgtk_linux_fb_2_0_la_LDFLAGS = $(libtool_opts)
libgtk_win32_2_0_la_LDFLAGS = $(libtool_opts)
libgtk_macosx_2_0_la_LDFLAGS = $(libtool_opts)
libgtk_x11_2_0_la_LIBADD = $(libadd)
libgtk_linux_fb_2_0_la_LIBADD = $(libadd)
libgtk_win32_2_0_la_LIBADD = $(libadd) $(gtk_win32res_lo) -lole32 -lwsock32 -lgdi32
libgtk_win32_2_0_la_DEPENDENCIES = $(gtk_def) $(gtk_win32res_lo)
libgtk_macosx_2_0_la_LIBADD = $(libadd)
if USE_WIN32
libgtk_target_ldflags = $(gtk_win32_symbols)
endif
EXTRA_LTLIBRARIES = libgtk-x11-2.0.la libgtk-linux-fb-2.0.la libgtk-win32-2.0.la
EXTRA_LTLIBRARIES = libgtk-x11-2.0.la libgtk-linux-fb-2.0.la libgtk-win32-2.0.la libgtk-macosx-2.0.la
install-exec-hook:
if DISABLE_EXPLICIT_DEPS