gtk2/gdk/quartz/gdkprivate-quartz.h

213 lines
7.9 KiB
C
Raw Normal View History

/* gdkwindow-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.
*/
#ifndef __GDK_PRIVATE_QUARTZ_H__
#define __GDK_PRIVATE_QUARTZ_H__
#define GDK_QUARTZ_ALLOC_POOL NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]
#define GDK_QUARTZ_RELEASE_POOL [pool release]
#include <gdk/gdkprivate.h>
#include <gdk/quartz/gdkpixmap-quartz.h>
#include <gdk/quartz/gdkwindow-quartz.h>
#include <gdk/quartz/gdkquartz.h>
#include <gdk/gdk.h>
#include "gdkinternals.h"
#include "config.h"
#define GDK_TYPE_GC_QUARTZ (_gdk_gc_quartz_get_type ())
#define GDK_GC_QUARTZ(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_QUARTZ, GdkGCQuartz))
#define GDK_GC_QUARTZ_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GC_QUARTZ, GdkGCQuartzClass))
#define GDK_IS_GC_QUARTZ(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GC_QUARTZ))
#define GDK_IS_GC_QUARTZ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GC_QUARTZ))
#define GDK_GC_QUARTZ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GC_QUARTZ, GdkGCQuartzClass))
#define GDK_DRAG_CONTEXT_PRIVATE(context) ((GdkDragContextPrivate *) GDK_DRAG_CONTEXT (context)->windowing_data)
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkGCQuartz GdkGCQuartz;
typedef struct _GdkGCQuartzClass GdkGCQuartzClass;
typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
struct _GdkGCQuartz
{
Implement lots of value setters for GdkGC, based on a heavily modified 2006-09-21 Michael Natterer <mitch@imendio.com> Implement lots of value setters for GdkGC, based on a heavily modified patch from Thomas Broyer (bug #328853): * gdk/quartz/gdkcolor-quartz.c: removed functions which set colors on the CGContext. Instead, added gdk_quartz_get_rgba_from_pixel() which simply returns RGBA values from a GdkColor's pixel value. See gdk_quartz_update_context_from_gc() below. * gdk/quartz/gdkprivate-quartz.h (struct GdkGCQuartz): added lots of members for the newly suppored GC values. Added enum GdkQuartzContextValuesMask which is used for setting up the CGContext for filling and/or stroking. * gdk/quartz/gdkgc-quartz.c (gdk_quartz_gc_get_values) (gdk_quartz_gc_set_values) (_gdk_windowing_gc_copy): support a lot more GC values. (gdk_quartz_update_context_from_gc): added GdkQuartzContextValuesMask parameter and set filling/stroking parameters accordingly. This function also gained full control over the FG and BG colors (they can't be set separately any more). The stipple mask part of the patch doesn't work but seems to take the right approach and doesn't make things worse, so I applied it. Did *not* apply the clipping part of the patch since I don't understand it (I don't understand the version in CVS either, but it at least works :-) * gdk/quartz/gdkdrawable-quartz.c: pass the right masks to gdk_quartz_update_context_from_gc() and removed separate color setting calls. Some minor fixes. * gdk/quartz/gdkwindow-quartz.c (gdk_window_impl_quartz_begin_paint_region): set the CGContext's fill color manually. We don't have/need a GC here.
2006-09-21 17:05:33 +00:00
GdkGC parent_instance;
Implement lots of value setters for GdkGC, based on a heavily modified 2006-09-21 Michael Natterer <mitch@imendio.com> Implement lots of value setters for GdkGC, based on a heavily modified patch from Thomas Broyer (bug #328853): * gdk/quartz/gdkcolor-quartz.c: removed functions which set colors on the CGContext. Instead, added gdk_quartz_get_rgba_from_pixel() which simply returns RGBA values from a GdkColor's pixel value. See gdk_quartz_update_context_from_gc() below. * gdk/quartz/gdkprivate-quartz.h (struct GdkGCQuartz): added lots of members for the newly suppored GC values. Added enum GdkQuartzContextValuesMask which is used for setting up the CGContext for filling and/or stroking. * gdk/quartz/gdkgc-quartz.c (gdk_quartz_gc_get_values) (gdk_quartz_gc_set_values) (_gdk_windowing_gc_copy): support a lot more GC values. (gdk_quartz_update_context_from_gc): added GdkQuartzContextValuesMask parameter and set filling/stroking parameters accordingly. This function also gained full control over the FG and BG colors (they can't be set separately any more). The stipple mask part of the patch doesn't work but seems to take the right approach and doesn't make things worse, so I applied it. Did *not* apply the clipping part of the patch since I don't understand it (I don't understand the version in CVS either, but it at least works :-) * gdk/quartz/gdkdrawable-quartz.c: pass the right masks to gdk_quartz_update_context_from_gc() and removed separate color setting calls. Some minor fixes. * gdk/quartz/gdkwindow-quartz.c (gdk_window_impl_quartz_begin_paint_region): set the CGContext's fill color manually. We don't have/need a GC here.
2006-09-21 17:05:33 +00:00
GdkFunction function;
GdkSubwindowMode subwindow_mode;
gboolean graphics_exposures;
Implement lots of value setters for GdkGC, based on a heavily modified 2006-09-21 Michael Natterer <mitch@imendio.com> Implement lots of value setters for GdkGC, based on a heavily modified patch from Thomas Broyer (bug #328853): * gdk/quartz/gdkcolor-quartz.c: removed functions which set colors on the CGContext. Instead, added gdk_quartz_get_rgba_from_pixel() which simply returns RGBA values from a GdkColor's pixel value. See gdk_quartz_update_context_from_gc() below. * gdk/quartz/gdkprivate-quartz.h (struct GdkGCQuartz): added lots of members for the newly suppored GC values. Added enum GdkQuartzContextValuesMask which is used for setting up the CGContext for filling and/or stroking. * gdk/quartz/gdkgc-quartz.c (gdk_quartz_gc_get_values) (gdk_quartz_gc_set_values) (_gdk_windowing_gc_copy): support a lot more GC values. (gdk_quartz_update_context_from_gc): added GdkQuartzContextValuesMask parameter and set filling/stroking parameters accordingly. This function also gained full control over the FG and BG colors (they can't be set separately any more). The stipple mask part of the patch doesn't work but seems to take the right approach and doesn't make things worse, so I applied it. Did *not* apply the clipping part of the patch since I don't understand it (I don't understand the version in CVS either, but it at least works :-) * gdk/quartz/gdkdrawable-quartz.c: pass the right masks to gdk_quartz_update_context_from_gc() and removed separate color setting calls. Some minor fixes. * gdk/quartz/gdkwindow-quartz.c (gdk_window_impl_quartz_begin_paint_region): set the CGContext's fill color manually. We don't have/need a GC here.
2006-09-21 17:05:33 +00:00
gboolean have_clip_region;
gboolean have_clip_mask;
CGImageRef clip_mask;
gint line_width;
GdkLineStyle line_style;
GdkCapStyle cap_style;
GdkJoinStyle join_style;
CGFloat *dash_lengths;
Implement lots of value setters for GdkGC, based on a heavily modified 2006-09-21 Michael Natterer <mitch@imendio.com> Implement lots of value setters for GdkGC, based on a heavily modified patch from Thomas Broyer (bug #328853): * gdk/quartz/gdkcolor-quartz.c: removed functions which set colors on the CGContext. Instead, added gdk_quartz_get_rgba_from_pixel() which simply returns RGBA values from a GdkColor's pixel value. See gdk_quartz_update_context_from_gc() below. * gdk/quartz/gdkprivate-quartz.h (struct GdkGCQuartz): added lots of members for the newly suppored GC values. Added enum GdkQuartzContextValuesMask which is used for setting up the CGContext for filling and/or stroking. * gdk/quartz/gdkgc-quartz.c (gdk_quartz_gc_get_values) (gdk_quartz_gc_set_values) (_gdk_windowing_gc_copy): support a lot more GC values. (gdk_quartz_update_context_from_gc): added GdkQuartzContextValuesMask parameter and set filling/stroking parameters accordingly. This function also gained full control over the FG and BG colors (they can't be set separately any more). The stipple mask part of the patch doesn't work but seems to take the right approach and doesn't make things worse, so I applied it. Did *not* apply the clipping part of the patch since I don't understand it (I don't understand the version in CVS either, but it at least works :-) * gdk/quartz/gdkdrawable-quartz.c: pass the right masks to gdk_quartz_update_context_from_gc() and removed separate color setting calls. Some minor fixes. * gdk/quartz/gdkwindow-quartz.c (gdk_window_impl_quartz_begin_paint_region): set the CGContext's fill color manually. We don't have/need a GC here.
2006-09-21 17:05:33 +00:00
gint dash_count;
CGFloat dash_phase;
Implement lots of value setters for GdkGC, based on a heavily modified 2006-09-21 Michael Natterer <mitch@imendio.com> Implement lots of value setters for GdkGC, based on a heavily modified patch from Thomas Broyer (bug #328853): * gdk/quartz/gdkcolor-quartz.c: removed functions which set colors on the CGContext. Instead, added gdk_quartz_get_rgba_from_pixel() which simply returns RGBA values from a GdkColor's pixel value. See gdk_quartz_update_context_from_gc() below. * gdk/quartz/gdkprivate-quartz.h (struct GdkGCQuartz): added lots of members for the newly suppored GC values. Added enum GdkQuartzContextValuesMask which is used for setting up the CGContext for filling and/or stroking. * gdk/quartz/gdkgc-quartz.c (gdk_quartz_gc_get_values) (gdk_quartz_gc_set_values) (_gdk_windowing_gc_copy): support a lot more GC values. (gdk_quartz_update_context_from_gc): added GdkQuartzContextValuesMask parameter and set filling/stroking parameters accordingly. This function also gained full control over the FG and BG colors (they can't be set separately any more). The stipple mask part of the patch doesn't work but seems to take the right approach and doesn't make things worse, so I applied it. Did *not* apply the clipping part of the patch since I don't understand it (I don't understand the version in CVS either, but it at least works :-) * gdk/quartz/gdkdrawable-quartz.c: pass the right masks to gdk_quartz_update_context_from_gc() and removed separate color setting calls. Some minor fixes. * gdk/quartz/gdkwindow-quartz.c (gdk_window_impl_quartz_begin_paint_region): set the CGContext's fill color manually. We don't have/need a GC here.
2006-09-21 17:05:33 +00:00
CGPatternRef ts_pattern;
guint is_window : 1;
};
struct _GdkGCQuartzClass
{
GdkGCClass parent_class;
};
struct _GdkVisualClass
{
GObjectClass parent_class;
};
struct _GdkCursorPrivate
{
GdkCursor cursor;
NSCursor *nscursor;
};
struct _GdkDragContextPrivate
{
id <NSDraggingInfo> dragging_info;
};
extern GdkDisplay *_gdk_display;
extern GdkScreen *_gdk_screen;
extern GdkWindow *_gdk_root;
extern GdkDragContext *_gdk_quartz_drag_source_context;
2009-01-07 13:08:02 +00:00
#define GDK_WINDOW_IS_QUARTZ(win) (GDK_IS_WINDOW_IMPL_QUARTZ (((GdkWindowObject *)win)->impl))
/* Initialization */
void _gdk_windowing_update_window_sizes (GdkScreen *screen);
void _gdk_windowing_window_init (void);
void _gdk_events_init (void);
void _gdk_visual_init (void);
void _gdk_input_init (void);
void _gdk_quartz_event_loop_init (void);
/* GC */
Implement lots of value setters for GdkGC, based on a heavily modified 2006-09-21 Michael Natterer <mitch@imendio.com> Implement lots of value setters for GdkGC, based on a heavily modified patch from Thomas Broyer (bug #328853): * gdk/quartz/gdkcolor-quartz.c: removed functions which set colors on the CGContext. Instead, added gdk_quartz_get_rgba_from_pixel() which simply returns RGBA values from a GdkColor's pixel value. See gdk_quartz_update_context_from_gc() below. * gdk/quartz/gdkprivate-quartz.h (struct GdkGCQuartz): added lots of members for the newly suppored GC values. Added enum GdkQuartzContextValuesMask which is used for setting up the CGContext for filling and/or stroking. * gdk/quartz/gdkgc-quartz.c (gdk_quartz_gc_get_values) (gdk_quartz_gc_set_values) (_gdk_windowing_gc_copy): support a lot more GC values. (gdk_quartz_update_context_from_gc): added GdkQuartzContextValuesMask parameter and set filling/stroking parameters accordingly. This function also gained full control over the FG and BG colors (they can't be set separately any more). The stipple mask part of the patch doesn't work but seems to take the right approach and doesn't make things worse, so I applied it. Did *not* apply the clipping part of the patch since I don't understand it (I don't understand the version in CVS either, but it at least works :-) * gdk/quartz/gdkdrawable-quartz.c: pass the right masks to gdk_quartz_update_context_from_gc() and removed separate color setting calls. Some minor fixes. * gdk/quartz/gdkwindow-quartz.c (gdk_window_impl_quartz_begin_paint_region): set the CGContext's fill color manually. We don't have/need a GC here.
2006-09-21 17:05:33 +00:00
typedef enum {
GDK_QUARTZ_CONTEXT_STROKE = 1 << 0,
GDK_QUARTZ_CONTEXT_FILL = 1 << 1,
GDK_QUARTZ_CONTEXT_TEXT = 1 << 2
} GdkQuartzContextValuesMask;
GType _gdk_gc_quartz_get_type (void);
GdkGC *_gdk_quartz_gc_new (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask values_mask);
void _gdk_quartz_gc_update_cg_context (GdkGC *gc,
GdkDrawable *drawable,
CGContextRef context,
GdkQuartzContextValuesMask mask);
/* Colormap */
CGColorRef _gdk_quartz_colormap_get_cgcolor_from_pixel (GdkDrawable *drawable,
guint32 pixel);
/* Window */
gboolean _gdk_quartz_window_is_ancestor (GdkWindow *ancestor,
GdkWindow *window);
void _gdk_quartz_window_gdk_xy_to_xy (gint gdk_x,
gint gdk_y,
gint *ns_x,
gint *ns_y);
void _gdk_quartz_window_xy_to_gdk_xy (gint ns_x,
gint ns_y,
gint *gdk_x,
gint *gdk_y);
void _gdk_quartz_window_nspoint_to_gdk_xy (NSPoint point,
gint *x,
gint *y);
GdkWindow *_gdk_quartz_window_find_child (GdkWindow *window,
gint x,
2010-05-25 22:38:44 +00:00
gint y,
gboolean get_toplevel);
void _gdk_quartz_window_attach_to_parent (GdkWindow *window);
void _gdk_quartz_window_detach_from_parent (GdkWindow *window);
void _gdk_quartz_window_did_become_main (GdkWindow *window);
void _gdk_quartz_window_did_resign_main (GdkWindow *window);
void _gdk_quartz_window_debug_highlight (GdkWindow *window,
gint number);
void _gdk_quartz_window_set_needs_display_in_region (GdkWindow *window,
cairo_region_t *region);
void _gdk_quartz_window_update_position (GdkWindow *window);
/* Events */
typedef enum {
GDK_QUARTZ_EVENT_SUBTYPE_EVENTLOOP
} GdkQuartzEventSubType;
void _gdk_quartz_events_update_focus_window (GdkWindow *new_window,
gboolean got_focus);
void _gdk_quartz_events_send_map_event (GdkWindow *window);
GdkEventMask _gdk_quartz_events_get_current_event_mask (void);
Improve enter/motion notify semantics On X11 we receive enter notify and motion notify events for a window regardless of its focus state. On Mac OS X this is not the case. This commit improves the semantics to overcome this difference. It improves on my earlier patch that sent a motion notify event when a window became main. Instead of sending a motion notify when a window becomes main, we now send one when a window becomes key, which comes closest to a window getting focus in X11. This motion notify is needed because Mac OS X does not send motion events when an application is inactive (none of its windows have focus), these events are sent in X11. This dummy motion notify event (with current coordinates of the mouse cursor) allows an application to get its prelight and other state right when it gets focus and thus user attention. Another change is to send an enter notify event when updating the tracking rectangle of a GdkQuartView and the mouse cursor is currently in this rectangle. This rectangle is at least updated on window creation. This enter notify event is important for the case where a new window appears right below the mouse cursor. The window has to receive an enter notify event for the subsequent events to be processed correctly. Mac OS X does not send one in this case, so we generate it ourselves. Both of these synthesized events have to go through _gdk_windowing_got_event() for updating statekeeping, etc. append_event() has a boolean flag now to make this convenient.
2010-01-03 14:27:53 +00:00
void _gdk_quartz_events_send_enter_notify_event (GdkWindow *window);
/* Event loop */
gboolean _gdk_quartz_event_loop_check_pending (void);
NSEvent * _gdk_quartz_event_loop_get_pending (void);
void _gdk_quartz_event_loop_release_event (NSEvent *event);
/* FIXME: image */
GdkImage *_gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height);
/* Keys */
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,
gint dy);
2009-01-07 13:08:02 +00:00
void _gdk_quartz_window_queue_translation (GdkWindow *window,
GdkGC *gc,
cairo_region_t *area,
2009-01-07 13:08:02 +00:00
gint dx,
gint dy);
gboolean _gdk_quartz_window_queue_antiexpose (GdkWindow *window,
cairo_region_t *area);
#endif /* __GDK_PRIVATE_QUARTZ_H__ */