[Xfce4-commits] <xfce4-panel:master> Fix menu positioning for moved external plugins (bug #7529).

Nick Schermer noreply at xfce.org
Sat May 28 17:50:01 CEST 2011


Updating branch refs/heads/master
         to 176a68b8f347f84e4dc8fdf7f8e81d1e8e6034b0 (commit)
       from 4e14f278ea242dae6b7f4a3e0ebc1a98f79a1c55 (commit)

commit 176a68b8f347f84e4dc8fdf7f8e81d1e8e6034b0
Author: Nick Schermer <nick at xfce.org>
Date:   Sat May 28 17:45:56 2011 +0200

    Fix menu positioning for moved external plugins (bug #7529).
    
    For some reason the window position cache in gdk is not updated
    so work around this.

 libxfce4panel/xfce-panel-plugin.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index d85a813..ba45bf5 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -2143,6 +2143,8 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
   GdkRectangle    monitor;
   gint            monitor_num;
   GTimeVal        now_t, end_t;
+  GtkWidget      *toplevel, *plug;
+  gint            px, py;
 
   g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
   g_return_if_fail (GTK_IS_WIDGET (menu_widget));
@@ -2165,7 +2167,19 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
   gtk_widget_size_request (menu_widget, &requisition);
 
   /* get the root position of the attach widget */
-  gdk_window_get_position (GDK_WINDOW (attach_widget->window), x, y);
+  toplevel = gtk_widget_get_toplevel (attach_widget);
+  gtk_window_get_position (GTK_WINDOW (toplevel), x, y);
+
+  /* correct position for external plugins */
+  plug = gtk_widget_get_ancestor (attach_widget, GTK_TYPE_PLUG);
+  if (plug != NULL)
+    {
+       gdk_window_get_geometry (gtk_plug_get_socket_window (GTK_PLUG (plug)),
+                                &px, &py, NULL, NULL, NULL);
+
+       *x += px;
+       *y += py;
+    }
 
   /* if the panel is hidden (auto hide is enabled) and we requested a
    * panel lock, wait for gtk to position the panel before we actually



More information about the Xfce4-commits mailing list