2005-11-22 10:03:32 +00:00
|
|
|
/* gdkdisplay-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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2005-11-22 10:03:32 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2010-12-23 11:59:26 +00:00
|
|
|
#include <gdk/gdk.h>
|
|
|
|
#include <gdk/gdkdisplayprivate.h>
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
#include "gdkprivate-quartz.h"
|
2010-12-23 11:59:26 +00:00
|
|
|
#include "gdkquartzscreen.h"
|
2018-03-20 10:46:11 +00:00
|
|
|
#include "gdkquartzsurface.h"
|
2010-12-23 11:59:26 +00:00
|
|
|
#include "gdkquartzdisplay.h"
|
|
|
|
#include "gdkquartzdevicemanager-core.h"
|
2017-02-27 21:38:46 +00:00
|
|
|
#include "gdkmonitorprivate.h"
|
|
|
|
#include "gdkdisplay-quartz.h"
|
2018-04-12 14:48:31 +00:00
|
|
|
#include "gdkcairocontext-quartz.h"
|
2010-12-23 11:59:26 +00:00
|
|
|
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
static GdkSurface *
|
2010-12-22 02:13:02 +00:00
|
|
|
gdk_quartz_display_get_default_group (GdkDisplay *display)
|
2006-03-27 10:47:29 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
|
|
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
GdkDeviceManager *
|
|
|
|
_gdk_device_manager_new (GdkDisplay *display)
|
|
|
|
{
|
2010-12-22 16:30:29 +00:00
|
|
|
return g_object_new (GDK_TYPE_QUARTZ_DEVICE_MANAGER_CORE,
|
2010-05-25 22:38:44 +00:00
|
|
|
"display", display,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
GdkDisplay *
|
2010-12-17 16:38:02 +00:00
|
|
|
_gdk_quartz_display_open (const gchar *display_name)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
if (_gdk_display != NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2010-12-23 12:39:07 +00:00
|
|
|
_gdk_display = g_object_new (gdk_quartz_display_get_type (), NULL);
|
2017-11-24 17:03:36 +00:00
|
|
|
_gdk_device_manager = _gdk_device_manager_new (_gdk_display);
|
2009-10-24 09:48:39 +00:00
|
|
|
|
2010-12-23 12:43:29 +00:00
|
|
|
_gdk_screen = g_object_new (gdk_quartz_screen_get_type (), NULL);
|
2010-12-17 16:05:53 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_quartz_surface_init_windowing (_gdk_display);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2010-12-17 16:38:02 +00:00
|
|
|
_gdk_quartz_events_init ();
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2020-01-08 14:10:06 +00:00
|
|
|
/* Initialize application */
|
|
|
|
[NSApplication sharedApplication];
|
2005-11-22 10:03:32 +00:00
|
|
|
#if 0
|
|
|
|
/* FIXME: Remove the #if 0 when we have these functions */
|
2010-12-17 15:53:00 +00:00
|
|
|
_gdk_quartz_dnd_init ();
|
2005-11-22 10:03:32 +00:00
|
|
|
#endif
|
|
|
|
|
2013-04-17 22:00:00 +00:00
|
|
|
g_signal_emit_by_name (_gdk_display, "opened");
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
return _gdk_display;
|
|
|
|
}
|
|
|
|
|
2010-12-22 02:13:02 +00:00
|
|
|
static const gchar *
|
|
|
|
gdk_quartz_display_get_name (GdkDisplay *display)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2006-08-24 19:41:40 +00:00
|
|
|
static gchar *display_name = NULL;
|
|
|
|
|
2007-03-10 21:04:05 +00:00
|
|
|
if (!display_name)
|
|
|
|
{
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
display_name = g_strdup ([[[NSHost currentHost] name] UTF8String]);
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
}
|
2006-08-24 19:41:40 +00:00
|
|
|
|
|
|
|
return display_name;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2010-12-22 02:13:02 +00:00
|
|
|
static void
|
|
|
|
gdk_quartz_display_beep (GdkDisplay *display)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_DISPLAY (display));
|
|
|
|
|
|
|
|
NSBeep();
|
|
|
|
}
|
|
|
|
|
2010-12-23 13:08:40 +00:00
|
|
|
static void
|
|
|
|
gdk_quartz_display_sync (GdkDisplay *display)
|
|
|
|
{
|
|
|
|
/* Not supported. */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_quartz_display_flush (GdkDisplay *display)
|
|
|
|
{
|
|
|
|
/* Not supported. */
|
|
|
|
}
|
|
|
|
|
2010-12-22 02:13:02 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_quartz_display_supports_shapes (GdkDisplay *display)
|
2006-02-20 11:57:12 +00:00
|
|
|
{
|
|
|
|
/* FIXME: Implement */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-12-22 02:13:02 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_quartz_display_supports_input_shapes (GdkDisplay *display)
|
2006-02-20 11:57:12 +00:00
|
|
|
{
|
|
|
|
/* FIXME: Implement */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-12-23 12:39:07 +00:00
|
|
|
static gulong
|
|
|
|
gdk_quartz_display_get_next_serial (GdkDisplay *display)
|
2009-01-24 09:03:25 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2010-12-22 02:13:02 +00:00
|
|
|
|
2010-12-23 12:09:01 +00:00
|
|
|
static void
|
2010-12-23 12:39:07 +00:00
|
|
|
gdk_quartz_display_notify_startup_complete (GdkDisplay *display,
|
|
|
|
const gchar *startup_id)
|
2010-12-23 12:09:01 +00:00
|
|
|
{
|
|
|
|
/* FIXME: Implement? */
|
|
|
|
}
|
|
|
|
|
2017-02-27 21:38:46 +00:00
|
|
|
static int
|
|
|
|
gdk_quartz_display_get_n_monitors (GdkDisplay *display)
|
|
|
|
{
|
|
|
|
GdkQuartzDisplay *quartz_display = GDK_QUARTZ_DISPLAY (display);
|
|
|
|
|
|
|
|
return quartz_display->monitors->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GdkMonitor *
|
|
|
|
gdk_quartz_display_get_monitor (GdkDisplay *display,
|
|
|
|
int monitor_num)
|
|
|
|
{
|
|
|
|
GdkQuartzDisplay *quartz_display = GDK_QUARTZ_DISPLAY (display);
|
|
|
|
|
|
|
|
if (0 <= monitor_num || monitor_num < quartz_display->monitors->len)
|
|
|
|
return (GdkMonitor *)quartz_display->monitors->pdata[monitor_num];
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:42:49 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_quartz_display_get_setting (GdkDisplay *display,
|
|
|
|
const gchar *name,
|
|
|
|
GValue *value)
|
|
|
|
{
|
2017-11-17 18:29:14 +00:00
|
|
|
return _gdk_quartz_get_setting (name, value);
|
2017-10-30 20:42:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-23 12:39:07 +00:00
|
|
|
G_DEFINE_TYPE (GdkQuartzDisplay, gdk_quartz_display, GDK_TYPE_DISPLAY)
|
2010-12-22 02:13:02 +00:00
|
|
|
|
|
|
|
static void
|
2010-12-23 12:39:07 +00:00
|
|
|
gdk_quartz_display_init (GdkQuartzDisplay *display)
|
2010-12-22 02:13:02 +00:00
|
|
|
{
|
2017-02-27 21:38:46 +00:00
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
|
|
display->monitors = g_ptr_array_new_with_free_func (g_object_unref);
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
2010-12-17 16:38:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-23 12:39:07 +00:00
|
|
|
gdk_quartz_display_dispose (GObject *object)
|
2010-12-17 16:38:02 +00:00
|
|
|
{
|
2010-12-22 15:05:12 +00:00
|
|
|
GdkQuartzDisplay *display_quartz = GDK_QUARTZ_DISPLAY (object);
|
|
|
|
|
2017-02-27 21:38:46 +00:00
|
|
|
g_ptr_array_free (display_quartz->monitors, TRUE);
|
|
|
|
|
2010-12-23 12:39:07 +00:00
|
|
|
G_OBJECT_CLASS (gdk_quartz_display_parent_class)->dispose (object);
|
2010-12-22 02:13:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-23 12:39:07 +00:00
|
|
|
gdk_quartz_display_finalize (GObject *object)
|
2010-12-22 02:13:02 +00:00
|
|
|
{
|
2010-12-22 15:05:12 +00:00
|
|
|
GdkQuartzDisplay *display_quartz = GDK_QUARTZ_DISPLAY (object);
|
|
|
|
|
2010-12-23 12:39:07 +00:00
|
|
|
G_OBJECT_CLASS (gdk_quartz_display_parent_class)->finalize (object);
|
2010-12-22 02:13:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-23 12:39:07 +00:00
|
|
|
gdk_quartz_display_class_init (GdkQuartzDisplayClass *class)
|
2010-12-22 02:13:02 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
|
|
|
|
|
2010-12-23 12:39:07 +00:00
|
|
|
object_class->finalize = gdk_quartz_display_finalize;
|
2011-05-22 10:29:37 +00:00
|
|
|
object_class->dispose = gdk_quartz_display_dispose;
|
2010-12-22 02:13:02 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
display_class->surface_type = GDK_TYPE_QUARTZ_SURFACE;
|
2018-04-12 14:48:31 +00:00
|
|
|
display_class->cairo_context_type = GDK_TYPE_QUARTZ_CAIRO_CONTEXT;
|
2010-12-22 15:56:58 +00:00
|
|
|
|
2010-12-22 02:13:02 +00:00
|
|
|
display_class->get_name = gdk_quartz_display_get_name;
|
|
|
|
display_class->beep = gdk_quartz_display_beep;
|
2010-12-23 13:08:40 +00:00
|
|
|
display_class->sync = gdk_quartz_display_sync;
|
|
|
|
display_class->flush = gdk_quartz_display_flush;
|
2010-12-17 16:46:22 +00:00
|
|
|
display_class->queue_events = _gdk_quartz_display_queue_events;
|
|
|
|
display_class->has_pending = _gdk_quartz_display_has_pending;
|
2010-12-22 02:13:02 +00:00
|
|
|
display_class->get_default_group = gdk_quartz_display_get_default_group;
|
|
|
|
display_class->supports_shapes = gdk_quartz_display_supports_shapes;
|
|
|
|
display_class->supports_input_shapes = gdk_quartz_display_supports_input_shapes;
|
2010-12-17 17:01:54 +00:00
|
|
|
display_class->get_default_cursor_size = _gdk_quartz_display_get_default_cursor_size;
|
|
|
|
display_class->get_maximal_cursor_size = _gdk_quartz_display_get_maximal_cursor_size;
|
|
|
|
display_class->supports_cursor_alpha = _gdk_quartz_display_supports_cursor_alpha;
|
|
|
|
display_class->supports_cursor_color = _gdk_quartz_display_supports_cursor_color;
|
2010-12-22 16:06:13 +00:00
|
|
|
|
2010-12-23 12:39:07 +00:00
|
|
|
display_class->get_next_serial = gdk_quartz_display_get_next_serial;
|
|
|
|
display_class->notify_startup_complete = gdk_quartz_display_notify_startup_complete;
|
2010-12-17 17:25:47 +00:00
|
|
|
display_class->event_data_copy = _gdk_quartz_display_event_data_copy;
|
|
|
|
display_class->event_data_free = _gdk_quartz_display_event_data_free;
|
2018-03-20 11:05:26 +00:00
|
|
|
display_class->create_surface_impl = _gdk_quartz_display_create_surface_impl;
|
2010-12-17 17:46:46 +00:00
|
|
|
display_class->get_keymap = _gdk_quartz_display_get_keymap;
|
2017-02-27 21:38:46 +00:00
|
|
|
display_class->get_n_monitors = gdk_quartz_display_get_n_monitors;
|
|
|
|
display_class->get_monitor = gdk_quartz_display_get_monitor;
|
2017-10-30 20:42:49 +00:00
|
|
|
display_class->get_setting = gdk_quartz_display_get_setting;
|
2013-05-02 13:43:09 +00:00
|
|
|
|
|
|
|
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
|
|
|
|
|
|
|
/* Make the current process a foreground application, i.e. an app
|
|
|
|
* with a user interface, in case we're not running from a .app bundle
|
|
|
|
*/
|
|
|
|
TransformProcessType (&psn, kProcessTransformToForegroundApplication);
|
2010-12-22 02:13:02 +00:00
|
|
|
}
|