Improve comments in those files. Add a debugging helper to print out

2007-06-30  Richard Hult  <richard@imendio.com>

	* gdk/quartz/gdkwindow-quartz.c:
	* gdk/quartz/gdkevents-quartz.c: Improve comments in those
	files. Add a debugging helper to print out information about a
	window.

svn path=/trunk/; revision=18313
This commit is contained in:
Richard Hult 2007-06-30 19:39:45 +00:00 committed by Richard Hult
parent aaab9c05a5
commit 95f61d98f3
3 changed files with 60 additions and 25 deletions

View File

@ -1,3 +1,10 @@
2007-06-30 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkwindow-quartz.c:
* gdk/quartz/gdkevents-quartz.c: Improve comments in those
files. Add a debugging helper to print out information about a
window.
2007-06-30 Johan Dahlin <jdahlin@async.com.br> 2007-06-30 Johan Dahlin <jdahlin@async.com.br>
* gtk/gtkbuilder.c: * gtk/gtkbuilder.c:

View File

@ -69,6 +69,38 @@ static void get_converted_window_coordinates (GdkWindow *in_window,
gint *out_y); gint *out_y);
static void append_event (GdkEvent *event); static void append_event (GdkEvent *event);
static const gchar *
which_window_is_this (GdkWindow *window)
{
static gchar buf[256];
const gchar *name = NULL;
gpointer widget;
/* Get rid of compiler warning. */
if (0) which_window_is_this (window);
if (window == _gdk_root)
name = "root";
else if (window == NULL)
name = "null";
if (window)
{
gdk_window_get_user_data (window, &widget);
if (widget)
name = G_OBJECT_TYPE_NAME (widget);
}
if (!name)
name = "unknown";
snprintf (buf, 256, "<%s (%p)%s>",
name, window,
window == current_mouse_window ? ", is mouse" : "");
return buf;
}
/* A category that exposes the protected carbon event for an NSEvent. */ /* A category that exposes the protected carbon event for an NSEvent. */
@interface NSEvent (GdkQuartzNSEvent) @interface NSEvent (GdkQuartzNSEvent)
- (void *)gdk_quartz_event_ref; - (void *)gdk_quartz_event_ref;
@ -987,7 +1019,7 @@ get_converted_window_coordinates (GdkWindow *in_window,
* finds the subwindow over which the pointer is located. Returns * finds the subwindow over which the pointer is located. Returns
* coordinates relative to the found window. If no window is found, * coordinates relative to the found window. If no window is found,
* returns NULL. * returns NULL.
*/ */
static GdkWindow * static GdkWindow *
find_mouse_window_for_ns_event (NSEvent *nsevent, find_mouse_window_for_ns_event (NSEvent *nsevent,
gint *x_ret, gint *x_ret,
@ -1067,12 +1099,11 @@ synthesize_crossing_events_for_ns_event (NSEvent *nsevent)
case NSLeftMouseDragged: case NSLeftMouseDragged:
case NSRightMouseDragged: case NSRightMouseDragged:
case NSOtherMouseDragged: case NSOtherMouseDragged:
mouse_window = find_mouse_window_for_ns_event (nsevent, &x, &y); /* We only handle moving the pointer to another GDK window.
* Leaving to a non-GDK toplevel window (or window title bar or
/* We don't need to handle the case where we don't find a mouse * the desktop) is covered by NSMouseExited events.
* window (i.e. after leaving a GDK toplevel and not entering a
* new one) here, it's covered by NSMouseExited events.
*/ */
mouse_window = find_mouse_window_for_ns_event (nsevent, &x, &y);
if (mouse_window && mouse_window != current_mouse_window) if (mouse_window && mouse_window != current_mouse_window)
synthesize_crossing_events (mouse_window, GDK_CROSSING_NORMAL, nsevent, x, y); synthesize_crossing_events (mouse_window, GDK_CROSSING_NORMAL, nsevent, x, y);
@ -1083,6 +1114,10 @@ synthesize_crossing_events_for_ns_event (NSEvent *nsevent)
GdkWindow *event_toplevel; GdkWindow *event_toplevel;
NSPoint point; NSPoint point;
/* This is the only case where we actually use the window from
* the event since we need to know which toplevel we entered
* so it can be tracked properly.
*/
event_toplevel = [(GdkQuartzView *)[[nsevent window] contentView] gdkWindow]; event_toplevel = [(GdkQuartzView *)[[nsevent window] contentView] gdkWindow];
point = [nsevent locationInWindow]; point = [nsevent locationInWindow];
@ -1099,16 +1134,12 @@ synthesize_crossing_events_for_ns_event (NSEvent *nsevent)
y = impl->height - point.y; y = impl->height - point.y;
} }
/* This is the only case where we actually use the window from
* the event since we need to know which toplevel we entered
* so it can be tracked properly.
*/
mouse_window = _gdk_quartz_window_find_child (event_toplevel, x, y); mouse_window = _gdk_quartz_window_find_child (event_toplevel, x, y);
/* Treat unknown windows (including title bar/buttons, /* Treat unknown windows (like the title bar buttons or
* desktop) as the root. * desktop) as the root window.
*/ */
if (!mouse_window) if (!mouse_window)
mouse_window = _gdk_root; mouse_window = _gdk_root;
if (mouse_window != event_toplevel) if (mouse_window != event_toplevel)
@ -1127,16 +1158,14 @@ synthesize_crossing_events_for_ns_event (NSEvent *nsevent)
NSPoint point; NSPoint point;
gint x_orig, y_orig; gint x_orig, y_orig;
/* We get mouse exited when leaving toplevels. We only use /* We only use NSMouseExited when leaving to the root
* this when leaving from a window to the root window. The * window. The other cases are handled above by checking the
* other case is handled above by checking the motion/button * motion/button events, or getting a NSMouseEntered for
* events, or getting a MouseEntered for another GDK window. * another GDK window. The reason we don't use NSMouseExited
* * for other windows is that quartz first delivers the entered
* The reason we don't use MouseExited for other windows is * event and then the exited which is the opposite from what
* that quartz first delivers the entered event and then the * we need.
* exited which is the opposite from what we need.
*/ */
event_toplevel = [(GdkQuartzView *)[[nsevent window] contentView] gdkWindow]; event_toplevel = [(GdkQuartzView *)[[nsevent window] contentView] gdkWindow];
point = [nsevent locationInWindow]; point = [nsevent locationInWindow];

View File

@ -481,9 +481,8 @@ find_child_window_helper (GdkWindow *window,
} }
/* Given a GdkWindow and coordinates relative to it, returns the /* Given a GdkWindow and coordinates relative to it, returns the
* window in which the point is. The returned window will be in the * innermost subwindow that contains the point. If the coordinates are
* same subtree as the passed in window (including the passed in * outside the passed in window, NULL is returned.
* window), if no window is found, NULL is returned.
*/ */
GdkWindow * GdkWindow *
_gdk_quartz_window_find_child (GdkWindow *window, _gdk_quartz_window_find_child (GdkWindow *window,