forked from AuroraMiddleware/gtk
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:
parent
c6df2828b7
commit
020c1846b7
@ -1890,7 +1890,7 @@ gtk_combo_box_menu_position_below (GtkMenu *menu,
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
|
||||
monitor_num = gdk_screen_get_monitor_at_window (screen,
|
||||
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)
|
||||
*x = monitor.x;
|
||||
@ -2089,7 +2089,7 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
|
||||
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
|
||||
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)
|
||||
*x = *x + allocation.width - *width;
|
||||
|
@ -8604,7 +8604,7 @@ popup_position_func (GtkMenu *menu,
|
||||
monitor_num = 0;
|
||||
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,
|
||||
&menu_req, NULL);
|
||||
height = gdk_window_get_height (priv->text_area);
|
||||
|
@ -1512,9 +1512,7 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
|
||||
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (completion->priv->entry));
|
||||
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)
|
||||
items = MIN (matches, (((monitor.y + y) - (actions * action_height)) / height) - 1);
|
||||
|
@ -4250,7 +4250,7 @@ popup_position_func (GtkMenu *menu,
|
||||
|
||||
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
|
||||
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));
|
||||
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
|
||||
|
@ -446,7 +446,7 @@ popup_position_func (GtkMenu *menu,
|
||||
|
||||
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
|
||||
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));
|
||||
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
|
||||
|
@ -3328,7 +3328,7 @@ gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
|
||||
GdkScreen *screen = gtk_widget_get_screen (priv->toplevel);
|
||||
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)
|
||||
min_height = monitor.y + monitor.height - priv->position_y;
|
||||
@ -4700,7 +4700,7 @@ gtk_menu_position (GtkMenu *menu,
|
||||
if (priv->monitor_num < 0)
|
||||
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
|
||||
{
|
||||
@ -4730,7 +4730,7 @@ gtk_menu_position (GtkMenu *menu,
|
||||
* Positioning in the vertical direction is similar: first try below
|
||||
* 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_right = monitor.x + monitor.width - x - 1;
|
||||
|
@ -2078,7 +2078,7 @@ gtk_menu_item_position_menu (GtkMenu *menu,
|
||||
monitor_num = gdk_screen_get_monitor_at_window (screen, priv->event_window);
|
||||
if (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))
|
||||
{
|
||||
|
@ -327,7 +327,7 @@ menu_position_func (GtkMenu *menu,
|
||||
monitor_num = gdk_screen_get_monitor_at_window (screen, window);
|
||||
if (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)
|
||||
{
|
||||
|
@ -960,7 +960,7 @@ set_default_size (GtkRecentChooserDefault *impl)
|
||||
monitor_num = gdk_screen_get_monitor_at_window (screen,
|
||||
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);
|
||||
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);
|
||||
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));
|
||||
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
|
||||
|
@ -985,7 +985,7 @@ gtk_scale_popup (GtkWidget *widget,
|
||||
monitor = gdk_screen_get_monitor_at_point (screen,
|
||||
button_event->x_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)
|
||||
y += button_event->y;
|
||||
|
@ -2218,7 +2218,7 @@ gtk_status_icon_position_menu (GtkMenu *menu,
|
||||
monitor_num = 0;
|
||||
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);
|
||||
|
||||
|
@ -8144,7 +8144,7 @@ popup_position_func (GtkMenu *menu,
|
||||
|
||||
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
|
||||
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));
|
||||
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
|
||||
|
@ -2659,7 +2659,7 @@ menu_position_func (GtkMenu *menu,
|
||||
gtk_widget_get_window (priv->arrow_button));
|
||||
if (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);
|
||||
|
||||
|
@ -1077,7 +1077,7 @@ gtk_tooltip_position (GtkTooltip *tooltip,
|
||||
monitor_num = gdk_screen_get_monitor_at_point (screen,
|
||||
tooltip->last_x,
|
||||
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);
|
||||
|
||||
|
@ -15064,7 +15064,7 @@ gtk_tree_view_search_position_func (GtkTreeView *tree_view,
|
||||
GdkRectangle monitor;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -6612,13 +6612,13 @@ center_window_on_monitor (GtkWindow *window,
|
||||
int monitor_num;
|
||||
|
||||
monitor_num = get_monitor_containing_pointer (window);
|
||||
|
||||
|
||||
if (monitor_num == -1)
|
||||
monitor_num = get_center_monitor_of_window (window);
|
||||
|
||||
gdk_screen_get_monitor_geometry (gtk_window_check_screen (window),
|
||||
monitor_num, &monitor);
|
||||
|
||||
gdk_screen_get_monitor_workarea (gtk_window_check_screen (window),
|
||||
monitor_num, &monitor);
|
||||
|
||||
*x = (monitor.width - w) / 2 + monitor.x;
|
||||
*y = (monitor.height - h) / 2 + monitor.y;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user