~unity-team/unity/trusty-1368427

« back to all changes in this revision

Viewing changes to services/panel-service.c

  • Committer: Marco Trevisan (Treviño)
  • Date: 2014-05-02 14:28:45 UTC
  • mfrom: (3791.2.4 menus-grab-races-fix)
  • Revision ID: mail@3v1n0.net-20140502142845-qfw9gx5wt439y2tu
PanelService: emit an invalid EntryActivated signal if the menu hasn't actually been shown

In addition, if the menu is not visible after the first popup call, try to show a menu
without keyboard focus. This will make possible to see menus also when there's a key-grab
(although they will be without keyboard support).

Finally, reset the menu state, if that failed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2159
2159
      g_signal_connect_after (priv->last_menu, "move-current",
2160
2160
                              G_CALLBACK (on_active_menu_move_current), self);
2161
2161
 
2162
 
      gtk_menu_popup (priv->last_menu, NULL, NULL, positon_menu, self, 0, CurrentTime);
2163
 
      gtk_menu_reposition (priv->last_menu);
2164
 
 
2165
 
      GdkWindow *gdkwin = gtk_widget_get_window (GTK_WIDGET (priv->last_menu));
2166
 
      if (gdkwin != NULL)
2167
 
        {
 
2162
      gtk_menu_shell_set_take_focus (GTK_MENU_SHELL (priv->last_menu), TRUE);
 
2163
      gtk_menu_popup (priv->last_menu, NULL, NULL, positon_menu, self, button, CurrentTime);
 
2164
      gboolean visible = gtk_widget_is_visible (GTK_WIDGET (priv->last_menu));
 
2165
 
 
2166
      if (!visible)
 
2167
        {
 
2168
          /* If the menu is not visible at this point, it's very likely that's
 
2169
           * due to a keyboard grab, so let's try with a menu with no key-grab */
 
2170
          gtk_menu_shell_set_take_focus (GTK_MENU_SHELL (priv->last_menu), FALSE);
 
2171
          gtk_menu_popup (priv->last_menu, NULL, NULL, positon_menu, self, button, CurrentTime);
 
2172
          visible = gtk_widget_is_visible (GTK_WIDGET (priv->last_menu));
 
2173
        }
 
2174
 
 
2175
      if (visible)
 
2176
        {
 
2177
          gtk_menu_reposition (priv->last_menu);
 
2178
 
 
2179
          GdkWindow *gdkwin = gtk_widget_get_window (GTK_WIDGET (priv->last_menu));
2168
2180
          gint left=0, top=0, width=0, height=0;
2169
2181
 
2170
2182
          gdk_window_get_geometry (gdkwin, NULL, NULL, &width, &height);
2182
2194
        }
2183
2195
      else
2184
2196
        {
2185
 
          priv->last_left = 0;
2186
 
          priv->last_right = 0;
2187
 
          priv->last_top = 0;
2188
 
          priv->last_bottom = 0;
 
2197
          on_active_menu_hidden (priv->last_menu, self);
2189
2198
        }
2190
2199
    }
2191
2200