winemac: Let Wine always drive window minimization; Cocoa just requests it.

This commit is contained in:
Ken Thomases 2013-09-30 10:29:23 -05:00 committed by Alexandre Julliard
parent e915cfd4e7
commit 54291ad3d1
6 changed files with 59 additions and 54 deletions

View File

@ -58,7 +58,6 @@ @interface WineWindow : NSPanel <NSWindowDelegate>
NSSize savedContentMinSize;
NSSize savedContentMaxSize;
BOOL ignore_windowMiniaturize;
BOOL ignore_windowDeminiaturize;
BOOL fakingClose;
}

View File

@ -689,10 +689,7 @@ - (void) setMacDrvState:(const struct macdrv_window_state*)state
if (state->minimized && ![self isMiniaturized])
{
if ([self isVisible])
{
ignore_windowMiniaturize = TRUE;
[self miniaturize:nil];
}
[super miniaturize:nil];
else
pendingMinimize = TRUE;
}
@ -703,8 +700,7 @@ - (void) setMacDrvState:(const struct macdrv_window_state*)state
}
/* Whatever events regarding minimization might have been in the queue are now stale. */
[queue discardEventsMatchingMask:event_mask_for_type(WINDOW_DID_MINIMIZE) |
event_mask_for_type(WINDOW_DID_UNMINIMIZE)
[queue discardEventsMatchingMask:event_mask_for_type(WINDOW_DID_UNMINIMIZE)
forWindow:self];
}
@ -1012,8 +1008,7 @@ - (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next activate:(BOOL)a
if (pendingMinimize)
{
ignore_windowMiniaturize = TRUE;
[self miniaturize:nil];
[super miniaturize:nil];
pendingMinimize = FALSE;
}
@ -1333,6 +1328,13 @@ - (void) sendEvent:(NSEvent*)event
[super sendEvent:event];
}
- (void) miniaturize:(id)sender
{
macdrv_event* event = macdrv_create_event(WINDOW_MINIMIZE_REQUESTED, self);
[queue postEvent:event];
macdrv_release_event(event);
}
// We normally use the generic/calibrated RGB color space for the window,
// rather than the device color space, to avoid expensive color conversion
// which slows down drawing. However, for windows displaying OpenGL, having
@ -1457,8 +1459,7 @@ - (void)windowDidDeminiaturize:(NSNotification *)notification
macdrv_event* event;
/* Coalesce events by discarding any previous ones still in the queue. */
[queue discardEventsMatchingMask:event_mask_for_type(WINDOW_DID_MINIMIZE) |
event_mask_for_type(WINDOW_DID_UNMINIMIZE)
[queue discardEventsMatchingMask:event_mask_for_type(WINDOW_DID_UNMINIMIZE)
forWindow:self];
event = macdrv_create_event(WINDOW_DID_UNMINIMIZE, self);
@ -1575,22 +1576,6 @@ - (void) windowWillClose:(NSNotification*)notification
- (void)windowWillMiniaturize:(NSNotification *)notification
{
[self becameIneligibleParentOrChild];
if (!ignore_windowMiniaturize)
{
macdrv_event* event;
/* Coalesce events by discarding any previous ones still in the queue. */
[queue discardEventsMatchingMask:event_mask_for_type(WINDOW_DID_MINIMIZE) |
event_mask_for_type(WINDOW_DID_UNMINIMIZE)
forWindow:self];
event = macdrv_create_event(WINDOW_DID_MINIMIZE, self);
[queue postEvent:event];
macdrv_release_event(event);
}
ignore_windowMiniaturize = FALSE;
}
- (void) windowWillStartLiveResize:(NSNotification *)notification

View File

@ -49,11 +49,11 @@ static const char *dbgstr_event(int type)
"STATUS_ITEM_MOUSE_BUTTON",
"STATUS_ITEM_MOUSE_MOVE",
"WINDOW_CLOSE_REQUESTED",
"WINDOW_DID_MINIMIZE",
"WINDOW_DID_UNMINIMIZE",
"WINDOW_FRAME_CHANGED",
"WINDOW_GOT_FOCUS",
"WINDOW_LOST_FOCUS",
"WINDOW_MINIMIZE_REQUESTED",
};
if (0 <= type && type < NUM_EVENT_TYPES) return event_names[type];
@ -101,7 +101,6 @@ static macdrv_event_mask get_event_mask(DWORD mask)
event_mask |= event_mask_for_type(STATUS_ITEM_MOUSE_BUTTON);
event_mask |= event_mask_for_type(STATUS_ITEM_MOUSE_MOVE);
event_mask |= event_mask_for_type(WINDOW_CLOSE_REQUESTED);
event_mask |= event_mask_for_type(WINDOW_DID_MINIMIZE);
event_mask |= event_mask_for_type(WINDOW_DID_UNMINIMIZE);
event_mask |= event_mask_for_type(WINDOW_FRAME_CHANGED);
event_mask |= event_mask_for_type(WINDOW_GOT_FOCUS);
@ -112,6 +111,7 @@ static macdrv_event_mask get_event_mask(DWORD mask)
{
event_mask |= event_mask_for_type(QUERY_EVENT);
event_mask |= event_mask_for_type(RELEASE_CAPTURE);
event_mask |= event_mask_for_type(WINDOW_MINIMIZE_REQUESTED);
}
return event_mask;
@ -233,9 +233,6 @@ void macdrv_handle_event(const macdrv_event *event)
case WINDOW_CLOSE_REQUESTED:
macdrv_window_close_requested(hwnd);
break;
case WINDOW_DID_MINIMIZE:
macdrv_window_did_minimize(hwnd);
break;
case WINDOW_DID_UNMINIMIZE:
macdrv_window_did_unminimize(hwnd);
break;
@ -248,6 +245,9 @@ void macdrv_handle_event(const macdrv_event *event)
case WINDOW_LOST_FOCUS:
macdrv_window_lost_focus(hwnd, event);
break;
case WINDOW_MINIMIZE_REQUESTED:
macdrv_window_minimize_requested(hwnd);
break;
default:
TRACE(" ignoring\n");
break;

