[gnome-panel] panel-action-protocol: use standalone menu from module



commit 063029cbabecf13ce2111dccfc447227086f26d9
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Sep 17 15:19:25 2018 +0300

    panel-action-protocol: use standalone menu from module

 gnome-panel/panel-action-protocol.c | 56 ++++++++++++++++++++++++++++++-------
 1 file changed, 46 insertions(+), 10 deletions(-)
---
diff --git a/gnome-panel/panel-action-protocol.c b/gnome-panel/panel-action-protocol.c
index e914ce9be..06ff85118 100644
--- a/gnome-panel/panel-action-protocol.c
+++ b/gnome-panel/panel-action-protocol.c
@@ -23,6 +23,7 @@
 #include <config.h>
 
 #include "panel-action-protocol.h"
+#include "panel-applets-manager.h"
 
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
@@ -40,26 +41,61 @@ static Atom atom_gnome_panel_action_main_menu  = None;
 static Atom atom_gnome_panel_action_run_dialog = None;
 static Atom atom_gnome_panel_action_kill_dialog = None;
 
+static void
+menu_destroy_cb (GtkWidget   *widget,
+                 PanelWidget *panel_widget)
+{
+       panel_toplevel_pop_autohide_disabler (panel_widget->toplevel);
+}
+
+static void
+menu_loaded_cb (GtkWidget   *widget,
+                PanelWidget *panel_widget)
+{
+       GdkWindow *window;
+       GdkRectangle rect;
+       GdkDisplay *display;
+       GdkSeat *seat;
+       GdkDevice *device;
+
+       g_signal_connect (widget, "destroy", G_CALLBACK (menu_destroy_cb), panel_widget);
+       panel_toplevel_push_autohide_disabler (panel_widget->toplevel);
+
+       window = gtk_widget_get_window (GTK_WIDGET (panel_widget));
+
+       rect.x = 0;
+       rect.y = 0;
+       rect.width = 1;
+       rect.height = 1;
+
+       display = gdk_display_get_default ();
+       seat = gdk_display_get_default_seat (display);
+       device = gdk_seat_get_pointer (seat);
+
+       gdk_window_get_device_position (window, device,
+                                       &rect.x, &rect.y,
+                                       NULL);
+
+       gtk_menu_popup_at_rect (GTK_MENU (widget), window, &rect,
+                               GDK_GRAVITY_SOUTH_EAST,
+                               GDK_GRAVITY_NORTH_WEST,
+                               NULL);
+}
+
 static void
 panel_action_protocol_main_menu (GdkScreen *screen,
                                 guint32    activate_time)
 {
-       GSList      *panels;
-       PanelWidget *panel_widget;
-       GtkWidget   *menu;
+       GSList *panels;
+       GtkWidget *menu;
 
        if (panel_applet_activate_main_menu (activate_time))
                return;
 
        panels = panel_widget_get_panels ();
-       panel_widget = panels->data;
-       menu = create_main_menu (panel_widget);
-
-       panel_toplevel_push_autohide_disabler (panel_widget->toplevel);
+       menu = panel_applets_manager_get_standalone_menu ();
 
-       gtk_menu_set_screen (GTK_MENU (menu), screen);
-       gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
-                       NULL, NULL, 0, activate_time);
+       g_signal_connect (menu, "loaded", G_CALLBACK (menu_loaded_cb), panels->data);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]