[Xfce4-commits] <xfce4-panel:master> Fix menu positioning with autohide panels.
Nick Schermer
noreply at xfce.org
Sun Jul 25 14:22:01 CEST 2010
Updating branch refs/heads/master
to 7b9a047f9417140659df7dd35e864a5daaf1a9cb (commit)
from bf74984f4b5605331a69cbedba9fb4aa8a5e5baa (commit)
commit 7b9a047f9417140659df7dd35e864a5daaf1a9cb
Author: Nick Schermer <nick at xfce.org>
Date: Sun Jul 25 14:20:38 2010 +0200
Fix menu positioning with autohide panels.
libxfce4panel/xfce-panel-plugin.c | 33 +++++++++++++++++++++++++++++----
1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 8122620..b35379b 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -2022,6 +2022,7 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
GdkScreen *screen;
GdkRectangle monitor;
gint monitor_num;
+ GTimeVal now_t, end_t;
g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
g_return_if_fail (GTK_IS_WIDGET (menu_widget));
@@ -2044,7 +2045,31 @@ 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_origin (GDK_WINDOW (attach_widget->window), x, y);
+ gdk_window_get_position (GDK_WINDOW (attach_widget->window), x, y);
+
+ /* 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
+ * use the coordinates */
+ if (plugin->priv->panel_lock > 0)
+ {
+ g_get_current_time (&end_t);
+ g_time_val_add (&end_t, G_USEC_PER_SEC / 2);
+
+ while (*x == -9999 && *y == -9999)
+ {
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
+
+ gdk_window_get_position (GDK_WINDOW (attach_widget->window), x, y);
+
+ /* don't try longer then 1/2 a second */
+ g_get_current_time (&now_t);
+ if (now_t.tv_sec > end_t.tv_sec
+ || (now_t.tv_sec == end_t.tv_sec
+ && now_t.tv_usec > end_t.tv_usec))
+ break;
+ }
+ }
/* add the widgets allocation */
*x += attach_widget->allocation.x;
@@ -2141,6 +2166,9 @@ xfce_panel_plugin_position_menu (GtkMenu *menu,
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (XFCE_PANEL_PLUGIN_CONSTRUCTED (panel_plugin));
+ /* register the menu */
+ xfce_panel_plugin_register_menu (XFCE_PANEL_PLUGIN (panel_plugin), menu);
+
/* calculate the coordinates */
attach_widget = gtk_menu_get_attach_widget (menu);
xfce_panel_plugin_position_widget (XFCE_PANEL_PLUGIN (panel_plugin),
@@ -2148,9 +2176,6 @@ xfce_panel_plugin_position_menu (GtkMenu *menu,
/* keep the menu inside screen */
*push_in = TRUE;
-
- /* register the menu */
- xfce_panel_plugin_register_menu (XFCE_PANEL_PLUGIN (panel_plugin), menu);
}
More information about the Xfce4-commits
mailing list