1/*
2
3Copyright 1993 by Davor Matic
4
5Permission to use, copy, modify, distribute, and sell this software
6and its documentation for any purpose is hereby granted without fee,
7provided that the above copyright notice appear in all copies and that
8both that copyright notice and this permission notice appear in
9supporting documentation.  Davor Matic makes no representations about
10the suitability of this software for any purpose.  It is provided "as
11is" 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
46Bool xnestDoFullGeneration = True;
47
48EventList *xnestEvents = NULL;
49
50void
51InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
52{
53  int i, j;
54
55  xnestOpenDisplay(argc, argv);
56
57  screenInfo->imageByteOrder = ImageByteOrder(xnestDisplay);
58  screenInfo->bitmapScanlineUnit = BitmapUnit(xnestDisplay);
59  screenInfo->bitmapScanlinePad = BitmapPad(xnestDisplay);
60  screenInfo->bitmapBitOrder = BitmapBitOrder(xnestDisplay);
61
62  screenInfo->numPixmapFormats = 0;
63  for (i = 0; i < xnestNumPixmapFormats; i++)
64    for (j = 0; j < xnestNumDepths; j++)
65      if ((xnestPixmapFormats[i].depth == 1) ||
66          (xnestPixmapFormats[i].depth == xnestDepths[j])) {
67	screenInfo->formats[screenInfo->numPixmapFormats].depth =
68	  xnestPixmapFormats[i].depth;
69	screenInfo->formats[screenInfo->numPixmapFormats].bitsPerPixel =
70	  xnestPixmapFormats[i].bits_per_pixel;
71	screenInfo->formats[screenInfo->numPixmapFormats].scanlinePad =
72	  xnestPixmapFormats[i].scanline_pad;
73	screenInfo->numPixmapFormats++;
74	break;
75      }
76
77  xnestFontPrivateIndex = AllocateFontPrivateIndex();
78
79  if (!xnestNumScreens) xnestNumScreens = 1;
80
81  for (i = 0; i < xnestNumScreens; i++)
82    AddScreen(xnestOpenScreen, argc, argv);
83
84  xnestNumScreens = screenInfo->numScreens;
85
86  xnestDoFullGeneration = xnestFullGeneration;
87}
88
89void
90InitInput(int argc, char *argv[])
91{
92  int rc;
93  rc = AllocDevicePair(serverClient, "Xnest",
94                       &xnestPointerDevice,
95                       &xnestKeyboardDevice,
96                       xnestPointerProc,
97                       xnestKeyboardProc,
98                       FALSE);
99
100  if (rc != Success)
101      FatalError("Failed to init Xnest default devices.\n");
102
103  GetEventList(&xnestEvents);
104
105  mieqInit();
106
107  AddEnabledDevice(XConnectionNumber(xnestDisplay));
108
109  RegisterBlockAndWakeupHandlers(xnestBlockHandler, xnestWakeupHandler, NULL);
110}
111
112void
113CloseInput(void)
114{
115}
116
117/*
118 * DDX - specific abort routine.  Called by AbortServer().
119 */
120void AbortDDX(void)
121{
122  xnestDoFullGeneration = True;
123  xnestCloseDisplay();
124}
125
126/* Called by GiveUp(). */
127void ddxGiveUp(void)
128{
129  AbortDDX();
130}
131
132#ifdef __APPLE__
133void
134DarwinHandleGUI(int argc, char *argv[])
135{
136}
137#endif
138
139void OsVendorInit(void)
140{
141    return;
142}
143
144void OsVendorFatalError(void)
145{
146    return;
147}
148
149#if defined(DDXBEFORERESET)
150void ddxBeforeReset(void)
151{
152    return;
153}
154#endif
155