https://bugs.winehq.org/show_bug.cgi?id=51984
--- Comment #21 from Gabriel Ivăncescu gabrielopcode@gmail.com --- (In reply to Zhiyi Zhang from comment #20)
So I'm guessing that the patch is correct, without overcomplicating matters—Zhiyi, please let me know if it doesn't break Office, so I can send it.
Your patch doesn't break Office 2016. However, I am not very comfortable with the patch as the root cause for the regression is still unknown. Regardless, feel free to send your patch whenever you think it's ready. And some tests would be nice.
Not sure how to add tests for this, since it's purely X11 behavior, it would probably involve grabbing the screen with X11 and we can't test that on Windows for obvious reasons.
So, I looked into it in a lot more depth to find out the root cause. I'm still not entirely sure why it happens (could be quirk/bug in compositor?), but I know for sure *what* part is required *at the very least*.
Here's what I did: I replaced the last set_window_pos in this patch with set_window_pos2, a copy-pasted identical function, except it calls a new driver WindowPosChanged2. WindowPosChanged2 is copy-pasted on winex11 side. Of course it worked now since it's identical but duplicated.
I started returning early/commenting out parts from it and I found that, at least for the systray icons case, it reaches this chunk:
if ((new_style & WS_VISIBLE) && ((new_style & WS_MINIMIZE) || is_window_rect_mapped( rectWindow ))) { if (!data->mapped) { BOOL needs_icon = !data->icon_pixmap; BOOL needs_map = TRUE;
/* layered windows are mapped only once their attributes are set */ if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED) needs_map = data->layered || IsRectEmpty( rectWindow ); release_win_data( data ); if (needs_icon) fetch_icon_data( hwnd, 0, 0 ); if (needs_map) map_window( hwnd, new_style ); return; }
Removing *just* the map_window makes it broken and have black background. So that's already the thing needed. Copying this chunk's logic into UpdateLayeredWindow works, but it feels convoluted and fragile. I'm not entirely certain if Logos 9 Bible Software needs exactly this either.
Note the comment in the chunk, I think it's the important bit here.