0001-Set-X11-as-the-backend-for-gtk3-of-open-vm-tools.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. From c5bc784da611ee929e0da7c20a410e03e6540613 Mon Sep 17 00:00:00 2001
  2. From: Oliver Kurth <okurth@vmware.com>
  3. Date: Fri, 26 Jan 2018 15:04:36 -0800
  4. Subject: [PATCH] Set X11 as the backend for gtk3 of open-vm-tools
  5. Open-vm-tools defaults to gtk3. For distros like Fedora 27, Wayland is
  6. the default display server. With no restriction on the backend, plugins
  7. will try to use Wayland as the backend of Gtk+3. As a result,
  8. gdk_display_get_default() returns a Wayland display;
  9. gdk_display_get_default_group() also returns a Wayland window. Applying
  10. GDK_WINDOW_XID() on the Wayland window will result in the crash reported
  11. on recent Linux releases that default to a Wayland display server.
  12. As X11-specific code is widely used in tools plugins, a migratation to
  13. Wayland in the short term is not possible. So, as a compromised solution,
  14. plugins can be forced to run on XWayland, which is the compatible mode
  15. of Wayland for legacy X11 clients.
  16. gdk_set_allowed_backends() only applies when flag GTK3 is defined, and Gtk
  17. version cwgreater than 3.10.
  18. ---
  19. open-vm-tools/services/plugins/desktopEvents/x11Lock.c | 12 +++++++++++-
  20. open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp | 14 +++++++++++++-
  21. 2 files changed, 24 insertions(+), 2 deletions(-)
  22. diff --git a/open-vm-tools/services/plugins/desktopEvents/x11Lock.c b/open-vm-tools/services/plugins/desktopEvents/x11Lock.c
  23. index 572234ac..613b6946 100644
  24. --- a/open-vm-tools/services/plugins/desktopEvents/x11Lock.c
  25. +++ b/open-vm-tools/services/plugins/desktopEvents/x11Lock.c
  26. @@ -1,5 +1,5 @@
  27. /*********************************************************
  28. - * Copyright (C) 2010-2016 VMware, Inc. All rights reserved.
  29. + * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
  30. *
  31. * This program is free software; you can redistribute it and/or modify it
  32. * under the terms of the GNU Lesser General Public License as published
  33. @@ -364,6 +364,16 @@ X11Lock_Init(ToolsAppCtx *ctx,
  34. g_set_prgname(VMUSER_TITLE);
  35. argv[0] = VMUSER_TITLE;
  36. +#if GTK_MAJOR_VERSION > 3 || (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION >= 10)
  37. + /*
  38. + * On recent distros, Wayland is the default display server. If the obtained
  39. + * display or window is a wayland one, applying X11 specific functions on them
  40. + * will result in crashes. Before migrating the X11 specific code to Wayland,
  41. + * force using X11 as the backend of Gtk+3. gdk_set_allowed_backends() is
  42. + * introduced since Gtk+3.10 and Wayland is supported from Gtk+3.10.
  43. + */
  44. + gdk_set_allowed_backends("x11");
  45. +#endif
  46. /* XXX: is calling gtk_init() multiple times safe? */
  47. gtk_init(&argc, (char ***) &argv);
  48. diff --git a/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp b/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp
  49. index fffdc402..4c2f3d8d 100644
  50. --- a/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp
  51. +++ b/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp
  52. @@ -1,5 +1,5 @@
  53. /*********************************************************
  54. - * Copyright (C) 2010-2016 VMware, Inc. All rights reserved.
  55. + * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
  56. *
  57. * This program is free software; you can redistribute it and/or modify it
  58. * under the terms of the GNU Lesser General Public License as published
  59. @@ -211,6 +211,18 @@ gboolean
  60. CopyPasteDnDX11::Init(ToolsAppCtx *ctx)
  61. {
  62. TRACE_CALL();
  63. +
  64. +#if GTK_MAJOR_VERSION > 3 || (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION >= 10)
  65. + /*
  66. + * On recent distros, Wayland is the default display server. If the obtained
  67. + * display or window is a wayland one, applying X11 specific functions on them
  68. + * will result in crashes. Before migrating the X11 specific code to Wayland,
  69. + * force using X11 as the backend of Gtk+3. gdk_set_allowed_backends() is
  70. + * introduced since Gtk+3.10 and Wayland is supported from Gtk+3.10.
  71. + */
  72. + gdk_set_allowed_backends("x11");
  73. +#endif
  74. +
  75. CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance();
  76. ASSERT(ctx);