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#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
48Bool xnestDoFullGeneration = True;
49
50#ifdef GLXEXT
51void
52GlxExtensionInit(void)
53{
54}
55#endif
56
57void
58InitOutput(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
97static void
98xnestNotifyConnection(int fd, int ready, void *data)
99{
100    xnestCollectEvents();
101}
102
103void
104InitInput(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
123void
124CloseInput(void)
125{
126    mieqFini();
127}
128
129void
130ddxGiveUp(enum ExitCode error)
131{
132    xnestDoFullGeneration = True;
133    xnestCloseDisplay();
134}
135
136#ifdef __APPLE__
137void
138DarwinHandleGUI(int argc, char *argv[])
139{
140}
141#endif
142
143void
144OsVendorInit(void)
145{
146    return;
147}
148
149void
150OsVendorFatalError(const char *f, va_list args)
151{
152    return;
153}
154
155#if defined(DDXBEFORERESET)
156void
157ddxBeforeReset(void)
158{
159    return;
160}
161#endif
162
163#if INPUTTHREAD
164/** This function is called in Xserver/os/inputthread.c when starting
165    the input thread. */
166void
167ddxInputThreadInit(void)
168{
169}
170#endif
171