Ken Thomases : winemac: Create 1x1 Cocoa window with empty shape for zero-sized Win32 window.
Alexandre Julliard
julliard at winehq.org
Wed Aug 21 14:09:05 CDT 2013
Module: wine
Branch: master
Commit: 20c3c80257db1e0399c0b7f07f691eeb040e81c3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=20c3c80257db1e0399c0b7f07f691eeb040e81c3
Author: Ken Thomases <ken at codeweavers.com>
Date: Tue Aug 20 17:00:34 2013 -0500
winemac: Create 1x1 Cocoa window with empty shape for zero-sized Win32 window.
---
dlls/winemac.drv/window.c | 29 +++++++++++++++++++++--------
1 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index 845fe01..9d83180 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -112,8 +112,9 @@ static void get_cocoa_window_state(struct macdrv_win_data *data,
state->no_activate = !can_activate_window(data->hwnd);
state->floating = (ex_style & WS_EX_TOPMOST) != 0;
state->excluded_by_expose = state->excluded_by_cycle =
- !(ex_style & WS_EX_APPWINDOW) &&
- (GetWindow(data->hwnd, GW_OWNER) || (ex_style & (WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE)));
+ IsRectEmpty(&data->window_rect) ||
+ (!(ex_style & WS_EX_APPWINDOW) &&
+ (GetWindow(data->hwnd, GW_OWNER) || (ex_style & (WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE))));
state->minimized = (style & WS_MINIMIZE) != 0;
}
@@ -331,6 +332,13 @@ static void sync_window_region(struct macdrv_win_data *data, HRGN win_region)
if (!data->cocoa_window) return;
data->shaped = FALSE;
+ if (IsRectEmpty(&data->window_rect)) /* set an empty shape */
+ {
+ TRACE("win %p/%p setting empty shape for zero-sized window\n", data->hwnd, data->cocoa_window);
+ macdrv_set_window_shape(data->cocoa_window, &CGRectZero, 1);
+ return;
+ }
+
if (hrgn == (HRGN)1) /* hack: win_region == 1 means retrieve region from server */
{
if (!(hrgn = CreateRectRgn(0, 0, 0, 0))) return;
@@ -492,6 +500,8 @@ static void create_cocoa_window(struct macdrv_win_data *data)
frame = cgrect_from_rect(data->whole_rect);
constrain_window_frame(&frame);
+ if (frame.size.width < 1 || frame.size.height < 1)
+ frame.size.width = frame.size.height = 1;
TRACE("creating %p window %s whole %s client %s\n", data->hwnd, wine_dbgstr_rect(&data->window_rect),
wine_dbgstr_rect(&data->whole_rect), wine_dbgstr_rect(&data->client_rect));
@@ -506,7 +516,7 @@ static void create_cocoa_window(struct macdrv_win_data *data)
macdrv_set_cocoa_window_title(data->cocoa_window, text, strlenW(text));
/* set the window region */
- if (win_rgn) sync_window_region(data, win_rgn);
+ if (win_rgn || IsRectEmpty(&data->window_rect)) sync_window_region(data, win_rgn);
/* set the window opacity */
if (!GetLayeredWindowAttributes(data->hwnd, &key, &alpha, &layered_flags)) layered_flags = 0;
@@ -704,7 +714,7 @@ RGNDATA *get_region_data(HRGN hrgn, HDC hdc_lptodp)
*
* Synchronize the Mac window position with the Windows one
*/
-static void sync_window_position(struct macdrv_win_data *data, UINT swp_flags)
+static void sync_window_position(struct macdrv_win_data *data, UINT swp_flags, const RECT *old_window_rect)
{
CGRect frame;
@@ -712,9 +722,12 @@ static void sync_window_position(struct macdrv_win_data *data, UINT swp_flags)
frame = cgrect_from_rect(data->whole_rect);
constrain_window_frame(&frame);
+ if (frame.size.width < 1 || frame.size.height < 1)
+ frame.size.width = frame.size.height = 1;
data->on_screen = macdrv_set_cocoa_window_frame(data->cocoa_window, &frame);
- if (data->shaped) sync_window_region(data, (HRGN)1);
+ if (old_window_rect && IsRectEmpty(old_window_rect) != IsRectEmpty(&data->window_rect))
+ sync_window_region(data, (HRGN)1);
TRACE("win %p/%p pos %s\n", data->hwnd, data->cocoa_window,
wine_dbgstr_rect(&data->whole_rect));
@@ -1236,7 +1249,7 @@ LRESULT CDECL macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
if ((data = get_win_data(hwnd)))
{
if (data->cocoa_window && data->on_screen)
- sync_window_position(data, SWP_NOZORDER | SWP_NOACTIVATE);
+ sync_window_position(data, SWP_NOZORDER | SWP_NOACTIVATE, NULL);
release_win_data(data);
}
SendMessageW(hwnd, WM_DISPLAYCHANGE, wp, lp);
@@ -1422,7 +1435,7 @@ void CDECL macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags,
thread_data->current_event->type != WINDOW_DID_MINIMIZE &&
thread_data->current_event->type != WINDOW_DID_UNMINIMIZE))
{
- sync_window_position(data, swp_flags);
+ sync_window_position(data, swp_flags, &old_window_rect);
set_cocoa_window_properties(data);
}
@@ -1533,7 +1546,7 @@ void macdrv_window_frame_changed(HWND hwnd, CGRect frame)
if ((data->window_rect.right - data->window_rect.left == width &&
data->window_rect.bottom - data->window_rect.top == height) ||
- (IsRectEmpty(&data->window_rect) && width <= 0 && height <= 0))
+ (IsRectEmpty(&data->window_rect) && width == 1 && height == 1))
flags |= SWP_NOSIZE;
else
TRACE("%p resizing from (%dx%d) to (%dx%d)\n", hwnd, data->window_rect.right - data->window_rect.left,
More information about the wine-cvs
mailing list