[gimp/gtk3-port: 338/440] app: gdk_screen_get_monitor_workarea() -> gdk_monitor_get_workarea()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 338/440] app: gdk_screen_get_monitor_workarea() -> gdk_monitor_get_workarea()
- Date: Sun, 13 May 2018 12:46:59 +0000 (UTC)
commit 41565f86830863f18945d2a56d8672b1435c259f
Author: Michael Natterer <mitch gimp org>
Date: Fri May 4 13:20:46 2018 +0200
app: gdk_screen_get_monitor_workarea() -> gdk_monitor_get_workarea()
app/dialogs/resolution-calibrate-dialog.c | 13 ++++---------
app/widgets/gimpuimanager.c | 16 +++++++---------
app/widgets/gimpview-popup.c | 24 +++++++++++++-----------
app/widgets/gimpwidgets-utils.c | 25 ++++++++++---------------
4 files changed, 34 insertions(+), 44 deletions(-)
---
diff --git a/app/dialogs/resolution-calibrate-dialog.c b/app/dialogs/resolution-calibrate-dialog.c
index e9c8c88..8d236b0 100644
--- a/app/dialogs/resolution-calibrate-dialog.c
+++ b/app/dialogs/resolution-calibrate-dialog.c
@@ -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);
diff --git a/app/widgets/gimpuimanager.c b/app/widgets/gimpuimanager.c
index fea596a..1fca232 100644
--- a/app/widgets/gimpuimanager.c
+++ b/app/widgets/gimpuimanager.c
@@ -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
diff --git a/app/widgets/gimpview-popup.c b/app/widgets/gimpview-popup.c
index e094cfc..be00710 100644
--- a/app/widgets/gimpview-popup.c
+++ b/app/widgets/gimpview-popup.c
@@ -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);
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 0de4dfb..56eb241 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]