From f1a1399927bc64e9eaf066724fcff0982edbf667 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 19 Apr 2007 15:26:28 +0000 Subject: [PATCH] Add clutter_backend_get_n_screens() Add clutter_backend_get_n_screens(), which returns the number of screens manager by the ClutterBackend, and change clutter_backend_get_screen_number() to return the screen number of the currently used screen; this is semantically equivalent to clutter_glx_get_default_screen(), but leaves the door open for a "screen" abstraction in Clutter, handled by the backend. Update the GLX and EGL backends to retrieve and set the screen_num and n_screens members of ClutterBackend using Xlib calls. --- clutter/clutter-backend.c | 20 ++++++++++++++++- clutter/clutter-backend.h | 4 +++- clutter/egl/clutter-backend-egl.c | 30 +++++++++++++++---------- clutter/egl/clutter-backend-egl.h | 3 ++- clutter/glx/clutter-backend-glx.c | 6 +++-- doc/reference/clutter-sections.txt | 1 + doc/reference/tmpl/clutter-backend.sgml | 9 ++++++++ 7 files changed, 56 insertions(+), 17 deletions(-) diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c index aed2132d1..9e0f2eeb6 100644 --- a/clutter/clutter-backend.c +++ b/clutter/clutter-backend.c @@ -312,7 +312,25 @@ clutter_backend_get_screen_number (ClutterBackend *backend) { g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), -1); - return backend->screen_n; + return backend->screen_num; +} + +/** + * clutter_backend_get_n_screens: + * @backend: a #ClutterBackend + * + * Gets the number of screens managed by @backend. + * + * Return value: the number of screens + * + * Since: 0.4 + */ +gint +clutter_backend_get_n_screens (ClutterBackend *backend) +{ + g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), 0); + + return backend->n_screens; } /** diff --git a/clutter/clutter-backend.h b/clutter/clutter-backend.h index 57ab438bf..7ab7f23cd 100644 --- a/clutter/clutter-backend.h +++ b/clutter/clutter-backend.h @@ -52,7 +52,8 @@ struct _ClutterBackend gint res_width; gint res_height; - gint screen_n; + gint screen_num; + gint n_screens; /* events queue: every backend must implement one */ GQueue *events_queue; @@ -101,6 +102,7 @@ gint clutter_backend_get_height (ClutterBackend *backend); gint clutter_backend_get_width_mm (ClutterBackend *backend); gint clutter_backend_get_height_mm (ClutterBackend *backend); gint clutter_backend_get_screen_number (ClutterBackend *backend); +gint clutter_backend_get_n_screens (ClutterBackend *backend); void clutter_backend_set_double_click_time (ClutterBackend *backend, guint msec); diff --git a/clutter/egl/clutter-backend-egl.c b/clutter/egl/clutter-backend-egl.c index 3ce51e027..0ccfa47ba 100644 --- a/clutter/egl/clutter-backend-egl.c +++ b/clutter/egl/clutter-backend-egl.c @@ -62,19 +62,24 @@ clutter_backend_egl_post_parse (ClutterBackend *backend, CLUTTER_NOTE (MISC, "Getting the X screen"); if (clutter_screen == 0) - backend_egl->xscreen = DefaultScreen (backend_egl->xdpy); + backend_egl->xscreen = DefaultScreenOfDisplay (backend_egl->xdpy); else - { - Screen *xscreen; - - xscreen = ScreenOfDisplay (backend_egl->xdpy, clutter_screen); - backend_egl->xscreen = XScreenNumberOfScreen (xscreen); - } + backend_egl->xscreen = ScreenOfDisplay (backend_egl->xdpy, + clutter_screen); + backend_egl->xscreen_num = XScreenNumberOfScreen (backend_egl->xscreen); backend_egl->xwin_root = RootWindow (backend_egl->xdpy, - backend_egl->xscreen); + backend_egl->xscreen_num); backend_egl->display_name = g_strdup (clutter_display_name); + + /* generic backend properties */ + backend->res_width = WidthOfScreen (backend_egl->xscreen); + backend->res_height = HeightOfScreen (backend_egl->xscreen); + backend->mm_width = WidthMMOfScreen (backend_egl->xscreen); + backend->mm_height = HeightMMOfScreen (backend_egl->xscreen); + backend->screen_num = backend_egl->xscreen_num; + backend->n_screens = ScreenCount (backend_egl->xdpy) } g_free (clutter_display_name); @@ -82,7 +87,7 @@ clutter_backend_egl_post_parse (ClutterBackend *backend, CLUTTER_NOTE (MISC, "X Display `%s' [%p] opened (screen:%d, root:%u)", backend_egl->display_name, backend_egl->xdpy, - backend_egl->xscreen, + backend_egl->xscreen_num, (unsigned int) backend_egl->xwin_root); return TRUE; @@ -105,7 +110,7 @@ clutter_backend_egl_init_stage (ClutterBackend *backend, stage_egl = CLUTTER_STAGE_EGL (stage); stage_egl->xdpy = backend_egl->xdpy; stage_egl->xwin_root = backend_egl->xwin_root; - stage_egl->xscreen = backend_egl->xscreen; + stage_egl->xscreen = backend_egl->xscreen_num; g_object_set_data (G_OBJECT (stage), "clutter-backend", backend); @@ -249,7 +254,8 @@ clutter_backend_egl_init (ClutterBackendEgl *backend_egl) backend->res_width = backend->res_height = -1; backend->mm_width = backend->mm_height = -1; - backend->screen_n = 0; + backend->screen_num = 0; + backend->n_screens = 0; backend->double_click_time = 250; backend->double_click_distance = 5 @@ -339,7 +345,7 @@ clutter_egl_get_default_screen (void) return -1; } - return backend_singleton->xscreen; + return backend_singleton->xscreen_num; } /** diff --git a/clutter/egl/clutter-backend-egl.h b/clutter/egl/clutter-backend-egl.h index f9092ab34..59a5f1bc7 100644 --- a/clutter/egl/clutter-backend-egl.h +++ b/clutter/egl/clutter-backend-egl.h @@ -46,7 +46,8 @@ struct _ClutterBackendEgl Display *xdpy; gchar *display_name; Window xwin_root; - int xscreen; + int xscreen_num; + Screen *xscreen; /* main stage singleton */ ClutterActor *stage; diff --git a/clutter/glx/clutter-backend-glx.c b/clutter/glx/clutter-backend-glx.c index 1e9c9ae04..c02875b7f 100644 --- a/clutter/glx/clutter-backend-glx.c +++ b/clutter/glx/clutter-backend-glx.c @@ -112,7 +112,8 @@ clutter_backend_glx_post_parse (ClutterBackend *backend, backend->res_height = HeightOfScreen (backend_glx->xscreen); backend->mm_width = WidthMMOfScreen (backend_glx->xscreen); backend->mm_height = HeightMMOfScreen (backend_glx->xscreen); - backend->screen_n = ScreenCount (backend_glx->xdpy); + backend->screen_num = backend_glx->xscreen_num; + backend->n_screens = ScreenCount (backend_glx->xdpy); } g_free (clutter_display_name); @@ -309,7 +310,8 @@ clutter_backend_glx_init (ClutterBackendGlx *backend_glx) backend->res_width = backend->res_height = -1; backend->mm_width = backend->mm_height = -1; - backend->screen_n = 0; + backend->screen_num = 0; + backend->n_screens = 0; /* FIXME - find a way to set this stuff from XSettings */ backend->double_click_time = 250; diff --git a/doc/reference/clutter-sections.txt b/doc/reference/clutter-sections.txt index f60395a09..efc6e9c7b 100644 --- a/doc/reference/clutter-sections.txt +++ b/doc/reference/clutter-sections.txt @@ -509,6 +509,7 @@ clutter_backend_get_height clutter_backend_get_width_mm clutter_backend_get_height_mm clutter_backend_get_screen_number +clutter_backend_get_n_screens clutter_backend_get_double_click_time clutter_backend_set_double_click_time clutter_backend_get_double_click_distance diff --git a/doc/reference/tmpl/clutter-backend.sgml b/doc/reference/tmpl/clutter-backend.sgml index d15da2d45..3a9ecebec 100644 --- a/doc/reference/tmpl/clutter-backend.sgml +++ b/doc/reference/tmpl/clutter-backend.sgml @@ -103,6 +103,15 @@ ClutterBackend @Returns: + + + + + +@backend: +@Returns: + +