cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=94509a3d86b470a54bac9a5974ea5a92847dd061
commit 94509a3d86b470a54bac9a5974ea5a92847dd061 Author: Vincent Torri <[email protected]> Date: Fri May 5 07:53:33 2017 +0200 Ecore_Evas (Win32): add geometry_get() method and fix dpi_get(), using the new API in Ecore_Win32. This fixes fullscreen feature in Elm on Windows as the geometry of the desktop was not known. In case of multiple displays, the desktop, where the window is displayed, is used for fullscreen. @fix Signed-off-by: Cedric BAIL <[email protected]> --- .../ecore_evas/engines/win32/ecore_evas_win32.c | 110 +++++++++++++++------ 1 file changed, 79 insertions(+), 31 deletions(-) diff --git a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c index d2c5bc7..af0fc3c 100644 --- a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c +++ b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c @@ -4,6 +4,7 @@ #endif #include <stdlib.h> /* for NULL */ +#include <inttypes.h> /* for UINT_MAX */ #include <Ecore.h> #include "ecore_private.h" @@ -1090,42 +1091,89 @@ _ecore_evas_win32_alpha_set(Ecore_Evas *ee, int alpha) } static void -_ecore_evas_win32_screen_dpi_get(const Ecore_Evas *ee EINA_UNUSED, int *xdpi, int *ydpi) +_ecore_evas_win32_screen_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h) { - HDC dc; - - dc = GetDC(NULL); - if (!dc) + Eina_Iterator *iter; + Ecore_Win32_Monitor *ewm; + Ecore_Win32_Monitor *m; + unsigned int dist; + int lx; + int ly; + int wx; + int wy; + int ww; + int wh; + + ecore_win32_window_geometry_get((Ecore_Win32_Window *)ee->prop.window, + &wx, &wy, &ww, &wh); + iter = ecore_win32_monitors_get(); + dist = UINT32_MAX; + + EINA_ITERATOR_FOREACH(iter, ewm) { - if (xdpi) *xdpi = 0; - if (ydpi) *ydpi = 0; - return; - } - - if (xdpi) *xdpi = GetDeviceCaps(dc, LOGPIXELSX); - if (ydpi) *ydpi = GetDeviceCaps(dc, LOGPIXELSY); - - /* - * Alternative (to test) - int width_mm; - int height_mm; - int width_px; - int height_px; + unsigned int d; - width_mm = GetDeviceCaps(dc, HORZSIZE); - height_mm = GetDeviceCaps(dc, VERTSIZE); - width_px = GetDeviceCaps(dc, HORZRES); - height_px = GetDeviceCaps(dc, VERTRES); - - *xdpi = (width_px * 254) / (width_mm * 10); - *ydpi = (height_px * 254) / (height_mm * 10); + lx = ewm->desktop.x - wx + (ewm->desktop.w - ww) / 2; + ly = ewm->desktop.y - wy + (ewm->desktop.h - wh) / 2; + d = lx * lx + ly * ly; + if (d < dist) + { + dist = d; + m = ewm; + } + } + eina_iterator_free(iter); + + if (x) + *x = m->desktop.x; + if (y) + *y = m->desktop.y; + if (w) + *w = m->desktop.w; + if (h) + *h = m->desktop.h; +} - code with LOGPIXELS gives 96x96 - code with the computation gives 101x77 +static void +_ecore_evas_win32_screen_dpi_get(const Ecore_Evas *ee, int *xdpi, int *ydpi) +{ + Eina_Iterator *iter; + Ecore_Win32_Monitor *ewm; + unsigned int dist; + int x_dpi; + int y_dpi; + int lx; + int ly; + int x; + int y; + int w; + int h; + + ecore_win32_window_geometry_get((Ecore_Win32_Window *)ee->prop.window, + &x, &y, &w, &h); + iter = ecore_win32_monitors_get(); + dist = UINT32_MAX; + + EINA_ITERATOR_FOREACH(iter, ewm) + { + unsigned int d; - */ + lx = ewm->desktop.x - x + (ewm->desktop.w - w) / 2; + ly = ewm->desktop.y - y + (ewm->desktop.h - h) / 2; + d = lx * lx + ly * ly; + if (d < dist) + { + dist = d; + x_dpi = ewm->dpi.x; + y_dpi = ewm->dpi.y; + } + } + eina_iterator_free(iter); - ReleaseDC(NULL, dc); + if (xdpi) + *xdpi = x_dpi; + if (ydpi) + *ydpi = y_dpi; } static Ecore_Evas_Engine_Func _ecore_win32_engine_func = @@ -1188,7 +1236,7 @@ static Ecore_Evas_Engine_Func _ecore_win32_engine_func = NULL, NULL, // render - NULL, // screen_geometry_get + _ecore_evas_win32_screen_geometry_get, _ecore_evas_win32_screen_dpi_get, NULL, NULL, // msg_send --
