Use the workarea when placing popups

This uses the new workarea API to avoid placing popups underneath
panels, docks, etc.
This commit is contained in:
Matthias Clasen 2011-12-18 14:28:01 -05:00
parent c6df2828b7
commit 020c1846b7
16 changed files with 23 additions and 25 deletions

View File

@ -1890,7 +1890,7 @@ gtk_combo_box_menu_position_below (GtkMenu *menu,
screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
monitor_num = gdk_screen_get_monitor_at_window (screen, monitor_num = gdk_screen_get_monitor_at_window (screen,
gtk_widget_get_window (GTK_WIDGET (combo_box))); gtk_widget_get_window (GTK_WIDGET (combo_box)));
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
if (*x < monitor.x) if (*x < monitor.x)
*x = monitor.x; *x = monitor.x;
@ -2089,7 +2089,7 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
monitor_num = gdk_screen_get_monitor_at_window (screen, window); monitor_num = gdk_screen_get_monitor_at_window (screen, window);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_RTL) if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_RTL)
*x = *x + allocation.width - *width; *x = *x + allocation.width - *width;

View File

@ -8604,7 +8604,7 @@ popup_position_func (GtkMenu *menu,
monitor_num = 0; monitor_num = 0;
gtk_menu_set_monitor (menu, monitor_num); gtk_menu_set_monitor (menu, monitor_num);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
gtk_widget_get_preferred_size (priv->popup_menu, gtk_widget_get_preferred_size (priv->popup_menu,
&menu_req, NULL); &menu_req, NULL);
height = gdk_window_get_height (priv->text_area); height = gdk_window_get_height (priv->text_area);

View File

@ -1512,9 +1512,7 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
screen = gtk_widget_get_screen (GTK_WIDGET (completion->priv->entry)); screen = gtk_widget_get_screen (GTK_WIDGET (completion->priv->entry));
monitor_num = gdk_screen_get_monitor_at_window (screen, window); monitor_num = gdk_screen_get_monitor_at_window (screen, window);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
if (y > monitor.height / 2) if (y > monitor.height / 2)
items = MIN (matches, (((monitor.y + y) - (actions * action_height)) / height) - 1); items = MIN (matches, (((monitor.y + y) - (actions * action_height)) / height) - 1);

View File

@ -4250,7 +4250,7 @@ popup_position_func (GtkMenu *menu,
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
gtk_menu_set_monitor (menu, monitor_num); gtk_menu_set_monitor (menu, monitor_num);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
*x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width)); *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height)); *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));

View File

@ -446,7 +446,7 @@ popup_position_func (GtkMenu *menu,
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
gtk_menu_set_monitor (menu, monitor_num); gtk_menu_set_monitor (menu, monitor_num);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
*x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width)); *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height)); *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));

View File

