mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
Convert a bunch of visual related calls to use the screen vtable
This commit is contained in:
parent
f52223f380
commit
ae146a2817
@ -372,6 +372,8 @@ struct _GdkScreenClass
|
||||
void (* get_monitor_geometry) (GdkScreen *screen,
|
||||
gint monitor_num,
|
||||
GdkRectangle *dest);
|
||||
GList * (* list_visuals) (GdkScreen *screen);
|
||||
GdkVisual * (* get_system_visual) (GdkScreen *screen);
|
||||
GdkVisual * (* get_rgba_visual) (GdkScreen *screen);
|
||||
gboolean (* is_composited) (GdkScreen *screen);
|
||||
gchar * (* make_display_name) (GdkScreen *screen);
|
||||
@ -382,6 +384,23 @@ struct _GdkScreenClass
|
||||
gboolean (* get_setting) (GdkScreen *screen,
|
||||
const gchar *name,
|
||||
GValue *value);
|
||||
gint (* visual_get_best_depth) (GdkScreen *screen);
|
||||
GdkVisualType (* visual_get_best_type) (GdkScreen *screen);
|
||||
GdkVisual * (* visual_get_best) (GdkScreen *screen);
|
||||
GdkVisual * (* visual_get_best_with_depth) (GdkScreen *screen,
|
||||
gint depth);
|
||||
GdkVisual * (* visual_get_best_with_type) (GdkScreen *screen,
|
||||
GdkVisualType visual_type);
|
||||
GdkVisual * (* visual_get_best_with_both) (GdkScreen *screen,
|
||||
gint depth,
|
||||
GdkVisualType visual_type);
|
||||
void (* query_depths) (GdkScreen *screen,
|
||||
gint **depths,
|
||||
gint *count);
|
||||
void (* query_visual_types) (GdkScreen *screen,
|
||||
GdkVisualType **visual_types,
|
||||
gint *count);
|
||||
|
||||
|
||||
/* Signals: */
|
||||
void (*size_changed) (GdkScreen *screen);
|
||||
|
@ -767,6 +767,46 @@ gdk_screen_get_monitor_geometry (GdkScreen *screen,
|
||||
GDK_SCREEN_GET_CLASS(screen)->get_monitor_geometry (screen, monitor_num, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_screen_list_visuals:
|
||||
* @screen: the relevant #GdkScreen.
|
||||
*
|
||||
* Lists the available visuals for the specified @screen.
|
||||
* A visual describes a hardware image data format.
|
||||
* For example, a visual might support 24-bit color, or 8-bit color,
|
||||
* and might expect pixels to be in a certain format.
|
||||
*
|
||||
* Call g_list_free() on the return value when you're finished with it.
|
||||
*
|
||||
* Return value: (transfer container) (element-type GdkVisual):
|
||||
* a list of visuals; the list must be freed, but not its contents
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
GList *
|
||||
gdk_screen_list_visuals (GdkScreen *screen)
|
||||
{
|
||||
return GDK_SCREEN_GET_CLASS(screen)->list_visuals (screen);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_screen_get_system_visual:
|
||||
* @screen: a #GdkScreen.
|
||||
*
|
||||
* Get the system's default visual for @screen.
|
||||
* This is the visual for the root window of the display.
|
||||
* The return value should not be freed.
|
||||
*
|
||||
* Return value: (transfer none): the system visual
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
GdkVisual *
|
||||
gdk_screen_get_system_visual (GdkScreen * screen)
|
||||
{
|
||||
return GDK_SCREEN_GET_CLASS(screen)->get_system_visual (screen);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_screen_get_rgba_visual:
|
||||
* @screen: a #GdkScreen
|
||||
|
150
gdk/gdkvisual.c
150
gdk/gdkvisual.c
@ -23,6 +23,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkvisual.h"
|
||||
|
||||
#include "gdkscreen.h"
|
||||
@ -90,6 +91,155 @@ gdk_visual_get_system (void)
|
||||
return gdk_screen_get_system_visual (gdk_screen_get_default());
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best_depth:
|
||||
*
|
||||
* Get the best available depth for the default GDK screen. "Best"
|
||||
* means "largest," i.e. 32 preferred over 24 preferred over 8 bits
|
||||
* per pixel.
|
||||
*
|
||||
* Return value: best available depth
|
||||
**/
|
||||
gint
|
||||
gdk_visual_get_best_depth (void)
|
||||
{
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
|
||||
return GDK_SCREEN_GET_CLASS(screen)->visual_get_best_depth (screen);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best_type:
|
||||
*
|
||||
* Return the best available visual type for the default GDK screen.
|
||||
*
|
||||
* Return value: best visual type
|
||||
**/
|
||||
GdkVisualType
|
||||
gdk_visual_get_best_type (void)
|
||||
{
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
|
||||
return GDK_SCREEN_GET_CLASS(screen)->visual_get_best_type (screen);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best:
|
||||
*
|
||||
* Get the visual with the most available colors for the default
|
||||
* GDK screen. The return value should not be freed.
|
||||
*
|
||||
* Return value: (transfer none): best visual
|
||||
**/
|
||||
GdkVisual*
|
||||
gdk_visual_get_best (void)
|
||||
{
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
|
||||
return GDK_SCREEN_GET_CLASS(screen)->visual_get_best (screen);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best_with_depth:
|
||||
* @depth: a bit depth
|
||||
*
|
||||
* Get the best visual with depth @depth for the default GDK screen.
|
||||
* Color visuals and visuals with mutable colormaps are preferred
|
||||
* over grayscale or fixed-colormap visuals. The return value should not
|
||||
* be freed. %NULL may be returned if no visual supports @depth.
|
||||
*
|
||||
* Return value: (transfer none): best visual for the given depth
|
||||
**/
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_depth (gint depth)
|
||||
{
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
|
||||
return GDK_SCREEN_GET_CLASS(screen)->visual_get_best_with_depth (screen, depth);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best_with_type:
|
||||
* @visual_type: a visual type
|
||||
*
|
||||
* Get the best visual of the given @visual_type for the default GDK screen.
|
||||
* Visuals with higher color depths are considered better. The return value
|
||||
* should not be freed. %NULL may be returned if no visual has type
|
||||
* @visual_type.
|
||||
*
|
||||
* Return value: (transfer none): best visual of the given type
|
||||
**/
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_type (GdkVisualType visual_type)
|
||||
{
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
|
||||
return GDK_SCREEN_GET_CLASS(screen)->visual_get_best_with_type (screen,
|
||||
visual_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best_with_both:
|
||||
* @depth: a bit depth
|
||||
* @visual_type: a visual type
|
||||
*
|
||||
* Combines gdk_visual_get_best_with_depth() and gdk_visual_get_best_with_type().
|
||||
*
|
||||
* Return value: (transfer none): best visual with both @depth and
|
||||
* @visual_type, or %NULL if none
|
||||
**/
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_both (gint depth,
|
||||
GdkVisualType visual_type)
|
||||
{
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
|
||||
return GDK_SCREEN_GET_CLASS(screen)->visual_get_best_with_both (screen, depth, visual_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_query_depths:
|
||||
* @depths: (out) (array): return location for available depths
|
||||
* @count: (out): return location for number of available depths
|
||||
*
|
||||
* This function returns the available bit depths for the default
|
||||
* screen. It's equivalent to listing the visuals
|
||||
* (gdk_list_visuals()) and then looking at the depth field in each
|
||||
* visual, removing duplicates.
|
||||
*
|
||||
* The array returned by this function should not be freed.
|
||||
*
|
||||
**/
|
||||
void
|
||||
gdk_query_depths (gint **depths,
|
||||
gint *count)
|
||||
{
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
|
||||
GDK_SCREEN_GET_CLASS(screen)->query_depths (screen, depths, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_query_visual_types:
|
||||
* @visual_types: return location for the available visual types
|
||||
* @count: return location for the number of available visual types
|
||||
*
|
||||
* This function returns the available visual types for the default
|
||||
* screen. It's equivalent to listing the visuals
|
||||
* (gdk_list_visuals()) and then looking at the type field in each
|
||||
* visual, removing duplicates.
|
||||
*
|
||||
* The array returned by this function should not be freed.
|
||||
**/
|
||||
void
|
||||
gdk_query_visual_types (GdkVisualType **visual_types,
|
||||
gint *count)
|
||||
{
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
|
||||
GDK_SCREEN_GET_CLASS(screen)->query_visual_types (screen, visual_types, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_visual_type:
|
||||
* @visual: A #GdkVisual.
|
||||
|
@ -54,6 +54,27 @@ void _gdk_x11_error_handler_pop (void);
|
||||
|
||||
Colormap _gdk_visual_get_x11_colormap (GdkVisual *visual);
|
||||
|
||||
gint _gdk_screen_x11_visual_get_best_depth (GdkScreen *screen);
|
||||
GdkVisualType _gdk_screen_x11_visual_get_best_type (GdkScreen *screen);
|
||||
GdkVisual * _gdk_screen_x11_get_system_visual (GdkScreen *screen);
|
||||
GdkVisual* _gdk_screen_x11_visual_get_best (GdkScreen *screen);
|
||||
GdkVisual* _gdk_screen_x11_visual_get_best_with_depth (GdkScreen *screen,
|
||||
gint depth);
|
||||
GdkVisual* _gdk_screen_x11_visual_get_best_with_type (GdkScreen *screen,
|
||||
GdkVisualType visual_type);
|
||||
GdkVisual* _gdk_screen_x11_visual_get_best_with_both (GdkScreen *screen,
|
||||
gint depth,
|
||||
GdkVisualType visual_type);
|
||||
void _gdk_screen_x11_query_depths (GdkScreen *screen,
|
||||
gint **depths,
|
||||
gint *count);
|
||||
void _gdk_screen_x11_query_visual_types (GdkScreen *screen,
|
||||
GdkVisualType **visual_types,
|
||||
gint *count);
|
||||
GList * _gdk_screen_x11_list_visuals (GdkScreen *screen);
|
||||
|
||||
|
||||
|
||||
void _gdk_xid_table_insert (GdkDisplay *display,
|
||||
XID *xid,
|
||||
gpointer data);
|
||||
|
@ -1721,6 +1721,7 @@ _gdk_screen_x11_class_init (GdkScreenX11Class *klass)
|
||||
screen_class->get_monitor_height_mm = gdk_screen_x11_get_monitor_height_mm;
|
||||
screen_class->get_monitor_plug_name = gdk_screen_x11_get_monitor_plug_name;
|
||||
screen_class->get_monitor_geometry = gdk_screen_x11_get_monitor_geometry;
|
||||
screen_class->get_system_visual = _gdk_screen_x11_get_system_visual;
|
||||
screen_class->get_rgba_visual = gdk_screen_x11_get_rgba_visual;
|
||||
screen_class->is_composited = gdk_screen_x11_is_composited;
|
||||
screen_class->make_display_name = gdk_screen_x11_make_display_name;
|
||||
@ -1728,6 +1729,15 @@ _gdk_screen_x11_class_init (GdkScreenX11Class *klass)
|
||||
screen_class->get_window_stack = gdk_screen_x11_get_window_stack;
|
||||
screen_class->broadcast_client_message = gdk_screen_x11_broadcast_client_message;
|
||||
screen_class->get_setting = gdk_screen_x11_get_setting;
|
||||
screen_class->visual_get_best_depth = _gdk_screen_x11_visual_get_best_depth;
|
||||
screen_class->visual_get_best_type = _gdk_screen_x11_visual_get_best_type;
|
||||
screen_class->visual_get_best = _gdk_screen_x11_visual_get_best;
|
||||
screen_class->visual_get_best_with_depth = _gdk_screen_x11_visual_get_best_with_depth;
|
||||
screen_class->visual_get_best_with_type = _gdk_screen_x11_visual_get_best_with_type;
|
||||
screen_class->visual_get_best_with_both = _gdk_screen_x11_visual_get_best_with_both;
|
||||
screen_class->query_depths = _gdk_screen_x11_query_depths;
|
||||
screen_class->query_visual_types = _gdk_screen_x11_query_visual_types;
|
||||
screen_class->list_visuals = _gdk_screen_x11_list_visuals;
|
||||
|
||||
signals[WINDOW_MANAGER_CHANGED] =
|
||||
g_signal_new (g_intern_static_string ("window_manager_changed"),
|
||||
|
@ -338,89 +338,39 @@ _gdk_visual_init (GdkScreen *screen)
|
||||
screen_x11->nvisuals = nvisuals;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best_depth:
|
||||
*
|
||||
* Get the best available depth for the default GDK screen. "Best"
|
||||
* means "largest," i.e. 32 preferred over 24 preferred over 8 bits
|
||||
* per pixel.
|
||||
*
|
||||
* Return value: best available depth
|
||||
**/
|
||||
gint
|
||||
gdk_visual_get_best_depth (void)
|
||||
_gdk_screen_x11_visual_get_best_depth (GdkScreen *screen)
|
||||
{
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
|
||||
return GDK_SCREEN_X11 (screen)->available_depths[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best_type:
|
||||
*
|
||||
* Return the best available visual type for the default GDK screen.
|
||||
*
|
||||
* Return value: best visual type
|
||||
**/
|
||||
GdkVisualType
|
||||
gdk_visual_get_best_type (void)
|
||||
_gdk_screen_x11_visual_get_best_type (GdkScreen *screen)
|
||||
{
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
|
||||
return GDK_SCREEN_X11 (screen)->available_types[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_screen_get_system_visual:
|
||||
* @screen: a #GdkScreen.
|
||||
*
|
||||
* Get the system's default visual for @screen.
|
||||
* This is the visual for the root window of the display.
|
||||
* The return value should not be freed.
|
||||
*
|
||||
* Return value: (transfer none): the system visual
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
GdkVisual *
|
||||
gdk_screen_get_system_visual (GdkScreen * screen)
|
||||
_gdk_screen_x11_get_system_visual (GdkScreen * screen)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
||||
|
||||
return ((GdkVisual *) GDK_SCREEN_X11 (screen)->system_visual);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best:
|
||||
*
|
||||
* Get the visual with the most available colors for the default
|
||||
* GDK screen. The return value should not be freed.
|
||||
*
|
||||
* Return value: (transfer none): best visual
|
||||
**/
|
||||
GdkVisual*
|
||||
gdk_visual_get_best (void)
|
||||
_gdk_screen_x11_visual_get_best (GdkScreen *screen)
|
||||
{
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (gdk_screen_get_default());
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
|
||||
|
||||
return (GdkVisual *)screen_x11->visuals[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best_with_depth:
|
||||
* @depth: a bit depth
|
||||
*
|
||||
* Get the best visual with depth @depth for the default GDK screen.
|
||||
* Color visuals and visuals with mutable colormaps are preferred
|
||||
* over grayscale or fixed-colormap visuals. The return value should not
|
||||
* be freed. %NULL may be returned if no visual supports @depth.
|
||||
*
|
||||
* Return value: (transfer none): best visual for the given depth
|
||||
**/
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_depth (gint depth)
|
||||
_gdk_screen_x11_visual_get_best_with_depth (GdkScreen *screen,
|
||||
gint depth)
|
||||
{
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (gdk_screen_get_default ());
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
@ -435,21 +385,11 @@ gdk_visual_get_best_with_depth (gint depth)
|
||||
return return_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best_with_type:
|
||||
* @visual_type: a visual type
|
||||
*
|
||||
* Get the best visual of the given @visual_type for the default GDK screen.
|
||||
* Visuals with higher color depths are considered better. The return value
|
||||
* should not be freed. %NULL may be returned if no visual has type
|
||||
* @visual_type.
|
||||
*
|
||||
* Return value: (transfer none): best visual of the given type
|
||||
**/
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_type (GdkVisualType visual_type)
|
||||
_gdk_screen_x11_visual_get_best_with_type (GdkScreen *screen,
|
||||
GdkVisualType visual_type)
|
||||
{
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (gdk_screen_get_default ());
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
@ -464,21 +404,12 @@ gdk_visual_get_best_with_type (GdkVisualType visual_type)
|
||||
return return_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_visual_get_best_with_both:
|
||||
* @depth: a bit depth
|
||||
* @visual_type: a visual type
|
||||
*
|
||||
* Combines gdk_visual_get_best_with_depth() and gdk_visual_get_best_with_type().
|
||||
*
|
||||
* Return value: (transfer none): best visual with both @depth and
|
||||
* @visual_type, or %NULL if none
|
||||
**/
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_both (gint depth,
|
||||
GdkVisualType visual_type)
|
||||
_gdk_screen_x11_visual_get_best_with_both (GdkScreen *screen,
|
||||
gint depth,
|
||||
GdkVisualType visual_type)
|
||||
{
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (gdk_screen_get_default ());
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
@ -494,69 +425,30 @@ gdk_visual_get_best_with_both (gint depth,
|
||||
return return_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_query_depths:
|
||||
* @depths: (out) (array): return location for available depths
|
||||
* @count: (out): return location for number of available depths
|
||||
*
|
||||
* This function returns the available bit depths for the default
|
||||
* screen. It's equivalent to listing the visuals
|
||||
* (gdk_list_visuals()) and then looking at the depth field in each
|
||||
* visual, removing duplicates.
|
||||
*
|
||||
* The array returned by this function should not be freed.
|
||||
*
|
||||
**/
|
||||
void
|
||||
gdk_query_depths (gint **depths,
|
||||
gint *count)
|
||||
_gdk_screen_x11_query_depths (GdkScreen *screen,
|
||||
gint **depths,
|
||||
gint *count)
|
||||
{
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (gdk_screen_get_default ());
|
||||
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
|
||||
|
||||
*count = screen_x11->navailable_depths;
|
||||
*depths = screen_x11->available_depths;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_query_visual_types:
|
||||
* @visual_types: return location for the available visual types
|
||||
* @count: return location for the number of available visual types
|
||||
*
|
||||
* This function returns the available visual types for the default
|
||||
* screen. It's equivalent to listing the visuals
|
||||
* (gdk_list_visuals()) and then looking at the type field in each
|
||||
* visual, removing duplicates.
|
||||
*
|
||||
* The array returned by this function should not be freed.
|
||||
**/
|
||||
void
|
||||
gdk_query_visual_types (GdkVisualType **visual_types,
|
||||
gint *count)
|
||||
_gdk_screen_x11_query_visual_types (GdkScreen *screen,
|
||||
GdkVisualType **visual_types,
|
||||
gint *count)
|
||||
{
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (gdk_screen_get_default ());
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
|
||||
|
||||
*count = screen_x11->navailable_types;
|
||||
*visual_types = screen_x11->available_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_screen_list_visuals:
|
||||
* @screen: the relevant #GdkScreen.
|
||||
*
|
||||
* Lists the available visuals for the specified @screen.
|
||||
* A visual describes a hardware image data format.
|
||||
* For example, a visual might support 24-bit color, or 8-bit color,
|
||||
* and might expect pixels to be in a certain format.
|
||||
*
|
||||
* Call g_list_free() on the return value when you're finished with it.
|
||||
*
|
||||
* Return value: (transfer container) (element-type GdkVisual):
|
||||
* a list of visuals; the list must be freed, but not its contents
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
GList *
|
||||
gdk_screen_list_visuals (GdkScreen *screen)
|
||||
_gdk_screen_x11_list_visuals (GdkScreen *screen)
|
||||
{
|
||||
GList *list;
|
||||
GdkScreenX11 *screen_x11;
|
||||
|
Loading…
Reference in New Issue
Block a user