~canonical-dx-team/ubuntu/maverick/gtk+2.0/menuproxy

« back to all changes in this revision

Viewing changes to gtk/gtkmenu.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2010-06-11 12:19:30 UTC
  • mfrom: (1.11.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 175.
  • Revision ID: james.westby@ubuntu.com-20100611121930-n4pklvkoqdsg12vm
Tags: 2.21.2-1
* New upstream development release:
  + debian/rules,
    debian/libgtk2.0-0.symbols:
    - Update for new API symbols.
  + debian/patches/070_mandatory-relibtoolize.patch:
    - Regenerated for the new version.
  + debian/control.in:
    - Update GLib (build-) dependency to >= 2.25.8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3216
3216
}
3217
3217
 
3218
3218
static gboolean
 
3219
gtk_menu_has_navigation_triangle (GtkMenu *menu)
 
3220
{
 
3221
  GtkMenuPrivate *priv;
 
3222
 
 
3223
  priv = gtk_menu_get_private (menu);
 
3224
 
 
3225
  return priv->navigation_height && priv->navigation_width;
 
3226
}
 
3227
 
 
3228
static gboolean
3219
3229
gtk_menu_motion_notify (GtkWidget      *widget,
3220
3230
                        GdkEventMotion *event)
3221
3231
{
3222
3232
  GtkWidget *menu_item;
3223
3233
  GtkMenu *menu;
3224
3234
  GtkMenuShell *menu_shell;
3225
 
  GtkMenuPrivate *priv;
3226
3235
 
3227
3236
  gboolean need_enter;
3228
3237
 
3257
3266
  if (definitely_within_item (menu_item, event->x, event->y))
3258
3267
    menu_shell->activate_time = 0;
3259
3268
 
3260
 
  priv = gtk_menu_get_private (menu);
3261
 
  need_enter = (priv->navigation_width > 0 || priv->navigation_height > 0 || menu_shell->ignore_enter);
 
3269
  need_enter = (gtk_menu_has_navigation_triangle (menu) || menu_shell->ignore_enter);
3262
3270
 
3263
3271
  /* Check to see if we are within an active submenu's navigation region
3264
3272
   */
4008
4016
                             gint     event_x,
4009
4017
                             gint     event_y)
4010
4018
{
4011
 
  GtkMenuPrivate *priv = gtk_menu_get_private (menu);
4012
 
 
4013
 
  if (priv->navigation_width && priv->navigation_height)
4014
 
    {
4015
 
      int width = priv->navigation_width;
4016
 
      int height = priv->navigation_height;
4017
 
 
4018
 
      /* check if x/y are in the triangle spanned by the navigation parameters */
4019
 
 
4020
 
      /* 1) Move the coordinates so the triangle starts at 0,0 */
4021
 
      event_x -= priv->navigation_x;
4022
 
      event_y -= priv->navigation_y;
4023
 
 
4024
 
      /* 2) Ensure both legs move along the positive axis */
4025
 
      if (width < 0)
4026
 
        {
4027
 
          event_x = -event_x;
4028
 
          width = -width;
4029
 
        }
4030
 
      if (height < 0)
4031
 
        {
4032
 
          event_y = -event_y;
4033
 
          height = -height;
4034
 
        }
4035
 
 
4036
 
      /* 3) Check that the given coordinate is inside the triangle. The formula
4037
 
       * is a transformed form of this formula: x/w + y/h <= 1
4038
 
       */
4039
 
      if (event_x >= 0 && event_y >= 0 &&
4040
 
          event_x * height + event_y * width <= width * height)
4041
 
        {
4042
 
          return TRUE;
4043
 
        }
4044
 
      else
4045
 
        {
4046
 
          gtk_menu_stop_navigating_submenu (menu);
4047
 
          return FALSE;
4048
 
        }
4049
 
    }
4050
 
  return FALSE;
 
4019
  GtkMenuPrivate *priv;
 
4020
  int width, height;
 
4021
 
 
4022
  if (!gtk_menu_has_navigation_triangle (menu))
 
4023
    return FALSE;
 
4024
 
 
4025
  priv = gtk_menu_get_private (menu);
 
4026
  width = priv->navigation_width;
 
4027
  height = priv->navigation_height;
 
4028
 
 
4029
  /* check if x/y are in the triangle spanned by the navigation parameters */
 
4030
 
 
4031
  /* 1) Move the coordinates so the triangle starts at 0,0 */
 
4032
  event_x -= priv->navigation_x;
 
4033
  event_y -= priv->navigation_y;
 
4034
 
 
4035
  /* 2) Ensure both legs move along the positive axis */
 
4036
  if (width < 0)
 
4037
    {
 
4038
      event_x = -event_x;
 
4039
      width = -width;
 
4040
    }
 
4041
  if (height < 0)
 
4042
    {
 
4043
      event_y = -event_y;
 
4044
      height = -height;
 
4045
    }
 
4046
 
 
4047
  /* 3) Check that the given coordinate is inside the triangle. The formula
 
4048
   * is a transformed form of this formula: x/w + y/h <= 1
 
4049
   */
 
4050
  if (event_x >= 0 && event_y >= 0 &&
 
4051
      event_x * height + event_y * width <= width * height)
 
4052
    {
 
4053
      return TRUE;
 
4054
    }
 
4055
  else
 
4056
    {
 
4057
      gtk_menu_stop_navigating_submenu (menu);
 
4058
      return FALSE;
 
4059
    }
4051
4060
}
4052
4061
 
4053
4062
static void