xref: /OK3568_Linux_fs/external/xserver/hw/xnest/Init.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun 
3*4882a593Smuzhiyun Copyright 1993 by Davor Matic
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun Permission to use, copy, modify, distribute, and sell this software
6*4882a593Smuzhiyun and its documentation for any purpose is hereby granted without fee,
7*4882a593Smuzhiyun provided that the above copyright notice appear in all copies and that
8*4882a593Smuzhiyun both that copyright notice and this permission notice appear in
9*4882a593Smuzhiyun supporting documentation.  Davor Matic makes no representations about
10*4882a593Smuzhiyun the suitability of this software for any purpose.  It is provided "as
11*4882a593Smuzhiyun is" without express or implied warranty.
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun */
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #ifdef HAVE_XNEST_CONFIG_H
16*4882a593Smuzhiyun #include <xnest-config.h>
17*4882a593Smuzhiyun #endif
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #include <X11/X.h>
20*4882a593Smuzhiyun #include <X11/Xproto.h>
21*4882a593Smuzhiyun #include "screenint.h"
22*4882a593Smuzhiyun #include "input.h"
23*4882a593Smuzhiyun #include "misc.h"
24*4882a593Smuzhiyun #include "scrnintstr.h"
25*4882a593Smuzhiyun #include "windowstr.h"
26*4882a593Smuzhiyun #include "servermd.h"
27*4882a593Smuzhiyun #include "mi.h"
28*4882a593Smuzhiyun #include <X11/fonts/fontstruct.h>
29*4882a593Smuzhiyun #include "dixfontstr.h"
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun #include "Xnest.h"
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #include "Display.h"
34*4882a593Smuzhiyun #include "Screen.h"
35*4882a593Smuzhiyun #include "Pointer.h"
36*4882a593Smuzhiyun #include "Keyboard.h"
37*4882a593Smuzhiyun #include "Handlers.h"
38*4882a593Smuzhiyun #include "Events.h"
39*4882a593Smuzhiyun #include "Init.h"
40*4882a593Smuzhiyun #include "Args.h"
41*4882a593Smuzhiyun #include "Drawable.h"
42*4882a593Smuzhiyun #include "XNGC.h"
43*4882a593Smuzhiyun #include "XNFont.h"
44*4882a593Smuzhiyun #ifdef DPMSExtension
45*4882a593Smuzhiyun #include "dpmsproc.h"
46*4882a593Smuzhiyun #endif
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun Bool xnestDoFullGeneration = True;
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun #ifdef GLXEXT
51*4882a593Smuzhiyun void
GlxExtensionInit(void)52*4882a593Smuzhiyun GlxExtensionInit(void)
53*4882a593Smuzhiyun {
54*4882a593Smuzhiyun }
55*4882a593Smuzhiyun #endif
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun void
InitOutput(ScreenInfo * screen_info,int argc,char * argv[])58*4882a593Smuzhiyun InitOutput(ScreenInfo * screen_info, int argc, char *argv[])
59*4882a593Smuzhiyun {
60*4882a593Smuzhiyun     int i, j;
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun     xnestOpenDisplay(argc, argv);
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun     screen_info->imageByteOrder = ImageByteOrder(xnestDisplay);
65*4882a593Smuzhiyun     screen_info->bitmapScanlineUnit = BitmapUnit(xnestDisplay);
66*4882a593Smuzhiyun     screen_info->bitmapScanlinePad = BitmapPad(xnestDisplay);
67*4882a593Smuzhiyun     screen_info->bitmapBitOrder = BitmapBitOrder(xnestDisplay);
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun     screen_info->numPixmapFormats = 0;
70*4882a593Smuzhiyun     for (i = 0; i < xnestNumPixmapFormats; i++)
71*4882a593Smuzhiyun         for (j = 0; j < xnestNumDepths; j++)
72*4882a593Smuzhiyun             if ((xnestPixmapFormats[i].depth == 1) ||
73*4882a593Smuzhiyun                 (xnestPixmapFormats[i].depth == xnestDepths[j])) {
74*4882a593Smuzhiyun                 screen_info->formats[screen_info->numPixmapFormats].depth =
75*4882a593Smuzhiyun                     xnestPixmapFormats[i].depth;
76*4882a593Smuzhiyun                 screen_info->formats[screen_info->numPixmapFormats].bitsPerPixel =
77*4882a593Smuzhiyun                     xnestPixmapFormats[i].bits_per_pixel;
78*4882a593Smuzhiyun                 screen_info->formats[screen_info->numPixmapFormats].scanlinePad =
79*4882a593Smuzhiyun                     xnestPixmapFormats[i].scanline_pad;
80*4882a593Smuzhiyun                 screen_info->numPixmapFormats++;
81*4882a593Smuzhiyun                 break;
82*4882a593Smuzhiyun             }
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun     xnestFontPrivateIndex = xfont2_allocate_font_private_index();
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun     if (!xnestNumScreens)
87*4882a593Smuzhiyun         xnestNumScreens = 1;
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun     for (i = 0; i < xnestNumScreens; i++)
90*4882a593Smuzhiyun         AddScreen(xnestOpenScreen, argc, argv);
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun     xnestNumScreens = screen_info->numScreens;
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun     xnestDoFullGeneration = xnestFullGeneration;
95*4882a593Smuzhiyun }
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun static void
xnestNotifyConnection(int fd,int ready,void * data)98*4882a593Smuzhiyun xnestNotifyConnection(int fd, int ready, void *data)
99*4882a593Smuzhiyun {
100*4882a593Smuzhiyun     xnestCollectEvents();
101*4882a593Smuzhiyun }
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun void
InitInput(int argc,char * argv[])104*4882a593Smuzhiyun InitInput(int argc, char *argv[])
105*4882a593Smuzhiyun {
106*4882a593Smuzhiyun     int rc;
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun     rc = AllocDevicePair(serverClient, "Xnest",
109*4882a593Smuzhiyun                          &xnestPointerDevice,
110*4882a593Smuzhiyun                          &xnestKeyboardDevice,
111*4882a593Smuzhiyun                          xnestPointerProc, xnestKeyboardProc, FALSE);
112*4882a593Smuzhiyun 
113*4882a593Smuzhiyun     if (rc != Success)
114*4882a593Smuzhiyun         FatalError("Failed to init Xnest default devices.\n");
115*4882a593Smuzhiyun 
116*4882a593Smuzhiyun     mieqInit();
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun     SetNotifyFd(XConnectionNumber(xnestDisplay), xnestNotifyConnection, X_NOTIFY_READ, NULL);
119*4882a593Smuzhiyun 
120*4882a593Smuzhiyun     RegisterBlockAndWakeupHandlers(xnestBlockHandler, xnestWakeupHandler, NULL);
121*4882a593Smuzhiyun }
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun void
CloseInput(void)124*4882a593Smuzhiyun CloseInput(void)
125*4882a593Smuzhiyun {
126*4882a593Smuzhiyun     mieqFini();
127*4882a593Smuzhiyun }
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun /*
130*4882a593Smuzhiyun  * DDX - specific abort routine.  Called by AbortServer().
131*4882a593Smuzhiyun  */
132*4882a593Smuzhiyun void
AbortDDX(enum ExitCode error)133*4882a593Smuzhiyun AbortDDX(enum ExitCode error)
134*4882a593Smuzhiyun {
135*4882a593Smuzhiyun     xnestDoFullGeneration = True;
136*4882a593Smuzhiyun     xnestCloseDisplay();
137*4882a593Smuzhiyun }
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun /* Called by GiveUp(). */
140*4882a593Smuzhiyun void
ddxGiveUp(enum ExitCode error)141*4882a593Smuzhiyun ddxGiveUp(enum ExitCode error)
142*4882a593Smuzhiyun {
143*4882a593Smuzhiyun     AbortDDX(error);
144*4882a593Smuzhiyun }
145*4882a593Smuzhiyun 
146*4882a593Smuzhiyun #ifdef __APPLE__
147*4882a593Smuzhiyun void
DarwinHandleGUI(int argc,char * argv[])148*4882a593Smuzhiyun DarwinHandleGUI(int argc, char *argv[])
149*4882a593Smuzhiyun {
150*4882a593Smuzhiyun }
151*4882a593Smuzhiyun #endif
152*4882a593Smuzhiyun 
153*4882a593Smuzhiyun void
OsVendorInit(void)154*4882a593Smuzhiyun OsVendorInit(void)
155*4882a593Smuzhiyun {
156*4882a593Smuzhiyun     return;
157*4882a593Smuzhiyun }
158*4882a593Smuzhiyun 
159*4882a593Smuzhiyun void
OsVendorFatalError(const char * f,va_list args)160*4882a593Smuzhiyun OsVendorFatalError(const char *f, va_list args)
161*4882a593Smuzhiyun {
162*4882a593Smuzhiyun     return;
163*4882a593Smuzhiyun }
164*4882a593Smuzhiyun 
165*4882a593Smuzhiyun #if defined(DDXBEFORERESET)
166*4882a593Smuzhiyun void
ddxBeforeReset(void)167*4882a593Smuzhiyun ddxBeforeReset(void)
168*4882a593Smuzhiyun {
169*4882a593Smuzhiyun     return;
170*4882a593Smuzhiyun }
171*4882a593Smuzhiyun #endif
172*4882a593Smuzhiyun 
173*4882a593Smuzhiyun #if INPUTTHREAD
174*4882a593Smuzhiyun /** This function is called in Xserver/os/inputthread.c when starting
175*4882a593Smuzhiyun     the input thread. */
176*4882a593Smuzhiyun void
ddxInputThreadInit(void)177*4882a593Smuzhiyun ddxInputThreadInit(void)
178*4882a593Smuzhiyun {
179*4882a593Smuzhiyun }
180*4882a593Smuzhiyun #endif
181