From 97d06e5b3f4b658d60ef9ff2e3d1d81ce86cb3b3 Mon Sep 17 00:00:00 2001 From: Rafael Antognolli Date: Tue, 2 Apr 2013 17:11:10 -0300 Subject: [PATCH] ecore/wayland: Fix screen geometry when it is rotated. Width and height should be swapped when the screen is rotated by 90 or 270 degrees. Additionally, add a command to the ecore_evas_window_sizes_example which returns the screen geometry. --- .../ecore/ecore_evas_window_sizes_example.c | 9 +++++++++ src/lib/ecore_wayland/Ecore_Wayland.h | 1 + src/lib/ecore_wayland/ecore_wl.c | 16 ++++++++++++++-- src/lib/ecore_wayland/ecore_wl_output.c | 3 ++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/examples/ecore/ecore_evas_window_sizes_example.c b/src/examples/ecore/ecore_evas_window_sizes_example.c index 5edd52a840..a0777a544c 100644 --- a/src/examples/ecore/ecore_evas_window_sizes_example.c +++ b/src/examples/ecore/ecore_evas_window_sizes_example.c @@ -36,6 +36,7 @@ static const char commands[] = \ "\tx - impose a maximum size to the window\n" "\tb - impose a base size to the window\n" "\ts - impose a step size (different than 1 px) to the window\n" + "\tg - get the screen geometry\n" "\th - print help\n"; /* to inform current window's size */ @@ -147,6 +148,14 @@ _on_keydown(void *data EINA_UNUSED, } return; } + + if (strcmp(ev->keyname, "g") == 0) /* get screen geometry */ + { + int x, y, w, h; + ecore_evas_screen_geometry_get(ee, &x, &y, &w, &h); + fprintf(stdout, "screen geometry: %d,%d, %dx%d\n", x, y, w, h); + return; + } } int diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h index 250429e3f4..372c9840fc 100644 --- a/src/lib/ecore_wayland/Ecore_Wayland.h +++ b/src/lib/ecore_wayland/Ecore_Wayland.h @@ -129,6 +129,7 @@ struct _Ecore_Wl_Output struct wl_output *output; Eina_Rectangle allocation; int mw, mh; + int transform; struct wl_list link; void (*destroy) (Ecore_Wl_Output *output, void *data); diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c index 82d8f86c42..5ebe3fa2c6 100644 --- a/src/lib/ecore_wayland/ecore_wl.c +++ b/src/lib/ecore_wayland/ecore_wl.c @@ -213,8 +213,20 @@ ecore_wl_screen_size_get(int *w, int *h) if (!_ecore_wl_disp->output) return; - if (w) *w = _ecore_wl_disp->output->allocation.w; - if (h) *h = _ecore_wl_disp->output->allocation.h; + switch (_ecore_wl_disp->output->transform) + { + case WL_OUTPUT_TRANSFORM_90: + case WL_OUTPUT_TRANSFORM_270: + case WL_OUTPUT_TRANSFORM_FLIPPED_90: + case WL_OUTPUT_TRANSFORM_FLIPPED_270: + /* Swap width and height */ + if (w) *w = _ecore_wl_disp->output->allocation.h; + if (h) *h = _ecore_wl_disp->output->allocation.w; + break; + default: + if (w) *w = _ecore_wl_disp->output->allocation.w; + if (h) *h = _ecore_wl_disp->output->allocation.h; + } } /* @since 1.2 */ diff --git a/src/lib/ecore_wayland/ecore_wl_output.c b/src/lib/ecore_wayland/ecore_wl_output.c index f0c59b4786..46408d5c56 100644 --- a/src/lib/ecore_wayland/ecore_wl_output.c +++ b/src/lib/ecore_wayland/ecore_wl_output.c @@ -54,7 +54,7 @@ _ecore_wl_output_del(Ecore_Wl_Output *output) /* local functions */ static void -_ecore_wl_output_cb_geometry(void *data, struct wl_output *wl_output EINA_UNUSED, int x, int y, int w, int h, int subpixel EINA_UNUSED, const char *make EINA_UNUSED, const char *model EINA_UNUSED, int transform EINA_UNUSED) +_ecore_wl_output_cb_geometry(void *data, struct wl_output *wl_output EINA_UNUSED, int x, int y, int w, int h, int subpixel EINA_UNUSED, const char *make EINA_UNUSED, const char *model EINA_UNUSED, int transform) { Ecore_Wl_Output *output; @@ -65,6 +65,7 @@ _ecore_wl_output_cb_geometry(void *data, struct wl_output *wl_output EINA_UNUSED output->allocation.y = y; output->mw = w; output->mh = h; + output->transform = transform; } static void