Commit cf354215 authored by Kristian Rietveld's avatar Kristian Rietveld Committed by Kristian Rietveld

adapt to use GdkWindowImpl interface.

2008-06-27  Kristian Rietveld  <kris@imendio.com>

	* gdk/quartz/gdkgeometry-quartz.c:
	* gdk/quartz/gdkwindow-quartz.c:
	* gdk/quartz/gdkprivate-quartz.h: adapt to use GdkWindowImpl
	interface.


svn path=/trunk/; revision=20697
parent b3bb8c47
2008-06-27 Kristian Rietveld <kris@imendio.com>
* gdk/quartz/gdkgeometry-quartz.c:
* gdk/quartz/gdkwindow-quartz.c:
* gdk/quartz/gdkprivate-quartz.h: adapt to use GdkWindowImpl
interface.
2008-06-27 Carlos Garnacho <carlos@imendio.com> 2008-06-27 Carlos Garnacho <carlos@imendio.com>
* gtk/gtkrecentmanager.c (get_icon_for_mime_type): Fix two potential * gtk/gtkrecentmanager.c (get_icon_for_mime_type): Fix two potential
......
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
#include "gdkprivate-quartz.h" #include "gdkprivate-quartz.h"
void void
gdk_window_scroll (GdkWindow *window, _gdk_quartz_window_scroll (GdkWindow *window,
gint dx, gint dx,
gint dy) gint dy)
{ {
NSRect visible_nsrect; NSRect visible_nsrect;
GdkRectangle visible_rect, scrolled_rect; GdkRectangle visible_rect, scrolled_rect;
...@@ -36,8 +36,6 @@ gdk_window_scroll (GdkWindow *window, ...@@ -36,8 +36,6 @@ gdk_window_scroll (GdkWindow *window,
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
GList *list; GList *list;
g_return_if_fail (GDK_IS_WINDOW (window));
/* Move the current invalid region */ /* Move the current invalid region */
if (private->update_area) if (private->update_area)
gdk_region_offset (private->update_area, dx, dy); gdk_region_offset (private->update_area, dx, dy);
...@@ -83,10 +81,10 @@ gdk_window_scroll (GdkWindow *window, ...@@ -83,10 +81,10 @@ gdk_window_scroll (GdkWindow *window,
} }
void void
gdk_window_move_region (GdkWindow *window, _gdk_quartz_window_move_region (GdkWindow *window,
const GdkRegion *region, const GdkRegion *region,
gint dx, gint dx,
gint dy) gint dy)
{ {
/* FIXME: Implement */ /* FIXME: Implement */
} }
...@@ -187,4 +187,13 @@ gboolean _gdk_quartz_keys_is_modifier (guint keycode); ...@@ -187,4 +187,13 @@ gboolean _gdk_quartz_keys_is_modifier (guint keycode);
/* Drawable */ /* Drawable */
void _gdk_quartz_drawable_finish (GdkDrawable *drawable); void _gdk_quartz_drawable_finish (GdkDrawable *drawable);
/* Geometry */
void _gdk_quartz_window_scroll (GdkWindow *window,
gint dx,
gint dy);
void _gdk_quartz_window_move_region (GdkWindow *window,
const GdkRegion *region,
gint dx,
gint dy);
#endif /* __GDK_PRIVATE_QUARTZ_H__ */ #endif /* __GDK_PRIVATE_QUARTZ_H__ */
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#include "gdk.h" #include "gdk.h"
#include "gdkwindowimpl.h"
#include "gdkprivate-quartz.h" #include "gdkprivate-quartz.h"
static gpointer parent_class; static gpointer parent_class;
...@@ -51,6 +52,8 @@ static FullscreenSavedGeometry *get_fullscreen_geometry (GdkWindow *window); ...@@ -51,6 +52,8 @@ static FullscreenSavedGeometry *get_fullscreen_geometry (GdkWindow *window);
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
static void gdk_window_impl_iface_init (GdkWindowImplIface *iface);
NSView * NSView *
gdk_quartz_window_get_nsview (GdkWindow *window) gdk_quartz_window_get_nsview (GdkWindow *window)
{ {
...@@ -488,12 +491,22 @@ _gdk_window_impl_quartz_get_type (void) ...@@ -488,12 +491,22 @@ _gdk_window_impl_quartz_get_type (void)
NULL NULL
}; };
const GInterfaceInfo window_impl_info =
{
(GInterfaceInitFunc) gdk_window_impl_iface_init,
NULL,
NULL
};
object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_QUARTZ, object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_QUARTZ,
"GdkWindowImplQuartz", "GdkWindowImplQuartz",
&object_info, 0); &object_info, 0);
g_type_add_interface_static (object_type, g_type_add_interface_static (object_type,
GDK_TYPE_PAINTABLE, GDK_TYPE_PAINTABLE,
&paintable_info); &paintable_info);
g_type_add_interface_static (object_type,
GDK_TYPE_WINDOW_IMPL,
&window_impl_info);
} }
return object_type; return object_type;
...@@ -801,7 +814,10 @@ _gdk_window_new (GdkWindow *parent, ...@@ -801,7 +814,10 @@ _gdk_window_new (GdkWindow *parent,
parent = _gdk_root; parent = _gdk_root;
window = g_object_new (GDK_TYPE_WINDOW, NULL); window = g_object_new (GDK_TYPE_WINDOW, NULL);
private = (GdkWindowObject *)window; private = (GdkWindowObject *)window;
private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
draw_impl = GDK_DRAWABLE_IMPL_QUARTZ (private->impl); draw_impl = GDK_DRAWABLE_IMPL_QUARTZ (private->impl);
draw_impl->wrapper = GDK_DRAWABLE (window); draw_impl->wrapper = GDK_DRAWABLE (window);
...@@ -1015,14 +1031,15 @@ _gdk_windowing_window_init (void) ...@@ -1015,14 +1031,15 @@ _gdk_windowing_window_init (void)
_gdk_root = g_object_new (GDK_TYPE_WINDOW, NULL); _gdk_root = g_object_new (GDK_TYPE_WINDOW, NULL);
private = (GdkWindowObject *)_gdk_root;
private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
/* Note: This needs to be reworked for multi-screen support. */ /* Note: This needs to be reworked for multi-screen support. */
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl); impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl);
rect = [[NSScreen mainScreen] frame]; rect = [[NSScreen mainScreen] frame];
impl->width = rect.size.width; impl->width = rect.size.width;
impl->height = rect.size.height; impl->height = rect.size.height;
private = (GdkWindowObject *)_gdk_root;
private->state = 0; /* We don't want GDK_WINDOW_STATE_WITHDRAWN here */ private->state = 0; /* We don't want GDK_WINDOW_STATE_WITHDRAWN here */
private->window_type = GDK_WINDOW_ROOT; private->window_type = GDK_WINDOW_ROOT;
private->depth = 24; private->depth = 24;
...@@ -1114,8 +1131,8 @@ all_parents_shown (GdkWindowObject *private) ...@@ -1114,8 +1131,8 @@ all_parents_shown (GdkWindowObject *private)
* possible to show a window without raising it? * possible to show a window without raising it?
*/ */
static void static void
show_window_internal (GdkWindow *window, gdk_window_quartz_show (GdkWindow *window,
gboolean raise) gboolean raise)
{ {
GdkWindowObject *private; GdkWindowObject *private;
GdkWindowImplQuartz *impl; GdkWindowImplQuartz *impl;
...@@ -1224,30 +1241,12 @@ _gdk_quartz_window_attach_to_parent (GdkWindow *window) ...@@ -1224,30 +1241,12 @@ _gdk_quartz_window_attach_to_parent (GdkWindow *window)
} }
void void
gdk_window_show_unraised (GdkWindow *window) gdk_window_quartz_hide (GdkWindow *window)
{
g_return_if_fail (GDK_IS_WINDOW (window));
show_window_internal (window, FALSE);
}
void
gdk_window_show (GdkWindow *window)
{
g_return_if_fail (GDK_IS_WINDOW (window));
show_window_internal (window, TRUE);
}
void
gdk_window_hide (GdkWindow *window)
{ {
GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowObject *private = (GdkWindowObject *)window;
GdkWindowImplQuartz *impl; GdkWindowImplQuartz *impl;
GdkWindow *mouse_window; GdkWindow *mouse_window;
g_return_if_fail (GDK_IS_WINDOW (window));
/* Make sure we're not stuck in fullscreen mode. */ /* Make sure we're not stuck in fullscreen mode. */
if (get_fullscreen_geometry (window)) if (get_fullscreen_geometry (window))
SetSystemUIMode (kUIModeNormal, 0); SetSystemUIMode (kUIModeNormal, 0);
...@@ -1294,7 +1293,7 @@ gdk_window_hide (GdkWindow *window) ...@@ -1294,7 +1293,7 @@ gdk_window_hide (GdkWindow *window)
} }
void void
gdk_window_withdraw (GdkWindow *window) gdk_window_quartz_withdraw (GdkWindow *window)
{ {
gdk_window_hide (window); gdk_window_hide (window);
} }
...@@ -1459,10 +1458,10 @@ move_resize_window_internal (GdkWindow *window, ...@@ -1459,10 +1458,10 @@ move_resize_window_internal (GdkWindow *window,
GDK_QUARTZ_RELEASE_POOL; GDK_QUARTZ_RELEASE_POOL;
} }
void static inline void
gdk_window_move (GdkWindow *window, window_quartz_move (GdkWindow *window,
gint x, gint x,
gint y) gint y)
{ {
g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_IS_WINDOW (window));
...@@ -1472,10 +1471,10 @@ gdk_window_move (GdkWindow *window, ...@@ -1472,10 +1471,10 @@ gdk_window_move (GdkWindow *window,
move_resize_window_internal (window, x, y, -1, -1); move_resize_window_internal (window, x, y, -1, -1);
} }
void static inline void
gdk_window_resize (GdkWindow *window, window_quartz_resize (GdkWindow *window,
gint width, gint width,
gint height) gint height)
{ {
g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_IS_WINDOW (window));
...@@ -1490,12 +1489,12 @@ gdk_window_resize (GdkWindow *window, ...@@ -1490,12 +1489,12 @@ gdk_window_resize (GdkWindow *window,
move_resize_window_internal (window, -1, -1, width, height); move_resize_window_internal (window, -1, -1, width, height);
} }
void static inline void
gdk_window_move_resize (GdkWindow *window, window_quartz_move_resize (GdkWindow *window,
gint x, gint x,
gint y, gint y,
gint width, gint width,
gint height) gint height)
{ {
if (width < 1) if (width < 1)
width = 1; width = 1;
...@@ -1505,11 +1504,30 @@ gdk_window_move_resize (GdkWindow *window, ...@@ -1505,11 +1504,30 @@ gdk_window_move_resize (GdkWindow *window,
move_resize_window_internal (window, x, y, width, height); move_resize_window_internal (window, x, y, width, height);
} }
void static void
_gdk_window_reparent (GdkWindow *window, gdk_window_quartz_move_resize (GdkWindow *window,
GdkWindow *new_parent, gboolean with_move,
gint x, gint x,
gint y) 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);
}
}
static gboolean
gdk_window_quartz_reparent (GdkWindow *window,
GdkWindow *new_parent,
gint x,
gint y)
{ {
GdkWindowObject *private, *old_parent_private, *new_parent_private; GdkWindowObject *private, *old_parent_private, *new_parent_private;
GdkWindowImplQuartz *impl, *old_parent_impl, *new_parent_impl; GdkWindowImplQuartz *impl, *old_parent_impl, *new_parent_impl;
...@@ -1519,7 +1537,7 @@ _gdk_window_reparent (GdkWindow *window, ...@@ -1519,7 +1537,7 @@ _gdk_window_reparent (GdkWindow *window,
{ {
/* Could be added, just needs implementing. */ /* Could be added, just needs implementing. */
g_warning ("Reparenting to root window is not supported yet in the Mac OS X backend"); g_warning ("Reparenting to root window is not supported yet in the Mac OS X backend");
return; return FALSE;
} }
private = GDK_WINDOW_OBJECT (window); private = GDK_WINDOW_OBJECT (window);
...@@ -1552,24 +1570,17 @@ _gdk_window_reparent (GdkWindow *window, ...@@ -1552,24 +1570,17 @@ _gdk_window_reparent (GdkWindow *window,
new_parent_private->children = g_list_prepend (new_parent_private->children, window); new_parent_private->children = g_list_prepend (new_parent_private->children, window);
new_parent_impl->sorted_children = g_list_prepend (new_parent_impl->sorted_children, window); new_parent_impl->sorted_children = g_list_prepend (new_parent_impl->sorted_children, window);
}
void return TRUE;
_gdk_windowing_window_clear_area (GdkWindow *window,
gint x,
gint y,
gint width,
gint height)
{
/* FIXME: Implement */
} }
void static void
_gdk_windowing_window_clear_area_e (GdkWindow *window, gdk_window_quartz_clear_area (GdkWindow *window,
gint x, gint x,
gint y, gint y,
gint width, gint width,
gint height) gint height,
gboolean send_expose)
{ {
/* FIXME: Implement */ /* FIXME: Implement */
} }
...@@ -1625,11 +1636,9 @@ clear_toplevel_order (void) ...@@ -1625,11 +1636,9 @@ clear_toplevel_order (void)
root_impl->sorted_children = NULL; root_impl->sorted_children = NULL;
} }
void static void
gdk_window_raise (GdkWindow *window) gdk_window_quartz_raise (GdkWindow *window)
{ {
g_return_if_fail (GDK_IS_WINDOW (window));
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
return; return;
...@@ -1658,11 +1667,9 @@ gdk_window_raise (GdkWindow *window) ...@@ -1658,11 +1667,9 @@ gdk_window_raise (GdkWindow *window)
} }
} }
void static void
gdk_window_lower (GdkWindow *window) gdk_window_quartz_lower (GdkWindow *window)
{ {
g_return_if_fail (GDK_IS_WINDOW (window));
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
return; return;
...@@ -1691,15 +1698,13 @@ gdk_window_lower (GdkWindow *window) ...@@ -1691,15 +1698,13 @@ gdk_window_lower (GdkWindow *window)
} }
} }
void static void
gdk_window_set_background (GdkWindow *window, gdk_window_quartz_set_background (GdkWindow *window,
const GdkColor *color) const GdkColor *color)
{ {
GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowObject *private = (GdkWindowObject *)window;
GdkWindowImplQuartz *impl; GdkWindowImplQuartz *impl;
g_return_if_fail (GDK_IS_WINDOW (window));
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
return; return;
...@@ -1715,17 +1720,13 @@ gdk_window_set_background (GdkWindow *window, ...@@ -1715,17 +1720,13 @@ gdk_window_set_background (GdkWindow *window,
private->bg_pixmap = NULL; private->bg_pixmap = NULL;
} }
void static void
gdk_window_set_back_pixmap (GdkWindow *window, gdk_window_quartz_set_back_pixmap (GdkWindow *window,
GdkPixmap *pixmap, GdkPixmap *pixmap,
gboolean parent_relative) gboolean parent_relative)
{ {
GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowObject *private = (GdkWindowObject *)window;
g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (pixmap == NULL || !parent_relative);
g_return_if_fail (pixmap == NULL || gdk_drawable_get_depth (window) == gdk_drawable_get_depth (pixmap));
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
return; return;
...@@ -1753,16 +1754,14 @@ gdk_window_set_back_pixmap (GdkWindow *window, ...@@ -1753,16 +1754,14 @@ gdk_window_set_back_pixmap (GdkWindow *window,
} }
} }
void static void
gdk_window_set_cursor (GdkWindow *window, gdk_window_quartz_set_cursor (GdkWindow *window,
GdkCursor *cursor) GdkCursor *cursor)
{ {
GdkWindowImplQuartz *impl; GdkWindowImplQuartz *impl;
GdkCursorPrivate *cursor_private; GdkCursorPrivate *cursor_private;
NSCursor *nscursor; NSCursor *nscursor;
g_return_if_fail (GDK_IS_WINDOW (window));
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
cursor_private = (GdkCursorPrivate *)cursor; cursor_private = (GdkCursorPrivate *)cursor;
...@@ -1786,22 +1785,17 @@ gdk_window_set_cursor (GdkWindow *window, ...@@ -1786,22 +1785,17 @@ gdk_window_set_cursor (GdkWindow *window,
_gdk_quartz_events_update_cursor (_gdk_quartz_events_get_mouse_window (TRUE)); _gdk_quartz_events_update_cursor (_gdk_quartz_events_get_mouse_window (TRUE));
} }
void static void
gdk_window_get_geometry (GdkWindow *window, gdk_window_quartz_get_geometry (GdkWindow *window,
gint *x, gint *x,
gint *y, gint *y,
gint *width, gint *width,
gint *height, gint *height,
gint *depth) gint *depth)
{ {
GdkWindowImplQuartz *impl; GdkWindowImplQuartz *impl;
NSRect ns_rect; NSRect ns_rect;
g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
if (!window)
window = _gdk_root;
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
return; return;
...@@ -1868,10 +1862,10 @@ gdk_window_get_geometry (GdkWindow *window, ...@@ -1868,10 +1862,10 @@ gdk_window_get_geometry (GdkWindow *window,
*depth = gdk_drawable_get_depth (window); *depth = gdk_drawable_get_depth (window);
} }
gboolean static gint
gdk_window_get_origin (GdkWindow *window, gdk_window_quartz_get_origin (GdkWindow *window,
gint *x, gint *x,
gint *y) gint *y)
{ {
GdkWindowObject *private; GdkWindowObject *private;
int tmp_x = 0, tmp_y = 0; int tmp_x = 0, tmp_y = 0;
...@@ -1879,8 +1873,6 @@ gdk_window_get_origin (GdkWindow *window, ...@@ -1879,8 +1873,6 @@ gdk_window_get_origin (GdkWindow *window,
NSRect content_rect; NSRect content_rect;
GdkWindowImplQuartz *impl; GdkWindowImplQuartz *impl;
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
{ {
if (x) if (x)
...@@ -1888,14 +1880,14 @@ gdk_window_get_origin (GdkWindow *window, ...@@ -1888,14 +1880,14 @@ gdk_window_get_origin (GdkWindow *window,
if (y) if (y)
*y = 0; *y = 0;
return FALSE; return 0;
} }
if (window == _gdk_root) if (window == _gdk_root)
{ {
*x = 0; *x = 0;
*y = 0; *y = 0;
return TRUE; return 1;
} }
private = GDK_WINDOW_OBJECT (window); private = GDK_WINDOW_OBJECT (window);
...@@ -2091,23 +2083,19 @@ _gdk_windowing_window_at_pointer (GdkDisplay *display, ...@@ -2091,23 +2083,19 @@ _gdk_windowing_window_at_pointer (GdkDisplay *display,
return found_window; return found_window;
} }
GdkEventMask static GdkEventMask
gdk_window_get_events (GdkWindow *window) gdk_window_quartz_get_events (GdkWindow *window)
{ {
g_return_val_if_fail (GDK_IS_WINDOW (window), 0);