mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 13:11:13 +00:00
Create the navigation region without flipping
Gets rid of some code in preparation to switching to do the computation completely without GdkRegion.
This commit is contained in:
parent
ef2dc17256
commit
239cfddc97
@ -4042,40 +4042,6 @@ draw_stay_up_triangle (GdkWindow *window,
|
||||
}
|
||||
#endif
|
||||
|
||||
static GdkRegion *
|
||||
flip_region (GdkRegion *region,
|
||||
gboolean flip_x,
|
||||
gboolean flip_y)
|
||||
{
|
||||
gint n_rectangles;
|
||||
GdkRectangle *rectangles;
|
||||
GdkRectangle clipbox;
|
||||
GdkRegion *new_region;
|
||||
gint i;
|
||||
|
||||
new_region = gdk_region_new ();
|
||||
|
||||
gdk_region_get_rectangles (region, &rectangles, &n_rectangles);
|
||||
gdk_region_get_clipbox (region, &clipbox);
|
||||
|
||||
for (i = 0; i < n_rectangles; ++i)
|
||||
{
|
||||
GdkRectangle rect = rectangles[i];
|
||||
|
||||
if (flip_y)
|
||||
rect.y -= 2 * (rect.y - clipbox.y) + rect.height;
|
||||
|
||||
if (flip_x)
|
||||
rect.x -= 2 * (rect.x - clipbox.x) + rect.width;
|
||||
|
||||
gdk_region_union_with_rect (new_region, &rect);
|
||||
}
|
||||
|
||||
g_free (rectangles);
|
||||
|
||||
return new_region;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_set_submenu_navigation_region (GtkMenu *menu,
|
||||
GtkMenuItem *menu_item,
|
||||
@ -4106,8 +4072,6 @@ gtk_menu_set_submenu_navigation_region (GtkMenu *menu,
|
||||
if (event->x >= 0 && event->x < width)
|
||||
{
|
||||
gint popdown_delay;
|
||||
gboolean flip_y = FALSE;
|
||||
gboolean flip_x = FALSE;
|
||||
|
||||
gtk_menu_stop_navigating_submenu (menu);
|
||||
|
||||
@ -4121,26 +4085,22 @@ gtk_menu_set_submenu_navigation_region (GtkMenu *menu,
|
||||
{
|
||||
/* left */
|
||||
point[0].x = event->x_root + 1;
|
||||
point[1].x = 2 * (event->x_root + 1) - submenu_right;
|
||||
|
||||
flip_x = TRUE;
|
||||
point[1].x = submenu_right;
|
||||
}
|
||||
|
||||
if (event->y < 0)
|
||||
{
|
||||
/* top */
|
||||
point[0].y = event->y_root + 1;
|
||||
point[1].y = 2 * (event->y_root + 1) - submenu_top + NAVIGATION_REGION_OVERSHOOT;
|
||||
point[0].y = event->y_root;
|
||||
point[1].y = submenu_top - NAVIGATION_REGION_OVERSHOOT;
|
||||
|
||||
if (point[0].y >= point[1].y - NAVIGATION_REGION_OVERSHOOT)
|
||||
if (point[0].y <= submenu_top)
|
||||
return;
|
||||
|
||||
flip_y = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* bottom */
|
||||
point[0].y = event->y_root;
|
||||
point[0].y = event->y_root + 1;
|
||||
point[1].y = submenu_bottom + NAVIGATION_REGION_OVERSHOOT;
|
||||
|
||||
if (point[0].y >= submenu_bottom)
|
||||
@ -4152,13 +4112,6 @@ gtk_menu_set_submenu_navigation_region (GtkMenu *menu,
|
||||
|
||||
menu->navigation_region = gdk_region_polygon (point, 3, GDK_WINDING_RULE);
|
||||
|
||||
if (flip_x || flip_y)
|
||||
{
|
||||
GdkRegion *new_region = flip_region (menu->navigation_region, flip_x, flip_y);
|
||||
gdk_region_destroy (menu->navigation_region);
|
||||
menu->navigation_region = new_region;
|
||||
}
|
||||
|
||||
g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu)),
|
||||
"gtk-menu-popdown-delay", &popdown_delay,
|
||||
NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user