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