1 /* GdkPixbuf library - Initialization functions
2  *
3  * Author: John Harper <john@dcs.warwick.ac.uk>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #include "config.h"
20 #include <X11/Xlib.h>
21 #include "gdk-pixbuf-xlib-private.h"
22 
23 /**
24  * SECTION:gdk-pixbuf-xlib-init
25  * @Short_description: Initializing the gdk-pixbuf Xlib library.
26  * @Title: gdk-pixbuf Xlib initialization
27  * @See_also:    XlibRGB
28  *
29  * In addition to the normal Gdk-specific functions, the &gdk-pixbuf;
30  * package provides a small library that lets Xlib-only applications
31  * use #GdkPixbuf structures and render them to X drawables.  The
32  * functions in this section are used to initialize the &gdk-pixbuf;
33  * Xlib library.  This library must be initialized near the beginning
34  * of the program or before calling any of the other &gdk-pixbuf;
35  * Xlib functions.
36  */
37 
38 Display *gdk_pixbuf_dpy = NULL;
39 int gdk_pixbuf_screen = -1;
40 
41 /**
42  * gdk_pixbuf_xlib_init:
43  * @display: X display to use.
44  * @screen_num: Screen number.
45  *
46  * Initializes the gdk-pixbuf Xlib machinery by calling xlib_rgb_init().  This
47  * function should be called near the beginning of your program, or before using
48  * any of the gdk-pixbuf-xlib functions.
49  **/
50 void
gdk_pixbuf_xlib_init(Display * display,int screen_num)51 gdk_pixbuf_xlib_init (Display *display, int screen_num)
52 {
53     xlib_rgb_init (display, ScreenOfDisplay (display, screen_num));
54     gdk_pixbuf_dpy = display;
55     gdk_pixbuf_screen = screen_num;
56 }
57 
58 /**
59  * gdk_pixbuf_xlib_init_with_depth:
60  * @display: X display to use.
61  * @screen_num: Screen number.
62  * @prefDepth: Preferred depth for XlibRGB.
63  *
64  * Similar to gdk_pixbuf_xlib_init(), but also lets you specify the preferred
65  * depth for XlibRGB if you do not want it to use the default depth it picks.
66  **/
67 void
gdk_pixbuf_xlib_init_with_depth(Display * display,int screen_num,int prefDepth)68 gdk_pixbuf_xlib_init_with_depth (Display *display,
69 				 int screen_num, int prefDepth)
70 {
71     xlib_rgb_init_with_depth (display, ScreenOfDisplay (display, screen_num),
72 			      prefDepth);
73     gdk_pixbuf_dpy = display;
74     gdk_pixbuf_screen = screen_num;
75 }
76