summaryrefslogtreecommitdiff
path: root/hw/kdrive/ephyr/ephyrinit.c
blob: a76da03b4e3be38a423c2a98cd9d3c4c0a96c787 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/*
 * Xephyr - A kdrive X server thats runs in a host X window.
 *          Authored by Matthew Allum <mallum@o-hand.com>
 * 
 * Copyright © 2004 Nokia 
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of Nokia not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission. Nokia makes no
 * representations about the suitability of this software for any purpose.  It
 * is provided "as is" without express or implied warranty.
 *
 * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */

#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "ephyr.h"

extern Window EphyrPreExistingHostWin;
extern Bool   EphyrWantGrayScale;
extern Bool   kdHasPointer;
extern Bool   kdHasKbd;

void
InitCard (char *name)
{
    KdCardAttr	attr;

    EPHYR_DBG("mark");


    KdCardInfoAdd (&ephyrFuncs, &attr, 0);
}

void
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
{
  KdInitOutput (pScreenInfo, argc, argv);
}

void
InitInput (int argc, char **argv)
{
  KdKeyboardInfo *ki;
  KdPointerInfo *pi;
        
  KdAddKeyboardDriver(&EphyrKeyboardDriver);
#ifdef linux
  KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
#endif
  KdAddPointerDriver(&EphyrMouseDriver);
#ifdef linux
  KdAddPointerDriver(&LinuxEvdevMouseDriver);
#endif

  if (!kdHasKbd) {
    ki = KdNewKeyboard();
    if (!ki)
      FatalError("Couldn't create Xephyr keyboard\n");
    ki->driver = &EphyrKeyboardDriver;
    KdAddKeyboard(ki);
  }

  if (!kdHasPointer) {
    pi = KdNewPointer();
    if (!pi)
      FatalError("Couldn't create Xephyr pointer\n");
    pi->driver = &EphyrMouseDriver;
    KdAddPointer(pi);
  }

  KdInitInput();
}

void
ddxUseMsg (void)
{
  KdUseMsg();

  ErrorF("\nXephyr Option Usage:\n");
  ErrorF("-parent XID   Use existing window as Xephyr root win\n");
  ErrorF("-host-cursor  Re-use exisiting X host server cursor\n");
  ErrorF("-fullscreen   Attempt to run Xephyr fullscreen\n");
  ErrorF("-grayscale    Simulate 8bit grayscale\n");
  ErrorF("-fakexa       Simulate acceleration using software rendering\n");
  ErrorF("\n");

  exit(1);
}

int
ddxProcessArgument (int argc, char **argv, int i)
{
  EPHYR_DBG("mark");

  if (!strcmp (argv[i], "-parent"))
    {
      if(i+1 < argc) 
	{
	  hostx_use_preexisting_window(strtol(argv[i+1], NULL, 0));
	  return 2;
	} 
      
      UseMsg();
      exit(1);
    }
  else if (!strcmp (argv[i], "-host-cursor"))
    {
      hostx_use_host_cursor();
      return 1;
    }
  else if (!strcmp (argv[i], "-fullscreen"))
    {
      hostx_use_fullscreen();
      return 1;
    }
  else if (!strcmp (argv[i], "-grayscale"))
    {
      EphyrWantGrayScale = 1;      
      return 1;
    }
  else if (!strcmp (argv[i], "-fakexa"))
    {
      ephyrFuncs.initAccel = ephyrDrawInit;
      ephyrFuncs.enableAccel = ephyrDrawEnable;
      ephyrFuncs.disableAccel = ephyrDrawDisable;
      ephyrFuncs.finiAccel = ephyrDrawFini;
      return 1;
    }
  else if (argv[i][0] == ':')
    {
      hostx_set_display_name(argv[i]);
    }

  return KdProcessArgument (argc, argv, i);
}

void
OsVendorInit (void)
{
  EPHYR_DBG("mark");

  if (hostx_want_host_cursor())
    {
      ephyrFuncs.initCursor   = &ephyrCursorInit;
      ephyrFuncs.enableCursor = &ephyrCursorEnable;
    }

  KdOsInit (&EphyrOsFuncs);
}

/* 'Fake' cursor stuff, could be improved */

static Bool
ephyrRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
{
  return TRUE;
}

static Bool
ephyrUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
{
  return TRUE;
}

static void
ephyrSetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
{
  ;
}

static void
ephyrMoveCursor(ScreenPtr pScreen, int x, int y)
{
  ;
}

miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
	ephyrRealizeCursor,
	ephyrUnrealizeCursor,
	ephyrSetCursor,
	ephyrMoveCursor,
};


Bool
ephyrCursorInit(ScreenPtr pScreen)
{
  miPointerInitialize(pScreen, &EphyrPointerSpriteFuncs,
		      &kdPointerScreenFuncs, FALSE);

  return TRUE;
}

void
ephyrCursorEnable(ScreenPtr pScreen)
{
  ;
}

KdCardFuncs ephyrFuncs = {
    ephyrCardInit,	    /* cardinit */
    ephyrScreenInit,	    /* scrinit */
    ephyrInitScreen,	    /* initScreen */
    ephyrFinishInitScreen,  /* finishInitScreen */
    ephyrCreateResources,   /* createRes */
    ephyrPreserve,	    /* preserve */
    ephyrEnable,	    /* enable */
    ephyrDPMS,		    /* dpms */
    ephyrDisable,	    /* disable */
    ephyrRestore,	    /* restore */
    ephyrScreenFini,	    /* scrfini */
    ephyrCardFini,	    /* cardfini */
    
    0,	                    /* initCursor */
    0,          	    /* enableCursor */
    0,			    /* disableCursor */
    0,			    /* finiCursor */
    0,			    /* recolorCursor */
    
    0,			    /* initAccel */
    0,			    /* enableAccel */
    0,			    /* disableAccel */
    0,			    /* finiAccel */
    
    ephyrGetColors,    	    /* getColors */
    ephyrPutColors,	    /* putColors */
};