diff options
| author | Alexander Valavanis <valavanisalex@gmail.com> | 2017-06-27 13:03:58 +0000 |
|---|---|---|
| committer | Alexander Valavanis <valavanisalex@gmail.com> | 2017-06-27 13:03:58 +0000 |
| commit | fa8a2ee7e2539b145a87ac9af0d9748effa91631 (patch) | |
| tree | 457bd081679e98e296be9846117508b4524ec7b3 | |
| parent | select-tool: Only stop the rubberband when it was started (diff) | |
| download | inkscape-fa8a2ee7e2539b145a87ac9af0d9748effa91631.tar.gz inkscape-fa8a2ee7e2539b145a87ac9af0d9748effa91631.zip | |
GdkScreen deprecation fixes
| -rw-r--r-- | CMakeScripts/DefineDependsandFlags.cmake | 12 | ||||
| -rw-r--r-- | config.h.cmake | 3 | ||||
| -rw-r--r-- | src/sp-namedview.cpp | 46 | ||||
| -rw-r--r-- | src/ui/dialog/dialog.cpp | 20 | ||||
| -rw-r--r-- | src/ui/interface.cpp | 29 |
5 files changed, 93 insertions, 17 deletions
diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index 52410fb2b..1fead418a 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -258,6 +258,18 @@ set(TRY_GTKSPELL ON) set (WITH_GTKMM_3_10 ON) endif() + # Check whether we can use new features in Gtkmm 3.22 + # TODO: Drop this test and bump the version number in the GTK test above + # as soon as all supported distributions provide Gtkmm >= 3.22 + pkg_check_modules(GTKMM_3_22 + gtkmm-3.0>=3.22, + ) + + if("${GTKMM_3_22_FOUND}") + message("Using Gtkmm 3.22 build") + set (WITH_GTKMM_3_22 ON) + endif() + pkg_check_modules(GDL_3_6 gdl-3.0>=3.6) if("${GDL_3_6_FOUND}") diff --git a/config.h.cmake b/config.h.cmake index 35e9818a9..2cd660d87 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -56,6 +56,9 @@ /* Build with Gtkmm 3.10.x or higher */ #cmakedefine WITH_GTKMM_3_10 1 +/* Build with Gtkmm 3.22.x or higher */ +#cmakedefine WITH_GTKMM_3_22 1 + /* Build with GDL 3.6 or higher */ #cmakedefine WITH_GDL_3_6 1 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); } |
