diff --git a/ChangeLog b/ChangeLog index 4a7303bddd..5fab3c2690 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-07-19 Richard Hult + + * gdk/quartz/GdkQuartzWindow.c + ([GdkQuartzWindow -windowDidResignMain:]): + * gdk/quartz/gdkevents-quartz.c (_gdk_quartz_update_focus_window): + Listen to windowDidResignMain notifications and properly update the + focus window when windows are unfocused. + 2006-07-19 Kristian Rietveld * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_init), diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 4a7303bddd..5fab3c2690 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +2006-07-19 Richard Hult + + * gdk/quartz/GdkQuartzWindow.c + ([GdkQuartzWindow -windowDidResignMain:]): + * gdk/quartz/gdkevents-quartz.c (_gdk_quartz_update_focus_window): + Listen to windowDidResignMain notifications and properly update the + focus window when windows are unfocused. + 2006-07-19 Kristian Rietveld * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_init), diff --git a/gdk/quartz/GdkQuartzWindow.c b/gdk/quartz/GdkQuartzWindow.c index 1c03de0bf8..3fc35f83ea 100644 --- a/gdk/quartz/GdkQuartzWindow.c +++ b/gdk/quartz/GdkQuartzWindow.c @@ -59,7 +59,14 @@ { GdkWindow *window = [[self contentView] gdkWindow]; - _gdk_quartz_update_focus_window (window); + _gdk_quartz_update_focus_window (window, TRUE); +} + +-(void)windowDidResignMain:(NSNotification *)aNotification +{ + GdkWindow *window = [[self contentView] gdkWindow]; + + _gdk_quartz_update_focus_window (window, FALSE); } -(void)windowDidMove:(NSNotification *)aNotification diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c index 409264a230..9129ae01ab 100644 --- a/gdk/quartz/gdkevents-quartz.c +++ b/gdk/quartz/gdkevents-quartz.c @@ -748,24 +748,42 @@ create_focus_event (GdkWindow *window, return event; } +/* Note: Used to both set a new focus window and to unset the old one. */ void -_gdk_quartz_update_focus_window (GdkWindow *new_window) +_gdk_quartz_update_focus_window (GdkWindow *window, + gboolean got_focus) { + GdkEvent *event; + + if (got_focus && window == current_keyboard_window) + return; + /* FIXME: Don't do this when grabbed */ - if (new_window != current_keyboard_window) + if (!got_focus) { - GdkEvent *event; + if (window == current_keyboard_window) + { + event = create_focus_event (current_keyboard_window, FALSE); + append_event (event); + g_object_unref (current_keyboard_window); + current_keyboard_window = NULL; + } + } - event = create_focus_event (current_keyboard_window, FALSE); + if (got_focus) + { + if (current_keyboard_window) + { + event = create_focus_event (current_keyboard_window, FALSE); + append_event (event); + g_object_unref (current_keyboard_window); + current_keyboard_window = NULL; + } + + event = create_focus_event (window, TRUE); append_event (event); - - event = create_focus_event (new_window, TRUE); - append_event (event); - - g_object_unref (current_keyboard_window); - - current_keyboard_window = g_object_ref (new_window); + current_keyboard_window = g_object_ref (window); } } @@ -1466,7 +1484,6 @@ gdk_event_translate (NSEvent *nsevent) case NSRightMouseUp: case NSOtherMouseUp: event = create_button_event (window, nsevent, x, y); - append_event (event); /* Ungrab implicit grab */ @@ -1550,17 +1567,14 @@ gdk_event_translate (NSEvent *nsevent) void _gdk_events_queue (GdkDisplay *display) { - if (current_event) - { - - if (!gdk_event_translate (current_event)) - { - [NSApp sendEvent:current_event]; - } - - [current_event release]; - current_event = NULL; - } + if (current_event) + { + if (!gdk_event_translate (current_event)) + [NSApp sendEvent:current_event]; + + [current_event release]; + current_event = NULL; + } } void diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h index 101fe80fed..bbd1f72f85 100644 --- a/gdk/quartz/gdkprivate-quartz.h +++ b/gdk/quartz/gdkprivate-quartz.h @@ -103,7 +103,8 @@ void _gdk_quartz_set_context_stroke_color_from_pixel (CGContextRef context, GdkC void _gdk_quartz_update_context_from_gc (CGContextRef context, GdkGC *gc); -void _gdk_quartz_update_focus_window (GdkWindow *new_window); +void _gdk_quartz_update_focus_window (GdkWindow *new_window, + gboolean got_focus); gint _gdk_quartz_get_inverted_screen_y (gint y);