View File

@ -160,7 +160,7 @@ static inline RECT rect_from_cgrect(CGRect cgrect)
extern void macdrv_window_lost_focus(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
extern void macdrv_app_deactivated(void) DECLSPEC_HIDDEN;
extern void macdrv_app_quit_requested(const macdrv_event *event) DECLSPEC_HIDDEN;
extern void macdrv_window_did_minimize(HWND hwnd) DECLSPEC_HIDDEN;
extern void macdrv_window_minimize_requested(HWND hwnd) DECLSPEC_HIDDEN;
extern void macdrv_window_did_unminimize(HWND hwnd) DECLSPEC_HIDDEN;
extern BOOL query_resize_end(HWND hwnd) DECLSPEC_HIDDEN;
extern BOOL query_resize_start(HWND hwnd) DECLSPEC_HIDDEN;

View File

@ -186,11 +186,11 @@ extern int macdrv_set_display_mode(const struct macdrv_display* display,
STATUS_ITEM_MOUSE_BUTTON,
STATUS_ITEM_MOUSE_MOVE,
WINDOW_CLOSE_REQUESTED,
WINDOW_DID_MINIMIZE,
WINDOW_DID_UNMINIMIZE,
WINDOW_FRAME_CHANGED,
WINDOW_GOT_FOCUS,
WINDOW_LOST_FOCUS,
WINDOW_MINIMIZE_REQUESTED,
NUM_EVENT_TYPES
};

View File

@ -1188,7 +1188,6 @@ UINT CDECL macdrv_ShowWindow(HWND hwnd, INT cmd, RECT *rect, UINT swp)
goto done;
if (thread_data->current_event->type != WINDOW_FRAME_CHANGED &&
thread_data->current_event->type != WINDOW_DID_MINIMIZE &&
thread_data->current_event->type != WINDOW_DID_UNMINIMIZE)
goto done;
@ -1570,7 +1569,6 @@ void CDECL macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags,
if (!thread_data || !thread_data->current_event ||
thread_data->current_event->window != data->cocoa_window ||
(thread_data->current_event->type != WINDOW_FRAME_CHANGED &&
thread_data->current_event->type != WINDOW_DID_MINIMIZE &&
thread_data->current_event->type != WINDOW_DID_UNMINIMIZE))
{
sync_window_position(data, swp_flags, &old_window_rect, &old_whole_rect);
@ -1768,34 +1766,57 @@ void macdrv_app_deactivated(void)
/***********************************************************************
* macdrv_window_did_minimize
* macdrv_window_minimize_requested
*
* Handler for WINDOW_DID_MINIMIZE events.
* Handler for WINDOW_MINIMIZE_REQUESTED events.
*/
void macdrv_window_did_minimize(HWND hwnd)
void macdrv_window_minimize_requested(HWND hwnd)
{
struct macdrv_win_data *data;
DWORD style;
TRACE("win %p\n", hwnd);
if (!(data = get_win_data(hwnd))) return;
if (data->minimized) goto done;
HMENU hSysMenu;
style = GetWindowLongW(hwnd, GWL_STYLE);
data->minimized = TRUE;
if ((style & WS_MINIMIZEBOX) && !(style & WS_DISABLED))
if (!(style & WS_MINIMIZEBOX) || (style & (WS_DISABLED | WS_MINIMIZE)))
{
TRACE("minimizing win %p/%p\n", hwnd, data->cocoa_window);
release_win_data(data);
SendMessageW(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
TRACE("not minimizing win %p style 0x%08x\n", hwnd, style);
return;
}
TRACE("not minimizing win %p/%p style %08x\n", hwnd, data->cocoa_window, style);
done:
release_win_data(data);
hSysMenu = GetSystemMenu(hwnd, FALSE);
if (hSysMenu)
{
UINT state = GetMenuState(hSysMenu, SC_MINIMIZE, MF_BYCOMMAND);
if (state == 0xFFFFFFFF || (state & (MF_DISABLED | MF_GRAYED)))
{
TRACE("not minimizing win %p menu state 0x%08x\n", hwnd, state);
return;
}
}
if (GetActiveWindow() != hwnd)
{
LRESULT ma = SendMessageW(hwnd, WM_MOUSEACTIVATE, (WPARAM)GetAncestor(hwnd, GA_ROOT),
MAKELPARAM(HTMINBUTTON, WM_NCLBUTTONDOWN));
switch (ma)
{
case MA_NOACTIVATEANDEAT:
case MA_ACTIVATEANDEAT:
TRACE("not minimizing win %p mouse-activate result %ld\n", hwnd, ma);
return;
case MA_NOACTIVATE:
break;
case MA_ACTIVATE:
case 0:
SetActiveWindow(hwnd);
break;
default:
WARN("unknown WM_MOUSEACTIVATE code %ld\n", ma);
break;
}
}
TRACE("minimizing win %p\n", hwnd);
SendMessageW(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
}