mirror of
https://github.com/brl/mutter.git
synced 2024-12-22 19:12:04 +00:00
Add API for getting properties of the ClutterBackend
Add functions to retrieve some of the properties of the screen used by the backend, like its dimensions (also physical, in millimeters); the number of screens. Also add setters and getters for the double click time (in milliseconds) and distance.
This commit is contained in:
parent
95eab3102e
commit
cd39202f23
@ -224,3 +224,85 @@ clutter_backend_put_event (ClutterBackend *backend,
|
|||||||
|
|
||||||
_clutter_event_queue_push (backend, clutter_event_copy (event));
|
_clutter_event_queue_push (backend, clutter_event_copy (event));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
clutter_backend_get_width (ClutterBackend *backend)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), -1);
|
||||||
|
|
||||||
|
return backend->res_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
clutter_backend_get_height (ClutterBackend *backend)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), -1);
|
||||||
|
|
||||||
|
return backend->res_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
clutter_backend_get_width_mm (ClutterBackend *backend)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), -1);
|
||||||
|
|
||||||
|
return backend->mm_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
clutter_backend_get_height_mm (ClutterBackend *backend)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), -1);
|
||||||
|
|
||||||
|
return backend->mm_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
clutter_backend_get_screen_number (ClutterBackend *backend)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), -1);
|
||||||
|
|
||||||
|
return backend->screen_n;
|
||||||
|
}
|
||||||
|
|
||||||
|
gdouble
|
||||||
|
clutter_backend_get_resolution (ClutterBackend *backend)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), 0.0);
|
||||||
|
|
||||||
|
return (gdouble) backend->res_width / (gdouble) backend->res_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
clutter_backend_set_double_click_time (ClutterBackend *backend,
|
||||||
|
guint msec)
|
||||||
|
{
|
||||||
|
g_return_if_fail (CLUTTER_IS_BACKEND (backend));
|
||||||
|
|
||||||
|
backend->double_click_time = msec;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
clutter_backend_get_double_click_time (ClutterBackend *backend)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), 0);
|
||||||
|
|
||||||
|
return backend->double_click_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
clutter_backend_set_double_click_distance (ClutterBackend *backend,
|
||||||
|
guint distance)
|
||||||
|
{
|
||||||
|
g_return_if_fail (CLUTTER_IS_BACKEND (backend));
|
||||||
|
|
||||||
|
backend->double_click_distance = distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
clutter_backend_get_double_click_distance (ClutterBackend *backend)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), 0);
|
||||||
|
|
||||||
|
return backend->double_click_distance;
|
||||||
|
}
|
||||||
|
@ -47,6 +47,12 @@ struct _ClutterBackend
|
|||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
|
gint mm_width;
|
||||||
|
gint mm_height;
|
||||||
|
gint res_width;
|
||||||
|
gint res_height;
|
||||||
|
|
||||||
|
gint screen_n;
|
||||||
|
|
||||||
/* events queue: every backend must implement one */
|
/* events queue: every backend must implement one */
|
||||||
GQueue *events_queue;
|
GQueue *events_queue;
|
||||||
@ -81,14 +87,27 @@ struct _ClutterBackendClass
|
|||||||
GOptionGroup *group);
|
GOptionGroup *group);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType clutter_backend_get_type (void) G_GNUC_CONST;
|
GType clutter_backend_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
ClutterBackend *clutter_get_default_backend (void);
|
ClutterBackend *clutter_get_default_backend (void);
|
||||||
|
|
||||||
ClutterEvent * clutter_backend_get_event (ClutterBackend *backend);
|
ClutterEvent *clutter_backend_get_event (ClutterBackend *backend);
|
||||||
ClutterEvent * clutter_backend_peek_event (ClutterBackend *backend);
|
ClutterEvent *clutter_backend_peek_event (ClutterBackend *backend);
|
||||||
void clutter_backend_put_event (ClutterBackend *backend,
|
void clutter_backend_put_event (ClutterBackend *backend,
|
||||||
ClutterEvent *event);
|
ClutterEvent *event);
|
||||||
|
|
||||||
|
gint clutter_backend_get_width (ClutterBackend *backend);
|
||||||
|
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);
|
||||||
|
|
||||||
|
void clutter_backend_set_double_click_time (ClutterBackend *backend,
|
||||||
|
guint msec);
|
||||||
|
guint clutter_backend_get_double_click_time (ClutterBackend *backend);
|
||||||
|
void clutter_backend_set_double_click_distance (ClutterBackend *backend,
|
||||||
|
guint distance);
|
||||||
|
guint clutter_backend_get_double_click_distance (ClutterBackend *backend);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -95,19 +95,24 @@ clutter_backend_glx_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_glx->xscreen = DefaultScreen (backend_glx->xdpy);
|
backend_glx->xscreen = DefaultScreenOfDisplay (backend_glx->xdpy);
|
||||||
else
|
else
|
||||||
{
|
backend_glx->xscreen = ScreenOfDisplay (backend_glx->xdpy,
|
||||||
Screen *xscreen;
|
clutter_screen);
|
||||||
|
|
||||||
xscreen = ScreenOfDisplay (backend_glx->xdpy, clutter_screen);
|
backend_glx->xscreen_num = XScreenNumberOfScreen (backend_glx->xscreen);
|
||||||
backend_glx->xscreen = XScreenNumberOfScreen (xscreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
backend_glx->xwin_root = RootWindow (backend_glx->xdpy,
|
backend_glx->xwin_root = RootWindow (backend_glx->xdpy,
|
||||||
backend_glx->xscreen);
|
backend_glx->xscreen_num);
|
||||||
|
|
||||||
backend_glx->display_name = g_strdup (clutter_display_name);
|
backend_glx->display_name = g_strdup (clutter_display_name);
|
||||||
|
|
||||||
|
/* generic backend properties */
|
||||||
|
backend->res_width = WidthOfScreen (backend_glx->xscreen);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (clutter_display_name);
|
g_free (clutter_display_name);
|
||||||
@ -115,7 +120,7 @@ clutter_backend_glx_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_glx->display_name,
|
backend_glx->display_name,
|
||||||
backend_glx->xdpy,
|
backend_glx->xdpy,
|
||||||
backend_glx->xscreen,
|
backend_glx->xscreen_num,
|
||||||
(unsigned int) backend_glx->xwin_root);
|
(unsigned int) backend_glx->xwin_root);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -146,7 +151,7 @@ clutter_backend_glx_init_stage (ClutterBackend *backend,
|
|||||||
stage_glx = CLUTTER_STAGE_GLX (stage);
|
stage_glx = CLUTTER_STAGE_GLX (stage);
|
||||||
stage_glx->xdpy = backend_glx->xdpy;
|
stage_glx->xdpy = backend_glx->xdpy;
|
||||||
stage_glx->xwin_root = backend_glx->xwin_root;
|
stage_glx->xwin_root = backend_glx->xwin_root;
|
||||||
stage_glx->xscreen = backend_glx->xscreen;
|
stage_glx->xscreen = backend_glx->xscreen_num;
|
||||||
|
|
||||||
CLUTTER_NOTE (MISC, "GLX stage created (display:%p, screen:%d, root:%u)",
|
CLUTTER_NOTE (MISC, "GLX stage created (display:%p, screen:%d, root:%u)",
|
||||||
stage_glx->xdpy,
|
stage_glx->xdpy,
|
||||||
@ -302,6 +307,10 @@ clutter_backend_glx_init (ClutterBackendGlx *backend_glx)
|
|||||||
backend->button_x[0] = backend->button_x[1] = 0;
|
backend->button_x[0] = backend->button_x[1] = 0;
|
||||||
backend->button_y[0] = backend->button_y[1] = 0;
|
backend->button_y[0] = backend->button_y[1] = 0;
|
||||||
|
|
||||||
|
backend->res_width = backend->res_height = -1;
|
||||||
|
backend->mm_width = backend->mm_height = -1;
|
||||||
|
backend->screen_n = 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;
|
||||||
backend->double_click_distance = 5;
|
backend->double_click_distance = 5;
|
||||||
@ -392,7 +401,7 @@ clutter_glx_get_default_screen (void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return backend_singleton->xscreen;
|
return backend_singleton->xscreen_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -415,5 +424,3 @@ clutter_glx_get_root_window (void)
|
|||||||
|
|
||||||
return backend_singleton->xwin_root;
|
return backend_singleton->xwin_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +48,8 @@ struct _ClutterBackendGlx
|
|||||||
|
|
||||||
Display *xdpy;
|
Display *xdpy;
|
||||||
Window xwin_root;
|
Window xwin_root;
|
||||||
int xscreen;
|
Screen *xscreen;
|
||||||
|
int xscreen_num;
|
||||||
gchar *display_name;
|
gchar *display_name;
|
||||||
|
|
||||||
/* main stage singleton */
|
/* main stage singleton */
|
||||||
|
Loading…
Reference in New Issue
Block a user