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 #include "dixfontstr.h"
30
31 #include "Xnest.h"
32
33 #include "Display.h"
34 #include "Screen.h"
35 #include "Pointer.h"
36 #include "Keyboard.h"
37 #include "Handlers.h"
38 #include "Events.h"
39 #include "Init.h"
40 #include "Args.h"
41 #include "Drawable.h"
42 #include "XNGC.h"
43 #include "XNFont.h"
44 #ifdef DPMSExtension
45 #include "dpmsproc.h"
46 #endif
47
48 Bool xnestDoFullGeneration = True;
49
50 #ifdef GLXEXT
51 void
GlxExtensionInit(void)52 GlxExtensionInit(void)
53 {
54 }
55 #endif
56
57 void
InitOutput(ScreenInfo * screen_info,int argc,char * argv[])58 InitOutput(ScreenInfo * screen_info, int argc, char *argv[])
59 {
60 int i, j;
61
62 xnestOpenDisplay(argc, argv);
63
64 screen_info->imageByteOrder = ImageByteOrder(xnestDisplay);
65 screen_info->bitmapScanlineUnit = BitmapUnit(xnestDisplay);
66 screen_info->bitmapScanlinePad = BitmapPad(xnestDisplay);
67 screen_info->bitmapBitOrder = BitmapBitOrder(xnestDisplay);
68
69 screen_info->numPixmapFormats = 0;
70 for (i = 0; i < xnestNumPixmapFormats; i++)
71 for (j = 0; j < xnestNumDepths; j++)
72 if ((xnestPixmapFormats[i].depth == 1) ||
73 (xnestPixmapFormats[i].depth == xnestDepths[j])) {
74 screen_info->formats[screen_info->numPixmapFormats].depth =
75 xnestPixmapFormats[i].depth;
76 screen_info->formats[screen_info->numPixmapFormats].bitsPerPixel =
77 xnestPixmapFormats[i].bits_per_pixel;
78 screen_info->formats[screen_info->numPixmapFormats].scanlinePad =
79 xnestPixmapFormats[i].scanline_pad;
80 screen_info->numPixmapFormats++;
81 break;
82 }
83
84 xnestFontPrivateIndex = xfont2_allocate_font_private_index();
85
86 if (!xnestNumScreens)
87 xnestNumScreens = 1;
88
89 for (i = 0; i < xnestNumScreens; i++)
90 AddScreen(xnestOpenScreen, argc, argv);
91
92 xnestNumScreens = screen_info->numScreens;
93
94 xnestDoFullGeneration = xnestFullGeneration;
95 }
96
97 static void
xnestNotifyConnection(int fd,int ready,void * data)98 xnestNotifyConnection(int fd, int ready, void *data)
99 {
100 xnestCollectEvents();
101 }
102
103 void
InitInput(int argc,char * argv[])104 InitInput(int argc, char *argv[])
105 {
106 int rc;
107
108 rc = AllocDevicePair(serverClient, "Xnest",
109 &xnestPointerDevice,
110 &xnestKeyboardDevice,
111 xnestPointerProc, xnestKeyboardProc, FALSE);
112
113 if (rc != Success)
114 FatalError("Failed to init Xnest default devices.\n");
115
116 mieqInit();
117
118 SetNotifyFd(XConnectionNumber(xnestDisplay), xnestNotifyConnection, X_NOTIFY_READ, NULL);
119
120 RegisterBlockAndWakeupHandlers(xnestBlockHandler, xnestWakeupHandler, NULL);
121 }
122
123 void
CloseInput(void)124 CloseInput(void)
125 {
126 mieqFini();
127 }
128
129 /*
130 * DDX - specific abort routine. Called by AbortServer().
131 */
132 void
AbortDDX(enum ExitCode error)133 AbortDDX(enum ExitCode error)
134 {
135 xnestDoFullGeneration = True;
136 xnestCloseDisplay();
137 }
138
139 /* Called by GiveUp(). */
140 void
ddxGiveUp(enum ExitCode error)141 ddxGiveUp(enum ExitCode error)
142 {
143 AbortDDX(error);
144 }
145
146 #ifdef __APPLE__
147 void
DarwinHandleGUI(int argc,char * argv[])148 DarwinHandleGUI(int argc, char *argv[])
149 {
150 }
151 #endif
152
153 void
OsVendorInit(void)154 OsVendorInit(void)
155 {
156 return;
157 }
158
159 void
OsVendorFatalError(const char * f,va_list args)160 OsVendorFatalError(const char *f, va_list args)
161 {
162 return;
163 }
164
165 #if defined(DDXBEFORERESET)
166 void
ddxBeforeReset(void)167 ddxBeforeReset(void)
168 {
169 return;
170 }
171 #endif
172
173 #if INPUTTHREAD
174 /** This function is called in Xserver/os/inputthread.c when starting
175 the input thread. */
176 void
ddxInputThreadInit(void)177 ddxInputThreadInit(void)
178 {
179 }
180 #endif
181