[gtk+] Use the workarea when placing popups
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Use the workarea when placing popups
- Date: Sun, 18 Dec 2011 19:30:03 +0000 (UTC)
commit 020c1846b750ffe56a83595919e88dd6b41bcece
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Dec 18 14:28:01 2011 -0500
Use the workarea when placing popups
This uses the new workarea API to avoid placing popups underneath
panels, docks, etc.
gtk/gtkcombobox.c | 4 ++--
gtk/gtkentry.c | 2 +-
gtk/gtkentrycompletion.c | 4 +---
gtk/gtkfilechooserdefault.c | 2 +-
gtk/gtklinkbutton.c | 2 +-
gtk/gtkmenu.c | 6 +++---
gtk/gtkmenuitem.c | 2 +-
gtk/gtkmenutoolbutton.c | 2 +-
gtk/gtkrecentchooserdefault.c | 4 ++--
gtk/gtkscalebutton.c | 2 +-
gtk/gtkstatusicon.c | 2 +-
gtk/gtktextview.c | 2 +-
gtk/gtktoolbar.c | 2 +-
gtk/gtktooltip.c | 2 +-
gtk/gtktreeview.c | 2 +-
gtk/gtkwindow.c | 8 ++++----
16 files changed, 23 insertions(+), 25 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 3f2b263..61be1f1 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -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;
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index c2377de..ef23f3e 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -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);
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index b7e9b6b..12c0fe4 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -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);
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 3236a7c..280e491 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -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));
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index f17be71..60ca435 100644
--- a/gtk/gtklinkbutton.c
+++ b/gtk/gtklinkbutton.c
@@ -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));
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index ecb4038..e1fc40a 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -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;
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index 727c7d6..cb4ee7a 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -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))
{
diff --git a/gtk/gtkmenutoolbutton.c b/gtk/gtkmenutoolbutton.c
index 5951803..afcd69a 100644
--- a/gtk/gtkmenutoolbutton.c
+++ b/gtk/gtkmenutoolbutton.c
@@ -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)
{
diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c
index 160b37f..b524a90 100644
--- a/gtk/gtkrecentchooserdefault.c
+++ b/gtk/gtkrecentchooserdefault.c
@@ -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));
diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c
index b6c10f4..54765e6 100644
--- a/gtk/gtkscalebutton.c
+++ b/gtk/gtkscalebutton.c
@@ -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;
diff --git a/gtk/gtkstatusicon.c b/gtk/gtkstatusicon.c
index bb0abe3..180936e 100644
--- a/gtk/gtkstatusicon.c
+++ b/gtk/gtkstatusicon.c
@@ -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);
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 0c12258..a048bc9 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -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));
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index 5e7cfe1..981c1f0 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -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);
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index df4fc50..ab58392 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -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);
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 1398ddb..e545519 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -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);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index a07da04..a64d0f3 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]