summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sp-namedview.cpp46
-rw-r--r--src/ui/dialog/dialog.cpp20
-rw-r--r--src/ui/interface.cpp29
3 files changed, 78 insertions, 17 deletions
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index c40006a92..a3a5617e1 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -37,6 +37,12 @@
#include "sp-root.h"
#include <gtkmm/window.h>
+#if WITH_GTKMM_3_22
+# include <gdkmm/monitor.h>
+#else
+# include <gdkmm/screen.h>
+#endif
+
using Inkscape::DocumentUndo;
using Inkscape::Util::unit_table;
@@ -742,9 +748,22 @@ gdouble const NEWDOC_Y_SCALE = NEWDOC_X_SCALE;
Geom::Point calcAnchorPoint(gint const x, gint const y,
gint const w, gint const h, gint const minOnscreen)
{
+#if WITH_GTKMM_3_22
+ Gdk::Rectangle screen_geometry;
+
+ auto const display = Gdk::Display::get_default();
+ auto const monitor = display->get_primary_monitor();
+ monitor->get_geometry(screen_geometry);
+ int screen_width = screen_geometry.get_width();
+ int screen_height = screen_geometry.get_height();
+#else
+ int screen_width = gdk_screen_width();
+ int screen_height = gdk_screen_height();
+#endif
+
// prevent the window from moving off the screen to the right or to the bottom
- gint ax = MIN(gdk_screen_width() - minOnscreen, x);
- gint ay = MIN(gdk_screen_height() - minOnscreen, y);
+ gint ax = MIN(screen_width - minOnscreen, x);
+ gint ay = MIN(screen_height - minOnscreen, y);
// prevent the window from moving off the screen to the left or to the top
ax = MAX(minOnscreen - w, ax);
@@ -778,16 +797,23 @@ void sp_namedview_window_from_document(SPDesktop *desktop)
win->maximize();
}
} else {
- // gdk_screen_width() / gdk_screen_height() return the dimensions of all displays combined
- // therefore we have to get the dimensions of one monitor explicitly (currently the primary monitor)
+
// TODO: account for multi-monitor setups (i.e. on which monitor do we want to display Inkscape?)
- gint monitor_number;
- GdkRectangle monitor_geometry;
- monitor_number = gdk_screen_get_primary_monitor(gdk_screen_get_default());
- gdk_screen_get_monitor_geometry(gdk_screen_get_default(), monitor_number, &monitor_geometry);
+ Gdk::Rectangle monitor_geometry;
+
+#if WITH_GTKMM_3_22
+ auto const display = Gdk::Display::get_default();
+ auto const monitor = display->get_primary_monitor();
+ monitor->get_geometry(monitor_geometry);
+#else
+ auto const default_screen = Gdk::Screen::get_default();
+ auto const monitor_number = default_screen->get_primary_monitor();
+ default_screen->get_monitor_geometry(monitor_number, monitor_geometry);
+#endif
+
+ int w = monitor_geometry.get_width();
+ int h = monitor_geometry.get_height();
- gint w = monitor_geometry.width;
- gint h = monitor_geometry.height;
bool move_to_screen = false;
if (geometry_from_file and !new_document) {
w = MIN(w, nv->window_width);
diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp
index 27a6e55d9..39c913175 100644
--- a/src/ui/dialog/dialog.cpp
+++ b/src/ui/dialog/dialog.cpp
@@ -19,6 +19,11 @@
#include "dialog-manager.h"
#include <gtkmm/dialog.h>
+
+#if WITH_GTKMM_3_22
+# include <gdkmm/monitor.h>
+#endif
+
#include <gdk/gdkkeysyms.h>
#include "inkscape.h"
@@ -161,10 +166,23 @@ void Dialog::read_geometry()
resize(w, h);
}
+#if WITH_GTKMM_3_22
+ auto const display = Gdk::Display::get_default();
+ auto const monitor = display->get_primary_monitor();
+
+ Gdk::Rectangle screen_geometry;
+ monitor->get_geometry(screen_geometry);
+ auto const screen_width = screen_geometry.get_width();
+ auto const screen_height = screen_geometry.get_height();
+#else
+ auto const screen_width = gdk_screen_width();
+ auto const screen_height = gdk_screen_width();
+#endif
+
// If there are stored values for where the dialog should be
// located, then restore the dialog to that position.
// also check if (x,y) is actually onscreen with the current screen dimensions
- if ( (x >= 0) && (y >= 0) && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE)) ) {
+ if ( (x >= 0) && (y >= 0) && (x < (screen_width-MIN_ONSCREEN_DISTANCE)) && (y < (screen_height-MIN_ONSCREEN_DISTANCE)) ) {
move(x, y);
} else {
// ...otherwise just put it in the middle of the screen
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 7e80c1a2f..9abc1f07b 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -30,6 +30,10 @@
#include <gtkmm/imagemenuitem.h>
#include <gtkmm/separatormenuitem.h>
+#if WITH_GTKMM_3_22
+# include <gdkmm/monitor.h>
+#endif
+
#include "inkscape.h"
#include "extension/db.h"
#include "extension/effect.h"
@@ -176,13 +180,26 @@ sp_create_window(SPViewWidget *vw, bool editable)
gint full = prefs->getBool("/desktop/geometry/fullscreen");
gint maxed = prefs->getBool("/desktop/geometry/maximized");
if (pw>0 && ph>0) {
- gint w = MIN(gdk_screen_width(), pw);
- gint h = MIN(gdk_screen_height(), ph);
- gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, px);
- gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, py);
+#if WITH_GTKMM_3_22
+ auto const display = Gdk::Display::get_default();
+ auto const monitor = display->get_primary_monitor();
+
+ // A Gdk::Rectangle in "application pixel" units
+ Gdk::Rectangle screen_geometry;
+ monitor->get_geometry(screen_geometry);
+ auto const screen_width = screen_geometry.get_width();
+ auto const screen_height = screen_geometry.get_height();
+#else
+ auto const screen_width = gdk_screen_width();
+ auto const screen_height = gdk_screen_height();
+#endif
+ gint w = MIN(screen_width, pw);
+ gint h = MIN(screen_height, ph);
+ gint x = MIN(screen_width - MIN_ONSCREEN_DISTANCE, px);
+ gint y = MIN(screen_height - MIN_ONSCREEN_DISTANCE, py);
if (w>0 && h>0) {
- x = MIN(gdk_screen_width() - w, x);
- y = MIN(gdk_screen_height() - h, y);
+ x = MIN(screen_width - w, x);
+ y = MIN(screen_height - h, y);
desktop->setWindowSize(w, h);
}