@ -3328,7 +3328,7 @@ gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
GdkScreen *screen = gtk_widget_get_screen (priv->toplevel); GdkScreen *screen = gtk_widget_get_screen (priv->toplevel);
GdkRectangle monitor; GdkRectangle monitor;
gdk_screen_get_monitor_geometry (screen, priv->monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, priv->monitor_num, &monitor);
if (priv->position_y + min_height > monitor.y + monitor.height) if (priv->position_y + min_height > monitor.y + monitor.height)
min_height = monitor.y + monitor.height - priv->position_y; min_height = monitor.y + monitor.height - priv->position_y;
@ -4700,7 +4700,7 @@ gtk_menu_position (GtkMenu *menu,
if (priv->monitor_num < 0) if (priv->monitor_num < 0)
priv->monitor_num = gdk_screen_get_monitor_at_point (screen, x, y); priv->monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
gdk_screen_get_monitor_geometry (screen, priv->monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, priv->monitor_num, &monitor);
} }
else else
{ {
@ -4730,7 +4730,7 @@ gtk_menu_position (GtkMenu *menu,
* Positioning in the vertical direction is similar: first try below * Positioning in the vertical direction is similar: first try below
* mouse cursor, then above. * mouse cursor, then above.
*/ */
gdk_screen_get_monitor_geometry (screen, priv->monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, priv->monitor_num, &monitor);
space_left = x - monitor.x; space_left = x - monitor.x;
space_right = monitor.x + monitor.width - x - 1; space_right = monitor.x + monitor.width - x - 1;

View File

@ -2078,7 +2078,7 @@ gtk_menu_item_position_menu (GtkMenu *menu,
monitor_num = gdk_screen_get_monitor_at_window (screen, priv->event_window); monitor_num = gdk_screen_get_monitor_at_window (screen, priv->event_window);
if (monitor_num < 0) if (monitor_num < 0)
monitor_num = 0; monitor_num = 0;
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
if (!gdk_window_get_origin (gtk_widget_get_window (widget), &tx, &ty)) if (!gdk_window_get_origin (gtk_widget_get_window (widget), &tx, &ty))
{ {

View File

@ -327,7 +327,7 @@ menu_position_func (GtkMenu *menu,
monitor_num = gdk_screen_get_monitor_at_window (screen, window); monitor_num = gdk_screen_get_monitor_at_window (screen, window);
if (monitor_num < 0) if (monitor_num < 0)
monitor_num = 0; monitor_num = 0;
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
if (orientation == GTK_ORIENTATION_HORIZONTAL) if (orientation == GTK_ORIENTATION_HORIZONTAL)
{ {

View File

@ -960,7 +960,7 @@ set_default_size (GtkRecentChooserDefault *impl)
monitor_num = gdk_screen_get_monitor_at_window (screen, monitor_num = gdk_screen_get_monitor_at_window (screen,
gtk_widget_get_window (widget)); gtk_widget_get_window (widget));
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
width = MIN (width, monitor.width * 3 / 4); width = MIN (width, monitor.width * 3 / 4);
height = MIN (height, monitor.height * 3 / 4); height = MIN (height, monitor.height * 3 / 4);
@ -1858,7 +1858,7 @@ popup_position_func (GtkMenu *menu,
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
gtk_menu_set_monitor (menu, monitor_num); gtk_menu_set_monitor (menu, monitor_num);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
*x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width)); *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height)); *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));

View File

@ -985,7 +985,7 @@ gtk_scale_popup (GtkWidget *widget,
monitor = gdk_screen_get_monitor_at_point (screen, monitor = gdk_screen_get_monitor_at_point (screen,
button_event->x_root, button_event->x_root,
button_event->y_root); button_event->y_root);
gdk_screen_get_monitor_geometry (screen, monitor, &rect); gdk_screen_get_monitor_workarea (screen, monitor, &rect);
if (priv->orientation == GTK_ORIENTATION_VERTICAL) if (priv->orientation == GTK_ORIENTATION_VERTICAL)
y += button_event->y; y += button_event->y;

View File

@ -2218,7 +2218,7 @@ gtk_status_icon_position_menu (GtkMenu *menu,
monitor_num = 0; monitor_num = 0;
gtk_menu_set_monitor (menu, monitor_num); gtk_menu_set_monitor (menu, monitor_num);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
gdk_window_get_origin (window, x, y); gdk_window_get_origin (window, x, y);

View File

@ -8144,7 +8144,7 @@ popup_position_func (GtkMenu *menu,
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
gtk_menu_set_monitor (menu, monitor_num); gtk_menu_set_monitor (menu, monitor_num);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
*x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width)); *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height)); *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));

View File

@ -2659,7 +2659,7 @@ menu_position_func (GtkMenu *menu,
gtk_widget_get_window (priv->arrow_button)); gtk_widget_get_window (priv->arrow_button));
if (monitor_num < 0) if (monitor_num < 0)
monitor_num = 0; monitor_num = 0;
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
gtk_widget_get_allocation (priv->arrow_button, &allocation); gtk_widget_get_allocation (priv->arrow_button, &allocation);

View File

@ -1077,7 +1077,7 @@ gtk_tooltip_position (GtkTooltip *tooltip,
monitor_num = gdk_screen_get_monitor_at_point (screen, monitor_num = gdk_screen_get_monitor_at_point (screen,
tooltip->last_x, tooltip->last_x,
tooltip->last_y); tooltip->last_y);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
get_bounding_box (new_tooltip_widget, &bounds); get_bounding_box (new_tooltip_widget, &bounds);

View File

@ -15064,7 +15064,7 @@ gtk_tree_view_search_position_func (GtkTreeView *tree_view,
GdkRectangle monitor; GdkRectangle monitor;
monitor_num = gdk_screen_get_monitor_at_window (screen, tree_window); monitor_num = gdk_screen_get_monitor_at_window (screen, tree_window);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
gtk_widget_realize (search_dialog); gtk_widget_realize (search_dialog);

View File

@ -6616,7 +6616,7 @@ center_window_on_monitor (GtkWindow *window,
if (monitor_num == -1) if (monitor_num == -1)
monitor_num = get_center_monitor_of_window (window); monitor_num = get_center_monitor_of_window (window);
gdk_screen_get_monitor_geometry (gtk_window_check_screen (window), gdk_screen_get_monitor_workarea (gtk_window_check_screen (window),
monitor_num, &monitor); monitor_num, &monitor);
*x = (monitor.width - w) / 2 + monitor.x; *x = (monitor.width - w) / 2 + monitor.x;