Port Quartz backend to latest rendering-cleanup changes
This commit is contained in:
parent
3b753aa05e
commit
fd6e57687d
@ -68,8 +68,7 @@
|
||||
-(void)drawRect:(NSRect)rect
|
||||
{
|
||||
GdkRectangle gdk_rect;
|
||||
GdkWindowObject *private = GDK_WINDOW_OBJECT (gdk_window);
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (gdk_window->impl);
|
||||
const NSRect *drawn_rects;
|
||||
NSInteger count;
|
||||
int i;
|
||||
@ -78,7 +77,7 @@
|
||||
if (GDK_WINDOW_DESTROYED (gdk_window))
|
||||
return;
|
||||
|
||||
if (!(private->event_mask & GDK_EXPOSURE_MASK))
|
||||
if (!(gdk_window->event_mask & GDK_EXPOSURE_MASK))
|
||||
return;
|
||||
|
||||
if (NSEqualRects (rect, NSZeroRect))
|
||||
@ -127,8 +126,7 @@
|
||||
*/
|
||||
-(void)updateTrackingRect
|
||||
{
|
||||
GdkWindowObject *private = GDK_WINDOW_OBJECT (gdk_window);
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (gdk_window->impl);
|
||||
NSRect rect;
|
||||
|
||||
if (!impl->toplevel)
|
||||
|
@ -140,7 +140,6 @@
|
||||
-(void)windowDidMove:(NSNotification *)aNotification
|
||||
{
|
||||
GdkWindow *window = [[self contentView] gdkWindow];
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkEvent *event;
|
||||
|
||||
_gdk_quartz_window_update_position (window);
|
||||
@ -148,10 +147,10 @@
|
||||
/* Synthesize a configure event */
|
||||
event = gdk_event_new (GDK_CONFIGURE);
|
||||
event->configure.window = g_object_ref (window);
|
||||
event->configure.x = private->x;
|
||||
event->configure.y = private->y;
|
||||
event->configure.width = private->width;
|
||||
event->configure.height = private->height;
|
||||
event->configure.x = window->x;
|
||||
event->configure.y = window->y;
|
||||
event->configure.width = window->width;
|
||||
event->configure.height = window->height;
|
||||
|
||||
_gdk_event_queue_append (gdk_display_get_default (), event);
|
||||
}
|
||||
@ -160,23 +159,22 @@
|
||||
{
|
||||
NSRect content_rect = [self contentRectForFrameRect:[self frame]];
|
||||
GdkWindow *window = [[self contentView] gdkWindow];
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkEvent *event;
|
||||
|
||||
private->width = content_rect.size.width;
|
||||
private->height = content_rect.size.height;
|
||||
window->width = content_rect.size.width;
|
||||
window->height = content_rect.size.height;
|
||||
|
||||
[[self contentView] setFrame:NSMakeRect (0, 0, private->width, private->height)];
|
||||
[[self contentView] setFrame:NSMakeRect (0, 0, window->width, window->height)];
|
||||
|
||||
_gdk_window_update_size (window);
|
||||
|
||||
/* Synthesize a configure event */
|
||||
event = gdk_event_new (GDK_CONFIGURE);
|
||||
event->configure.window = g_object_ref (window);
|
||||
event->configure.x = private->x;
|
||||
event->configure.y = private->y;
|
||||
event->configure.width = private->width;
|
||||
event->configure.height = private->height;
|
||||
event->configure.x = window->x;
|
||||
event->configure.y = window->y;
|
||||
event->configure.width = window->width;
|
||||
event->configure.height = window->height;
|
||||
|
||||
_gdk_event_queue_append (gdk_display_get_default (), event);
|
||||
}
|
||||
@ -199,8 +197,7 @@
|
||||
-(BOOL)canBecomeMainWindow
|
||||
{
|
||||
GdkWindow *window = [[self contentView] gdkWindow];
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
||||
|
||||
switch (impl->type_hint)
|
||||
{
|
||||
@ -229,16 +226,15 @@
|
||||
-(BOOL)canBecomeKeyWindow
|
||||
{
|
||||
GdkWindow *window = [[self contentView] gdkWindow];
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
||||
|
||||
if (!private->accept_focus)
|
||||
if (!window->accept_focus)
|
||||
return NO;
|
||||
|
||||
/* Popup windows should not be able to get focused in the window
|
||||
* manager sense, it's only handled through grabs.
|
||||
*/
|
||||
if (private->window_type == GDK_WINDOW_TEMP)
|
||||
if (window->window_type == GDK_WINDOW_TEMP)
|
||||
return NO;
|
||||
|
||||
switch (impl->type_hint)
|
||||
@ -268,8 +264,7 @@
|
||||
- (void)showAndMakeKey:(BOOL)makeKey
|
||||
{
|
||||
GdkWindow *window = [[self contentView] gdkWindow];
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
||||
|
||||
inShowOrHide = YES;
|
||||
|
||||
@ -284,8 +279,7 @@
|
||||
- (void)hide
|
||||
{
|
||||
GdkWindow *window = [[self contentView] gdkWindow];
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
||||
|
||||
inShowOrHide = YES;
|
||||
[impl->toplevel orderOut:nil];
|
||||
|
@ -27,8 +27,6 @@ libgdk_quartz_la_SOURCES = \
|
||||
gdkdevicemanager-core.c \
|
||||
gdkdisplay-quartz.c \
|
||||
gdkdnd-quartz.c \
|
||||
gdkdrawable-quartz.c \
|
||||
gdkdrawable-quartz.h \
|
||||
gdkevents-quartz.c \
|
||||
gdkeventloop-quartz.c \
|
||||
gdkgeometry-quartz.c \
|
||||
|
@ -188,8 +188,7 @@ gdk_device_core_query_state_helper (GdkWindow *window,
|
||||
gint *y,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
GdkWindowObject *toplevel;
|
||||
GdkWindowObject *private;
|
||||
GdkWindow *toplevel;
|
||||
NSPoint point;
|
||||
gint x_tmp, y_tmp;
|
||||
GdkWindow *found_window;
|
||||
@ -204,7 +203,7 @@ gdk_device_core_query_state_helper (GdkWindow *window,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
toplevel = GDK_WINDOW_OBJECT (gdk_window_get_effective_toplevel (window));
|
||||
toplevel = gdk_window_get_effective_toplevel (window);
|
||||
|
||||
*mask = _gdk_quartz_events_get_current_event_mask ();
|
||||
|
||||
@ -220,15 +219,14 @@ gdk_device_core_query_state_helper (GdkWindow *window,
|
||||
NSWindow *nswindow;
|
||||
|
||||
impl = GDK_WINDOW_IMPL_QUARTZ (toplevel->impl);
|
||||
private = GDK_WINDOW_OBJECT (toplevel);
|
||||
nswindow = impl->toplevel;
|
||||
|
||||
point = [nswindow mouseLocationOutsideOfEventStream];
|
||||
|
||||
x_tmp = point.x;
|
||||
y_tmp = private->height - point.y;
|
||||
y_tmp = toplevel->height - point.y;
|
||||
|
||||
window = (GdkWindow *)toplevel;
|
||||
window = toplevel;
|
||||
}
|
||||
|
||||
found_window = _gdk_quartz_window_find_child (window, x_tmp, y_tmp,
|
||||
|
@ -1,232 +0,0 @@
|
||||
/* gdkdrawable-quartz.c
|
||||
*
|
||||
* Copyright (C) 2005-2007 Imendio AB
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <sys/time.h>
|
||||
#include <cairo-quartz.h>
|
||||
#include "gdkprivate-quartz.h"
|
||||
|
||||
static gpointer parent_class;
|
||||
|
||||
static cairo_user_data_key_t gdk_quartz_cairo_key;
|
||||
|
||||
typedef struct {
|
||||
GdkDrawable *drawable;
|
||||
CGContextRef cg_context;
|
||||
} GdkQuartzCairoSurfaceData;
|
||||
|
||||
static void
|
||||
gdk_quartz_cairo_surface_destroy (void *data)
|
||||
{
|
||||
GdkQuartzCairoSurfaceData *surface_data = data;
|
||||
GdkDrawableImplQuartz *impl = GDK_DRAWABLE_IMPL_QUARTZ (surface_data->drawable);
|
||||
|
||||
impl->cairo_surface = NULL;
|
||||
|
||||
gdk_quartz_drawable_release_context (surface_data->drawable,
|
||||
surface_data->cg_context);
|
||||
|
||||
g_free (surface_data);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_quartz_create_cairo_surface (GdkDrawable *drawable,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
CGContextRef cg_context;
|
||||
GdkQuartzCairoSurfaceData *surface_data;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
cg_context = gdk_quartz_drawable_get_context (drawable, TRUE);
|
||||
|
||||
if (!cg_context)
|
||||
return NULL;
|
||||
|
||||
surface_data = g_new (GdkQuartzCairoSurfaceData, 1);
|
||||
surface_data->drawable = drawable;
|
||||
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 (GdkDrawable *drawable)
|
||||
{
|
||||
GdkDrawableImplQuartz *impl = GDK_DRAWABLE_IMPL_QUARTZ (drawable);
|
||||
|
||||
if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable) &&
|
||||
GDK_WINDOW_DESTROYED (impl->wrapper))
|
||||
return NULL;
|
||||
|
||||
if (!impl->cairo_surface)
|
||||
{
|
||||
impl->cairo_surface =
|
||||
gdk_quartz_create_cairo_surface (drawable,
|
||||
gdk_window_get_width (impl->wrapper),
|
||||
gdk_window_get_height (impl->wrapper));
|
||||
}
|
||||
else
|
||||
cairo_surface_reference (impl->cairo_surface);
|
||||
|
||||
return impl->cairo_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drawable_impl_quartz_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drawable_impl_quartz_class_init (GdkDrawableImplQuartzClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gdk_drawable_impl_quartz_finalize;
|
||||
|
||||
drawable_class->ref_cairo_surface = gdk_quartz_ref_cairo_surface;
|
||||
drawable_class->create_cairo_surface = gdk_quartz_create_cairo_surface;
|
||||
}
|
||||
|
||||
GType
|
||||
gdk_drawable_impl_quartz_get_type (void)
|
||||
{
|
||||
static GType object_type = 0;
|
||||
|
||||
if (!object_type)
|
||||
{
|
||||
const GTypeInfo object_info =
|
||||
{
|
||||
sizeof (GdkDrawableImplQuartzClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gdk_drawable_impl_quartz_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GdkDrawableImplQuartz),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) NULL,
|
||||
};
|
||||
|
||||
object_type = g_type_register_static (GDK_TYPE_DRAWABLE,
|
||||
"GdkDrawableImplQuartz",
|
||||
&object_info, 0);
|
||||
}
|
||||
|
||||
return object_type;
|
||||
}
|
||||
|
||||
CGContextRef
|
||||
gdk_quartz_drawable_get_context (GdkDrawable *drawable,
|
||||
gboolean antialias)
|
||||
{
|
||||
if (!GDK_DRAWABLE_IMPL_QUARTZ_GET_CLASS (drawable)->get_context)
|
||||
{
|
||||
g_warning ("%s doesn't implement GdkDrawableImplQuartzClass::get_context()",
|
||||
G_OBJECT_TYPE_NAME (drawable));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return GDK_DRAWABLE_IMPL_QUARTZ_GET_CLASS (drawable)->get_context (drawable, antialias);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_quartz_drawable_release_context (GdkDrawable *drawable,
|
||||
CGContextRef cg_context)
|
||||
{
|
||||
if (!GDK_DRAWABLE_IMPL_QUARTZ_GET_CLASS (drawable)->release_context)
|
||||
{
|
||||
g_warning ("%s doesn't implement GdkDrawableImplQuartzClass::release_context()",
|
||||
G_OBJECT_TYPE_NAME (drawable));
|
||||
return;
|
||||
}
|
||||
|
||||
GDK_DRAWABLE_IMPL_QUARTZ_GET_CLASS (drawable)->release_context (drawable, cg_context);
|
||||
}
|
||||
|
||||
/* 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
|
||||
* for some quick manual flushes (such as gtkruler or gimp's marching ants)
|
||||
* without hitting the max flush frequency.
|
||||
*
|
||||
* If drawable NULL, no flushing is done, only registering that a flush was
|
||||
* done externally.
|
||||
*/
|
||||
void
|
||||
_gdk_quartz_drawable_flush (GdkDrawable *drawable)
|
||||
{
|
||||
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 (drawable)
|
||||
{
|
||||
ms = intervals[0] + intervals[1] + intervals[2] + intervals[3];
|
||||
|
||||
/* ~25Hz on average. */
|
||||
if (ms > 4*40)
|
||||
{
|
||||
if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
|
||||
{
|
||||
GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (drawable);
|
||||
|
||||
[window_impl->toplevel flushWindow];
|
||||
}
|
||||
|
||||
prev_tv = tv;
|
||||
}
|
||||
}
|
||||
else
|
||||
prev_tv = tv;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_quartz_drawable_finish (GdkDrawable *drawable)
|
||||
{
|
||||
GdkDrawableImplQuartz *impl = GDK_DRAWABLE_IMPL_QUARTZ (drawable);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/* gdkdrawable-quartz.h
|
||||
*
|
||||
* Copyright (C) 2005 Imendio AB
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_DRAWABLE_QUARTZ_H__
|
||||
#define __GDK_DRAWABLE_QUARTZ_H__
|
||||
|
||||
#include <gdk/gdkdrawable.h>
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Drawable implementation for Quartz
|
||||
*/
|
||||
|
||||
typedef struct _GdkDrawableImplQuartz GdkDrawableImplQuartz;
|
||||
typedef struct _GdkDrawableImplQuartzClass GdkDrawableImplQuartzClass;
|
||||
|
||||
#define GDK_TYPE_DRAWABLE_IMPL_QUARTZ (gdk_drawable_impl_quartz_get_type ())
|
||||
#define GDK_DRAWABLE_IMPL_QUARTZ(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAWABLE_IMPL_QUARTZ, GdkDrawableImplQuartz))
|
||||
#define GDK_DRAWABLE_IMPL_QUARTZ_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAWABLE_IMPL_QUARTZ, GdkDrawableImplQuartzClass))
|
||||
#define GDK_IS_DRAWABLE_IMPL_QUARTZ(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAWABLE_IMPL_QUARTZ))
|
||||
#define GDK_IS_DRAWABLE_IMPL_QUARTZ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAWABLE_IMPL_QUARTZ))
|
||||
#define GDK_DRAWABLE_IMPL_QUARTZ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAWABLE_IMPL_QUARTZ, GdkDrawableImplQuartzClass))
|
||||
|
||||
struct _GdkDrawableImplQuartz
|
||||
{
|
||||
GdkDrawable parent_instance;
|
||||
|
||||
GdkDrawable *wrapper;
|
||||
|
||||
cairo_surface_t *cairo_surface;
|
||||
};
|
||||
|
||||
struct _GdkDrawableImplQuartzClass
|
||||
{
|
||||
GdkDrawableClass parent_class;
|
||||
|
||||
/* vtable */
|
||||
CGContextRef (*get_context) (GdkDrawable* drawable,
|
||||
gboolean antialias);
|
||||
void (*release_context) (GdkDrawable *drawable,
|
||||
CGContextRef cg_context);
|
||||
};
|
||||
|
||||
GType gdk_drawable_impl_quartz_get_type (void);
|
||||
CGContextRef gdk_quartz_drawable_get_context (GdkDrawable *drawable,
|
||||
gboolean antialias);
|
||||
void gdk_quartz_drawable_release_context (GdkDrawable *drawable,
|
||||
CGContextRef context);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_DRAWABLE_QUARTZ_H__ */
|
@ -374,7 +374,6 @@ generate_motion_event (GdkWindow *window)
|
||||
NSPoint screen_point;
|
||||
NSWindow *nswindow;
|
||||
GdkQuartzView *view;
|
||||
GdkWindowObject *private;
|
||||
GdkEvent *event;
|
||||
gint x, y, x_root, y_root;
|
||||
GdkDisplay *display;
|
||||
@ -383,8 +382,7 @@ generate_motion_event (GdkWindow *window)
|
||||
event->any.window = NULL;
|
||||
event->any.send_event = TRUE;
|
||||
|
||||
private = (GdkWindowObject *)window;
|
||||
nswindow = ((GdkWindowImplQuartz *)private->impl)->toplevel;
|
||||
nswindow = ((GdkWindowImplQuartz *)window->impl)->toplevel;
|
||||
view = (GdkQuartzView *)[nswindow contentView];
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
@ -396,7 +394,7 @@ generate_motion_event (GdkWindow *window)
|
||||
point = [nswindow convertScreenToBase:screen_point];
|
||||
|
||||
x = point.x;
|
||||
y = private->height - point.y;
|
||||
y = window->height - point.y;
|
||||
|
||||
event->any.type = GDK_MOTION_NOTIFY;
|
||||
event->motion.window = window;
|
||||
@ -464,7 +462,6 @@ _gdk_quartz_events_send_enter_notify_event (GdkWindow *window)
|
||||
NSPoint point;
|
||||
NSPoint screen_point;
|
||||
NSWindow *nswindow;
|
||||
GdkWindowObject *private;
|
||||
GdkEvent *event;
|
||||
gint x, y, x_root, y_root;
|
||||
|
||||
@ -472,8 +469,7 @@ _gdk_quartz_events_send_enter_notify_event (GdkWindow *window)
|
||||
event->any.window = NULL;
|
||||
event->any.send_event = FALSE;
|
||||
|
||||
private = (GdkWindowObject *)window;
|
||||
nswindow = ((GdkWindowImplQuartz *)private->impl)->toplevel;
|
||||
nswindow = ((GdkWindowImplQuartz *)window->impl)->toplevel;
|
||||
|
||||
screen_point = [NSEvent mouseLocation];
|
||||
|
||||
@ -482,7 +478,7 @@ _gdk_quartz_events_send_enter_notify_event (GdkWindow *window)
|
||||
point = [nswindow convertScreenToBase:screen_point];
|
||||
|
||||
x = point.x;
|
||||
y = private->height - point.y;
|
||||
y = window->height - point.y;
|
||||
|
||||
event->crossing.window = window;
|
||||
event->crossing.subwindow = NULL;
|
||||
@ -503,13 +499,12 @@ _gdk_quartz_events_send_enter_notify_event (GdkWindow *window)
|
||||
void
|
||||
_gdk_quartz_events_send_map_event (GdkWindow *window)
|
||||
{
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
||||
|
||||
if (!impl->toplevel)
|
||||
return;
|
||||
|
||||
if (private->event_mask & GDK_STRUCTURE_MASK)
|
||||
if (window->event_mask & GDK_STRUCTURE_MASK)
|
||||
{
|
||||
GdkEvent event;
|
||||
|
||||
@ -533,17 +528,15 @@ find_toplevel_under_pointer (GdkDisplay *display,
|
||||
toplevel = info->toplevel_under_pointer;
|
||||
if (toplevel && WINDOW_IS_TOPLEVEL (toplevel))
|
||||
{
|
||||
GdkWindowObject *private;
|
||||
NSWindow *nswindow;
|
||||
NSPoint point;
|
||||
|
||||
private = (GdkWindowObject *)toplevel;
|
||||
nswindow = ((GdkWindowImplQuartz *)private->impl)->toplevel;
|
||||
nswindow = ((GdkWindowImplQuartz *)toplevel->impl)->toplevel;
|
||||
|
||||
point = [nswindow convertScreenToBase:screen_point];
|
||||
|
||||
*x = point.x;
|
||||
*y = private->height - point.y;
|
||||
*y = toplevel->height - point.y;
|
||||
}
|
||||
|
||||
return toplevel;
|
||||
@ -599,13 +592,11 @@ find_toplevel_for_mouse_event (NSEvent *nsevent,
|
||||
GdkQuartzView *view;
|
||||
GdkDisplay *display;
|
||||
GdkDeviceGrabInfo *grab;
|
||||
GdkWindowObject *private;
|
||||
|
||||
view = (GdkQuartzView *)[[nsevent window] contentView];
|
||||
toplevel = [view gdkWindow];
|
||||
|
||||
display = gdk_window_get_display (toplevel);
|
||||
private = GDK_WINDOW_OBJECT (toplevel);
|
||||
|
||||
event_type = [nsevent type];
|
||||
point = [nsevent locationInWindow];
|
||||
@ -657,18 +648,16 @@ find_toplevel_for_mouse_event (NSEvent *nsevent,
|
||||
{
|
||||
/* Finally check the grab window. */
|
||||
GdkWindow *grab_toplevel;
|
||||
GdkWindowObject *grab_private;
|
||||
NSWindow *grab_nswindow;
|
||||
|
||||
grab_toplevel = gdk_window_get_effective_toplevel (grab->window);
|
||||
grab_private = (GdkWindowObject *)grab_toplevel;
|
||||
|
||||
grab_nswindow = ((GdkWindowImplQuartz *)grab_private->impl)->toplevel;
|
||||
grab_nswindow = ((GdkWindowImplQuartz *)grab_toplevel->impl)->toplevel;
|
||||
point = [grab_nswindow convertScreenToBase:screen_point];
|
||||
|
||||
/* Note: x_root and y_root are already right. */
|
||||
*x = point.x;
|
||||
*y = grab_private->height - point.y;
|
||||
*y = grab_toplevel->height - point.y;
|
||||
|
||||
return grab_toplevel;
|
||||
}
|
||||
@ -699,13 +688,11 @@ find_toplevel_for_mouse_event (NSEvent *nsevent,
|
||||
if (toplevel_under_pointer
|
||||
&& WINDOW_IS_TOPLEVEL (toplevel_under_pointer))
|
||||
{
|
||||
GdkWindowObject *toplevel_private;
|
||||
GdkWindowImplQuartz *toplevel_impl;
|
||||
|
||||
toplevel = toplevel_under_pointer;
|
||||
|
||||
toplevel_private = (GdkWindowObject *)toplevel;
|
||||
toplevel_impl = (GdkWindowImplQuartz *)toplevel_private->impl;
|
||||
toplevel_impl = (GdkWindowImplQuartz *)toplevel->impl;
|
||||
|
||||
if ([toplevel_impl->toplevel showsResizeIndicator])
|
||||
{
|
||||
@ -756,17 +743,15 @@ find_window_for_ns_event (NSEvent *nsevent,
|
||||
NSPoint screen_point;
|
||||
NSEventType event_type;
|
||||
GdkWindow *toplevel;
|
||||
GdkWindowObject *private;
|
||||
|
||||
view = (GdkQuartzView *)[[nsevent window] contentView];
|
||||
toplevel = [view gdkWindow];
|
||||
private = GDK_WINDOW_OBJECT (toplevel);
|
||||
|
||||
point = [nsevent locationInWindow];
|
||||
screen_point = [[nsevent window] convertBaseToScreen:point];
|
||||
|
||||
*x = point.x;
|
||||
*y = private->height - point.y;
|
||||
*y = toplevel->height - point.y;
|
||||
|
||||
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, x_root, y_root);
|
||||
|
||||
@ -934,11 +919,8 @@ fill_scroll_event (GdkWindow *window,
|
||||
gint y_root,
|
||||
GdkScrollDirection direction)
|
||||
{
|
||||
GdkWindowObject *private;
|
||||
NSPoint point;
|
||||
|
||||
private = GDK_WINDOW_OBJECT (window);
|
||||
|
||||
point = [nsevent locationInWindow];
|
||||
|
||||
event->any.type = GDK_SCROLL;
|
||||
@ -1083,17 +1065,13 @@ synthesize_crossing_event (GdkWindow *window,
|
||||
gint x_root,
|
||||
gint y_root)
|
||||
{
|
||||
GdkWindowObject *private;
|
||||
|
||||
private = GDK_WINDOW_OBJECT (window);
|
||||
|
||||
switch ([nsevent type])
|
||||
{
|
||||
case NSMouseEntered:
|
||||
/* Enter events are considered always to be from the root window as we
|
||||
* can't know for sure from what window we enter.
|
||||
*/
|
||||
if (!(private->event_mask & GDK_ENTER_NOTIFY_MASK))
|
||||
if (!(window->event_mask & GDK_ENTER_NOTIFY_MASK))
|
||||
return FALSE;
|
||||
|
||||
fill_crossing_event (window, event, nsevent,
|
||||
@ -1109,7 +1087,7 @@ synthesize_crossing_event (GdkWindow *window,
|
||||
* since there is no way to reliably get information about what new
|
||||
* window is entered when exiting one.
|
||||
*/
|
||||
if (!(private->event_mask & GDK_LEAVE_NOTIFY_MASK))
|
||||
if (!(window->event_mask & GDK_LEAVE_NOTIFY_MASK))
|
||||
return FALSE;
|
||||
|
||||
fill_crossing_event (window, event, nsevent,
|
||||
@ -1220,14 +1198,13 @@ gdk_event_translate (GdkEvent *event,
|
||||
/* Apply any window filters. */
|
||||
if (GDK_IS_WINDOW (window))
|
||||
{
|
||||
GdkWindowObject *filter_private = (GdkWindowObject *) window;
|
||||
GdkFilterReturn result;
|
||||
|
||||
if (filter_private->filters)
|
||||
if (window->filters)
|
||||
{
|
||||
g_object_ref (window);
|
||||
|
||||
result = gdk_event_apply_filters (nsevent, event, &filter_private->filters);
|
||||
result = gdk_event_apply_filters (nsevent, event, &window->filters);
|
||||
|
||||
g_object_unref (window);
|
||||
|
||||
@ -1248,8 +1225,7 @@ gdk_event_translate (GdkEvent *event,
|
||||
event_type == NSOtherMouseDown ||
|
||||
event_type == NSLeftMouseDown))
|
||||
{
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
||||
|
||||
if (![NSApp isActive])
|
||||
{
|
||||
|
@ -29,8 +29,7 @@ _gdk_quartz_window_translate (GdkWindow *window,
|
||||
gint dy)
|
||||
{
|
||||
cairo_region_t *invalidate, *scrolled;
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkWindowImplQuartz *impl = (GdkWindowImplQuartz *)private->impl;
|
||||
GdkWindowImplQuartz *impl = (GdkWindowImplQuartz *)window->impl;
|
||||
GdkRectangle extents;
|
||||
|
||||
cairo_region_get_extents (area, &extents);
|
||||
|
@ -65,7 +65,7 @@ _gdk_input_select_device_events (GdkWindow *impl_window,
|
||||
GdkDevice *device)
|
||||
{
|
||||
guint event_mask;
|
||||
GdkWindowObject *w;
|
||||
GdkWindow *w;
|
||||
GdkInputWindow *iw;
|
||||
GdkInputMode mode;
|
||||
gboolean has_cursor;
|
||||
@ -73,7 +73,7 @@ _gdk_input_select_device_events (GdkWindow *impl_window,
|
||||
GList *l;
|
||||
|
||||
event_mask = 0;
|
||||
iw = ((GdkWindowObject *)impl_window)->input_window;
|
||||
iw = impl_window->input_window;
|
||||
|
||||
g_object_get (device,
|
||||
"type", &type,
|
||||
@ -140,16 +140,14 @@ gdk_input_set_extension_events (GdkWindow *window,
|
||||
gint mask,
|
||||
GdkExtensionMode mode)
|
||||
{
|
||||
GdkWindowObject *window_private;
|
||||
GdkWindowObject *impl_window;
|
||||
GList *tmp_list;
|
||||
GdkInputWindow *iw;
|
||||
GdkWindow *impl_window;
|
||||
|
||||
g_return_if_fail (window != NULL);
|
||||
g_return_if_fail (GDK_WINDOW_IS_QUARTZ (window));
|
||||
|
||||
window_private = (GdkWindowObject*) window;
|
||||
impl_window = (GdkWindowObject *)_gdk_window_get_impl_window (window);
|
||||
impl_window = (GdkWindow *)_gdk_window_get_impl_window (window);
|
||||
|
||||
if (mode == GDK_EXTENSION_EVENTS_NONE)
|
||||
mask = 0;
|
||||
@ -166,7 +164,7 @@ gdk_input_set_extension_events (GdkWindow *window,
|
||||
iw->grabbed = FALSE;
|
||||
|
||||
_gdk_input_windows = g_list_append (_gdk_input_windows, iw);
|
||||
window_private->extension_events = mask;
|
||||
window->extension_events = mask;
|
||||
|
||||
/* Add enter window events to the event mask */
|
||||
/* FIXME, this is not needed for XINPUT_NONE */
|
||||
@ -183,7 +181,7 @@ gdk_input_set_extension_events (GdkWindow *window,
|
||||
g_free (iw);
|
||||
}
|
||||
|
||||
window_private->extension_events = 0;
|
||||
window->extension_events = 0;
|
||||
}
|
||||
|
||||
for (tmp_list = _gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
|
||||
|
@ -62,7 +62,7 @@ extern GdkWindow *_gdk_root;
|
||||
|
||||
extern GdkDragContext *_gdk_quartz_drag_source_context;
|
||||
|
||||
#define GDK_WINDOW_IS_QUARTZ(win) (GDK_IS_WINDOW_IMPL_QUARTZ (((GdkWindowObject *)win)->impl))
|
||||
#define GDK_WINDOW_IS_QUARTZ(win) (GDK_IS_WINDOW_IMPL_QUARTZ (((GdkWindow *)win)->impl))
|
||||
|
||||
/* Initialization */
|
||||
void _gdk_windowing_update_window_sizes (GdkScreen *screen);
|
||||
@ -130,10 +130,6 @@ void _gdk_quartz_event_loop_release_event (NSEvent *event);
|
||||
GdkEventType _gdk_quartz_keys_event_type (NSEvent *event);
|
||||
gboolean _gdk_quartz_keys_is_modifier (guint keycode);
|
||||
|
||||
/* Drawable */
|
||||
void _gdk_quartz_drawable_finish (GdkDrawable *drawable);
|
||||
void _gdk_quartz_drawable_flush (GdkDrawable *drawable);
|
||||
|
||||
/* Geometry */
|
||||
void _gdk_quartz_window_scroll (GdkWindow *window,
|
||||
gint dx,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,9 +21,9 @@
|
||||
#ifndef __GDK_WINDOW_QUARTZ_H__
|
||||
#define __GDK_WINDOW_QUARTZ_H__
|
||||
|
||||
#include <gdk/quartz/gdkdrawable-quartz.h>
|
||||
#import <gdk/quartz/GdkQuartzView.h>
|
||||
#import <gdk/quartz/GdkQuartzWindow.h>
|
||||
#include "gdk/gdkwindowimpl.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -42,7 +42,9 @@ typedef struct _GdkWindowImplQuartzClass GdkWindowImplQuartzClass;
|
||||
|
||||
struct _GdkWindowImplQuartz
|
||||
{
|
||||
GdkDrawableImplQuartz parent_instance;
|
||||
GdkWindowImpl parent_instance;
|
||||
|
||||
GdkWindow *wrapper;
|
||||
|
||||
NSWindow *toplevel;
|
||||
NSTrackingRectTag tracking_rect;
|
||||
@ -60,15 +62,26 @@ struct _GdkWindowImplQuartz
|
||||
GList *sorted_children;
|
||||
|
||||
cairo_region_t *needs_display_region;
|
||||
|
||||
cairo_surface_t *cairo_surface;
|
||||
};
|
||||
|
||||
struct _GdkWindowImplQuartzClass
|
||||
{
|
||||
GdkDrawableImplQuartzClass parent_class;
|
||||
GdkWindowImplClass parent_class;
|
||||
|
||||
CGContextRef (* get_context) (GdkWindowImplQuartz *window,
|
||||
gboolean antialias);
|
||||
void (* release_context) (GdkWindowImplQuartz *window,
|
||||
CGContextRef cg_context);
|
||||
};
|
||||
|
||||
GType _gdk_window_impl_quartz_get_type (void);
|
||||
|
||||
CGContextRef gdk_quartz_window_get_context (GdkWindowImplQuartz *window,
|
||||
gboolean antialias);
|
||||
void gdk_quartz_window_release_context (GdkWindowImplQuartz *window,
|
||||
CGContextRef context);
|
||||
|
||||
/* Root window implementation for Quartz
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user