3218
3218
static gboolean
3219
gtk_menu_has_navigation_triangle (GtkMenu *menu)
3221
GtkMenuPrivate *priv;
3223
priv = gtk_menu_get_private (menu);
3225
return priv->navigation_height && priv->navigation_width;
3219
3229
gtk_menu_motion_notify (GtkWidget *widget,
3220
3230
GdkEventMotion *event)
3222
3232
GtkWidget *menu_item;
3224
3234
GtkMenuShell *menu_shell;
3225
GtkMenuPrivate *priv;
3227
3236
gboolean need_enter;
3257
3266
if (definitely_within_item (menu_item, event->x, event->y))
3258
3267
menu_shell->activate_time = 0;
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);
3263
3271
/* Check to see if we are within an active submenu's navigation region
4011
GtkMenuPrivate *priv = gtk_menu_get_private (menu);
4013
if (priv->navigation_width && priv->navigation_height)
4015
int width = priv->navigation_width;
4016
int height = priv->navigation_height;
4018
/* check if x/y are in the triangle spanned by the navigation parameters */
4020
/* 1) Move the coordinates so the triangle starts at 0,0 */
4021
event_x -= priv->navigation_x;
4022
event_y -= priv->navigation_y;
4024
/* 2) Ensure both legs move along the positive axis */
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
4039
if (event_x >= 0 && event_y >= 0 &&
4040
event_x * height + event_y * width <= width * height)
4046
gtk_menu_stop_navigating_submenu (menu);
4019
GtkMenuPrivate *priv;
4022
if (!gtk_menu_has_navigation_triangle (menu))
4025
priv = gtk_menu_get_private (menu);
4026
width = priv->navigation_width;
4027
height = priv->navigation_height;
4029
/* check if x/y are in the triangle spanned by the navigation parameters */
4031
/* 1) Move the coordinates so the triangle starts at 0,0 */
4032
event_x -= priv->navigation_x;
4033
event_y -= priv->navigation_y;
4035
/* 2) Ensure both legs move along the positive axis */
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
4050
if (event_x >= 0 && event_y >= 0 &&
4051
event_x * height + event_y * width <= width * height)
4057
gtk_menu_stop_navigating_submenu (menu);