2005-11-22 10:03:32 +00:00
|
|
|
|
/* gdkwindow-quartz.c
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
2007-03-10 21:58:49 +00:00
|
|
|
|
* Copyright (C) 2005-2007 Imendio AB
|
2005-11-22 10:03:32 +00:00
|
|
|
|
*
|
|
|
|
|
* 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/gdkdeviceprivate.h>
|
|
|
|
|
#include <gdk/gdkdisplayprivate.h>
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
#include "gdkwindowimpl.h"
|
2005-11-22 10:03:32 +00:00
|
|
|
|
#include "gdkprivate-quartz.h"
|
2015-04-09 06:31:51 +00:00
|
|
|
|
#include "gdkglcontext-quartz.h"
|
2010-12-23 11:59:26 +00:00
|
|
|
|
#include "gdkquartzscreen.h"
|
|
|
|
|
#include "gdkquartzcursor.h"
|
|
|
|
|
|
|
|
|
|
#include <Carbon/Carbon.h>
|
2014-08-23 14:04:46 +00:00
|
|
|
|
#include <AvailabilityMacros.h>
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <cairo-quartz.h>
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
static gpointer parent_class;
|
2010-10-04 09:43:16 +00:00
|
|
|
|
static gpointer root_window_parent_class;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2009-01-26 19:33:33 +00:00
|
|
|
|
static GSList *update_nswindows;
|
|
|
|
|
static gboolean in_process_all_updates = FALSE;
|
2007-07-07 16:19:40 +00:00
|
|
|
|
|
|
|
|
|
static GSList *main_window_stack;
|
2006-08-08 20:53:09 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
void _gdk_quartz_window_flush (GdkWindowImplQuartz *window_impl);
|
|
|
|
|
|
2008-02-14 21:41:59 +00:00
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
gint x, y;
|
|
|
|
|
gint width, height;
|
|
|
|
|
GdkWMDecoration decor;
|
|
|
|
|
} FullscreenSavedGeometry;
|
|
|
|
|
|
|
|
|
|
|
2014-10-27 10:49:46 +00:00
|
|
|
|
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
|
|
|
|
static FullscreenSavedGeometry *get_fullscreen_geometry (GdkWindow *window);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define FULLSCREEN_DATA "fullscreen-data"
|
|
|
|
|
|
2007-10-23 13:06:31 +00:00
|
|
|
|
static void update_toplevel_order (void);
|
2008-02-14 21:41:59 +00:00
|
|
|
|
static void clear_toplevel_order (void);
|
|
|
|
|
|
2009-01-05 14:34:44 +00:00
|
|
|
|
#define WINDOW_IS_TOPLEVEL(window) \
|
|
|
|
|
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
|
|
|
|
|
GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
|
|
|
|
|
GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
|
2006-08-08 20:53:09 +00:00
|
|
|
|
|
2010-12-22 15:56:44 +00:00
|
|
|
|
/*
|
|
|
|
|
* GdkQuartzWindow
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct _GdkQuartzWindow
|
|
|
|
|
{
|
|
|
|
|
GdkWindow parent;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GdkQuartzWindowClass
|
|
|
|
|
{
|
|
|
|
|
GdkWindowClass parent_class;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GdkQuartzWindow, gdk_quartz_window, GDK_TYPE_WINDOW);
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_class_init (GdkQuartzWindowClass *quartz_window_class)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_init (GdkQuartzWindow *quartz_window)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* GdkQuartzWindowImpl
|
|
|
|
|
*/
|
|
|
|
|
|
2006-03-21 08:02:17 +00:00
|
|
|
|
NSView *
|
|
|
|
|
gdk_quartz_window_get_nsview (GdkWindow *window)
|
|
|
|
|
{
|
2007-12-10 20:44:23 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
return ((GdkWindowImplQuartz *)window->impl)->view;
|
2006-03-21 08:02:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-10 20:44:23 +00:00
|
|
|
|
NSWindow *
|
|
|
|
|
gdk_quartz_window_get_nswindow (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
return ((GdkWindowImplQuartz *)window->impl)->toplevel;
|
2007-12-10 20:44:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-20 16:14:35 +00:00
|
|
|
|
static CGContextRef
|
2010-12-06 13:13:40 +00:00
|
|
|
|
gdk_window_impl_quartz_get_context (GdkWindowImplQuartz *window_impl,
|
|
|
|
|
gboolean antialias)
|
2008-07-20 16:14:35 +00:00
|
|
|
|
{
|
|
|
|
|
CGContextRef cg_context;
|
2016-03-16 18:25:30 +00:00
|
|
|
|
CGSize scale;
|
2008-07-20 16:14:35 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window_impl->wrapper))
|
2008-07-20 16:14:35 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* Lock focus when not called as part of a drawRect call. This
|
|
|
|
|
* is needed when called from outside "real" expose events, for
|
|
|
|
|
* example for synthesized expose events when realizing windows
|
|
|
|
|
* and for widgets that send fake expose events like the arrow
|
2009-02-18 15:20:06 +00:00
|
|
|
|
* buttons in spinbuttons or the position marker in rulers.
|
2008-07-20 16:14:35 +00:00
|
|
|
|
*/
|
|
|
|
|
if (window_impl->in_paint_rect_count == 0)
|
|
|
|
|
{
|
|
|
|
|
if (![window_impl->view lockFocusIfCanDraw])
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cg_context = [[NSGraphicsContext currentContext] graphicsPort];
|
|
|
|
|
CGContextSaveGState (cg_context);
|
|
|
|
|
CGContextSetAllowsAntialiasing (cg_context, antialias);
|
|
|
|
|
|
2016-03-16 18:25:30 +00:00
|
|
|
|
/* Undo the default scaling transform, since we apply our own
|
|
|
|
|
* in gdk_quartz_ref_cairo_surface () */
|
|
|
|
|
scale = CGContextConvertSizeToDeviceSpace (cg_context,
|
|
|
|
|
CGSizeMake (1.0, 1.0));
|
|
|
|
|
CGContextScaleCTM (cg_context, 1.0 / scale.width, 1.0 / scale.height);
|
|
|
|
|
|
2008-07-20 16:14:35 +00:00
|
|
|
|
return cg_context;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-04 09:43:16 +00:00
|
|
|
|
static void
|
2010-12-06 13:13:40 +00:00
|
|
|
|
gdk_window_impl_quartz_release_context (GdkWindowImplQuartz *window_impl,
|
|
|
|
|
CGContextRef cg_context)
|
2010-10-04 09:43:16 +00:00
|
|
|
|
{
|
|
|
|
|
CGContextRestoreGState (cg_context);
|
|
|
|
|
CGContextSetAllowsAntialiasing (cg_context, TRUE);
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
/* See comment in gdk_quartz_window_get_context(). */
|
2010-10-04 09:43:16 +00:00
|
|
|
|
if (window_impl->in_paint_rect_count == 0)
|
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
_gdk_quartz_window_flush (window_impl);
|
2010-10-04 09:43:16 +00:00
|
|
|
|
[window_impl->view unlockFocus];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-02 18:14:07 +00:00
|
|
|
|
static void
|
|
|
|
|
check_grab_unmap (GdkWindow *window)
|
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GList *list, *l;
|
2010-08-29 00:08:47 +00:00
|
|
|
|
GdkDisplay *display = gdk_window_get_display (window);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkDeviceManager *device_manager;
|
2009-02-02 18:14:07 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
device_manager = gdk_display_get_device_manager (display);
|
|
|
|
|
list = gdk_device_manager_list_devices (device_manager,
|
|
|
|
|
GDK_DEVICE_TYPE_FLOATING);
|
|
|
|
|
for (l = list; l; l = l->next)
|
2009-02-02 18:14:07 +00:00
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
_gdk_display_end_device_grab (display, l->data, 0, window, TRUE);
|
2009-02-02 18:14:07 +00:00
|
|
|
|
}
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
g_list_free (list);
|
2009-02-02 18:14:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
check_grab_destroy (GdkWindow *window)
|
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GList *list, *l;
|
2010-08-29 00:08:47 +00:00
|
|
|
|
GdkDisplay *display = gdk_window_get_display (window);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkDeviceManager *device_manager;
|
2009-02-02 18:14:07 +00:00
|
|
|
|
|
|
|
|
|
/* Make sure there is no lasting grab in this native window */
|
2010-05-25 22:38:44 +00:00
|
|
|
|
device_manager = gdk_display_get_device_manager (display);
|
|
|
|
|
list = gdk_device_manager_list_devices (device_manager,
|
|
|
|
|
GDK_DEVICE_TYPE_MASTER);
|
|
|
|
|
|
|
|
|
|
for (l = list; l; l = l->next)
|
2009-02-02 18:14:07 +00:00
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkDeviceGrabInfo *grab;
|
|
|
|
|
|
|
|
|
|
grab = _gdk_display_get_last_device_grab (display, l->data);
|
|
|
|
|
if (grab && grab->native_window == window)
|
|
|
|
|
{
|
|
|
|
|
/* Serials are always 0 in quartz, but for clarity: */
|
|
|
|
|
grab->serial_end = grab->serial_start;
|
|
|
|
|
grab->implicit_ungrab = TRUE;
|
|
|
|
|
}
|
2009-02-02 18:14:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
g_list_free (list);
|
2009-02-02 18:14:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_impl_quartz_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (object);
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
check_grab_destroy (GDK_WINDOW_IMPL_QUARTZ (object)->wrapper);
|
2009-02-02 18:14:07 +00:00
|
|
|
|
|
2007-06-04 20:02:58 +00:00
|
|
|
|
if (impl->transient_for)
|
|
|
|
|
g_object_unref (impl->transient_for);
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
/* Help preventing "beam sync penalty" where CG makes all graphics code
|
|
|
|
|
* block until the next vsync if we try to flush (including call display on
|
|
|
|
|
* a view) too often. We do this by limiting the manual flushing done
|
|
|
|
|
* outside of expose calls to less than some frequency when measured over
|
|
|
|
|
* the last 4 flushes. This is a bit arbitray, but seems to make it possible
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* for some quick manual flushes (such as gtkruler or gimp’s marching ants)
|
2010-12-06 13:13:40 +00:00
|
|
|
|
* without hitting the max flush frequency.
|
|
|
|
|
*
|
|
|
|
|
* If drawable NULL, no flushing is done, only registering that a flush was
|
|
|
|
|
* done externally.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
_gdk_quartz_window_flush (GdkWindowImplQuartz *window_impl)
|
|
|
|
|
{
|
|
|
|
|
static struct timeval prev_tv;
|
|
|
|
|
static gint intervals[4];
|
|
|
|
|
static gint index;
|
|
|
|
|
struct timeval tv;
|
|
|
|
|
gint ms;
|
|
|
|
|
|
|
|
|
|
gettimeofday (&tv, NULL);
|
|
|
|
|
ms = (tv.tv_sec - prev_tv.tv_sec) * 1000 + (tv.tv_usec - prev_tv.tv_usec) / 1000;
|
|
|
|
|
intervals[index++ % 4] = ms;
|
|
|
|
|
|
|
|
|
|
if (window_impl)
|
|
|
|
|
{
|
|
|
|
|
ms = intervals[0] + intervals[1] + intervals[2] + intervals[3];
|
|
|
|
|
|
|
|
|
|
/* ~25Hz on average. */
|
|
|
|
|
if (ms > 4*40)
|
|
|
|
|
{
|
|
|
|
|
if (window_impl)
|
|
|
|
|
[window_impl->toplevel flushWindow];
|
|
|
|
|
|
|
|
|
|
prev_tv = tv;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
prev_tv = tv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static cairo_user_data_key_t gdk_quartz_cairo_key;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
GdkWindowImplQuartz *window_impl;
|
|
|
|
|
CGContextRef cg_context;
|
|
|
|
|
} GdkQuartzCairoSurfaceData;
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
static void
|
2010-12-06 13:13:40 +00:00
|
|
|
|
gdk_quartz_cairo_surface_destroy (void *data)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkQuartzCairoSurfaceData *surface_data = data;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
surface_data->window_impl->cairo_surface = NULL;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
gdk_quartz_window_release_context (surface_data->window_impl,
|
|
|
|
|
surface_data->cg_context);
|
2006-04-10 23:17:26 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
g_free (surface_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static cairo_surface_t *
|
|
|
|
|
gdk_quartz_create_cairo_surface (GdkWindowImplQuartz *impl,
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
|
|
|
|
{
|
|
|
|
|
CGContextRef cg_context;
|
|
|
|
|
GdkQuartzCairoSurfaceData *surface_data;
|
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
|
|
|
|
|
|
cg_context = gdk_quartz_window_get_context (impl, TRUE);
|
|
|
|
|
|
|
|
|
|
if (!cg_context)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
surface_data = g_new (GdkQuartzCairoSurfaceData, 1);
|
|
|
|
|
surface_data->window_impl = impl;
|
|
|
|
|
surface_data->cg_context = cg_context;
|
|
|
|
|
|
|
|
|
|
surface = cairo_quartz_surface_create_for_cg_context (cg_context,
|
|
|
|
|
width, height);
|
|
|
|
|
|
|
|
|
|
cairo_surface_set_user_data (surface, &gdk_quartz_cairo_key,
|
|
|
|
|
surface_data,
|
|
|
|
|
gdk_quartz_cairo_surface_destroy);
|
|
|
|
|
|
|
|
|
|
return surface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static cairo_surface_t *
|
|
|
|
|
gdk_quartz_ref_cairo_surface (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (!impl->cairo_surface)
|
|
|
|
|
{
|
2016-03-16 18:25:30 +00:00
|
|
|
|
gint scale = gdk_window_get_scale_factor (impl->wrapper);
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl->cairo_surface =
|
|
|
|
|
gdk_quartz_create_cairo_surface (impl,
|
2016-03-16 18:25:30 +00:00
|
|
|
|
gdk_window_get_width (impl->wrapper) * scale,
|
|
|
|
|
gdk_window_get_height (impl->wrapper) * scale);
|
|
|
|
|
|
|
|
|
|
cairo_surface_set_device_scale (impl->cairo_surface, scale, scale);
|
2010-12-06 13:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
cairo_surface_reference (impl->cairo_surface);
|
|
|
|
|
|
|
|
|
|
return impl->cairo_surface;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_window_impl_quartz_init (GdkWindowImplQuartz *impl)
|
|
|
|
|
{
|
2006-07-19 09:13:24 +00:00
|
|
|
|
impl->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-29 16:40:10 +00:00
|
|
|
|
static gboolean
|
2014-11-22 16:08:34 +00:00
|
|
|
|
gdk_window_impl_quartz_begin_paint (GdkWindow *window)
|
2006-04-10 23:17:26 +00:00
|
|
|
|
{
|
2013-04-29 16:40:10 +00:00
|
|
|
|
return FALSE;
|
2006-04-10 23:17:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-23 13:13:35 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_needs_display_in_region (GdkWindow *window,
|
|
|
|
|
cairo_region_t *region)
|
2009-09-20 13:27:14 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
2010-06-28 12:44:12 +00:00
|
|
|
|
int i, n_rects;
|
2009-09-20 13:27:14 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2009-09-20 13:27:14 +00:00
|
|
|
|
|
|
|
|
|
if (!impl->needs_display_region)
|
2010-06-28 12:44:12 +00:00
|
|
|
|
impl->needs_display_region = cairo_region_create ();
|
2009-09-20 13:27:14 +00:00
|
|
|
|
|
2010-06-28 12:44:12 +00:00
|
|
|
|
cairo_region_union (impl->needs_display_region, region);
|
2009-09-20 13:27:14 +00:00
|
|
|
|
|
2010-06-28 12:44:12 +00:00
|
|
|
|
n_rects = cairo_region_num_rectangles (region);
|
|
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
|
{
|
|
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
|
cairo_region_get_rectangle (region, i, &rect);
|
|
|
|
|
[impl->view setNeedsDisplayInRect:NSMakeRect (rect.x, rect.y,
|
|
|
|
|
rect.width, rect.height)];
|
|
|
|
|
}
|
2009-09-20 13:27:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-26 19:33:33 +00:00
|
|
|
|
void
|
2010-12-17 17:01:54 +00:00
|
|
|
|
_gdk_quartz_window_process_updates_recurse (GdkWindow *window,
|
|
|
|
|
cairo_region_t *region)
|
2006-08-08 20:53:09 +00:00
|
|
|
|
{
|
2009-01-26 19:33:33 +00:00
|
|
|
|
/* Make sure to only flush each toplevel at most once if we're called
|
|
|
|
|
* from process_all_updates.
|
|
|
|
|
*/
|
|
|
|
|
if (in_process_all_updates)
|
2006-08-08 20:53:09 +00:00
|
|
|
|
{
|
2008-03-14 10:20:55 +00:00
|
|
|
|
GdkWindow *toplevel;
|
|
|
|
|
|
2010-08-08 16:22:51 +00:00
|
|
|
|
toplevel = gdk_window_get_effective_toplevel (window);
|
|
|
|
|
if (toplevel && WINDOW_IS_TOPLEVEL (toplevel))
|
2008-03-14 10:20:55 +00:00
|
|
|
|
{
|
2009-01-26 19:33:33 +00:00
|
|
|
|
GdkWindowImplQuartz *toplevel_impl;
|
2008-03-25 13:35:20 +00:00
|
|
|
|
NSWindow *nswindow;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
toplevel_impl = (GdkWindowImplQuartz *)toplevel->impl;
|
2009-01-26 19:33:33 +00:00
|
|
|
|
nswindow = toplevel_impl->toplevel;
|
2008-03-25 13:35:20 +00:00
|
|
|
|
|
2009-02-04 09:40:40 +00:00
|
|
|
|
/* In theory, we could skip the flush disabling, since we only
|
|
|
|
|
* have one NSView.
|
|
|
|
|
*/
|
2008-03-25 13:35:20 +00:00
|
|
|
|
if (nswindow && ![nswindow isFlushWindowDisabled])
|
|
|
|
|
{
|
2009-01-26 19:33:33 +00:00
|
|
|
|
[nswindow retain];
|
2008-03-25 13:35:20 +00:00
|
|
|
|
[nswindow disableFlushWindow];
|
2009-01-26 19:33:33 +00:00
|
|
|
|
update_nswindows = g_slist_prepend (update_nswindows, nswindow);
|
2008-03-25 13:35:20 +00:00
|
|
|
|
}
|
2008-03-14 10:20:55 +00:00
|
|
|
|
}
|
2006-08-08 20:53:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-08 16:22:51 +00:00
|
|
|
|
if (WINDOW_IS_TOPLEVEL (window))
|
2010-12-23 13:13:35 +00:00
|
|
|
|
gdk_quartz_window_set_needs_display_in_region (window, region);
|
2010-08-08 16:22:51 +00:00
|
|
|
|
else
|
|
|
|
|
_gdk_window_process_updates_recurse (window, region);
|
2009-01-26 19:33:33 +00:00
|
|
|
|
|
2009-02-04 09:40:40 +00:00
|
|
|
|
/* NOTE: I'm not sure if we should displayIfNeeded here. It slows down a
|
|
|
|
|
* lot (since it triggers the beam syncing) and things seem to work
|
|
|
|
|
* without it.
|
|
|
|
|
*/
|
2006-08-08 20:53:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-26 19:33:33 +00:00
|
|
|
|
void
|
2010-12-17 17:01:54 +00:00
|
|
|
|
_gdk_quartz_display_before_process_all_updates (GdkDisplay *display)
|
2006-08-08 20:53:09 +00:00
|
|
|
|
{
|
2009-01-26 19:33:33 +00:00
|
|
|
|
in_process_all_updates = TRUE;
|
2009-02-05 07:23:58 +00:00
|
|
|
|
|
|
|
|
|
NSDisableScreenUpdates ();
|
2006-08-08 20:53:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-26 19:33:33 +00:00
|
|
|
|
void
|
2010-12-17 17:01:54 +00:00
|
|
|
|
_gdk_quartz_display_after_process_all_updates (GdkDisplay *display)
|
2006-04-10 23:17:26 +00:00
|
|
|
|
{
|
2009-01-26 19:33:33 +00:00
|
|
|
|
GSList *old_update_nswindows = update_nswindows;
|
|
|
|
|
GSList *tmp_list = update_nswindows;
|
2006-04-10 23:17:26 +00:00
|
|
|
|
|
2009-01-26 19:33:33 +00:00
|
|
|
|
update_nswindows = NULL;
|
2006-04-10 23:17:26 +00:00
|
|
|
|
|
2009-01-26 19:33:33 +00:00
|
|
|
|
while (tmp_list)
|
2006-08-08 20:53:09 +00:00
|
|
|
|
{
|
2009-01-26 19:33:33 +00:00
|
|
|
|
NSWindow *nswindow = tmp_list->data;
|
|
|
|
|
|
2009-02-04 09:40:40 +00:00
|
|
|
|
[[nswindow contentView] displayIfNeeded];
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
_gdk_quartz_window_flush (NULL);
|
2009-02-09 14:46:30 +00:00
|
|
|
|
|
2009-01-26 19:33:33 +00:00
|
|
|
|
[nswindow enableFlushWindow];
|
|
|
|
|
[nswindow flushWindow];
|
|
|
|
|
[nswindow release];
|
2006-04-10 23:17:26 +00:00
|
|
|
|
|
2009-01-26 19:33:33 +00:00
|
|
|
|
tmp_list = tmp_list->next;
|
2006-08-08 20:53:09 +00:00
|
|
|
|
}
|
2006-04-10 23:17:26 +00:00
|
|
|
|
|
2009-01-26 19:33:33 +00:00
|
|
|
|
g_slist_free (old_update_nswindows);
|
2006-04-10 23:17:26 +00:00
|
|
|
|
|
2009-01-26 19:33:33 +00:00
|
|
|
|
in_process_all_updates = FALSE;
|
2009-02-05 07:23:58 +00:00
|
|
|
|
|
|
|
|
|
NSEnableScreenUpdates ();
|
2006-04-10 23:17:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
static const gchar *
|
|
|
|
|
get_default_title (void)
|
|
|
|
|
{
|
|
|
|
|
const char *title;
|
|
|
|
|
|
|
|
|
|
title = g_get_application_name ();
|
|
|
|
|
if (!title)
|
|
|
|
|
title = g_get_prgname ();
|
|
|
|
|
|
|
|
|
|
return title;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-16 00:27:29 +00:00
|
|
|
|
static void
|
|
|
|
|
get_ancestor_coordinates_from_child (GdkWindow *child_window,
|
|
|
|
|
gint child_x,
|
|
|
|
|
gint child_y,
|
|
|
|
|
GdkWindow *ancestor_window,
|
|
|
|
|
gint *ancestor_x,
|
|
|
|
|
gint *ancestor_y)
|
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
while (child_window != ancestor_window)
|
2008-02-16 00:27:29 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
child_x += child_window->x;
|
|
|
|
|
child_y += child_window->y;
|
2008-02-16 00:27:29 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
child_window = child_window->parent;
|
2008-02-16 00:27:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*ancestor_x = child_x;
|
|
|
|
|
*ancestor_y = child_y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2008-03-31 13:15:15 +00:00
|
|
|
|
_gdk_quartz_window_debug_highlight (GdkWindow *window, gint number)
|
2008-02-16 00:27:29 +00:00
|
|
|
|
{
|
|
|
|
|
gint x, y;
|
2009-10-25 20:36:56 +00:00
|
|
|
|
gint gx, gy;
|
2008-02-16 00:27:29 +00:00
|
|
|
|
GdkWindow *toplevel;
|
|
|
|
|
gint tx, ty;
|
2008-03-31 13:15:15 +00:00
|
|
|
|
static NSWindow *debug_window[10];
|
|
|
|
|
static NSRect old_rect[10];
|
2008-02-16 00:27:29 +00:00
|
|
|
|
NSRect rect;
|
2008-03-31 13:15:15 +00:00
|
|
|
|
NSColor *color;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (number >= 0 && number <= 9);
|
2008-02-16 00:27:29 +00:00
|
|
|
|
|
|
|
|
|
if (window == _gdk_root)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (window == NULL)
|
2008-03-31 13:15:15 +00:00
|
|
|
|
{
|
|
|
|
|
if (debug_window[number])
|
|
|
|
|
[debug_window[number] close];
|
|
|
|
|
debug_window[number] = NULL;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-02-16 00:27:29 +00:00
|
|
|
|
|
|
|
|
|
toplevel = gdk_window_get_toplevel (window);
|
|
|
|
|
get_ancestor_coordinates_from_child (window, 0, 0, toplevel, &x, &y);
|
|
|
|
|
|
|
|
|
|
gdk_window_get_origin (toplevel, &tx, &ty);
|
|
|
|
|
x += tx;
|
|
|
|
|
y += ty;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
_gdk_quartz_window_gdk_xy_to_xy (x, y + window->height,
|
2009-10-25 20:36:56 +00:00
|
|
|
|
&gx, &gy);
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
rect = NSMakeRect (gx, gy, window->width, window->height);
|
2008-02-16 00:27:29 +00:00
|
|
|
|
|
2008-03-31 13:15:15 +00:00
|
|
|
|
if (debug_window[number] && NSEqualRects (rect, old_rect[number]))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
old_rect[number] = rect;
|
2008-02-16 00:27:29 +00:00
|
|
|
|
|
2008-03-31 13:15:15 +00:00
|
|
|
|
if (debug_window[number])
|
|
|
|
|
[debug_window[number] close];
|
2008-02-16 00:27:29 +00:00
|
|
|
|
|
2008-03-31 13:15:15 +00:00
|
|
|
|
debug_window[number] = [[NSWindow alloc] initWithContentRect:rect
|
|
|
|
|
styleMask:NSBorderlessWindowMask
|
|
|
|
|
backing:NSBackingStoreBuffered
|
|
|
|
|
defer:NO];
|
2008-02-16 00:27:29 +00:00
|
|
|
|
|
2008-03-31 13:15:15 +00:00
|
|
|
|
switch (number)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
color = [NSColor redColor];
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
color = [NSColor blueColor];
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
color = [NSColor greenColor];
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
color = [NSColor yellowColor];
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
color = [NSColor brownColor];
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
color = [NSColor purpleColor];
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
color = [NSColor blackColor];
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-02-16 00:27:29 +00:00
|
|
|
|
|
2008-03-31 13:15:15 +00:00
|
|
|
|
[debug_window[number] setBackgroundColor:color];
|
|
|
|
|
[debug_window[number] setAlphaValue:0.4];
|
|
|
|
|
[debug_window[number] setOpaque:NO];
|
|
|
|
|
[debug_window[number] setReleasedWhenClosed:YES];
|
|
|
|
|
[debug_window[number] setIgnoresMouseEvents:YES];
|
|
|
|
|
[debug_window[number] setLevel:NSFloatingWindowLevel];
|
2008-02-16 00:27:29 +00:00
|
|
|
|
|
2008-03-31 13:15:15 +00:00
|
|
|
|
[debug_window[number] orderFront:nil];
|
2008-02-16 00:27:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-13 19:09:10 +00:00
|
|
|
|
gboolean
|
|
|
|
|
_gdk_quartz_window_is_ancestor (GdkWindow *ancestor,
|
|
|
|
|
GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
if (ancestor == NULL || window == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return (gdk_window_get_parent (window) == ancestor ||
|
|
|
|
|
_gdk_quartz_window_is_ancestor (ancestor,
|
|
|
|
|
gdk_window_get_parent (window)));
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-25 20:36:56 +00:00
|
|
|
|
|
2009-11-15 14:29:45 +00:00
|
|
|
|
/* See notes on top of gdkscreen-quartz.c */
|
2009-10-25 20:36:56 +00:00
|
|
|
|
void
|
|
|
|
|
_gdk_quartz_window_gdk_xy_to_xy (gint gdk_x,
|
|
|
|
|
gint gdk_y,
|
|
|
|
|
gint *ns_x,
|
|
|
|
|
gint *ns_y)
|
|
|
|
|
{
|
2010-12-22 13:50:39 +00:00
|
|
|
|
GdkQuartzScreen *screen_quartz = GDK_QUARTZ_SCREEN (_gdk_screen);
|
2009-10-25 20:36:56 +00:00
|
|
|
|
|
|
|
|
|
if (ns_y)
|
|
|
|
|
*ns_y = screen_quartz->height - gdk_y + screen_quartz->min_y;
|
|
|
|
|
|
|
|
|
|
if (ns_x)
|
|
|
|
|
*ns_x = gdk_x + screen_quartz->min_x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gdk_quartz_window_xy_to_gdk_xy (gint ns_x,
|
|
|
|
|
gint ns_y,
|
|
|
|
|
gint *gdk_x,
|
|
|
|
|
gint *gdk_y)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2010-12-22 13:50:39 +00:00
|
|
|
|
GdkQuartzScreen *screen_quartz = GDK_QUARTZ_SCREEN (_gdk_screen);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2009-10-25 20:36:56 +00:00
|
|
|
|
if (gdk_y)
|
|
|
|
|
*gdk_y = screen_quartz->height - ns_y + screen_quartz->min_y;
|
2009-09-27 11:36:08 +00:00
|
|
|
|
|
2009-10-25 20:36:56 +00:00
|
|
|
|
if (gdk_x)
|
|
|
|
|
*gdk_x = ns_x - screen_quartz->min_x;
|
|
|
|
|
}
|
2009-09-27 11:36:08 +00:00
|
|
|
|
|
2009-10-25 20:36:56 +00:00
|
|
|
|
void
|
|
|
|
|
_gdk_quartz_window_nspoint_to_gdk_xy (NSPoint point,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y)
|
|
|
|
|
{
|
|
|
|
|
_gdk_quartz_window_xy_to_gdk_xy (point.x, point.y,
|
|
|
|
|
x, y);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-28 20:42:51 +00:00
|
|
|
|
static GdkWindow *
|
|
|
|
|
find_child_window_helper (GdkWindow *window,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint x_offset,
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gint y_offset,
|
|
|
|
|
gboolean get_toplevel)
|
2007-05-28 20:42:51 +00:00
|
|
|
|
{
|
2007-10-23 13:06:31 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
2007-05-28 20:42:51 +00:00
|
|
|
|
GList *l;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
|
|
|
|
if (window == _gdk_root)
|
|
|
|
|
update_toplevel_order ();
|
|
|
|
|
|
|
|
|
|
for (l = impl->sorted_children; l; l = l->next)
|
2007-05-28 20:42:51 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindow *child = l->data;
|
|
|
|
|
GdkWindowImplQuartz *child_impl = GDK_WINDOW_IMPL_QUARTZ (child->impl);
|
2007-05-28 20:42:51 +00:00
|
|
|
|
int temp_x, temp_y;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (!GDK_WINDOW_IS_MAPPED (child))
|
2007-05-28 20:42:51 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
temp_x = x_offset + child->x;
|
|
|
|
|
temp_y = y_offset + child->y;
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
|
|
|
|
/* Special-case the root window. We have to include the title
|
|
|
|
|
* bar in the checks, otherwise the window below the title bar
|
|
|
|
|
* will be found i.e. events punch through. (If we can find a
|
|
|
|
|
* better way to deal with the events in gdkevents-quartz, this
|
|
|
|
|
* might not be needed.)
|
|
|
|
|
*/
|
|
|
|
|
if (window == _gdk_root)
|
|
|
|
|
{
|
|
|
|
|
NSRect frame = NSMakeRect (0, 0, 100, 100);
|
|
|
|
|
NSRect content;
|
2009-12-27 16:01:25 +00:00
|
|
|
|
NSUInteger mask;
|
2007-10-23 13:06:31 +00:00
|
|
|
|
int titlebar_height;
|
|
|
|
|
|
|
|
|
|
mask = [child_impl->toplevel styleMask];
|
|
|
|
|
|
|
|
|
|
/* Get the title bar height. */
|
|
|
|
|
content = [NSWindow contentRectForFrameRect:frame
|
|
|
|
|
styleMask:mask];
|
|
|
|
|
titlebar_height = frame.size.height - content.size.height;
|
|
|
|
|
|
|
|
|
|
if (titlebar_height > 0 &&
|
|
|
|
|
x >= temp_x && y >= temp_y - titlebar_height &&
|
2010-12-06 13:13:40 +00:00
|
|
|
|
x < temp_x + child->width && y < temp_y)
|
2007-10-23 13:06:31 +00:00
|
|
|
|
{
|
|
|
|
|
/* The root means "unknown" i.e. a window not managed by
|
|
|
|
|
* GDK.
|
|
|
|
|
*/
|
|
|
|
|
return (GdkWindow *)_gdk_root;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
if ((!get_toplevel || (get_toplevel && window == _gdk_root)) &&
|
|
|
|
|
x >= temp_x && y >= temp_y &&
|
2010-12-06 13:13:40 +00:00
|
|
|
|
x < temp_x + child->width && y < temp_y + child->height)
|
2007-05-28 20:42:51 +00:00
|
|
|
|
{
|
|
|
|
|
/* Look for child windows. */
|
|
|
|
|
return find_child_window_helper (l->data,
|
|
|
|
|
x, y,
|
2010-05-25 22:38:44 +00:00
|
|
|
|
temp_x, temp_y,
|
|
|
|
|
get_toplevel);
|
2007-05-28 20:42:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Given a GdkWindow and coordinates relative to it, returns the
|
2007-06-30 19:39:45 +00:00
|
|
|
|
* innermost subwindow that contains the point. If the coordinates are
|
|
|
|
|
* outside the passed in window, NULL is returned.
|
2007-05-28 20:42:51 +00:00
|
|
|
|
*/
|
|
|
|
|
GdkWindow *
|
|
|
|
|
_gdk_quartz_window_find_child (GdkWindow *window,
|
|
|
|
|
gint x,
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gint y,
|
|
|
|
|
gboolean get_toplevel)
|
2007-05-28 20:42:51 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (x >= 0 && y >= 0 && x < window->width && y < window->height)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
return find_child_window_helper (window, x, y, 0, 0, get_toplevel);
|
2007-05-28 20:42:51 +00:00
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-25 15:23:54 +00:00
|
|
|
|
|
2007-07-07 16:19:40 +00:00
|
|
|
|
void
|
|
|
|
|
_gdk_quartz_window_did_become_main (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
main_window_stack = g_slist_remove (main_window_stack, window);
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (window->window_type != GDK_WINDOW_TEMP)
|
2010-01-03 14:27:53 +00:00
|
|
|
|
main_window_stack = g_slist_prepend (main_window_stack, window);
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
|
|
|
|
clear_toplevel_order ();
|
2007-07-07 16:19:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gdk_quartz_window_did_resign_main (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *new_window = NULL;
|
|
|
|
|
|
|
|
|
|
if (main_window_stack)
|
|
|
|
|
new_window = main_window_stack->data;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GList *toplevels;
|
|
|
|
|
|
2010-05-14 16:18:10 +00:00
|
|
|
|
toplevels = gdk_screen_get_toplevel_windows (gdk_screen_get_default ());
|
2007-07-07 16:19:40 +00:00
|
|
|
|
if (toplevels)
|
|
|
|
|
new_window = toplevels->data;
|
|
|
|
|
g_list_free (toplevels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (new_window &&
|
|
|
|
|
new_window != window &&
|
|
|
|
|
GDK_WINDOW_IS_MAPPED (new_window) &&
|
2010-08-08 16:22:51 +00:00
|
|
|
|
WINDOW_IS_TOPLEVEL (new_window))
|
2007-07-07 16:19:40 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (new_window->impl);
|
2007-07-07 16:19:40 +00:00
|
|
|
|
|
|
|
|
|
[impl->toplevel makeKeyAndOrderFront:impl->toplevel];
|
|
|
|
|
}
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
|
|
|
|
clear_toplevel_order ();
|
2007-07-07 16:19:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-25 20:36:56 +00:00
|
|
|
|
static NSScreen *
|
2009-10-26 07:58:12 +00:00
|
|
|
|
get_nsscreen_for_point (gint x, gint y)
|
2009-10-25 20:36:56 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
NSArray *screens;
|
2009-12-30 13:12:42 +00:00
|
|
|
|
NSScreen *screen = NULL;
|
2009-10-25 20:36:56 +00:00
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
|
|
|
|
screens = [NSScreen screens];
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < [screens count]; i++)
|
|
|
|
|
{
|
|
|
|
|
NSRect rect = [[screens objectAtIndex:i] frame];
|
|
|
|
|
|
2009-10-26 07:58:12 +00:00
|
|
|
|
if (x >= rect.origin.x && x <= rect.origin.x + rect.size.width &&
|
|
|
|
|
y >= rect.origin.y && y <= rect.origin.y + rect.size.height)
|
2009-12-30 13:12:42 +00:00
|
|
|
|
{
|
|
|
|
|
screen = [screens objectAtIndex:i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-10-25 20:36:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
|
2009-12-30 13:12:42 +00:00
|
|
|
|
return screen;
|
2009-10-25 20:36:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-05 15:22:47 +00:00
|
|
|
|
void
|
2010-12-22 14:47:46 +00:00
|
|
|
|
_gdk_quartz_display_create_window_impl (GdkDisplay *display,
|
|
|
|
|
GdkWindow *window,
|
|
|
|
|
GdkWindow *real_parent,
|
|
|
|
|
GdkScreen *screen,
|
|
|
|
|
GdkEventMask event_mask,
|
|
|
|
|
GdkWindowAttr *attributes,
|
|
|
|
|
gint attributes_mask)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
2007-10-23 13:06:31 +00:00
|
|
|
|
GdkWindowImplQuartz *parent_impl;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2006-07-19 09:13:24 +00:00
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-11-23 00:03:55 +00:00
|
|
|
|
impl = g_object_new (GDK_TYPE_WINDOW_IMPL_QUARTZ, NULL);
|
2010-12-06 13:13:40 +00:00
|
|
|
|
window->impl = GDK_WINDOW_IMPL (impl);
|
|
|
|
|
impl->wrapper = window;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
parent_impl = GDK_WINDOW_IMPL_QUARTZ (window->parent->impl);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
switch (window->window_type)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
case GDK_WINDOW_TOPLEVEL:
|
|
|
|
|
case GDK_WINDOW_TEMP:
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (GDK_WINDOW_TYPE (window->parent) != GDK_WINDOW_ROOT)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2009-01-05 15:22:47 +00:00
|
|
|
|
/* The common code warns for this case */
|
2010-12-06 13:13:40 +00:00
|
|
|
|
parent_impl = GDK_WINDOW_IMPL_QUARTZ (_gdk_root->impl);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-23 13:06:31 +00:00
|
|
|
|
/* Maintain the z-ordered list of children. */
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (window->parent != _gdk_root)
|
2007-10-23 13:06:31 +00:00
|
|
|
|
parent_impl->sorted_children = g_list_prepend (parent_impl->sorted_children, window);
|
|
|
|
|
else
|
|
|
|
|
clear_toplevel_order ();
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
|
|
|
|
|
(attributes->cursor) :
|
|
|
|
|
NULL));
|
|
|
|
|
|
2010-08-08 16:22:51 +00:00
|
|
|
|
impl->view = NULL;
|
|
|
|
|
|
2015-02-22 12:01:17 +00:00
|
|
|
|
switch (window->window_type)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
case GDK_WINDOW_TOPLEVEL:
|
|
|
|
|
case GDK_WINDOW_TEMP:
|
|
|
|
|
{
|
2009-10-25 20:36:56 +00:00
|
|
|
|
NSScreen *screen;
|
|
|
|
|
NSRect screen_rect;
|
2007-07-10 19:18:59 +00:00
|
|
|
|
NSRect content_rect;
|
2009-12-27 16:01:25 +00:00
|
|
|
|
NSUInteger style_mask;
|
2009-10-25 20:36:56 +00:00
|
|
|
|
int nx, ny;
|
2007-07-10 19:18:59 +00:00
|
|
|
|
const char *title;
|
|
|
|
|
|
2009-10-25 20:36:56 +00:00
|
|
|
|
/* initWithContentRect will place on the mainScreen by default.
|
|
|
|
|
* We want to select the screen to place on ourselves. We need
|
|
|
|
|
* to find the screen the window will be on and correct the
|
|
|
|
|
* content_rect coordinates to be relative to that screen.
|
|
|
|
|
*/
|
2010-12-06 13:13:40 +00:00
|
|
|
|
_gdk_quartz_window_gdk_xy_to_xy (window->x, window->y, &nx, &ny);
|
2009-10-25 20:36:56 +00:00
|
|
|
|
|
2009-10-26 07:58:12 +00:00
|
|
|
|
screen = get_nsscreen_for_point (nx, ny);
|
2009-10-25 20:36:56 +00:00
|
|
|
|
screen_rect = [screen frame];
|
|
|
|
|
nx -= screen_rect.origin.x;
|
|
|
|
|
ny -= screen_rect.origin.y;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
content_rect = NSMakeRect (nx, ny - window->height,
|
|
|
|
|
window->width,
|
|
|
|
|
window->height);
|
2006-01-02 16:34:21 +00:00
|
|
|
|
|
2015-02-22 12:01:17 +00:00
|
|
|
|
if (window->window_type == GDK_WINDOW_TEMP ||
|
|
|
|
|
((attributes_mask & GDK_WA_TYPE_HINT) &&
|
|
|
|
|
attributes->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN))
|
2007-06-19 22:09:56 +00:00
|
|
|
|
{
|
|
|
|
|
style_mask = NSBorderlessWindowMask;
|
2008-10-09 11:27:31 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-06-19 22:09:56 +00:00
|
|
|
|
style_mask = (NSTitledWindowMask |
|
|
|
|
|
NSClosableWindowMask |
|
|
|
|
|
NSMiniaturizableWindowMask |
|
|
|
|
|
NSResizableWindowMask);
|
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-12-22 15:55:56 +00:00
|
|
|
|
impl->toplevel = [[GdkQuartzNSWindow alloc] initWithContentRect:content_rect
|
|
|
|
|
styleMask:style_mask
|
|
|
|
|
backing:NSBackingStoreBuffered
|
|
|
|
|
defer:NO
|
|
|
|
|
screen:screen];
|
2006-08-08 21:00:23 +00:00
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
if (attributes_mask & GDK_WA_TITLE)
|
|
|
|
|
title = attributes->title;
|
|
|
|
|
else
|
|
|
|
|
title = get_default_title ();
|
|
|
|
|
|
|
|
|
|
gdk_window_set_title (window, title);
|
2007-06-19 22:09:56 +00:00
|
|
|
|
|
2010-08-29 10:37:58 +00:00
|
|
|
|
if (gdk_window_get_visual (window) == gdk_screen_get_rgba_visual (_gdk_screen))
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
[impl->toplevel setOpaque:NO];
|
|
|
|
|
[impl->toplevel setBackgroundColor:[NSColor clearColor]];
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-07 20:25:12 +00:00
|
|
|
|
content_rect.origin.x = 0;
|
|
|
|
|
content_rect.origin.y = 0;
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
impl->view = [[GdkQuartzView alloc] initWithFrame:content_rect];
|
|
|
|
|
[impl->view setGdkWindow:window];
|
|
|
|
|
[impl->toplevel setContentView:impl->view];
|
2009-12-30 13:14:21 +00:00
|
|
|
|
[impl->view release];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2007-06-19 22:09:56 +00:00
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
case GDK_WINDOW_CHILD:
|
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindowImplQuartz *parent_impl = GDK_WINDOW_IMPL_QUARTZ (window->parent->impl);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (!window->input_only)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
NSRect frame_rect = NSMakeRect (window->x + window->parent->abs_x,
|
|
|
|
|
window->y + window->parent->abs_y,
|
|
|
|
|
window->width,
|
|
|
|
|
window->height);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
impl->view = [[GdkQuartzView alloc] initWithFrame:frame_rect];
|
|
|
|
|
|
|
|
|
|
[impl->view setGdkWindow:window];
|
|
|
|
|
|
|
|
|
|
/* GdkWindows should be hidden by default */
|
|
|
|
|
[impl->view setHidden:YES];
|
|
|
|
|
[parent_impl->view addSubview:impl->view];
|
2009-12-30 13:14:21 +00:00
|
|
|
|
[impl->view release];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2007-06-19 22:09:56 +00:00
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
|
2007-04-25 23:44:54 +00:00
|
|
|
|
if (attributes_mask & GDK_WA_TYPE_HINT)
|
|
|
|
|
gdk_window_set_type_hint (window, attributes->type_hint);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-26 07:53:20 +00:00
|
|
|
|
void
|
2009-10-26 08:20:28 +00:00
|
|
|
|
_gdk_quartz_window_update_position (GdkWindow *window)
|
2009-10-26 07:53:20 +00:00
|
|
|
|
{
|
2009-10-26 08:20:28 +00:00
|
|
|
|
NSRect frame_rect;
|
|
|
|
|
NSRect content_rect;
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2009-10-26 08:20:28 +00:00
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
|
|
|
|
frame_rect = [impl->toplevel frame];
|
|
|
|
|
content_rect = [impl->toplevel contentRectForFrameRect:frame_rect];
|
|
|
|
|
|
|
|
|
|
_gdk_quartz_window_xy_to_gdk_xy (content_rect.origin.x,
|
|
|
|
|
content_rect.origin.y + content_rect.size.height,
|
2010-12-06 13:13:40 +00:00
|
|
|
|
&window->x, &window->y);
|
2009-10-26 08:20:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2010-12-23 13:08:40 +00:00
|
|
|
|
_gdk_quartz_window_init_windowing (GdkDisplay *display,
|
|
|
|
|
GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-05-28 20:22:26 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
g_assert (_gdk_root == NULL);
|
|
|
|
|
|
2010-12-23 13:08:40 +00:00
|
|
|
|
_gdk_root = _gdk_display_create_window (display);
|
2006-01-16 10:52:40 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
_gdk_root->impl = g_object_new (_gdk_root_window_impl_quartz_get_type (), NULL);
|
|
|
|
|
_gdk_root->impl_window = _gdk_root;
|
2010-12-23 13:08:40 +00:00
|
|
|
|
_gdk_root->visual = gdk_screen_get_system_visual (screen);
|
2008-06-27 17:06:06 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (_gdk_root->impl);
|
2009-01-05 14:56:57 +00:00
|
|
|
|
|
2010-12-23 13:08:40 +00:00
|
|
|
|
_gdk_quartz_screen_update_window_sizes (screen);
|
2007-05-28 20:22:26 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
_gdk_root->state = 0; /* We don't want GDK_WINDOW_STATE_WITHDRAWN here */
|
|
|
|
|
_gdk_root->window_type = GDK_WINDOW_ROOT;
|
|
|
|
|
_gdk_root->depth = 24;
|
|
|
|
|
_gdk_root->viewable = TRUE;
|
2007-12-04 19:08:11 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl->wrapper = _gdk_root;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-05 15:26:33 +00:00
|
|
|
|
static void
|
2010-12-10 19:06:13 +00:00
|
|
|
|
gdk_quartz_window_destroy (GdkWindow *window,
|
|
|
|
|
gboolean recursing,
|
|
|
|
|
gboolean foreign_destroy)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-10-23 13:06:31 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindow *parent;
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
2007-07-07 16:19:40 +00:00
|
|
|
|
main_window_stack = g_slist_remove (main_window_stack, window);
|
2006-08-08 20:53:09 +00:00
|
|
|
|
|
2007-10-23 13:06:31 +00:00
|
|
|
|
g_list_free (impl->sorted_children);
|
|
|
|
|
impl->sorted_children = NULL;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
parent = window->parent;
|
2007-10-23 13:06:31 +00:00
|
|
|
|
if (parent)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *parent_impl = GDK_WINDOW_IMPL_QUARTZ (parent->impl);
|
|
|
|
|
|
|
|
|
|
parent_impl->sorted_children = g_list_remove (parent_impl->sorted_children, window);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (impl->cairo_surface)
|
|
|
|
|
{
|
|
|
|
|
cairo_surface_finish (impl->cairo_surface);
|
|
|
|
|
cairo_surface_set_user_data (impl->cairo_surface, &gdk_quartz_cairo_key,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
impl->cairo_surface = NULL;
|
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2007-12-21 20:21:05 +00:00
|
|
|
|
if (!recursing && !foreign_destroy)
|
|
|
|
|
{
|
2007-02-18 11:04:06 +00:00
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
if (impl->toplevel)
|
|
|
|
|
[impl->toplevel close];
|
|
|
|
|
else if (impl->view)
|
2007-12-21 20:21:05 +00:00
|
|
|
|
[impl->view removeFromSuperview];
|
2007-02-18 11:04:06 +00:00
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:06:13 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_destroy_foreign (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2006-07-17 08:07:55 +00:00
|
|
|
|
/* Foreign windows aren't supported in OSX. */
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-20 09:17:15 +00:00
|
|
|
|
/* FIXME: This might be possible to simplify with client-side windows. Also
|
|
|
|
|
* note that already_mapped is not used yet, see the x11 backend.
|
|
|
|
|
*/
|
2005-11-22 10:03:32 +00:00
|
|
|
|
static void
|
2009-06-20 09:17:15 +00:00
|
|
|
|
gdk_window_quartz_show (GdkWindow *window, gboolean already_mapped)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-06-04 20:45:30 +00:00
|
|
|
|
gboolean focus_on_map;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
2007-06-04 20:45:30 +00:00
|
|
|
|
if (!GDK_WINDOW_IS_MAPPED (window))
|
2010-12-06 13:13:40 +00:00
|
|
|
|
focus_on_map = window->focus_on_map;
|
2007-06-04 20:45:30 +00:00
|
|
|
|
else
|
|
|
|
|
focus_on_map = TRUE;
|
|
|
|
|
|
2010-08-08 16:22:51 +00:00
|
|
|
|
if (WINDOW_IS_TOPLEVEL (window) && impl->toplevel)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2008-01-10 19:35:53 +00:00
|
|
|
|
gboolean make_key;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
make_key = (window->accept_focus && focus_on_map &&
|
|
|
|
|
window->window_type != GDK_WINDOW_TEMP);
|
2007-07-10 19:18:59 +00:00
|
|
|
|
|
2010-12-22 15:55:56 +00:00
|
|
|
|
[(GdkQuartzNSWindow*)impl->toplevel showAndMakeKey:make_key];
|
2008-02-17 10:01:52 +00:00
|
|
|
|
clear_toplevel_order ();
|
2009-01-16 19:12:58 +00:00
|
|
|
|
|
2009-01-16 19:34:56 +00:00
|
|
|
|
_gdk_quartz_events_send_map_event (window);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[impl->view setHidden:NO];
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-07 16:19:40 +00:00
|
|
|
|
[impl->view setNeedsDisplay:YES];
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_WITHDRAWN, 0);
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (window->state & GDK_WINDOW_STATE_MAXIMIZED)
|
2006-08-10 09:16:38 +00:00
|
|
|
|
gdk_window_maximize (window);
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (window->state & GDK_WINDOW_STATE_ICONIFIED)
|
2006-08-10 09:16:38 +00:00
|
|
|
|
gdk_window_iconify (window);
|
|
|
|
|
|
2007-07-06 19:49:42 +00:00
|
|
|
|
if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for))
|
|
|
|
|
_gdk_quartz_window_attach_to_parent (window);
|
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Temporarily unsets the parent window, if the window is a
|
|
|
|
|
* transient.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
_gdk_quartz_window_detach_from_parent (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-07-06 19:49:42 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (impl->toplevel != NULL);
|
|
|
|
|
|
2007-06-04 20:02:58 +00:00
|
|
|
|
if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for))
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *parent_impl;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
parent_impl = GDK_WINDOW_IMPL_QUARTZ (impl->transient_for->impl);
|
2007-07-06 19:49:42 +00:00
|
|
|
|
[parent_impl->toplevel removeChildWindow:impl->toplevel];
|
2008-02-17 10:01:52 +00:00
|
|
|
|
clear_toplevel_order ();
|
2007-06-04 20:02:58 +00:00
|
|
|
|
}
|
2007-07-06 19:49:42 +00:00
|
|
|
|
}
|
2007-06-04 20:02:58 +00:00
|
|
|
|
|
2007-07-06 19:49:42 +00:00
|
|
|
|
/* Re-sets the parent window, if the window is a transient. */
|
|
|
|
|
void
|
|
|
|
|
_gdk_quartz_window_attach_to_parent (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-07-06 19:49:42 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (impl->toplevel != NULL);
|
|
|
|
|
|
|
|
|
|
if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for))
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *parent_impl;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
parent_impl = GDK_WINDOW_IMPL_QUARTZ (impl->transient_for->impl);
|
2007-07-06 19:49:42 +00:00
|
|
|
|
[parent_impl->toplevel addChildWindow:impl->toplevel ordered:NSWindowAbove];
|
2008-02-17 10:01:52 +00:00
|
|
|
|
clear_toplevel_order ();
|
2007-07-06 19:49:42 +00:00
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2008-06-27 17:06:06 +00:00
|
|
|
|
gdk_window_quartz_hide (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
2008-02-14 21:41:59 +00:00
|
|
|
|
/* Make sure we're not stuck in fullscreen mode. */
|
2014-08-23 14:04:46 +00:00
|
|
|
|
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
2008-02-14 21:41:59 +00:00
|
|
|
|
if (get_fullscreen_geometry (window))
|
2008-05-19 20:56:51 +00:00
|
|
|
|
SetSystemUIMode (kUIModeNormal, 0);
|
2014-08-23 14:04:46 +00:00
|
|
|
|
#endif
|
2008-02-14 21:41:59 +00:00
|
|
|
|
|
2009-02-02 18:14:07 +00:00
|
|
|
|
check_grab_unmap (window);
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
_gdk_window_clear_update_area (window);
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-08-08 16:22:51 +00:00
|
|
|
|
if (WINDOW_IS_TOPLEVEL (window))
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-07-10 19:18:59 +00:00
|
|
|
|
/* Update main window. */
|
2007-07-07 16:19:40 +00:00
|
|
|
|
main_window_stack = g_slist_remove (main_window_stack, window);
|
|
|
|
|
if ([NSApp mainWindow] == impl->toplevel)
|
|
|
|
|
_gdk_quartz_window_did_resign_main (window);
|
|
|
|
|
|
2007-06-04 20:02:58 +00:00
|
|
|
|
if (impl->transient_for)
|
2007-07-06 19:49:42 +00:00
|
|
|
|
_gdk_quartz_window_detach_from_parent (window);
|
2007-06-04 20:02:58 +00:00
|
|
|
|
|
2010-12-22 15:55:56 +00:00
|
|
|
|
[(GdkQuartzNSWindow*)impl->toplevel hide];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
else if (impl->view)
|
|
|
|
|
{
|
|
|
|
|
[impl->view setHidden:YES];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2008-06-27 17:06:06 +00:00
|
|
|
|
gdk_window_quartz_withdraw (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
gdk_window_hide (window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
move_resize_window_internal (GdkWindow *window,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
2007-10-08 17:30:02 +00:00
|
|
|
|
GdkRectangle old_visible;
|
|
|
|
|
GdkRectangle new_visible;
|
|
|
|
|
GdkRectangle scroll_rect;
|
2010-06-28 12:54:37 +00:00
|
|
|
|
cairo_region_t *old_region;
|
|
|
|
|
cairo_region_t *expose_region;
|
2007-10-08 17:30:02 +00:00
|
|
|
|
NSSize delta;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
2006-07-17 08:07:55 +00:00
|
|
|
|
return;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if ((x == -1 || (x == window->x)) &&
|
|
|
|
|
(y == -1 || (y == window->y)) &&
|
|
|
|
|
(width == -1 || (width == window->width)) &&
|
|
|
|
|
(height == -1 || (height == window->height)))
|
2007-10-08 17:37:44 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-08 17:30:02 +00:00
|
|
|
|
if (!impl->toplevel)
|
|
|
|
|
{
|
|
|
|
|
/* The previously visible area of this window in a coordinate
|
|
|
|
|
* system rooted at the origin of this window.
|
|
|
|
|
*/
|
2010-12-06 13:13:40 +00:00
|
|
|
|
old_visible.x = -window->x;
|
|
|
|
|
old_visible.y = -window->y;
|
2007-10-08 17:30:02 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
old_visible.width = window->width;
|
|
|
|
|
old_visible.height = window->height;
|
2007-10-08 17:30:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
if (x != -1)
|
2007-10-08 17:30:02 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
delta.width = x - window->x;
|
|
|
|
|
window->x = x;
|
2007-10-08 17:30:02 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
delta.width = 0;
|
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
if (y != -1)
|
2007-10-08 17:30:02 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
delta.height = y - window->y;
|
|
|
|
|
window->y = y;
|
2007-10-08 17:30:02 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
delta.height = 0;
|
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
if (width != -1)
|
2010-12-06 13:13:40 +00:00
|
|
|
|
window->width = width;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
if (height != -1)
|
2010-12-06 13:13:40 +00:00
|
|
|
|
window->height = height;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2006-07-17 08:07:55 +00:00
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
if (impl->toplevel)
|
|
|
|
|
{
|
2007-11-03 09:45:25 +00:00
|
|
|
|
NSRect content_rect;
|
|
|
|
|
NSRect frame_rect;
|
2009-10-25 20:36:56 +00:00
|
|
|
|
gint gx, gy;
|
2007-11-03 09:45:25 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
_gdk_quartz_window_gdk_xy_to_xy (window->x, window->y + window->height,
|
2009-10-25 20:36:56 +00:00
|
|
|
|
&gx, &gy);
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
content_rect = NSMakeRect (gx, gy, window->width, window->height);
|
2008-01-10 19:35:53 +00:00
|
|
|
|
|
2009-01-07 20:25:12 +00:00
|
|
|
|
frame_rect = [impl->toplevel frameRectForContentRect:content_rect];
|
|
|
|
|
[impl->toplevel setFrame:frame_rect display:YES];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (!window->input_only)
|
2007-10-08 17:30:02 +00:00
|
|
|
|
{
|
|
|
|
|
NSRect nsrect;
|
2006-07-17 08:07:55 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
nsrect = NSMakeRect (window->x, window->y, window->width, window->height);
|
2007-10-08 17:30:02 +00:00
|
|
|
|
|
|
|
|
|
/* The newly visible area of this window in a coordinate
|
|
|
|
|
* system rooted at the origin of this window.
|
|
|
|
|
*/
|
2010-12-06 13:13:40 +00:00
|
|
|
|
new_visible.x = -window->x;
|
|
|
|
|
new_visible.y = -window->y;
|
2007-10-08 17:30:02 +00:00
|
|
|
|
new_visible.width = old_visible.width; /* parent has not changed size */
|
|
|
|
|
new_visible.height = old_visible.height; /* parent has not changed size */
|
|
|
|
|
|
2010-06-28 12:44:12 +00:00
|
|
|
|
expose_region = cairo_region_create_rectangle (&new_visible);
|
|
|
|
|
old_region = cairo_region_create_rectangle (&old_visible);
|
|
|
|
|
cairo_region_subtract (expose_region, old_region);
|
2007-10-08 17:30:02 +00:00
|
|
|
|
|
|
|
|
|
/* Determine what (if any) part of the previously visible
|
|
|
|
|
* part of the window can be copied without a redraw
|
|
|
|
|
*/
|
|
|
|
|
scroll_rect = old_visible;
|
|
|
|
|
scroll_rect.x -= delta.width;
|
|
|
|
|
scroll_rect.y -= delta.height;
|
|
|
|
|
gdk_rectangle_intersect (&scroll_rect, &old_visible, &scroll_rect);
|
|
|
|
|
|
2010-06-28 12:44:12 +00:00
|
|
|
|
if (!cairo_region_is_empty (expose_region))
|
2007-10-08 17:30:02 +00:00
|
|
|
|
{
|
|
|
|
|
if (scroll_rect.width != 0 && scroll_rect.height != 0)
|
|
|
|
|
{
|
|
|
|
|
[impl->view scrollRect:NSMakeRect (scroll_rect.x,
|
|
|
|
|
scroll_rect.y,
|
|
|
|
|
scroll_rect.width,
|
|
|
|
|
scroll_rect.height)
|
|
|
|
|
by:delta];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[impl->view setFrame:nsrect];
|
|
|
|
|
|
2010-12-23 13:13:35 +00:00
|
|
|
|
gdk_quartz_window_set_needs_display_in_region (window, expose_region);
|
2007-10-08 17:30:02 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[impl->view setFrame:nsrect];
|
|
|
|
|
[impl->view setNeedsDisplay:YES];
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-28 12:44:12 +00:00
|
|
|
|
cairo_region_destroy (expose_region);
|
|
|
|
|
cairo_region_destroy (old_region);
|
2007-10-08 17:30:02 +00:00
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
2006-07-09 07:50:44 +00:00
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static inline void
|
|
|
|
|
window_quartz_move (GdkWindow *window,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
|
2007-10-02 17:51:06 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
move_resize_window_internal (window, x, y, -1, -1);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static inline void
|
|
|
|
|
window_quartz_resize (GdkWindow *window,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
|
2007-10-02 17:51:06 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
if (width < 1)
|
|
|
|
|
width = 1;
|
|
|
|
|
if (height < 1)
|
|
|
|
|
height = 1;
|
|
|
|
|
|
|
|
|
|
move_resize_window_internal (window, -1, -1, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static inline void
|
|
|
|
|
window_quartz_move_resize (GdkWindow *window,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (width < 1)
|
|
|
|
|
width = 1;
|
|
|
|
|
if (height < 1)
|
|
|
|
|
height = 1;
|
|
|
|
|
|
|
|
|
|
move_resize_window_internal (window, x, y, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_quartz_move_resize (GdkWindow *window,
|
|
|
|
|
gboolean with_move,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
|
|
|
|
{
|
|
|
|
|
if (with_move && (width < 0 && height < 0))
|
|
|
|
|
window_quartz_move (window, x, y);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (with_move)
|
|
|
|
|
window_quartz_move_resize (window, x, y, width, height);
|
|
|
|
|
else
|
|
|
|
|
window_quartz_resize (window, width, height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-05 18:32:52 +00:00
|
|
|
|
/* FIXME: This might need fixing (reparenting didn't work before client-side
|
|
|
|
|
* windows either).
|
|
|
|
|
*/
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_window_quartz_reparent (GdkWindow *window,
|
|
|
|
|
GdkWindow *new_parent,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindow *old_parent;
|
2008-03-11 10:14:47 +00:00
|
|
|
|
GdkWindowImplQuartz *impl, *old_parent_impl, *new_parent_impl;
|
|
|
|
|
NSView *view, *new_parent_view;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2009-01-05 18:32:52 +00:00
|
|
|
|
if (new_parent == _gdk_root)
|
2008-03-11 10:14:47 +00:00
|
|
|
|
{
|
|
|
|
|
/* Could be added, just needs implementing. */
|
|
|
|
|
g_warning ("Reparenting to root window is not supported yet in the Mac OS X backend");
|
2008-06-27 17:06:06 +00:00
|
|
|
|
return FALSE;
|
2008-03-11 10:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2008-03-11 10:14:47 +00:00
|
|
|
|
view = impl->view;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
new_parent_impl = GDK_WINDOW_IMPL_QUARTZ (new_parent->impl);
|
2008-03-11 10:14:47 +00:00
|
|
|
|
new_parent_view = new_parent_impl->view;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
old_parent = window->parent;
|
|
|
|
|
old_parent_impl = GDK_WINDOW_IMPL_QUARTZ (old_parent->impl);
|
2008-03-11 10:14:47 +00:00
|
|
|
|
|
|
|
|
|
[view retain];
|
|
|
|
|
|
|
|
|
|
[view removeFromSuperview];
|
|
|
|
|
[new_parent_view addSubview:view];
|
|
|
|
|
|
|
|
|
|
[view release];
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
window->parent = new_parent;
|
2008-03-11 10:14:47 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (old_parent)
|
2008-03-11 10:14:47 +00:00
|
|
|
|
{
|
|
|
|
|
old_parent_impl->sorted_children = g_list_remove (old_parent_impl->sorted_children, window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
new_parent_impl->sorted_children = g_list_prepend (new_parent_impl->sorted_children, window);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2009-01-05 18:32:52 +00:00
|
|
|
|
return FALSE;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-10-23 13:06:31 +00:00
|
|
|
|
/* Get the toplevel ordering from NSApp and update our own list. We do
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* this on demand since the NSApp’s list is not up to date directly
|
2007-10-23 13:06:31 +00:00
|
|
|
|
* after we get windowDidBecomeMain.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
update_toplevel_order (void)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *root_impl;
|
|
|
|
|
NSEnumerator *enumerator;
|
|
|
|
|
id nswindow;
|
|
|
|
|
GList *toplevels = NULL;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
root_impl = GDK_WINDOW_IMPL_QUARTZ (_gdk_root->impl);
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
|
|
|
|
if (root_impl->sorted_children)
|
|
|
|
|
return;
|
|
|
|
|
|
2007-10-24 12:56:28 +00:00
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
2007-10-23 13:06:31 +00:00
|
|
|
|
enumerator = [[NSApp orderedWindows] objectEnumerator];
|
|
|
|
|
while ((nswindow = [enumerator nextObject]))
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *window;
|
|
|
|
|
|
|
|
|
|
if (![[nswindow contentView] isKindOfClass:[GdkQuartzView class]])
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
window = [(GdkQuartzView *)[nswindow contentView] gdkWindow];
|
|
|
|
|
toplevels = g_list_prepend (toplevels, window);
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-24 12:56:28 +00:00
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
|
2007-10-23 13:06:31 +00:00
|
|
|
|
root_impl->sorted_children = g_list_reverse (toplevels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
clear_toplevel_order (void)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *root_impl;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
root_impl = GDK_WINDOW_IMPL_QUARTZ (_gdk_root->impl);
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
|
|
|
|
g_list_free (root_impl->sorted_children);
|
|
|
|
|
root_impl->sorted_children = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_quartz_raise (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-06-04 20:08:31 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-06-04 20:08:31 +00:00
|
|
|
|
[impl->toplevel orderFront:impl->toplevel];
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
|
|
|
|
clear_toplevel_order ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindow *parent = window->parent;
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
|
|
|
|
impl = (GdkWindowImplQuartz *)parent->impl;
|
|
|
|
|
|
|
|
|
|
impl->sorted_children = g_list_remove (impl->sorted_children, window);
|
|
|
|
|
impl->sorted_children = g_list_prepend (impl->sorted_children, window);
|
|
|
|
|
}
|
2007-06-04 20:08:31 +00:00
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_quartz_lower (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-06-04 20:08:31 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-06-04 20:08:31 +00:00
|
|
|
|
[impl->toplevel orderBack:impl->toplevel];
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
|
|
|
|
clear_toplevel_order ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindow *parent = window->parent;
|
2007-10-23 13:06:31 +00:00
|
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
|
|
|
|
impl = (GdkWindowImplQuartz *)parent->impl;
|
|
|
|
|
|
|
|
|
|
impl->sorted_children = g_list_remove (impl->sorted_children, window);
|
|
|
|
|
impl->sorted_children = g_list_append (impl->sorted_children, window);
|
|
|
|
|
}
|
2007-06-04 20:08:31 +00:00
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-02 21:38:55 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_quartz_restack_toplevel (GdkWindow *window,
|
|
|
|
|
GdkWindow *sibling,
|
|
|
|
|
gboolean above)
|
|
|
|
|
{
|
2012-01-26 09:11:17 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
gint sibling_num;
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (sibling->impl);
|
|
|
|
|
sibling_num = [impl->toplevel windowNumber];
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
|
|
|
|
|
|
|
|
|
if (above)
|
|
|
|
|
[impl->toplevel orderWindow:NSWindowAbove relativeTo:sibling_num];
|
|
|
|
|
else
|
|
|
|
|
[impl->toplevel orderWindow:NSWindowBelow relativeTo:sibling_num];
|
2009-09-02 21:38:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static void
|
2010-08-15 11:49:30 +00:00
|
|
|
|
gdk_window_quartz_set_background (GdkWindow *window,
|
|
|
|
|
cairo_pattern_t *pattern)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2009-01-05 20:07:13 +00:00
|
|
|
|
/* FIXME: We could theoretically set the background color for toplevels
|
|
|
|
|
* here. (Currently we draw the background before emitting expose events)
|
|
|
|
|
*/
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static void
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gdk_window_quartz_set_device_cursor (GdkWindow *window,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkCursor *cursor)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
NSCursor *nscursor;
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2010-12-23 11:59:26 +00:00
|
|
|
|
nscursor = _gdk_quartz_cursor_get_ns_cursor (cursor);
|
2007-07-13 19:09:10 +00:00
|
|
|
|
|
2009-02-02 18:45:41 +00:00
|
|
|
|
[nscursor set];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_quartz_get_geometry (GdkWindow *window,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y,
|
|
|
|
|
gint *width,
|
2010-12-05 13:40:35 +00:00
|
|
|
|
gint *height)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-07-31 19:25:28 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
NSRect ns_rect;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2007-07-31 19:25:28 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-07-31 19:25:28 +00:00
|
|
|
|
if (window == _gdk_root)
|
|
|
|
|
{
|
|
|
|
|
if (x)
|
|
|
|
|
*x = 0;
|
|
|
|
|
if (y)
|
|
|
|
|
*y = 0;
|
|
|
|
|
|
|
|
|
|
if (width)
|
2010-12-06 13:13:40 +00:00
|
|
|
|
*width = window->width;
|
2007-07-31 19:25:28 +00:00
|
|
|
|
if (height)
|
2010-12-06 13:13:40 +00:00
|
|
|
|
*height = window->height;
|
2007-07-31 19:25:28 +00:00
|
|
|
|
}
|
|
|
|
|
else if (WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
{
|
|
|
|
|
ns_rect = [impl->toplevel contentRectForFrameRect:[impl->toplevel frame]];
|
|
|
|
|
|
|
|
|
|
/* This doesn't work exactly as in X. There doesn't seem to be a
|
|
|
|
|
* way to get the coords relative to the parent window (usually
|
|
|
|
|
* the window frame), but that seems useless except for
|
|
|
|
|
* borderless windows where it's relative to the root window. So
|
|
|
|
|
* we return (0, 0) (should be something like (0, 22)) for
|
|
|
|
|
* windows with borders and the root relative coordinates
|
|
|
|
|
* otherwise.
|
|
|
|
|
*/
|
|
|
|
|
if ([impl->toplevel styleMask] == NSBorderlessWindowMask)
|
|
|
|
|
{
|
2009-10-25 20:36:56 +00:00
|
|
|
|
_gdk_quartz_window_xy_to_gdk_xy (ns_rect.origin.x,
|
|
|
|
|
ns_rect.origin.y + ns_rect.size.height,
|
|
|
|
|
x, y);
|
2007-07-31 19:25:28 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (x)
|
|
|
|
|
*x = 0;
|
|
|
|
|
if (y)
|
|
|
|
|
*y = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (width)
|
|
|
|
|
*width = ns_rect.size.width;
|
|
|
|
|
if (height)
|
|
|
|
|
*height = ns_rect.size.height;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ns_rect = [impl->view frame];
|
|
|
|
|
|
|
|
|
|
if (x)
|
|
|
|
|
*x = ns_rect.origin.x;
|
|
|
|
|
if (y)
|
|
|
|
|
*y = ns_rect.origin.y;
|
|
|
|
|
if (width)
|
|
|
|
|
*width = ns_rect.size.width;
|
|
|
|
|
if (height)
|
|
|
|
|
*height = ns_rect.size.height;
|
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-28 01:58:13 +00:00
|
|
|
|
static void
|
2009-06-20 09:17:15 +00:00
|
|
|
|
gdk_window_quartz_get_root_coords (GdkWindow *window,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint *root_x,
|
|
|
|
|
gint *root_y)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2006-01-02 16:34:21 +00:00
|
|
|
|
int tmp_x = 0, tmp_y = 0;
|
|
|
|
|
GdkWindow *toplevel;
|
|
|
|
|
NSRect content_rect;
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
{
|
2009-06-20 09:17:15 +00:00
|
|
|
|
if (root_x)
|
|
|
|
|
*root_x = 0;
|
|
|
|
|
if (root_y)
|
|
|
|
|
*root_y = 0;
|
2006-01-02 16:34:21 +00:00
|
|
|
|
|
2014-02-28 01:58:13 +00:00
|
|
|
|
return;
|
2006-01-02 16:34:21 +00:00
|
|
|
|
}
|
2007-06-30 09:12:56 +00:00
|
|
|
|
|
|
|
|
|
if (window == _gdk_root)
|
|
|
|
|
{
|
2009-06-20 09:17:15 +00:00
|
|
|
|
if (root_x)
|
|
|
|
|
*root_x = x;
|
|
|
|
|
if (root_y)
|
|
|
|
|
*root_y = y;
|
2009-02-15 08:25:56 +00:00
|
|
|
|
|
2014-02-28 01:58:13 +00:00
|
|
|
|
return;
|
2007-06-30 09:12:56 +00:00
|
|
|
|
}
|
2006-01-02 16:34:21 +00:00
|
|
|
|
|
|
|
|
|
toplevel = gdk_window_get_toplevel (window);
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (toplevel->impl);
|
2006-01-02 16:34:21 +00:00
|
|
|
|
|
|
|
|
|
content_rect = [impl->toplevel contentRectForFrameRect:[impl->toplevel frame]];
|
|
|
|
|
|
2009-10-25 20:36:56 +00:00
|
|
|
|
_gdk_quartz_window_xy_to_gdk_xy (content_rect.origin.x,
|
|
|
|
|
content_rect.origin.y + content_rect.size.height,
|
|
|
|
|
&tmp_x, &tmp_y);
|
|
|
|
|
|
|
|
|
|
tmp_x += x;
|
|
|
|
|
tmp_y += y;
|
2006-01-02 16:34:21 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
while (window != toplevel)
|
2006-01-02 16:34:21 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (_gdk_window_has_impl ((GdkWindow *)window))
|
2009-02-15 08:25:56 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
tmp_x += window->x;
|
|
|
|
|
tmp_y += window->y;
|
2009-02-15 08:25:56 +00:00
|
|
|
|
}
|
2006-01-02 16:34:21 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
window = window->parent;
|
2006-01-02 16:34:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-20 09:17:15 +00:00
|
|
|
|
if (root_x)
|
|
|
|
|
*root_x = tmp_x;
|
|
|
|
|
if (root_y)
|
|
|
|
|
*root_y = tmp_y;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-28 20:20:46 +00:00
|
|
|
|
/* Returns coordinates relative to the passed in window. */
|
2009-06-20 09:17:15 +00:00
|
|
|
|
static GdkWindow *
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gdk_window_quartz_get_device_state_helper (GdkWindow *window,
|
|
|
|
|
GdkDevice *device,
|
2013-07-03 09:52:58 +00:00
|
|
|
|
gdouble *x,
|
|
|
|
|
gdouble *y,
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkModifierType *mask)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2006-07-19 07:28:42 +00:00
|
|
|
|
NSPoint point;
|
2006-07-20 08:06:54 +00:00
|
|
|
|
gint x_tmp, y_tmp;
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindow *toplevel;
|
2007-05-28 20:42:51 +00:00
|
|
|
|
GdkWindow *found_window;
|
2006-07-20 08:06:54 +00:00
|
|
|
|
|
2009-01-07 14:16:46 +00:00
|
|
|
|
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
|
|
|
|
|
|
2006-07-20 08:06:54 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
{
|
|
|
|
|
*x = 0;
|
|
|
|
|
*y = 0;
|
|
|
|
|
*mask = 0;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
toplevel = gdk_window_get_toplevel (window);
|
2007-05-28 20:42:51 +00:00
|
|
|
|
|
2011-07-25 20:26:52 +00:00
|
|
|
|
*mask = _gdk_quartz_events_get_current_keyboard_modifiers () |
|
|
|
|
|
_gdk_quartz_events_get_current_mouse_modifiers ();
|
2006-04-16 20:13:13 +00:00
|
|
|
|
|
2007-05-28 20:42:51 +00:00
|
|
|
|
/* Get the y coordinate, needs to be flipped. */
|
2006-07-19 07:28:42 +00:00
|
|
|
|
if (window == _gdk_root)
|
|
|
|
|
{
|
|
|
|
|
point = [NSEvent mouseLocation];
|
2009-10-25 20:36:56 +00:00
|
|
|
|
_gdk_quartz_window_nspoint_to_gdk_xy (point, &x_tmp, &y_tmp);
|
2006-07-19 07:28:42 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-05-28 20:42:51 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
NSWindow *nswindow;
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (toplevel->impl);
|
|
|
|
|
nswindow = impl->toplevel;
|
|
|
|
|
|
2006-07-19 07:28:42 +00:00
|
|
|
|
point = [nswindow mouseLocationOutsideOfEventStream];
|
2009-01-31 20:16:27 +00:00
|
|
|
|
|
2007-05-28 20:42:51 +00:00
|
|
|
|
x_tmp = point.x;
|
2010-12-06 13:13:40 +00:00
|
|
|
|
y_tmp = toplevel->height - point.y;
|
2006-07-20 08:06:54 +00:00
|
|
|
|
|
2009-02-02 13:11:46 +00:00
|
|
|
|
window = (GdkWindow *)toplevel;
|
2006-07-19 07:28:42 +00:00
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
found_window = _gdk_quartz_window_find_child (window, x_tmp, y_tmp,
|
|
|
|
|
FALSE);
|
2007-05-28 20:42:51 +00:00
|
|
|
|
|
|
|
|
|
/* We never return the root window. */
|
|
|
|
|
if (found_window == _gdk_root)
|
|
|
|
|
found_window = NULL;
|
|
|
|
|
|
2006-07-19 07:28:42 +00:00
|
|
|
|
*x = x_tmp;
|
|
|
|
|
*y = y_tmp;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2007-05-28 20:42:51 +00:00
|
|
|
|
return found_window;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-20 09:17:15 +00:00
|
|
|
|
static gboolean
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gdk_window_quartz_get_device_state (GdkWindow *window,
|
|
|
|
|
GdkDevice *device,
|
2013-07-03 09:52:58 +00:00
|
|
|
|
gdouble *x,
|
|
|
|
|
gdouble *y,
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkModifierType *mask)
|
2009-06-20 09:17:15 +00:00
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
return gdk_window_quartz_get_device_state_helper (window,
|
|
|
|
|
device,
|
|
|
|
|
x, y, mask) != NULL;
|
2009-06-20 09:17:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-03 08:56:37 +00:00
|
|
|
|
static GdkEventMask
|
2008-06-27 17:06:06 +00:00
|
|
|
|
gdk_window_quartz_get_events (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
2010-12-06 13:13:40 +00:00
|
|
|
|
return window->event_mask;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_quartz_set_events (GdkWindow *window,
|
|
|
|
|
GdkEventMask event_mask)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2009-01-05 20:27:16 +00:00
|
|
|
|
/* The mask is set in the common code. */
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 13:50:39 +00:00
|
|
|
|
static void
|
2010-12-22 02:12:04 +00:00
|
|
|
|
gdk_quartz_window_set_urgency_hint (GdkWindow *window,
|
|
|
|
|
gboolean urgent)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2009-01-05 18:41:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_geometry_hints (GdkWindow *window,
|
|
|
|
|
const GdkGeometry *geometry,
|
|
|
|
|
GdkWindowHints geom_mask)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2006-08-08 22:55:27 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (geometry != NULL);
|
|
|
|
|
|
2009-01-05 18:41:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2006-08-08 22:55:27 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2006-08-08 22:55:27 +00:00
|
|
|
|
if (!impl->toplevel)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_POS)
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_USER_POS)
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_USER_SIZE)
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_MIN_SIZE)
|
|
|
|
|
{
|
|
|
|
|
NSSize size;
|
|
|
|
|
|
|
|
|
|
size.width = geometry->min_width;
|
|
|
|
|
size.height = geometry->min_height;
|
|
|
|
|
|
|
|
|
|
[impl->toplevel setContentMinSize:size];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_MAX_SIZE)
|
|
|
|
|
{
|
|
|
|
|
NSSize size;
|
|
|
|
|
|
|
|
|
|
size.width = geometry->max_width;
|
|
|
|
|
size.height = geometry->max_height;
|
|
|
|
|
|
|
|
|
|
[impl->toplevel setContentMaxSize:size];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_BASE_SIZE)
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_RESIZE_INC)
|
|
|
|
|
{
|
|
|
|
|
NSSize size;
|
|
|
|
|
|
|
|
|
|
size.width = geometry->width_inc;
|
|
|
|
|
size.height = geometry->height_inc;
|
|
|
|
|
|
|
|
|
|
[impl->toplevel setContentResizeIncrements:size];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_ASPECT)
|
|
|
|
|
{
|
2015-07-06 15:34:37 +00:00
|
|
|
|
NSSize size;
|
|
|
|
|
|
|
|
|
|
if (geometry->min_aspect != geometry->max_aspect)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Only equal minimum and maximum aspect ratios are supported on Mac OS. Using minimum aspect ratio...");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size.width = geometry->min_aspect;
|
|
|
|
|
size.height = 1.0;
|
|
|
|
|
|
|
|
|
|
[impl->toplevel setContentAspectRatio:size];
|
2006-08-08 22:55:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_WIN_GRAVITY)
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_title (GdkWindow *window,
|
|
|
|
|
const gchar *title)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (title != NULL);
|
|
|
|
|
|
2009-01-05 19:35:25 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
2009-08-07 04:10:43 +00:00
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2005-11-22 10:03:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
if (impl->toplevel)
|
|
|
|
|
{
|
2006-07-17 08:07:55 +00:00
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
[impl->toplevel setTitle:[NSString stringWithUTF8String:title]];
|
2006-07-17 08:07:55 +00:00
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_role (GdkWindow *window,
|
|
|
|
|
const gchar *role)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2009-01-05 19:35:25 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-23 12:09:01 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_startup_id (GdkWindow *window,
|
|
|
|
|
const gchar *startup_id)
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement? */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_transient_for (GdkWindow *window,
|
|
|
|
|
GdkWindow *parent)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-06-04 20:02:58 +00:00
|
|
|
|
GdkWindowImplQuartz *window_impl;
|
|
|
|
|
GdkWindowImplQuartz *parent_impl;
|
|
|
|
|
|
2009-08-07 04:10:43 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (parent) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2009-01-05 20:57:04 +00:00
|
|
|
|
return;
|
2007-06-04 20:02:58 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
window_impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-06-04 20:02:58 +00:00
|
|
|
|
if (!window_impl->toplevel)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
|
|
|
|
if (window_impl->transient_for)
|
|
|
|
|
{
|
2007-07-06 19:49:42 +00:00
|
|
|
|
_gdk_quartz_window_detach_from_parent (window);
|
2007-06-04 20:02:58 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (window_impl->transient_for);
|
|
|
|
|
window_impl->transient_for = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
parent_impl = GDK_WINDOW_IMPL_QUARTZ (parent->impl);
|
2007-06-04 20:02:58 +00:00
|
|
|
|
if (parent_impl->toplevel)
|
|
|
|
|
{
|
|
|
|
|
/* We save the parent because it needs to be unset/reset when
|
|
|
|
|
* hiding and showing the window.
|
|
|
|
|
*/
|
2007-06-16 15:38:33 +00:00
|
|
|
|
|
|
|
|
|
/* We don't set transients for tooltips, they are already
|
|
|
|
|
* handled by the window level being the top one. If we do, then
|
|
|
|
|
* the parent window will be brought to the top just because the
|
|
|
|
|
* tooltip is, which is not what we want.
|
|
|
|
|
*/
|
|
|
|
|
if (gdk_window_get_type_hint (window) != GDK_WINDOW_TYPE_HINT_TOOLTIP)
|
|
|
|
|
{
|
|
|
|
|
window_impl->transient_for = g_object_ref (parent);
|
2007-06-16 21:21:52 +00:00
|
|
|
|
|
|
|
|
|
/* We only add the window if it is shown, otherwise it will
|
|
|
|
|
* be shown unconditionally here. If it is not shown, the
|
|
|
|
|
* window will be added in show() instead.
|
|
|
|
|
*/
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (!(window->state & GDK_WINDOW_STATE_WITHDRAWN))
|
2007-07-06 19:49:42 +00:00
|
|
|
|
_gdk_quartz_window_attach_to_parent (window);
|
2007-06-16 15:38:33 +00:00
|
|
|
|
}
|
2007-06-04 20:02:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_quartz_shape_combine_region (GdkWindow *window,
|
2010-06-28 12:54:37 +00:00
|
|
|
|
const cairo_region_t *shape,
|
2008-06-27 17:06:06 +00:00
|
|
|
|
gint x,
|
|
|
|
|
gint y)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static void
|
2009-01-05 20:27:16 +00:00
|
|
|
|
gdk_window_quartz_input_shape_combine_region (GdkWindow *window,
|
2010-06-28 12:54:37 +00:00
|
|
|
|
const cairo_region_t *shape_region,
|
2009-01-05 20:27:16 +00:00
|
|
|
|
gint offset_x,
|
|
|
|
|
gint offset_y)
|
2006-02-20 11:57:12 +00:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_override_redirect (GdkWindow *window,
|
|
|
|
|
gboolean override_redirect)
|
2006-03-27 10:47:29 +00:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_accept_focus (GdkWindow *window,
|
|
|
|
|
gboolean accept_focus)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
window->accept_focus = accept_focus != FALSE;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_focus_on_map (GdkWindow *window,
|
|
|
|
|
gboolean focus_on_map)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
window->focus_on_map = focus_on_map != FALSE;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_icon_name (GdkWindow *window,
|
|
|
|
|
const gchar *name)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_focus (GdkWindow *window,
|
|
|
|
|
guint32 timestamp)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-10-08 17:50:26 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-10-08 17:50:26 +00:00
|
|
|
|
|
2009-01-05 18:36:24 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (window->accept_focus && window->window_type != GDK_WINDOW_TEMP)
|
2007-10-08 17:50:26 +00:00
|
|
|
|
{
|
2009-01-05 18:36:24 +00:00
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
[impl->toplevel makeKeyAndOrderFront:impl->toplevel];
|
|
|
|
|
clear_toplevel_order ();
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
2007-10-08 17:50:26 +00:00
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-13 18:58:40 +00:00
|
|
|
|
static gint
|
|
|
|
|
window_type_hint_to_level (GdkWindowTypeHint hint)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2012-11-18 16:42:31 +00:00
|
|
|
|
/* the order in this switch statement corresponds to the actual
|
|
|
|
|
* stacking order: the first group is top, the last group is bottom
|
|
|
|
|
*/
|
2007-08-30 08:21:32 +00:00
|
|
|
|
switch (hint)
|
|
|
|
|
{
|
2012-11-18 16:42:31 +00:00
|
|
|
|
case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_COMBO:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_DND:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_TOOLTIP:
|
|
|
|
|
return NSPopUpMenuWindowLevel;
|
2006-07-24 10:46:21 +00:00
|
|
|
|
|
2007-08-30 08:21:32 +00:00
|
|
|
|
case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
|
2012-11-13 18:58:40 +00:00
|
|
|
|
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
|
2007-08-30 08:21:32 +00:00
|
|
|
|
return NSStatusWindowLevel;
|
2006-07-24 10:46:21 +00:00
|
|
|
|
|
2012-11-18 16:42:31 +00:00
|
|
|
|
case GDK_WINDOW_TYPE_HINT_MENU: /* Torn-off menu */
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU: /* Menu from menubar */
|
|
|
|
|
return NSTornOffMenuWindowLevel;
|
|
|
|
|
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_DOCK:
|
2013-06-06 13:39:53 +00:00
|
|
|
|
return NSFloatingWindowLevel; /* NSDockWindowLevel is deprecated, and not replaced */
|
|
|
|
|
|
2012-11-18 16:42:31 +00:00
|
|
|
|
case GDK_WINDOW_TYPE_HINT_UTILITY:
|
2013-06-06 13:39:53 +00:00
|
|
|
|
case GDK_WINDOW_TYPE_HINT_DIALOG: /* Dialog window */
|
2006-07-24 10:46:21 +00:00
|
|
|
|
case GDK_WINDOW_TYPE_HINT_NORMAL: /* Normal toplevel window */
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_TOOLBAR: /* Window used to implement toolbars */
|
2013-06-06 13:39:53 +00:00
|
|
|
|
return NSNormalWindowLevel;
|
|
|
|
|
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_DESKTOP:
|
|
|
|
|
return kCGDesktopWindowLevelKey; /* doesn't map to any real Cocoa model */
|
2006-07-24 10:46:21 +00:00
|
|
|
|
|
2007-08-30 08:21:32 +00:00
|
|
|
|
default:
|
2006-07-24 10:46:21 +00:00
|
|
|
|
break;
|
2007-08-30 08:21:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NSNormalWindowLevel;
|
|
|
|
|
}
|
2006-07-24 10:46:21 +00:00
|
|
|
|
|
2012-11-13 18:58:40 +00:00
|
|
|
|
static gboolean
|
2007-08-30 08:21:32 +00:00
|
|
|
|
window_type_hint_to_shadow (GdkWindowTypeHint hint)
|
|
|
|
|
{
|
|
|
|
|
switch (hint)
|
|
|
|
|
{
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_NORMAL: /* Normal toplevel window */
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_DIALOG: /* Dialog window */
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_DOCK:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_UTILITY:
|
2006-07-24 10:46:21 +00:00
|
|
|
|
case GDK_WINDOW_TYPE_HINT_MENU: /* Torn-off menu */
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU: /* Menu from menubar */
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_COMBO:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_TOOLTIP:
|
2007-08-30 08:21:32 +00:00
|
|
|
|
return TRUE;
|
2006-07-24 10:46:21 +00:00
|
|
|
|
|
2007-08-30 08:21:32 +00:00
|
|
|
|
case GDK_WINDOW_TYPE_HINT_TOOLBAR: /* Window used to implement toolbars */
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_DESKTOP: /* N/A */
|
2006-07-24 10:46:21 +00:00
|
|
|
|
case GDK_WINDOW_TYPE_HINT_DND:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-30 08:21:32 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-20 08:52:39 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
window_type_hint_to_hides_on_deactivate (GdkWindowTypeHint hint)
|
|
|
|
|
{
|
|
|
|
|
switch (hint)
|
|
|
|
|
{
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_UTILITY:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_MENU: /* Torn-off menu */
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_TOOLTIP:
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2007-08-30 08:21:32 +00:00
|
|
|
|
|
2015-07-19 18:13:22 +00:00
|
|
|
|
static void
|
|
|
|
|
_gdk_quartz_window_update_has_shadow (GdkWindowImplQuartz *impl)
|
|
|
|
|
{
|
|
|
|
|
gboolean has_shadow;
|
|
|
|
|
|
|
|
|
|
/* In case there is any shadow set we have to turn off the
|
|
|
|
|
* NSWindow setHasShadow as the system drawn ones wont match our
|
|
|
|
|
* window boundary anymore */
|
|
|
|
|
has_shadow = (window_type_hint_to_shadow (impl->type_hint) && !impl->shadow_max);
|
|
|
|
|
|
|
|
|
|
[impl->toplevel setHasShadow: has_shadow];
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_type_hint (GdkWindow *window,
|
|
|
|
|
GdkWindowTypeHint hint)
|
2007-08-30 08:21:32 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
2012-11-20 08:52:39 +00:00
|
|
|
|
|
2009-01-05 18:37:47 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2007-08-30 08:21:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-08-30 08:21:32 +00:00
|
|
|
|
|
|
|
|
|
impl->type_hint = hint;
|
|
|
|
|
|
|
|
|
|
/* Match the documentation, only do something if we're not mapped yet. */
|
|
|
|
|
if (GDK_WINDOW_IS_MAPPED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2015-07-19 18:13:22 +00:00
|
|
|
|
_gdk_quartz_window_update_has_shadow (impl);
|
2007-08-30 08:21:32 +00:00
|
|
|
|
[impl->toplevel setLevel: window_type_hint_to_level (hint)];
|
2012-11-20 08:52:39 +00:00
|
|
|
|
[impl->toplevel setHidesOnDeactivate: window_type_hint_to_hides_on_deactivate (hint)];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static GdkWindowTypeHint
|
|
|
|
|
gdk_quartz_window_get_type_hint (GdkWindow *window)
|
2006-07-09 18:09:09 +00:00
|
|
|
|
{
|
2009-01-05 18:37:47 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2006-07-19 09:13:24 +00:00
|
|
|
|
return GDK_WINDOW_TYPE_HINT_NORMAL;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
return GDK_WINDOW_IMPL_QUARTZ (window->impl)->type_hint;
|
2006-07-09 18:09:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_modal_hint (GdkWindow *window,
|
|
|
|
|
gboolean modal)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2009-01-05 18:41:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_skip_taskbar_hint (GdkWindow *window,
|
|
|
|
|
gboolean skips_taskbar)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2009-01-05 18:41:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_skip_pager_hint (GdkWindow *window,
|
|
|
|
|
gboolean skips_pager)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2009-01-05 18:41:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_begin_resize_drag (GdkWindow *window,
|
|
|
|
|
GdkWindowEdge edge,
|
2011-11-05 05:11:50 +00:00
|
|
|
|
GdkDevice *device,
|
2010-12-22 02:12:04 +00:00
|
|
|
|
gint button,
|
|
|
|
|
gint root_x,
|
|
|
|
|
gint root_y,
|
|
|
|
|
guint32 timestamp)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-10-31 11:01:56 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
|
2007-10-31 11:01:56 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-10-31 11:01:56 +00:00
|
|
|
|
|
|
|
|
|
if (!impl->toplevel)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Can't call gdk_window_begin_resize_drag on non-toplevel window");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-06 19:36:57 +00:00
|
|
|
|
[(GdkQuartzNSWindow *)impl->toplevel beginManualResize:edge];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_begin_move_drag (GdkWindow *window,
|
2011-11-05 05:11:50 +00:00
|
|
|
|
GdkDevice *device,
|
2010-12-22 02:12:04 +00:00
|
|
|
|
gint button,
|
|
|
|
|
gint root_x,
|
|
|
|
|
gint root_y,
|
|
|
|
|
guint32 timestamp)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-10-31 11:01:56 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2007-10-31 11:01:56 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-10-31 11:01:56 +00:00
|
|
|
|
|
|
|
|
|
if (!impl->toplevel)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Can't call gdk_window_begin_move_drag on non-toplevel window");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 15:55:56 +00:00
|
|
|
|
[(GdkQuartzNSWindow *)impl->toplevel beginManualMove];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_icon_list (GdkWindow *window,
|
|
|
|
|
GList *pixbufs)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_get_frame_extents (GdkWindow *window,
|
|
|
|
|
GdkRectangle *rect)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2006-07-17 08:07:55 +00:00
|
|
|
|
GdkWindow *toplevel;
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
NSRect ns_rect;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (rect != NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rect->x = 0;
|
|
|
|
|
rect->y = 0;
|
|
|
|
|
rect->width = 1;
|
|
|
|
|
rect->height = 1;
|
|
|
|
|
|
2010-08-15 11:30:55 +00:00
|
|
|
|
toplevel = gdk_window_get_effective_toplevel (window);
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (toplevel->impl);
|
2006-07-17 08:07:55 +00:00
|
|
|
|
|
|
|
|
|
ns_rect = [impl->toplevel frame];
|
|
|
|
|
|
2009-10-25 20:36:56 +00:00
|
|
|
|
_gdk_quartz_window_xy_to_gdk_xy (ns_rect.origin.x,
|
|
|
|
|
ns_rect.origin.y + ns_rect.size.height,
|
|
|
|
|
&rect->x, &rect->y);
|
|
|
|
|
|
2006-07-17 08:07:55 +00:00
|
|
|
|
rect->width = ns_rect.size.width;
|
|
|
|
|
rect->height = ns_rect.size.height;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-09 16:52:14 +00:00
|
|
|
|
/* Fake protocol to make gcc think that it's OK to call setStyleMask
|
|
|
|
|
even if it isn't. We check to make sure before actually calling
|
|
|
|
|
it. */
|
|
|
|
|
|
|
|
|
|
@protocol CanSetStyleMask
|
|
|
|
|
- (void)setStyleMask:(int)mask;
|
|
|
|
|
@end
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_decorations (GdkWindow *window,
|
2011-10-09 16:52:14 +00:00
|
|
|
|
GdkWMDecoration decorations)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-08-30 09:01:12 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
2009-12-27 16:01:25 +00:00
|
|
|
|
NSUInteger old_mask, new_mask;
|
2007-08-30 09:01:12 +00:00
|
|
|
|
NSView *old_view;
|
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2007-08-30 09:01:12 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-08-30 09:01:12 +00:00
|
|
|
|
|
2008-10-09 11:27:31 +00:00
|
|
|
|
if (decorations == 0 || GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP ||
|
|
|
|
|
impl->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN )
|
2007-08-30 09:01:12 +00:00
|
|
|
|
{
|
2007-10-02 17:51:06 +00:00
|
|
|
|
new_mask = NSBorderlessWindowMask;
|
2007-08-30 09:01:12 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-10-02 17:51:06 +00:00
|
|
|
|
/* FIXME: Honor other GDK_DECOR_* flags. */
|
|
|
|
|
new_mask = (NSTitledWindowMask | NSClosableWindowMask |
|
2007-08-30 09:01:12 +00:00
|
|
|
|
NSMiniaturizableWindowMask | NSResizableWindowMask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
2007-10-02 17:51:06 +00:00
|
|
|
|
old_mask = [impl->toplevel styleMask];
|
|
|
|
|
|
|
|
|
|
if (old_mask != new_mask)
|
2007-08-30 09:01:12 +00:00
|
|
|
|
{
|
2007-10-02 17:51:06 +00:00
|
|
|
|
NSRect rect;
|
|
|
|
|
|
2012-12-28 21:11:13 +00:00
|
|
|
|
old_view = [[impl->toplevel contentView] retain];
|
2007-08-30 09:01:12 +00:00
|
|
|
|
|
2007-10-02 17:51:06 +00:00
|
|
|
|
rect = [impl->toplevel frame];
|
|
|
|
|
|
|
|
|
|
/* Properly update the size of the window when the titlebar is
|
|
|
|
|
* added or removed.
|
|
|
|
|
*/
|
|
|
|
|
if (old_mask == NSBorderlessWindowMask &&
|
|
|
|
|
new_mask != NSBorderlessWindowMask)
|
|
|
|
|
{
|
|
|
|
|
rect = [NSWindow frameRectForContentRect:rect styleMask:new_mask];
|
2008-02-16 00:27:29 +00:00
|
|
|
|
|
2007-10-02 17:51:06 +00:00
|
|
|
|
}
|
|
|
|
|
else if (old_mask != NSBorderlessWindowMask &&
|
|
|
|
|
new_mask == NSBorderlessWindowMask)
|
|
|
|
|
{
|
|
|
|
|
rect = [NSWindow contentRectForFrameRect:rect styleMask:old_mask];
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-28 20:59:02 +00:00
|
|
|
|
/* Note, before OS 10.6 there doesn't seem to be a way to change this
|
|
|
|
|
* without recreating the toplevel. From 10.6 onward, a simple call to
|
|
|
|
|
* setStyleMask takes care of most of this, except for ensuring that the
|
|
|
|
|
* title is set.
|
2011-07-25 08:29:23 +00:00
|
|
|
|
*/
|
|
|
|
|
if ([impl->toplevel respondsToSelector:@selector(setStyleMask:)])
|
|
|
|
|
{
|
2012-12-28 20:59:02 +00:00
|
|
|
|
NSString *title = [impl->toplevel title];
|
|
|
|
|
|
2011-10-09 16:52:14 +00:00
|
|
|
|
[(id<CanSetStyleMask>)impl->toplevel setStyleMask:new_mask];
|
2012-12-28 20:59:02 +00:00
|
|
|
|
|
|
|
|
|
/* It appears that unsetting and then resetting NSTitledWindowMask
|
|
|
|
|
* does not reset the title in the title bar as might be expected.
|
|
|
|
|
*
|
|
|
|
|
* In theory we only need to set this if new_mask includes
|
|
|
|
|
* NSTitledWindowMask. This behaved extremely oddly when
|
|
|
|
|
* conditionalized upon that and since it has no side effects (i.e.
|
|
|
|
|
* if NSTitledWindowMask is not requested, the title will not be
|
2013-03-06 11:06:09 +00:00
|
|
|
|
* displayed) just do it unconditionally. We also must null check
|
|
|
|
|
* 'title' before setting it to avoid crashing.
|
2012-12-28 20:59:02 +00:00
|
|
|
|
*/
|
2013-03-06 11:06:09 +00:00
|
|
|
|
if (title)
|
|
|
|
|
[impl->toplevel setTitle:title];
|
2011-07-25 08:29:23 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-12-28 20:59:02 +00:00
|
|
|
|
NSString *title = [impl->toplevel title];
|
|
|
|
|
NSColor *bg = [impl->toplevel backgroundColor];
|
|
|
|
|
NSScreen *screen = [impl->toplevel screen];
|
|
|
|
|
|
2012-12-28 21:06:32 +00:00
|
|
|
|
/* Make sure the old window is closed, recall that releasedWhenClosed
|
|
|
|
|
* is set on GdkQuartzWindows.
|
|
|
|
|
*/
|
|
|
|
|
[impl->toplevel close];
|
|
|
|
|
|
2011-07-25 08:29:23 +00:00
|
|
|
|
impl->toplevel = [[GdkQuartzNSWindow alloc] initWithContentRect:rect
|
|
|
|
|
styleMask:new_mask
|
|
|
|
|
backing:NSBackingStoreBuffered
|
2012-12-28 20:59:02 +00:00
|
|
|
|
defer:NO
|
|
|
|
|
screen:screen];
|
2015-07-19 18:13:22 +00:00
|
|
|
|
_gdk_quartz_window_update_has_shadow (impl);
|
|
|
|
|
|
2011-07-25 08:29:23 +00:00
|
|
|
|
[impl->toplevel setLevel: window_type_hint_to_level (impl->type_hint)];
|
2013-03-06 11:06:09 +00:00
|
|
|
|
if (title)
|
|
|
|
|
[impl->toplevel setTitle:title];
|
2012-12-28 20:59:02 +00:00
|
|
|
|
[impl->toplevel setBackgroundColor:bg];
|
2012-11-20 08:52:39 +00:00
|
|
|
|
[impl->toplevel setHidesOnDeactivate: window_type_hint_to_hides_on_deactivate (impl->type_hint)];
|
2011-07-25 08:29:23 +00:00
|
|
|
|
[impl->toplevel setContentView:old_view];
|
|
|
|
|
}
|
2008-02-20 20:10:30 +00:00
|
|
|
|
|
2012-12-28 20:59:02 +00:00
|
|
|
|
if (new_mask == NSBorderlessWindowMask)
|
2017-02-28 22:07:55 +00:00
|
|
|
|
{
|
|
|
|
|
[impl->toplevel setContentSize:rect.size];
|
|
|
|
|
[impl->toplevel setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
|
|
|
|
}
|
2012-12-28 20:59:02 +00:00
|
|
|
|
else
|
|
|
|
|
[impl->toplevel setFrame:rect display:YES];
|
2008-02-27 10:49:22 +00:00
|
|
|
|
|
|
|
|
|
/* Invalidate the window shadow for non-opaque views that have shadow
|
|
|
|
|
* enabled, to get the shadow shape updated.
|
|
|
|
|
*/
|
|
|
|
|
if (![old_view isOpaque] && [impl->toplevel hasShadow])
|
|
|
|
|
[(GdkQuartzView*)old_view setNeedsInvalidateShadow:YES];
|
2012-12-28 21:11:13 +00:00
|
|
|
|
|
|
|
|
|
[old_view release];
|
2007-08-30 09:01:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_quartz_window_get_decorations (GdkWindow *window,
|
|
|
|
|
GdkWMDecoration *decorations)
|
2006-03-27 10:47:29 +00:00
|
|
|
|
{
|
2007-08-30 09:01:12 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2007-08-30 09:01:12 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-08-30 09:01:12 +00:00
|
|
|
|
|
|
|
|
|
if (decorations)
|
|
|
|
|
{
|
2007-10-02 17:51:06 +00:00
|
|
|
|
/* Borderless is 0, so we can't check it as a bit being set. */
|
|
|
|
|
if ([impl->toplevel styleMask] == NSBorderlessWindowMask)
|
2007-08-30 09:01:12 +00:00
|
|
|
|
{
|
|
|
|
|
*decorations = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-10-02 17:51:06 +00:00
|
|
|
|
/* FIXME: Honor the other GDK_DECOR_* flags. */
|
2007-08-30 09:01:12 +00:00
|
|
|
|
*decorations = GDK_DECOR_ALL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2006-03-27 10:47:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_functions (GdkWindow *window,
|
|
|
|
|
GdkWMFunction functions)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 13:50:39 +00:00
|
|
|
|
static void
|
2010-12-22 02:12:04 +00:00
|
|
|
|
gdk_quartz_window_stick (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_unstick (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_maximize (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2006-08-08 21:00:23 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
2015-07-20 07:05:52 +00:00
|
|
|
|
gboolean maximized;
|
2006-08-08 21:00:23 +00:00
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2006-08-08 21:00:23 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2015-07-20 07:05:52 +00:00
|
|
|
|
maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED;
|
2006-08-08 21:00:23 +00:00
|
|
|
|
|
2006-08-10 09:16:38 +00:00
|
|
|
|
if (GDK_WINDOW_IS_MAPPED (window))
|
|
|
|
|
{
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
2015-07-20 07:05:52 +00:00
|
|
|
|
if (impl->toplevel && !maximized)
|
|
|
|
|
[impl->toplevel zoom:nil];
|
2006-08-10 09:16:38 +00:00
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_unmaximize (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2006-08-08 21:00:23 +00:00
|
|
|
|
GdkWindowImplQuartz *impl;
|
2015-07-20 07:05:52 +00:00
|
|
|
|
gboolean maximized;
|
2006-08-08 21:00:23 +00:00
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2006-08-08 21:00:23 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2015-07-20 07:05:52 +00:00
|
|
|
|
maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED;
|
2006-08-08 21:00:23 +00:00
|
|
|
|
|
2006-08-10 09:16:38 +00:00
|
|
|
|
if (GDK_WINDOW_IS_MAPPED (window))
|
|
|
|
|
{
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
2015-07-20 07:05:52 +00:00
|
|
|
|
if (impl->toplevel && maximized)
|
|
|
|
|
[impl->toplevel zoom:nil];
|
2006-08-10 09:16:38 +00:00
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_iconify (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2005-11-22 10:03:32 +00:00
|
|
|
|
return;
|
2009-01-05 20:57:04 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2006-08-08 21:00:23 +00:00
|
|
|
|
|
2006-08-10 09:16:38 +00:00
|
|
|
|
if (GDK_WINDOW_IS_MAPPED (window))
|
|
|
|
|
{
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
|
|
|
|
if (impl->toplevel)
|
|
|
|
|
[impl->toplevel miniaturize:nil];
|
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gdk_synthesize_window_state (window,
|
|
|
|
|
0,
|
|
|
|
|
GDK_WINDOW_STATE_ICONIFIED);
|
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_deiconify (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2005-11-22 10:03:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2006-08-10 09:16:38 +00:00
|
|
|
|
if (GDK_WINDOW_IS_MAPPED (window))
|
|
|
|
|
{
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
|
|
|
|
if (impl->toplevel)
|
|
|
|
|
[impl->toplevel deminiaturize:nil];
|
|
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gdk_synthesize_window_state (window,
|
|
|
|
|
GDK_WINDOW_STATE_ICONIFIED,
|
|
|
|
|
0);
|
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-23 14:04:46 +00:00
|
|
|
|
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
window_is_fullscreen (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
|
|
|
|
|
|
|
|
|
return ([impl->toplevel styleMask] & NSFullScreenWindowMask) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_fullscreen (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
|
|
|
|
|
|
|
|
|
if (!window_is_fullscreen (window))
|
|
|
|
|
[impl->toplevel toggleFullScreen:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_unfullscreen (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
|
|
|
|
|
|
|
|
|
if (window_is_fullscreen (window))
|
|
|
|
|
[impl->toplevel toggleFullScreen:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gdk_quartz_window_update_fullscreen_state (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
gboolean is_fullscreen;
|
|
|
|
|
gboolean was_fullscreen;
|
|
|
|
|
|
|
|
|
|
is_fullscreen = window_is_fullscreen (window);
|
|
|
|
|
was_fullscreen = (gdk_window_get_state (window) & GDK_WINDOW_STATE_FULLSCREEN) != 0;
|
|
|
|
|
|
|
|
|
|
if (is_fullscreen != was_fullscreen)
|
|
|
|
|
{
|
|
|
|
|
if (is_fullscreen)
|
|
|
|
|
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
|
|
|
|
|
else
|
|
|
|
|
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
2008-02-14 21:41:59 +00:00
|
|
|
|
static FullscreenSavedGeometry *
|
|
|
|
|
get_fullscreen_geometry (GdkWindow *window)
|
2007-10-02 17:51:06 +00:00
|
|
|
|
{
|
2008-02-14 21:41:59 +00:00
|
|
|
|
return g_object_get_data (G_OBJECT (window), FULLSCREEN_DATA);
|
|
|
|
|
}
|
2007-10-02 17:51:06 +00:00
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_fullscreen (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2007-10-02 17:51:06 +00:00
|
|
|
|
FullscreenSavedGeometry *geometry;
|
2012-12-28 20:04:09 +00:00
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-10-02 17:51:06 +00:00
|
|
|
|
NSRect frame;
|
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2008-02-14 21:41:59 +00:00
|
|
|
|
geometry = get_fullscreen_geometry (window);
|
|
|
|
|
if (!geometry)
|
|
|
|
|
{
|
|
|
|
|
geometry = g_new (FullscreenSavedGeometry, 1);
|
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
geometry->x = window->x;
|
|
|
|
|
geometry->y = window->y;
|
|
|
|
|
geometry->width = window->width;
|
|
|
|
|
geometry->height = window->height;
|
2007-10-02 17:51:06 +00:00
|
|
|
|
|
2008-02-14 21:41:59 +00:00
|
|
|
|
if (!gdk_window_get_decorations (window, &geometry->decor))
|
|
|
|
|
geometry->decor = GDK_DECOR_ALL;
|
2007-10-02 17:51:06 +00:00
|
|
|
|
|
2008-02-14 21:41:59 +00:00
|
|
|
|
g_object_set_data_full (G_OBJECT (window),
|
|
|
|
|
FULLSCREEN_DATA, geometry,
|
|
|
|
|
g_free);
|
2007-10-02 17:51:06 +00:00
|
|
|
|
|
2008-02-14 21:41:59 +00:00
|
|
|
|
gdk_window_set_decorations (window, 0);
|
2007-10-02 17:51:06 +00:00
|
|
|
|
|
2012-12-28 20:04:09 +00:00
|
|
|
|
frame = [[impl->toplevel screen] frame];
|
2008-02-14 21:41:59 +00:00
|
|
|
|
move_resize_window_internal (window,
|
|
|
|
|
0, 0,
|
|
|
|
|
frame.size.width, frame.size.height);
|
2012-12-28 20:04:09 +00:00
|
|
|
|
[impl->toplevel setContentSize:frame.size];
|
|
|
|
|
[impl->toplevel makeKeyAndOrderFront:impl->toplevel];
|
|
|
|
|
|
|
|
|
|
clear_toplevel_order ();
|
2008-02-14 21:41:59 +00:00
|
|
|
|
}
|
2007-10-02 17:51:06 +00:00
|
|
|
|
|
2008-05-19 20:56:51 +00:00
|
|
|
|
SetSystemUIMode (kUIModeAllHidden, kUIOptionAutoShowMenuBar);
|
2007-10-02 17:51:06 +00:00
|
|
|
|
|
|
|
|
|
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
2010-12-22 13:50:39 +00:00
|
|
|
|
gdk_quartz_window_unfullscreen (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2012-12-28 20:04:09 +00:00
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-10-02 17:51:06 +00:00
|
|
|
|
FullscreenSavedGeometry *geometry;
|
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
2008-02-14 21:41:59 +00:00
|
|
|
|
geometry = get_fullscreen_geometry (window);
|
2007-10-02 17:51:06 +00:00
|
|
|
|
if (geometry)
|
|
|
|
|
{
|
2008-05-19 20:56:51 +00:00
|
|
|
|
SetSystemUIMode (kUIModeNormal, 0);
|
2007-10-02 17:51:06 +00:00
|
|
|
|
|
|
|
|
|
move_resize_window_internal (window,
|
|
|
|
|
geometry->x,
|
|
|
|
|
geometry->y,
|
|
|
|
|
geometry->width,
|
|
|
|
|
geometry->height);
|
|
|
|
|
|
|
|
|
|
gdk_window_set_decorations (window, geometry->decor);
|
|
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (window), FULLSCREEN_DATA, NULL);
|
|
|
|
|
|
2012-12-28 20:04:09 +00:00
|
|
|
|
[impl->toplevel makeKeyAndOrderFront:impl->toplevel];
|
|
|
|
|
clear_toplevel_order ();
|
|
|
|
|
|
2007-10-02 17:51:06 +00:00
|
|
|
|
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
|
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-23 14:04:46 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_keep_above (GdkWindow *window,
|
|
|
|
|
gboolean setting)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-08-30 08:21:32 +00:00
|
|
|
|
gint level;
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2007-08-30 08:21:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
level = window_type_hint_to_level (gdk_window_get_type_hint (window));
|
|
|
|
|
|
|
|
|
|
/* Adjust normal window level by one if necessary. */
|
|
|
|
|
[impl->toplevel setLevel: level + (setting ? 1 : 0)];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_keep_below (GdkWindow *window,
|
|
|
|
|
gboolean setting)
|
2005-11-22 10:03:32 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-08-30 08:21:32 +00:00
|
|
|
|
gint level;
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2007-08-30 08:21:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
level = window_type_hint_to_level (gdk_window_get_type_hint (window));
|
|
|
|
|
|
|
|
|
|
/* Adjust normal window level by one if necessary. */
|
|
|
|
|
[impl->toplevel setLevel: level - (setting ? 1 : 0)];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static GdkWindow *
|
|
|
|
|
gdk_quartz_window_get_group (GdkWindow *window)
|
2006-03-27 10:47:29 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD, NULL);
|
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2006-03-27 10:47:29 +00:00
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_group (GdkWindow *window,
|
|
|
|
|
GdkWindow *leader)
|
2006-03-27 10:47:29 +00:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: Implement */
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_destroy_notify (GdkWindow *window)
|
2006-07-09 18:09:09 +00:00
|
|
|
|
{
|
2009-02-02 18:14:07 +00:00
|
|
|
|
check_grab_destroy (window);
|
2006-07-09 18:09:09 +00:00
|
|
|
|
}
|
2006-08-30 03:30:43 +00:00
|
|
|
|
|
2010-12-22 02:12:04 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_opacity (GdkWindow *window,
|
|
|
|
|
gdouble opacity)
|
2007-04-30 17:42:49 +00:00
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2007-04-30 17:42:49 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
g_return_if_fail (WINDOW_IS_TOPLEVEL (window));
|
|
|
|
|
|
2009-01-05 20:57:04 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
2007-04-30 17:42:49 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (opacity < 0)
|
|
|
|
|
opacity = 0;
|
|
|
|
|
else if (opacity > 1)
|
|
|
|
|
opacity = 1;
|
|
|
|
|
|
|
|
|
|
[impl->toplevel setAlphaValue: opacity];
|
|
|
|
|
}
|
2007-06-01 12:16:12 +00:00
|
|
|
|
|
2013-12-13 04:31:52 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_quartz_window_set_shadow_width (GdkWindow *window,
|
|
|
|
|
gint left,
|
|
|
|
|
gint right,
|
|
|
|
|
gint top,
|
|
|
|
|
gint bottom)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
g_return_if_fail (WINDOW_IS_TOPLEVEL (window));
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
impl->shadow_top = top;
|
2015-07-19 18:13:22 +00:00
|
|
|
|
impl->shadow_max = MAX (MAX (left, right), MAX (top, bottom));
|
|
|
|
|
_gdk_quartz_window_update_has_shadow (impl);
|
2013-12-13 04:31:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-25 11:17:11 +00:00
|
|
|
|
static cairo_region_t *
|
|
|
|
|
gdk_quartz_window_get_shape (GdkWindow *window)
|
2009-07-31 19:22:54 +00:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: implement */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-25 11:17:11 +00:00
|
|
|
|
static cairo_region_t *
|
|
|
|
|
gdk_quartz_window_get_input_shape (GdkWindow *window)
|
2009-07-31 19:22:54 +00:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: implement */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-18 14:47:29 +00:00
|
|
|
|
/* Protocol to build cleanly for OSX < 10.7 */
|
|
|
|
|
@protocol ScaleFactor
|
|
|
|
|
- (CGFloat) backingScaleFactor;
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
|
gdk_quartz_window_get_scale_factor (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplQuartz *impl;
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
|
|
|
|
|
2014-10-11 04:35:23 +00:00
|
|
|
|
if (impl->toplevel != NULL && gdk_quartz_osx_version() >= GDK_OSX_LION)
|
2013-01-18 14:47:29 +00:00
|
|
|
|
return [(id <ScaleFactor>) impl->toplevel backingScaleFactor];
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2010-12-06 13:13:40 +00:00
|
|
|
|
|
2008-06-27 17:06:06 +00:00
|
|
|
|
static void
|
2010-12-06 13:13:40 +00:00
|
|
|
|
gdk_window_impl_quartz_class_init (GdkWindowImplQuartzClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass);
|
|
|
|
|
GdkWindowImplQuartzClass *impl_quartz_class = GDK_WINDOW_IMPL_QUARTZ_CLASS (klass);
|
|
|
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
|
|
|
|
|
object_class->finalize = gdk_window_impl_quartz_finalize;
|
|
|
|
|
|
|
|
|
|
impl_class->ref_cairo_surface = gdk_quartz_ref_cairo_surface;
|
|
|
|
|
impl_class->show = gdk_window_quartz_show;
|
|
|
|
|
impl_class->hide = gdk_window_quartz_hide;
|
|
|
|
|
impl_class->withdraw = gdk_window_quartz_withdraw;
|
|
|
|
|
impl_class->set_events = gdk_window_quartz_set_events;
|
|
|
|
|
impl_class->get_events = gdk_window_quartz_get_events;
|
|
|
|
|
impl_class->raise = gdk_window_quartz_raise;
|
|
|
|
|
impl_class->lower = gdk_window_quartz_lower;
|
|
|
|
|
impl_class->restack_toplevel = gdk_window_quartz_restack_toplevel;
|
|
|
|
|
impl_class->move_resize = gdk_window_quartz_move_resize;
|
|
|
|
|
impl_class->set_background = gdk_window_quartz_set_background;
|
|
|
|
|
impl_class->reparent = gdk_window_quartz_reparent;
|
|
|
|
|
impl_class->set_device_cursor = gdk_window_quartz_set_device_cursor;
|
|
|
|
|
impl_class->get_geometry = gdk_window_quartz_get_geometry;
|
|
|
|
|
impl_class->get_root_coords = gdk_window_quartz_get_root_coords;
|
|
|
|
|
impl_class->get_device_state = gdk_window_quartz_get_device_state;
|
|
|
|
|
impl_class->shape_combine_region = gdk_window_quartz_shape_combine_region;
|
|
|
|
|
impl_class->input_shape_combine_region = gdk_window_quartz_input_shape_combine_region;
|
2010-12-10 19:06:13 +00:00
|
|
|
|
impl_class->destroy = gdk_quartz_window_destroy;
|
|
|
|
|
impl_class->destroy_foreign = gdk_quartz_window_destroy_foreign;
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl_class->get_shape = gdk_quartz_window_get_shape;
|
|
|
|
|
impl_class->get_input_shape = gdk_quartz_window_get_input_shape;
|
2014-11-22 16:08:34 +00:00
|
|
|
|
impl_class->begin_paint = gdk_window_impl_quartz_begin_paint;
|
2013-01-18 14:47:29 +00:00
|
|
|
|
impl_class->get_scale_factor = gdk_quartz_window_get_scale_factor;
|
2010-12-06 13:13:40 +00:00
|
|
|
|
|
2010-12-22 16:04:40 +00:00
|
|
|
|
impl_class->focus = gdk_quartz_window_focus;
|
|
|
|
|
impl_class->set_type_hint = gdk_quartz_window_set_type_hint;
|
|
|
|
|
impl_class->get_type_hint = gdk_quartz_window_get_type_hint;
|
|
|
|
|
impl_class->set_modal_hint = gdk_quartz_window_set_modal_hint;
|
|
|
|
|
impl_class->set_skip_taskbar_hint = gdk_quartz_window_set_skip_taskbar_hint;
|
|
|
|
|
impl_class->set_skip_pager_hint = gdk_quartz_window_set_skip_pager_hint;
|
|
|
|
|
impl_class->set_urgency_hint = gdk_quartz_window_set_urgency_hint;
|
|
|
|
|
impl_class->set_geometry_hints = gdk_quartz_window_set_geometry_hints;
|
|
|
|
|
impl_class->set_title = gdk_quartz_window_set_title;
|
|
|
|
|
impl_class->set_role = gdk_quartz_window_set_role;
|
2010-12-23 12:09:01 +00:00
|
|
|
|
impl_class->set_startup_id = gdk_quartz_window_set_startup_id;
|
2010-12-22 16:04:40 +00:00
|
|
|
|
impl_class->set_transient_for = gdk_quartz_window_set_transient_for;
|
|
|
|
|
impl_class->get_frame_extents = gdk_quartz_window_get_frame_extents;
|
|
|
|
|
impl_class->set_override_redirect = gdk_quartz_window_set_override_redirect;
|
|
|
|
|
impl_class->set_accept_focus = gdk_quartz_window_set_accept_focus;
|
|
|
|
|
impl_class->set_focus_on_map = gdk_quartz_window_set_focus_on_map;
|
|
|
|
|
impl_class->set_icon_list = gdk_quartz_window_set_icon_list;
|
|
|
|
|
impl_class->set_icon_name = gdk_quartz_window_set_icon_name;
|
|
|
|
|
impl_class->iconify = gdk_quartz_window_iconify;
|
|
|
|
|
impl_class->deiconify = gdk_quartz_window_deiconify;
|
|
|
|
|
impl_class->stick = gdk_quartz_window_stick;
|
|
|
|
|
impl_class->unstick = gdk_quartz_window_unstick;
|
|
|
|
|
impl_class->maximize = gdk_quartz_window_maximize;
|
|
|
|
|
impl_class->unmaximize = gdk_quartz_window_unmaximize;
|
|
|
|
|
impl_class->fullscreen = gdk_quartz_window_fullscreen;
|
|
|
|
|
impl_class->unfullscreen = gdk_quartz_window_unfullscreen;
|
|
|
|
|
impl_class->set_keep_above = gdk_quartz_window_set_keep_above;
|
|
|
|
|
impl_class->set_keep_below = gdk_quartz_window_set_keep_below;
|
|
|
|
|
impl_class->get_group = gdk_quartz_window_get_group;
|
|
|
|
|
impl_class->set_group = gdk_quartz_window_set_group;
|
|
|
|
|
impl_class->set_decorations = gdk_quartz_window_set_decorations;
|
|
|
|
|
impl_class->get_decorations = gdk_quartz_window_get_decorations;
|
|
|
|
|
impl_class->set_functions = gdk_quartz_window_set_functions;
|
|
|
|
|
impl_class->set_functions = gdk_quartz_window_set_functions;
|
|
|
|
|
impl_class->begin_resize_drag = gdk_quartz_window_begin_resize_drag;
|
|
|
|
|
impl_class->begin_move_drag = gdk_quartz_window_begin_move_drag;
|
|
|
|
|
impl_class->set_opacity = gdk_quartz_window_set_opacity;
|
2013-12-13 04:31:52 +00:00
|
|
|
|
impl_class->set_shadow_width = gdk_quartz_window_set_shadow_width;
|
2010-12-22 16:04:40 +00:00
|
|
|
|
impl_class->destroy_notify = gdk_quartz_window_destroy_notify;
|
|
|
|
|
impl_class->register_dnd = _gdk_quartz_window_register_dnd;
|
|
|
|
|
impl_class->drag_begin = _gdk_quartz_window_drag_begin;
|
|
|
|
|
impl_class->process_updates_recurse = _gdk_quartz_window_process_updates_recurse;
|
|
|
|
|
impl_class->sync_rendering = _gdk_quartz_window_sync_rendering;
|
|
|
|
|
impl_class->simulate_key = _gdk_quartz_window_simulate_key;
|
|
|
|
|
impl_class->simulate_button = _gdk_quartz_window_simulate_button;
|
|
|
|
|
impl_class->get_property = _gdk_quartz_window_get_property;
|
|
|
|
|
impl_class->change_property = _gdk_quartz_window_change_property;
|
|
|
|
|
impl_class->delete_property = _gdk_quartz_window_delete_property;
|
|
|
|
|
|
2015-04-09 06:31:51 +00:00
|
|
|
|
impl_class->create_gl_context = gdk_quartz_window_create_gl_context;
|
2010-12-22 16:04:40 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
impl_quartz_class->get_context = gdk_window_impl_quartz_get_context;
|
|
|
|
|
impl_quartz_class->release_context = gdk_window_impl_quartz_release_context;
|
2008-06-27 17:06:06 +00:00
|
|
|
|
}
|
2010-10-04 09:43:16 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GType
|
|
|
|
|
_gdk_window_impl_quartz_get_type (void)
|
|
|
|
|
{
|
|
|
|
|
static GType object_type = 0;
|
|
|
|
|
|
|
|
|
|
if (!object_type)
|
|
|
|
|
{
|
|
|
|
|
const GTypeInfo object_info =
|
|
|
|
|
{
|
|
|
|
|
sizeof (GdkWindowImplQuartzClass),
|
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
|
(GClassInitFunc) gdk_window_impl_quartz_class_init,
|
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
|
NULL, /* class_data */
|
|
|
|
|
sizeof (GdkWindowImplQuartz),
|
|
|
|
|
0, /* n_preallocs */
|
|
|
|
|
(GInstanceInitFunc) gdk_window_impl_quartz_init,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
object_type = g_type_register_static (GDK_TYPE_WINDOW_IMPL,
|
|
|
|
|
"GdkWindowImplQuartz",
|
|
|
|
|
&object_info, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return object_type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGContextRef
|
|
|
|
|
gdk_quartz_window_get_context (GdkWindowImplQuartz *window,
|
|
|
|
|
gboolean antialias)
|
|
|
|
|
{
|
|
|
|
|
if (!GDK_WINDOW_IMPL_QUARTZ_GET_CLASS (window)->get_context)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("%s doesn't implement GdkWindowImplQuartzClass::get_context()",
|
|
|
|
|
G_OBJECT_TYPE_NAME (window));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return GDK_WINDOW_IMPL_QUARTZ_GET_CLASS (window)->get_context (window, antialias);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_quartz_window_release_context (GdkWindowImplQuartz *window,
|
|
|
|
|
CGContextRef cg_context)
|
|
|
|
|
{
|
|
|
|
|
if (!GDK_WINDOW_IMPL_QUARTZ_GET_CLASS (window)->release_context)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("%s doesn't implement GdkWindowImplQuartzClass::release_context()",
|
|
|
|
|
G_OBJECT_TYPE_NAME (window));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GDK_WINDOW_IMPL_QUARTZ_GET_CLASS (window)->release_context (window, cg_context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-10-04 09:43:16 +00:00
|
|
|
|
|
|
|
|
|
static CGContextRef
|
2010-12-06 13:13:40 +00:00
|
|
|
|
gdk_root_window_impl_quartz_get_context (GdkWindowImplQuartz *window,
|
|
|
|
|
gboolean antialias)
|
2010-10-04 09:43:16 +00:00
|
|
|
|
{
|
|
|
|
|
CGColorSpaceRef colorspace;
|
|
|
|
|
CGContextRef cg_context;
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (window);
|
2010-10-04 09:43:16 +00:00
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window_impl->wrapper))
|
2010-10-04 09:43:16 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* We do not have the notion of a root window on OS X. We fake this
|
|
|
|
|
* by creating a 1x1 bitmap and return a context to that.
|
|
|
|
|
*/
|
|
|
|
|
colorspace = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB);
|
|
|
|
|
cg_context = CGBitmapContextCreate (NULL,
|
|
|
|
|
1, 1, 8, 4, colorspace,
|
|
|
|
|
kCGImageAlphaPremultipliedLast);
|
|
|
|
|
CGColorSpaceRelease (colorspace);
|
|
|
|
|
|
|
|
|
|
return cg_context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-12-06 13:13:40 +00:00
|
|
|
|
gdk_root_window_impl_quartz_release_context (GdkWindowImplQuartz *window,
|
|
|
|
|
CGContextRef cg_context)
|
2010-10-04 09:43:16 +00:00
|
|
|
|
{
|
|
|
|
|
CGContextRelease (cg_context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_root_window_impl_quartz_class_init (GdkRootWindowImplQuartzClass *klass)
|
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
|
GdkWindowImplQuartzClass *window_quartz_class = GDK_WINDOW_IMPL_QUARTZ_CLASS (klass);
|
2010-10-04 09:43:16 +00:00
|
|
|
|
|
|
|
|
|
root_window_parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
|
2010-12-22 13:50:39 +00:00
|
|
|
|
window_quartz_class->get_context = gdk_root_window_impl_quartz_get_context;
|
|
|
|
|
window_quartz_class->release_context = gdk_root_window_impl_quartz_release_context;
|
2010-10-04 09:43:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_root_window_impl_quartz_init (GdkRootWindowImplQuartz *impl)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
|
_gdk_root_window_impl_quartz_get_type (void)
|
|
|
|
|
{
|
|
|
|
|
static GType object_type = 0;
|
|
|
|
|
|
|
|
|
|
if (!object_type)
|
|
|
|
|
{
|
|
|
|
|
const GTypeInfo object_info =
|
|
|
|
|
{
|
|
|
|
|
sizeof (GdkRootWindowImplQuartzClass),
|
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
|
(GClassInitFunc) gdk_root_window_impl_quartz_class_init,
|
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
|
NULL, /* class_data */
|
|
|
|
|
sizeof (GdkRootWindowImplQuartz),
|
|
|
|
|
0, /* n_preallocs */
|
|
|
|
|
(GInstanceInitFunc) gdk_root_window_impl_quartz_init,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
object_type = g_type_register_static (GDK_TYPE_WINDOW_IMPL_QUARTZ,
|
|
|
|
|
"GdkRootWindowQuartz",
|
|
|
|
|
&object_info, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return object_type;
|
|
|
|
|
}
|