diff options
Diffstat (limited to 'matchbox2/mb-window-manager.c')
-rw-r--r-- | matchbox2/mb-window-manager.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/matchbox2/mb-window-manager.c b/matchbox2/mb-window-manager.c index 6468873..71485b9 100644 --- a/matchbox2/mb-window-manager.c +++ b/matchbox2/mb-window-manager.c @@ -2250,3 +2250,22 @@ mb_wm_select_desktop (MBWindowManager *wm, int desktop) #endif } +int +mb_wm_util_pixels_to_points (MBWindowManager *wm, int pixels) +{ + static double scale = 0.0; /* Points per pixel */ + int points; + + if (scale == 0.0) + { + scale = + ((double)DisplayHeightMM (wm->xdpy, wm->xscreen) * 2.8346456693) + / (double) DisplayHeight(wm->xdpy, wm->xscreen); + } + + /* Scale and round */ + points = (((int)((double)(pixels << 10) * scale) + 512) >> 10); + + return points; +} + |