]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes to common source files not directly applicable to open-vm-tools.
authorOliver Kurth <okurth@vmware.com>
Wed, 22 May 2019 20:09:36 +0000 (13:09 -0700)
committerOliver Kurth <okurth@vmware.com>
Wed, 22 May 2019 20:09:36 +0000 (13:09 -0700)
open-vm-tools/services/plugins/dndcp/xutils/xutils.cc
open-vm-tools/services/plugins/dndcp/xutils/xutils.hh

index bae910781c28ae5812a83311d18cbe25cc626da4..7fcf9a0ba3a6db23ee87a8d9d2771b5e52d80bba 100644 (file)
@@ -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<Gdk::Window>& 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<Gdk::Window>& window, // IN
+                    int& width,                              // OUT
+                    int& height)                             // OUT
+{
+   Glib::RefPtr<Gdk::Display> display = Gdk::Display::get_default();
+   ::Display *xdisplay = GDK_DISPLAY_XDISPLAY(display->gobj());
+   XWindowAttributes attr;
+   GdkWindow *gdkwin = const_cast<GdkWindow *>(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<Gdk::Window>& window, // IN
+                      int& x,                                  // OUT
+                      int& y)                                  // OUT
+{
+   Glib::RefPtr<Gdk::Display> display = Gdk::Display::get_default();
+   ::Display *xdisplay = GDK_DISPLAY_XDISPLAY(display->gobj());
+   GdkWindow *gdkwin = const_cast<GdkWindow *>(window->gobj());
+   Window child;
+   if (XTranslateCoordinates(xdisplay, GDK_WINDOW_XID(gdkwin),
+                             XDefaultRootWindow(xdisplay), 0, 0, &x, &y,
+                             &child)) {
+      return true;
+   }
+   return false;
+}
+
+
 } // namespace xutils
index 3ef8d75f4a725f1abeeabcc95b4b0d5b98ff5582..29d69003ff061c6fd9a4e1c8c3ba67bac3a8ac40 100644 (file)
@@ -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<Gdk::Window>& window,
 
 extern sigc::signal<void, Glib::RefPtr<Gdk::Screen> > workAreaChanged;
 
-
+bool GetXWindowSize(const Glib::RefPtr<Gdk::Window>& window, int& width,
+                    int& height);
+bool GetXWindowOrigin(const Glib::RefPtr<Gdk::Window>& window, int& x, int& y);
 } // namespace xutils