From: Oliver Kurth Date: Wed, 22 May 2019 20:09:36 +0000 (-0700) Subject: Changes to common source files not directly applicable to open-vm-tools. X-Git-Tag: stable-11.0.0~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da3efa69411c5fe8897e6295927dc4b8eacaff04;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 bae910781..7fcf9a0ba 100644 --- a/open-vm-tools/services/plugins/dndcp/xutils/xutils.cc +++ b/open-vm-tools/services/plugins/dndcp/xutils/xutils.cc @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2018 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -1388,4 +1388,71 @@ GetPointerLocation(const Glib::RefPtr& window, // IN } +/* + *----------------------------------------------------------------------------- + * + * xutils::GetXWindowSize -- + * + * Get the width and height of the given window. + * + * Results: + * true if success, false otherwise. + * + * Side effects: + * None. + * + *----------------------------------------------------------------------------- + */ + +bool GetXWindowSize(const Glib::RefPtr& window, // IN + int& width, // OUT + int& height) // OUT +{ + Glib::RefPtr display = Gdk::Display::get_default(); + ::Display *xdisplay = GDK_DISPLAY_XDISPLAY(display->gobj()); + XWindowAttributes attr; + GdkWindow *gdkwin = const_cast(window->gobj()); + + if (XGetWindowAttributes(xdisplay, GDK_WINDOW_XID(gdkwin), &attr)) { + width = attr.width; + height = attr.height; + return true; + } + return false; +} + + +/* + *----------------------------------------------------------------------------- + * + * xutils::GetXWindowOrigin -- + * + * Get the x and y of the given window. + * + * Results: + * true if success, false otherwise. + * + * Side effects: + * None. + * + *----------------------------------------------------------------------------- + */ + +bool GetXWindowOrigin(const Glib::RefPtr& window, // IN + int& x, // OUT + int& y) // OUT +{ + Glib::RefPtr display = Gdk::Display::get_default(); + ::Display *xdisplay = GDK_DISPLAY_XDISPLAY(display->gobj()); + GdkWindow *gdkwin = const_cast(window->gobj()); + Window child; + if (XTranslateCoordinates(xdisplay, GDK_WINDOW_XID(gdkwin), + XDefaultRootWindow(xdisplay), 0, 0, &x, &y, + &child)) { + return true; + } + return false; +} + + } // namespace xutils diff --git a/open-vm-tools/services/plugins/dndcp/xutils/xutils.hh b/open-vm-tools/services/plugins/dndcp/xutils/xutils.hh index 3ef8d75f4..29d69003f 100644 --- a/open-vm-tools/services/plugins/dndcp/xutils/xutils.hh +++ b/open-vm-tools/services/plugins/dndcp/xutils/xutils.hh @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2016 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -110,7 +110,9 @@ void GetPointerLocation(const Glib::RefPtr& window, extern sigc::signal > workAreaChanged; - +bool GetXWindowSize(const Glib::RefPtr& window, int& width, + int& height); +bool GetXWindowOrigin(const Glib::RefPtr& window, int& x, int& y); } // namespace xutils