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.
This commit is contained in:
Emmanuele Bassi 2007-04-19 15:26:28 +00:00
parent ea0cd22e4b
commit f1a1399927
7 changed files with 56 additions and 17 deletions

View File

@ -312,7 +312,25 @@ clutter_backend_get_screen_number (ClutterBackend *backend)
{ {
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), -1); 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;
} }
/** /**

View File

@ -52,7 +52,8 @@ struct _ClutterBackend
gint res_width; gint res_width;
gint res_height; gint res_height;
gint screen_n; gint screen_num;
gint n_screens;
/* events queue: every backend must implement one */ /* events queue: every backend must implement one */
GQueue *events_queue; 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_width_mm (ClutterBackend *backend);
gint clutter_backend_get_height_mm (ClutterBackend *backend); gint clutter_backend_get_height_mm (ClutterBackend *backend);
gint clutter_backend_get_screen_number (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, void clutter_backend_set_double_click_time (ClutterBackend *backend,
guint msec); guint msec);

View File

@ -62,19 +62,24 @@ clutter_backend_egl_post_parse (ClutterBackend *backend,
CLUTTER_NOTE (MISC, "Getting the X screen"); CLUTTER_NOTE (MISC, "Getting the X screen");
if (clutter_screen == 0) if (clutter_screen == 0)
backend_egl->xscreen = DefaultScreen (backend_egl->xdpy); backend_egl->xscreen = DefaultScreenOfDisplay (backend_egl->xdpy);
else else
{ backend_egl->xscreen = ScreenOfDisplay (backend_egl->xdpy,
Screen *xscreen; clutter_screen);
xscreen = ScreenOfDisplay (backend_egl->xdpy, clutter_screen);
backend_egl->xscreen = XScreenNumberOfScreen (xscreen);
}
backend_egl->xscreen_num = XScreenNumberOfScreen (backend_egl->xscreen);
backend_egl->xwin_root = RootWindow (backend_egl->xdpy, backend_egl->xwin_root = RootWindow (backend_egl->xdpy,
backend_egl->xscreen); backend_egl->xscreen_num);
backend_egl->display_name = g_strdup (clutter_display_name); 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); 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)", CLUTTER_NOTE (MISC, "X Display `%s' [%p] opened (screen:%d, root:%u)",
backend_egl->display_name, backend_egl->display_name,
backend_egl->xdpy, backend_egl->xdpy,
backend_egl->xscreen, backend_egl->xscreen_num,
(unsigned int) backend_egl->xwin_root); (unsigned int) backend_egl->xwin_root);
return TRUE; return TRUE;
@ -105,7 +110,7 @@ clutter_backend_egl_init_stage (ClutterBackend *backend,
stage_egl = CLUTTER_STAGE_EGL (stage); stage_egl = CLUTTER_STAGE_EGL (stage);
stage_egl->xdpy = backend_egl->xdpy; stage_egl->xdpy = backend_egl->xdpy;
stage_egl->xwin_root = backend_egl->xwin_root; 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); 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->res_width = backend->res_height = -1;
backend->mm_width = backend->mm_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_time = 250;
backend->double_click_distance = 5 backend->double_click_distance = 5
@ -339,7 +345,7 @@ clutter_egl_get_default_screen (void)
return -1; return -1;
} }
return backend_singleton->xscreen; return backend_singleton->xscreen_num;
} }
/** /**

View File

@ -46,7 +46,8 @@ struct _ClutterBackendEgl
Display *xdpy; Display *xdpy;
gchar *display_name; gchar *display_name;
Window xwin_root; Window xwin_root;
int xscreen; int xscreen_num;
Screen *xscreen;
/* main stage singleton */ /* main stage singleton */
ClutterActor *stage; ClutterActor *stage;

View File

@ -112,7 +112,8 @@ clutter_backend_glx_post_parse (ClutterBackend *backend,
backend->res_height = HeightOfScreen (backend_glx->xscreen); backend->res_height = HeightOfScreen (backend_glx->xscreen);
backend->mm_width = WidthMMOfScreen (backend_glx->xscreen); backend->mm_width = WidthMMOfScreen (backend_glx->xscreen);
backend->mm_height = HeightMMOfScreen (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); g_free (clutter_display_name);
@ -309,7 +310,8 @@ clutter_backend_glx_init (ClutterBackendGlx *backend_glx)
backend->res_width = backend->res_height = -1; backend->res_width = backend->res_height = -1;
backend->mm_width = backend->mm_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 */ /* FIXME - find a way to set this stuff from XSettings */
backend->double_click_time = 250; backend->double_click_time = 250;

View File

@ -509,6 +509,7 @@ clutter_backend_get_height
clutter_backend_get_width_mm clutter_backend_get_width_mm
clutter_backend_get_height_mm clutter_backend_get_height_mm
clutter_backend_get_screen_number clutter_backend_get_screen_number
clutter_backend_get_n_screens
clutter_backend_get_double_click_time clutter_backend_get_double_click_time
clutter_backend_set_double_click_time clutter_backend_set_double_click_time
clutter_backend_get_double_click_distance clutter_backend_get_double_click_distance

View File

@ -103,6 +103,15 @@ ClutterBackend
@Returns: @Returns:
<!-- ##### FUNCTION clutter_backend_get_n_screens ##### -->
<para>
</para>
@backend:
@Returns:
<!-- ##### FUNCTION clutter_backend_get_double_click_time ##### --> <!-- ##### FUNCTION clutter_backend_get_double_click_time ##### -->
<para> <para>