Module: wine Branch: master Commit: 3c5973139fa61d24d1e980de48c592da1dacafd3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=3c5973139fa61d24d1e980de48...
Author: Ken Thomases ken@codeweavers.com Date: Sun Jan 27 16:19:53 2013 -0600
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(+), 0 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index a6e6856..e5e78f9 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 969c5e7..634fe52 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 0be4b59..e6c747f 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 35229ba..2084d78 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 c87897a..5356687 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); +}