From 4d0bc620fc8d612dba8bdba9569a453e88747f77 Mon Sep 17 00:00:00 2001 From: devilhorns Date: Tue, 26 Jul 2011 11:19:55 +0000 Subject: [PATCH] Ecore_X: Add some new api functions for getting default Depth/Visual/Colormap of a given screen. NB: Added these so that we can remove xlib specific calls in ecore_evas and just generic ecore_x calls (so we are engine independant). git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@61742 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore_x/Ecore_X.h | 7 +++ src/lib/ecore_x/xcb/ecore_xcb.c | 118 +++++++++++++++++++++++++++++++++++++++- src/lib/ecore_x/xlib/ecore_x.c | 73 +++++++++++++++++++++++++ 3 files changed, 196 insertions(+), 2 deletions(-) diff --git a/src/lib/ecore_x/Ecore_X.h b/src/lib/ecore_x/Ecore_X.h index 261a078..c6b1634 100644 --- a/src/lib/ecore_x/Ecore_X.h +++ b/src/lib/ecore_x/Ecore_X.h @@ -1089,6 +1089,9 @@ EAPI int ecore_x_fd_get(void); EAPI Ecore_X_Screen * ecore_x_default_screen_get(void); EAPI void ecore_x_screen_size_get(const Ecore_X_Screen *screen, int *w, int *h); EAPI int ecore_x_screen_count_get(void); +EAPI int ecore_x_screen_index_get(const Ecore_X_Screen *screen); +EAPI Ecore_X_Screen * ecore_x_screen_get(int index); + EAPI void ecore_x_double_click_time_set(double t); EAPI double ecore_x_double_click_time_get(void); EAPI void ecore_x_flush(void); @@ -1099,6 +1102,10 @@ EAPI int ecore_x_dpi_get(void); EAPI Eina_Bool ecore_x_bell(int percent); EAPI unsigned int ecore_x_visual_id_get(Ecore_X_Visual visual); +EAPI Ecore_X_Visual ecore_x_default_visual_get(Ecore_X_Display *disp, Ecore_X_Screen *screen); +EAPI Ecore_X_Colormap ecore_x_default_colormap_get(Ecore_X_Display *disp, Ecore_X_Screen *screen); +EAPI int ecore_x_default_depth_get(Ecore_X_Display *disp, Ecore_X_Screen *screen); + EAPI Ecore_X_Time ecore_x_current_time_get(void); EAPI void ecore_x_error_handler_set(void (*func)(void *data), const void *data); diff --git a/src/lib/ecore_x/xcb/ecore_xcb.c b/src/lib/ecore_x/xcb/ecore_xcb.c index ff51905..dcddd26 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb.c +++ b/src/lib/ecore_x/xcb/ecore_xcb.c @@ -1058,9 +1058,9 @@ ecore_x_screen_size_get(const Ecore_X_Screen *screen, int *w, int *h) } /** - * Retrieves the number of screens. + * Retrieves the count of screens. * - * @return The count of the number of screens. + * @return The count of screens. * @ingroup Ecore_X_Display_Attr_Group * * @since 1.1 @@ -1073,6 +1073,54 @@ ecore_x_screen_count_get(void) return xcb_setup_roots_length(xcb_get_setup(_ecore_xcb_conn)); } +/** + * Retrieves the index number of the given screen. + * + * @return The index number of the screen. + * @ingroup Ecore_X_Display_Attr_Group + * + * @since 1.1 + */ +EAPI int +ecore_x_screen_index_get(const Ecore_X_Screen *screen) +{ + xcb_screen_iterator_t iter; + + iter = + xcb_setup_roots_iterator(xcb_get_setup((xcb_connection_t *)_ecore_xcb_conn)); + for (; iter.rem; xcb_screen_next(&iter)) + { + if (iter.data == (xcb_screen_t *)screen) + return iter.index; + } + + return 0; +} + +/** + * Retrieves the screen based on index number. + * + * @return The Ecore_X_Screen at this index. + * @ingroup Ecore_X_Display_Attr_Group + * + * @since 1.1 + */ +EAPI Ecore_X_Screen * +ecore_x_screen_get(int index) +{ + xcb_screen_iterator_t iter; + + iter = + xcb_setup_roots_iterator(xcb_get_setup((xcb_connection_t *)_ecore_xcb_conn)); + for (; iter.rem; xcb_screen_next(&iter)) + { + if (iter.index == index) + return iter.data; + } + + return NULL; +} + EAPI unsigned int ecore_x_visual_id_get(Ecore_X_Visual visual) { @@ -1080,6 +1128,72 @@ ecore_x_visual_id_get(Ecore_X_Visual visual) } /** + * Retrieve the default Visual. + * + * @param disp The Display to get the Default Visual from + * @param screen The Screen. + * + * @return The default visual. + * @since 1.1.0 + */ +EAPI Ecore_X_Visual +ecore_x_default_visual_get(Ecore_X_Display *disp __UNUSED__, Ecore_X_Screen *screen) +{ + xcb_screen_t *s; + xcb_depth_iterator_t diter; + xcb_visualtype_iterator_t viter; + + s = (xcb_screen_t *)screen; + diter = xcb_screen_allowed_depths_iterator(s); + for (; diter.rem; xcb_depth_next(&diter)) + { + viter = xcb_depth_visuals_iterator(diter.data); + for (; viter.rem; xcb_visualtype_next(&viter)) + { + if (viter.data->visual_id == s->root_visual) + return viter.data; + } + } + return 0; +} + +/** + * Retrieve the default Colormap. + * + * @param disp The Display to get the Default Colormap from + * @param screen The Screen. + * + * @return The default colormap. + * @since 1.1.0 + */ +EAPI Ecore_X_Colormap +ecore_x_default_colormap_get(Ecore_X_Display *disp __UNUSED__, Ecore_X_Screen *screen) +{ + xcb_screen_t *s; + + s = (xcb_screen_t *)screen; + return s->default_colormap; +} + +/** + * Retrieve the default depth. + * + * @param disp The Display to get the Default Depth from + * @param screen The Screen. + * + * @return The default depth. + * @since 1.1.0 + */ +EAPI int +ecore_x_default_depth_get(Ecore_X_Display *disp __UNUSED__, Ecore_X_Screen *screen) +{ + xcb_screen_t *s; + + s = (xcb_screen_t *)screen; + return s->root_depth; +} + +/** * Sets the timeout for a double and triple clicks to be flagged. * * This sets the time between clicks before the double_click flag is diff --git a/src/lib/ecore_x/xlib/ecore_x.c b/src/lib/ecore_x/xlib/ecore_x.c index 346bb9f..58a4a09 100644 --- a/src/lib/ecore_x/xlib/ecore_x.c +++ b/src/lib/ecore_x/xlib/ecore_x.c @@ -728,6 +728,34 @@ ecore_x_screen_count_get(void) } /** + * Retrieves the index number of the given screen. + * + * @return The index number of the screen. + * @ingroup Ecore_X_Display_Attr_Group + * + * @since 1.1 + */ +EAPI int +ecore_x_screen_index_get(const Ecore_X_Screen *screen) +{ + return XScreenNumberOfScreen((Screen *)screen); +} + +/** + * Retrieves the screen based on index number. + * + * @return The Ecore_X_Screen at this index. + * @ingroup Ecore_X_Display_Attr_Group + * + * @since 1.1 + */ +EAPI Ecore_X_Screen * +ecore_x_screen_get(int index) +{ + return XScreenOfDisplay(_ecore_x_disp, index); +} + +/** * Sets the timeout for a double and triple clicks to be flagged. * * This sets the time between clicks before the double_click flag is @@ -1876,6 +1904,51 @@ ecore_x_visual_id_get(Ecore_X_Visual visual) return XVisualIDFromVisual(visual); } +/** + * Retrieve the default Visual. + * + * @param disp The Display to get the Default Visual from + * @param screen The Screen. + * + * @return The default visual. + * @since 1.1.0 + */ +EAPI Ecore_X_Visual +ecore_x_default_visual_get(Ecore_X_Display *disp, Ecore_X_Screen *screen) +{ + return DefaultVisual(disp, screen); +} + +/** + * Retrieve the default Colormap. + * + * @param disp The Display to get the Default Colormap from + * @param screen The Screen. + * + * @return The default colormap. + * @since 1.1.0 + */ +EAPI Ecore_X_Colormap +ecore_x_default_colormap_get(Ecore_X_Display *disp, Ecore_X_Screen *screen) +{ + return DefaultColormap(disp, screen); +} + +/** + * Retrieve the default depth. + * + * @param disp The Display to get the Default Depth from + * @param screen The Screen. + * + * @return The default depth. + * @since 1.1.0 + */ +EAPI int +ecore_x_default_depth_get(Ecore_X_Display *disp, Ecore_X_Screen *screen) +{ + return DefaultDepth(disp, screen); +} + /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ -- 2.7.4