Checking flags of the thread desktop to determine whether virtual desktop is on is unreliable. For example, CEF applications create their own desktop and so is_virtual_desktop() could incorrectly report that virtual desktop is off.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55810
-- v2: server: inherit DF_WINE_CREATE_DESKTOP when creating a non-root desktop.
From: Zhiyi Zhang zzhang@codeweavers.com
Based on Rémi's idea.
CEF applications create their own desktops and so is_virtual_desktop() could incorrectly report that virtual desktop is off if DF_WINE_CREATE_DESKTOP is not inherited.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55810 --- server/winstation.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/server/winstation.c b/server/winstation.c index 5903497d61e..4d187b78b10 100644 --- a/server/winstation.c +++ b/server/winstation.c @@ -221,14 +221,27 @@ struct desktop *get_desktop_obj( struct process *process, obj_handle_t handle, u static struct desktop *create_desktop( const struct unicode_str *name, unsigned int attr, unsigned int flags, struct winstation *winstation ) { - struct desktop *desktop; + static const WCHAR rootW[] = {'r','o','o','t'}; + struct desktop *desktop, *current_desktop;
if ((desktop = create_named_object( &winstation->obj, &desktop_ops, name, attr, NULL ))) { if (get_error() != STATUS_OBJECT_NAME_EXISTS) { /* initialize it if it didn't already exist */ - desktop->flags = flags; + + /* inherit DF_WINE_CREATE_DESKTOP when creating a non-root desktop */ + if ((name->len != sizeof(rootW) || memcmp( name->str, rootW, name->len )) + && (current_desktop = get_thread_desktop( current, 0 ))) + { + desktop->flags = flags | (current_desktop->flags & DF_WINE_CREATE_DESKTOP); + release_object( current_desktop ); + } + else + { + desktop->flags = flags; + } + desktop->winstation = (struct winstation *)grab_object( winstation ); desktop->top_window = NULL; desktop->msg_window = NULL;
This merge request was approved by Rémi Bernon.
I don't think the server should know about the 'root' name, or check the name at all, particularly if we consider that the desktop is being created from non-Wine code.
So I guess instead we could have another private `DF_WINE_USE_ROOT_WINDOW` flag or something, that `explorer.exe` would use, and we would inherit desktop flags only if neither private flags are set?