[med-svn] [SCM] aghermann branch, master, updated. 505432cf6ab4f88fa0a0d245da279903586957f3
Andrei Zavada
johnhommer at gmail.com
Mon Apr 1 20:54:36 UTC 2013
The following commit has been merged in the master branch:
commit 2e6d39588f87cb4f3dcaf26c107ddaaf32cedd7b
Author: Andrei Zavada <johnhommer at gmail.com>
Date: Tue Mar 12 20:02:12 2013 +0200
determine screen dpi and prepare for its use
diff --git a/src/ui/globals.hh b/src/ui/globals.hh
index 87381a5..368798c 100644
--- a/src/ui/globals.hh
+++ b/src/ui/globals.hh
@@ -42,6 +42,10 @@ extern char
extern GString
*__ss__;
+extern double
+ __dpi__;
+
+
int prepare_for_expdesign();
void set_unique_app_window( GtkWindow*);
diff --git a/src/ui/libcommon.cc b/src/ui/libcommon.cc
index 566fdac..56a79d6 100644
--- a/src/ui/libcommon.cc
+++ b/src/ui/libcommon.cc
@@ -33,6 +33,8 @@ UniqueApp
GtkWindow
*aghui::__main_window__;
+double aghui::__dpi__;
+
#define AGH_UI_GRESOURCE_FILE "aghermann.gresource"
// unique
@@ -59,6 +61,21 @@ prepare_for_expdesign()
gdk_device_manager_get_client_pointer(
gdk_display_get_device_manager( gdk_display_get_default()));
+ {
+ auto scr = gdk_screen_get_default();
+ double hdpi = (double)gdk_screen_get_width ( scr) / gdk_screen_get_width_mm ( scr),
+ vdpi = (double)gdk_screen_get_height( scr) / gdk_screen_get_height_mm( scr);
+ if ( hdpi != vdpi ) {
+ __dpi__ = (hdpi + vdpi)/2;
+ printf( "Calculated screen dpi is avg of (%g v, %g h) %g\n", hdpi, vdpi, __dpi__);
+ } else {
+ __dpi__ = hdpi;
+ printf( "Screen dpi is %g\n", __dpi__);
+ }
+
+ gdk_screen_set_resolution( scr, __dpi__);
+ }
+
GResource
*gresource
= g_resource_load(
diff --git a/src/ui/ui.hh b/src/ui/ui.hh
index eafa9a8..7c6ab2f 100644
--- a/src/ui/ui.hh
+++ b/src/ui/ui.hh
@@ -22,6 +22,7 @@
#include <gtk/gtk.h>
#include "common/lang.hh"
+#include "globals.hh"
#if HAVE_CONFIG_H && !defined(VERSION)
# include "config.h"
@@ -32,6 +33,10 @@ using namespace std;
namespace aghui {
+inline int operator"" _mm( long double v)
+{
+ return v * aghui::__dpi__;
+}
struct SGeometry {
int x, y, w, h;
--
Sleep experiment manager
More information about the debian-med-commit
mailing list