[shotwell] Remove gdk_screen_get_width/height
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] Remove gdk_screen_get_width/height
- Date: Sat, 31 Mar 2018 20:03:31 +0000 (UTC)
commit 1b56db4b2bd9ee9ff35d2a91fcef7736f3431031
Author: Jens Georg <mail jensge org>
Date: Fri Mar 30 15:03:04 2018 +0200
Remove gdk_screen_get_width/height
src/Dimensions.vala | 8 +++++---
src/PhotoPage.vala | 12 ++++++------
src/editing_tools/EditingTools.vala | 16 ++++++++--------
3 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/src/Dimensions.vala b/src/Dimensions.vala
index 99fe469..3b4163c 100644
--- a/src/Dimensions.vala
+++ b/src/Dimensions.vala
@@ -315,10 +315,12 @@ public struct Scaling {
return Scaling(constraint, scale, Dimensions(), scale_up);
}
- private static Dimensions get_screen_dimensions(Gtk.Window window) {
- Gdk.Screen screen = window.get_screen();
+ public static Dimensions get_screen_dimensions(Gtk.Window window) {
+ var display = window.get_window().get_display();
+ var monitor = display.get_monitor_at_window(window.get_window());
+ var geom = monitor.get_geometry();
- return Dimensions(screen.get_width(), screen.get_height());
+ return Dimensions(geom.width, geom.height);
}
private int scale_to_pixels() {
diff --git a/src/PhotoPage.vala b/src/PhotoPage.vala
index 5c2a1de..8615c8f 100644
--- a/src/PhotoPage.vala
+++ b/src/PhotoPage.vala
@@ -2226,9 +2226,9 @@ public abstract class EditingHostPage : SinglePhotoPage {
Gtk.Allocation toolbar_alloc;
get_toolbar().get_allocation(out toolbar_alloc);
- Gdk.Screen screen = get_container().get_screen();
- x = screen.get_width();
- y = screen.get_height() - toolbar_alloc.height -
+ var dimensions = Scaling.get_screen_dimensions(get_container());
+ x = dimensions.width;
+ y = dimensions.height - toolbar_alloc.height -
tool_alloc.height - TOOL_WINDOW_SEPARATOR;
// put larger adjust tool off to the side
@@ -2241,9 +2241,9 @@ public abstract class EditingHostPage : SinglePhotoPage {
}
// however, clamp the window so it's never off-screen initially
- Gdk.Screen screen = get_container().get_screen();
- x = x.clamp(0, screen.get_width() - tool_alloc.width);
- y = y.clamp(0, screen.get_height() - tool_alloc.height);
+ var dimensions = Scaling.get_screen_dimensions(get_container());
+ x = x.clamp(0, dimensions.width - tool_alloc.width);
+ y = y.clamp(0, dimensions.height - tool_alloc.height);
tool_window.move(x, y);
tool_window.show();
diff --git a/src/editing_tools/EditingTools.vala b/src/editing_tools/EditingTools.vala
index ee08f84..b782d30 100644
--- a/src/editing_tools/EditingTools.vala
+++ b/src/editing_tools/EditingTools.vala
@@ -786,9 +786,9 @@ public class CropTool : EditingTool {
result.basis_width = canvas.get_scaled_pixbuf_position().width;
result.basis_height = canvas.get_scaled_pixbuf_position().height;
} else if (result.aspect_ratio == SCREEN_ASPECT_RATIO) {
- Gdk.Screen screen = Gdk.Screen.get_default();
- result.basis_width = screen.get_width();
- result.basis_height = screen.get_height();
+ var dim = Scaling.get_screen_dimensions(AppWindow.get_instance());
+ result.basis_width = dim.width;
+ result.basis_height = dim.height;
}
return result;
@@ -890,14 +890,14 @@ public class CropTool : EditingTool {
}
private float get_constraint_aspect_ratio() {
- float result = get_selected_constraint().aspect_ratio;
+ var result = get_selected_constraint().aspect_ratio;
if (result == ORIGINAL_ASPECT_RATIO) {
result = ((float) canvas.get_scaled_pixbuf_position().width) /
((float) canvas.get_scaled_pixbuf_position().height);
} else if (result == SCREEN_ASPECT_RATIO) {
- Gdk.Screen screen = Gdk.Screen.get_default();
- result = ((float) screen.get_width()) / ((float) screen.get_height());
+ var dim = Scaling.get_screen_dimensions(AppWindow.get_instance());
+ result = ((float) dim.width) / ((float) dim.height);
} else if (result == CUSTOM_ASPECT_RATIO) {
result = custom_aspect_ratio;
}
@@ -914,8 +914,8 @@ public class CropTool : EditingTool {
Dimensions orig_dim = photo.get_original_dimensions();
result = ((float) orig_dim.width) / ((float) orig_dim.height);
} else if (result == SCREEN_ASPECT_RATIO) {
- Gdk.Screen screen = Gdk.Screen.get_default();
- result = ((float) screen.get_width()) / ((float) screen.get_height());
+ var dim = Scaling.get_screen_dimensions(AppWindow.get_instance());
+ result = ((float) dim.width) / ((float) dim.height);
} else if (result == CUSTOM_ASPECT_RATIO) {
result = custom_aspect_ratio;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]