From 3c5973139fa61d24d1e980de48c592da1dacafd3 Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Sun, 27 Jan 2013 16:19:53 -0600 Subject: [PATCH] winemac: Implement a WINDOW_LOST_FOCUS event. --- dlls/winemac.drv/cocoa_window.m | 11 +++++++++++ dlls/winemac.drv/event.c | 5 +++++ dlls/winemac.drv/macdrv.h | 1 + dlls/winemac.drv/macdrv_cocoa.h | 1 + dlls/winemac.drv/window.c | 16 ++++++++++++++++ 5 files changed, 34 insertions(+) diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index a6e6856df1c..e5e78f99076 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -556,6 +556,17 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens) [self windowDidResize:notification]; } + - (void)windowDidResignKey:(NSNotification *)notification + { + macdrv_event event; + + if (causing_becomeKeyWindow) return; + + event.type = WINDOW_LOST_FOCUS; + event.window = (macdrv_window)[self retain]; + [queue postEvent:&event]; + } + - (void)windowDidResize:(NSNotification *)notification { macdrv_event event; diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index 969c5e76a30..634fe5264ed 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -36,6 +36,7 @@ static const char *dbgstr_event(int type) "WINDOW_CLOSE_REQUESTED", "WINDOW_FRAME_CHANGED", "WINDOW_GOT_FOCUS", + "WINDOW_LOST_FOCUS", }; if (0 <= type && type < NUM_EVENT_TYPES) return event_names[type]; @@ -60,6 +61,7 @@ static macdrv_event_mask get_event_mask(DWORD mask) event_mask |= event_mask_for_type(WINDOW_CLOSE_REQUESTED); event_mask |= event_mask_for_type(WINDOW_FRAME_CHANGED); event_mask |= event_mask_for_type(WINDOW_GOT_FOCUS); + event_mask |= event_mask_for_type(WINDOW_LOST_FOCUS); } return event_mask; @@ -95,6 +97,9 @@ void macdrv_handle_event(macdrv_event *event) case WINDOW_GOT_FOCUS: macdrv_window_got_focus(hwnd, event); break; + case WINDOW_LOST_FOCUS: + macdrv_window_lost_focus(hwnd, event); + break; default: TRACE(" ignoring\n"); break; diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 0be4b593895..e6c747fd06d 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -120,6 +120,7 @@ extern void set_surface_use_alpha(struct window_surface *window_surface, BOOL us extern void macdrv_window_close_requested(HWND hwnd) DECLSPEC_HIDDEN; extern void macdrv_window_frame_changed(HWND hwnd, CGRect frame) DECLSPEC_HIDDEN; extern void macdrv_window_got_focus(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN; +extern void macdrv_window_lost_focus(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN; extern void macdrv_mouse_button(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index 35229ba1a17..2084d78fef9 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -128,6 +128,7 @@ enum { WINDOW_CLOSE_REQUESTED, WINDOW_FRAME_CHANGED, WINDOW_GOT_FOCUS, + WINDOW_LOST_FOCUS, NUM_EVENT_TYPES }; diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index c87897a227b..5356687b86b 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1453,3 +1453,19 @@ void macdrv_window_got_focus(HWND hwnd, const macdrv_event *event) TRACE("win %p/%p rejecting focus\n", hwnd, event->window); macdrv_window_rejected_focus(event); } + + +/*********************************************************************** + * macdrv_window_lost_focus + * + * Handler for WINDOW_LOST_FOCUS events. + */ +void macdrv_window_lost_focus(HWND hwnd, const macdrv_event *event) +{ + if (!hwnd) return; + + TRACE("win %p/%p fg %p\n", hwnd, event->window, GetForegroundWindow()); + + if (hwnd == GetForegroundWindow()) + SendMessageW(hwnd, WM_CANCELMODE, 0, 0); +}