[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 12/473: Fix incorrect menu position for auto-hidden panels.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:53:02 CET 2015


This is an automated email from the git hooks/post-receive script.

gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 9a161509364bc8da9e0088fcaa127bb585df994c
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sat Jun 22 20:35:08 2013 -0400

    Fix incorrect menu position for auto-hidden panels.
---
 src/menu.cpp         |   23 +++++++++++++++++++++--
 src/panel_plugin.cpp |   23 +++++++++++------------
 src/panel_plugin.hpp |    2 +-
 3 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/src/menu.cpp b/src/menu.cpp
index 5170389..6d28297 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -26,6 +26,8 @@
 #include "section_button.hpp"
 #include "slot.hpp"
 
+#include <ctime>
+
 extern "C"
 {
 #include <exo/exo.h>
@@ -220,10 +222,27 @@ void Menu::show(GtkWidget* parent, bool horizontal)
 	// Reset mouse cursor by forcing favorites to hide
 	gtk_widget_show(m_favorites->get_widget());
 
+	// Wait up to half a second for auto-hidden panels to be shown
+	clock_t end = clock() + (CLOCKS_PER_SEC / 2);
+	GtkWindow* parent_window = GTK_WINDOW(gtk_widget_get_toplevel(parent));
+	int parent_x = 0, parent_y = 0;
+	gtk_window_get_position(parent_window, &parent_x, &parent_y);
+	while ((parent_x == -9999) && (parent_y == -9999) && (clock() < end))
+	{
+		while (gtk_events_pending())
+		{
+			gtk_main_iteration();
+		}
+		gtk_window_get_position(parent_window, &parent_x, &parent_y);
+	}
+
 	// Fetch parent geometry
+	if (!gtk_widget_get_realized(parent))
+	{
+		gtk_widget_realize(parent);
+	}
 	GdkWindow* window = gtk_widget_get_window(parent);
-	int parent_x = 0, parent_y = 0;
-	gdk_window_get_origin(window, &parent_x, &parent_y);
+	gdk_window_get_position(window, &parent_x, &parent_y);
 	int parent_w = gdk_window_get_width(window);
 	int parent_h = gdk_window_get_height(window);
 
diff --git a/src/panel_plugin.cpp b/src/panel_plugin.cpp
index a895623..bddb250 100644
--- a/src/panel_plugin.cpp
+++ b/src/panel_plugin.cpp
@@ -63,7 +63,6 @@ PanelPlugin::PanelPlugin(XfcePanelPlugin* plugin) :
 	{
 		m_menu = new Menu(nullptr);
 	}
-	g_signal_connect_slot(m_menu->get_widget(), "map", &PanelPlugin::menu_shown, this);
 	g_signal_connect_slot(m_menu->get_widget(), "unmap", &PanelPlugin::menu_hidden, this);
 
 	// Create toggle button
@@ -143,8 +142,7 @@ gboolean PanelPlugin::button_clicked(GtkWidget*, GdkEventButton* event)
 	}
 	else
 	{
-		m_menu->show(m_button, xfce_panel_plugin_get_orientation(m_plugin) == GTK_ORIENTATION_HORIZONTAL);
-		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_button), true);
+		popup_menu();
 	}
 
 	return true;
@@ -160,13 +158,6 @@ void PanelPlugin::menu_hidden()
 
 //-----------------------------------------------------------------------------
 
-void PanelPlugin::menu_shown()
-{
-	xfce_panel_plugin_block_autohide(m_plugin, true);
-}
-
-//-----------------------------------------------------------------------------
-
 void PanelPlugin::configure()
 {
 	new ConfigurationDialog(this);
@@ -181,8 +172,7 @@ gboolean PanelPlugin::remote_event(XfcePanelPlugin*, gchar* name, GValue*)
 		return false;
 	}
 
-	m_menu->show(m_button, xfce_panel_plugin_get_orientation(m_plugin) == GTK_ORIENTATION_HORIZONTAL);
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_button), true);
+	popup_menu();
 
 	return true;
 }
@@ -216,3 +206,12 @@ gboolean PanelPlugin::size_changed(XfcePanelPlugin*, gint size)
 }
 
 //-----------------------------------------------------------------------------
+
+void PanelPlugin::popup_menu()
+{
+	xfce_panel_plugin_block_autohide(m_plugin, true);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_button), true);
+	m_menu->show(m_button, xfce_panel_plugin_get_orientation(m_plugin) == GTK_ORIENTATION_HORIZONTAL);
+}
+
+//-----------------------------------------------------------------------------
diff --git a/src/panel_plugin.hpp b/src/panel_plugin.hpp
index c178bca..d0ecc67 100644
--- a/src/panel_plugin.hpp
+++ b/src/panel_plugin.hpp
@@ -53,11 +53,11 @@ public:
 private:
 	gboolean button_clicked(GtkWidget*, GdkEventButton* event);
 	void menu_hidden();
-	void menu_shown();
 	void configure();
 	gboolean remote_event(XfcePanelPlugin* plugin, gchar* name, GValue* value);
 	void save();
 	gboolean size_changed(XfcePanelPlugin*, gint size);
+	void popup_menu();
 
 private:
 	XfcePanelPlugin* m_plugin;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list