Commit 73af1873 authored by Michael Natterer's avatar Michael Natterer 😴

app: gdk_screen_get_monitor_workarea() -> gdk_monitor_get_workarea()

parent 885f6615
......@@ -55,9 +55,7 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry,
GtkWidget *hbox;
GtkWidget *ruler;
GtkWidget *label;
GdkScreen *screen;
GdkRectangle rect;
gint monitor;
GdkRectangle workarea;
g_return_if_fail (GIMP_IS_SIZE_ENTRY (resolution_entry));
g_return_if_fail (gtk_widget_get_realized (resolution_entry));
......@@ -82,13 +80,10 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry,
GTK_RESPONSE_CANCEL,
-1);
screen = gtk_widget_get_screen (dialog);
monitor = gdk_screen_get_monitor_at_window (screen,
gtk_widget_get_window (resolution_entry));
gdk_screen_get_monitor_workarea (screen, monitor, &rect);
gdk_monitor_get_workarea (gimp_widget_get_monitor (dialog), &workarea);
ruler_width = rect.width - 300 - (rect.width % 100);
ruler_height = rect.height - 300 - (rect.height % 100);
ruler_width = workarea.width - 300 - (workarea.width % 100);
ruler_height = workarea.height - 300 - (workarea.height % 100);
grid = gtk_grid_new ();
gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
......
......@@ -894,8 +894,7 @@ gimp_ui_manager_menu_position (GtkMenu *menu,
GdkDevice *device;
GdkScreen *screen;
GtkRequisition requisition;
GdkRectangle rect;
gint monitor;
GdkRectangle workarea;
gint pointer_x;
gint pointer_y;
......@@ -909,8 +908,7 @@ gimp_ui_manager_menu_position (GtkMenu *menu,
gdk_device_get_position (device, &screen, &pointer_x, &pointer_y);
monitor = gdk_screen_get_monitor_at_point (screen, pointer_x, pointer_y);
gdk_screen_get_monitor_workarea (screen, monitor, &rect);
gdk_monitor_get_workarea (gimp_get_monitor_at_pointer (), &workarea);
gtk_menu_set_screen (menu, screen);
......@@ -920,24 +918,24 @@ gimp_ui_manager_menu_position (GtkMenu *menu,
{
*x = pointer_x - 2 - requisition.width;
if (*x < rect.x)
if (*x < workarea.x)
*x = pointer_x + 2;
}
else
{
*x = pointer_x + 2;
if (*x + requisition.width > rect.x + rect.width)
if (*x + requisition.width > workarea.x + workarea.width)
*x = pointer_x - 2 - requisition.width;
}
*y = pointer_y + 2;
if (*y + requisition.height > rect.y + rect.height)
if (*y + requisition.height > workarea.y + workarea.height)
*y = pointer_y - 2 - requisition.height;
if (*x < rect.x) *x = rect.x;
if (*y < rect.y) *y = rect.y;
if (*x < workarea.x) *x = workarea.x;
if (*y < workarea.y) *y = workarea.y;
}
static void
......
......@@ -193,20 +193,18 @@ gimp_view_popup_timeout (GimpViewPopup *popup)
GtkWidget *window;
GtkWidget *frame;
GtkWidget *view;
GdkScreen *screen;
GdkRectangle rect;
gint monitor;
GdkDisplay *display;
GdkRectangle workarea;
gint x;
gint y;
popup->timeout_id = 0;
screen = gtk_widget_get_screen (popup->widget);
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_screen (GTK_WINDOW (window), screen);
gtk_window_set_screen (GTK_WINDOW (window),
gtk_widget_get_screen (popup->widget));
gtk_window_set_transient_for (GTK_WINDOW (window),
GTK_WINDOW (gtk_widget_get_toplevel (popup->widget)));
......@@ -225,14 +223,18 @@ gimp_view_popup_timeout (GimpViewPopup *popup)
gtk_container_add (GTK_CONTAINER (frame), view);
gtk_widget_show (view);
display = gtk_widget_get_display (popup->widget);
gdk_monitor_get_workarea (gdk_display_get_monitor_at_point (display,
popup->button_x,
popup->button_y),
&workarea);
x = popup->button_x - (popup->popup_width / 2);
y = popup->button_y - (popup->popup_height / 2);
monitor = gdk_screen_get_monitor_at_point (screen, x, y);
gdk_screen_get_monitor_workarea (screen, monitor, &rect);
x = CLAMP (x, rect.x, rect.x + rect.width - popup->popup_width);
y = CLAMP (y, rect.y, rect.y + rect.height - popup->popup_height);
x = CLAMP (x, workarea.x, workarea.x + workarea.width - popup->popup_width);
y = CLAMP (y, workarea.y, workarea.y + workarea.height - popup->popup_height);
gtk_window_move (GTK_WINDOW (window), x, y);
gtk_widget_show (window);
......
......@@ -140,10 +140,8 @@ gimp_menu_position (GtkMenu *menu,
gint *y)
{
GtkWidget *widget;
GdkScreen *screen;
GtkRequisition requisition;
GdkRectangle rect;
gint monitor;
GdkRectangle workarea;
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (x != NULL);
......@@ -151,35 +149,32 @@ gimp_menu_position (GtkMenu *menu,
widget = GTK_WIDGET (menu);
screen = gtk_widget_get_screen (widget);
gdk_monitor_get_workarea (gimp_widget_get_monitor (widget), &workarea);
monitor = gdk_screen_get_monitor_at_point (screen, *x, *y);
gdk_screen_get_monitor_workarea (screen, monitor, &rect);
gtk_menu_set_screen (menu, screen);
gtk_menu_set_screen (menu, gtk_widget_get_screen (widget));
gtk_widget_get_preferred_size (widget, &requisition, NULL);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
{
*x -= requisition.width;
if (*x < rect.x)
if (*x < workarea.x)
*x += requisition.width;
}
else
{
if (*x + requisition.width > rect.x + rect.width)
if (*x + requisition.width > workarea.x + workarea.width)
*x -= requisition.width;
}
if (*x < rect.x)
*x = rect.x;
if (*x < workarea.x)
*x = workarea.x;
if (*y + requisition.height > rect.y + rect.height)
if (*y + requisition.height > workarea.y + workarea.height)
*y -= requisition.height;
if (*y < rect.y)
*y = rect.y;
if (*y < workarea.y)
*y = workarea.y;
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment