From: John Wolfe Date: Tue, 18 Aug 2020 14:14:11 +0000 (-0700) Subject: Changes to common source files not directly applicable to open-vm-tools. X-Git-Tag: stable-11.2.0~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=697e20320ee71b8feb248582ccf0100b919f5b32;p=thirdparty%2Fopen-vm-tools.git Changes to common source files not directly applicable to open-vm-tools. --- diff --git a/open-vm-tools/services/plugins/dndcp/xutils/xutils.cc b/open-vm-tools/services/plugins/dndcp/xutils/xutils.cc index 3fad2ce31..15c250137 100644 --- a/open-vm-tools/services/plugins/dndcp/xutils/xutils.cc +++ b/open-vm-tools/services/plugins/dndcp/xutils/xutils.cc @@ -249,7 +249,7 @@ GetCardinal(Glib::RefPtr window, // IN: Window bool GetCardinalList(Glib::RefPtr window, // IN: Window const utf::string& atomName, // IN: Atom name - std::vector& retValues) // IN: Return values + std::vector& retValues) // IN: Return values { ASSERT(window); ASSERT(window->get_display()); @@ -306,6 +306,64 @@ GetCardinalList(Glib::RefPtr window, // IN: Window } +/* + *----------------------------------------------------------------------------- + * + * xutils::CheckDockPanel -- + * + * Utility function to check dock or panel window. + * + * Results: + * true if the dock or panel window found. + * Otherwise false. + * + * Side effects: + * None. + * + *----------------------------------------------------------------------------- + */ + +bool +CheckDockPanel(Glib::RefPtr window) +{ + ASSERT(window); + ASSERT(window->get_display()); + + GdkDisplay* display = const_cast(window->get_display()->gobj()); + GdkWindow* gdkwin = const_cast(window->gobj()); + + Atom atom = gdk_x11_get_xatom_by_name_for_display(display, "_NET_WM_WINDOW_TYPE"); + Atom type; + int format; + unsigned long nitems; + unsigned long bytes_after; + uint8* values; + + gdk_error_trap_push(); + int ret = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(display), + GDK_WINDOW_XID(gdkwin), + atom, 0, G_MAXLONG, False, AnyPropertyType, &type, + &format, &nitems, &bytes_after, &values); + int err = gdk_error_trap_pop(); + if (err) { + Log("Ignore xerror in XGetWindowProperty. Error code %d", err); + return false; + } + if (ret == Success && type == XA_ATOM + && format == 32 && values != NULL && nitems > 0) { + unsigned long* stack = (unsigned long*)values; + if (stack[0] == XInternAtom(GDK_DISPLAY_XDISPLAY(display), + "_NET_WM_WINDOW_TYPE_DOCK", false)) { + Log("found dock window: %ld.\n",GDK_WINDOW_XID(gdkwin)); + XFree(values); + return true; + } + } + XFree(values); + return false; +} + + /* *----------------------------------------------------------------------------- * diff --git a/open-vm-tools/services/plugins/dndcp/xutils/xutils.hh b/open-vm-tools/services/plugins/dndcp/xutils/xutils.hh index 190a0a82a..f8acc2379 100644 --- a/open-vm-tools/services/plugins/dndcp/xutils/xutils.hh +++ b/open-vm-tools/services/plugins/dndcp/xutils/xutils.hh @@ -41,6 +41,7 @@ bool GetCardinal(Glib::RefPtr window, bool GetCardinalList(Glib::RefPtr window, const utf::string& atomName, std::vector& retValues); +bool CheckDockPanel(Glib::RefPtr window); /* * Utility functions for virtual desktops.