forked from dnschneid/crouton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xiwi
executable file
·421 lines (377 loc) · 12.1 KB
/
xiwi
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
#!/bin/sh -e
# Copyright (c) 2016 The crouton Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
REQUIRES='audio extension'
PROVIDES='x11'
DESCRIPTION='X.org X11 backend running unaccelerated in a Chromium OS window.'
HOSTBIN='startxiwi'
CHROOTBIN='croutoncycle croutonfindnacl croutontriggerd croutonxinitrc-wrapper setres xinit xiwi'
CHROOTETC='xbindkeysrc.scm xiwi.conf xorg-dummy.conf xserverrc xserverrc-xiwi xserverrc-local.example'
. "${TARGETSDIR:="$PWD"}/common"
### Append to prepare.sh:
XMETHOD="${XMETHOD:-xiwi}"
ltspackages=''
# On non-ARM precise, install lts-trusty xorg server for compatibility with xorg
# if kernel version != 3.4 (lts-trusty mesa requires version >=3.6)
if [ "${ARCH#arm}" = "$ARCH" ] && release -eq precise \
&& ! uname -r | grep -q "^3.4."; then
# We still install xorg later to pull in its dependencies
ltspackages='-lts-trusty'
install --minimal "xserver-xorg$ltspackages" "libgl1-mesa-glx$ltspackages"
fi
# Unhold xserver-xorg-video-dummy to make sure deps are pulled in
if [ "${DISTROAKA:-"$DISTRO"}" = 'debian' ]; then
apt-mark unhold xserver-xorg-video-dummy$ltspackages || true 2>/dev/null
fi
install xorg xserver-xorg-video-dummy$ltspackages
install --minimal i3
# Remove some unsupported options on old versions of i3
if release -le precise; then
sed -i '/#.*#.*#.*#/s/ #......$//;/--release/d' /etc/crouton/xiwi.conf
fi
# Compile croutonfbserver
compile fbserver '-lX11 -lXfixes -lXdamage -lXext -lXtst' \
libx11-dev libxfixes-dev libxdamage-dev libxext-dev libxtst-dev
compile findnacld ''
ln -sf /etc/crouton/xorg-dummy.conf /etc/X11/
# Download the latest xf86-video-dummy package
urlbase="https://xorg.freedesktop.org/releases/individual/driver"
DUMMYBUILDTMP="`mktemp -d crouton-cras.XXXXXX --tmpdir=/tmp`"
addtrap "rm -rf --one-file-system '$DUMMYBUILDTMP'"
echo "Download Xorg dummy driver..." 1>&2
superinsecure=''
if release -le wheezy; then
# Wheezy doesn't have the right CA in ca-certificates that validates x.org
superinsecure='--no-check-certificate'
fi
wget $superinsecure -O "$DUMMYBUILDTMP/dummy.tar.gz" \
"$urlbase/xf86-video-dummy-0.3.8.tar.gz"
install --minimal --asdeps patch gcc libc-dev pkg-config \
xserver-xorg-dev$ltspackages x11proto-xf86dga-dev
(
cd "$DUMMYBUILDTMP"
# -m prevents "time stamp is in the future" spam
tar --strip-components=1 -xmf dummy.tar.gz
echo "Patching Xorg dummy driver (xrandr 1.2 support)..." 1>&2
patch -p1 <<EOF
diff --git a/src/dummy_driver.c b/src/dummy_driver.c
index 2656602..0718e1f 100644
--- a/src/dummy_driver.c
+++ b/src/dummy_driver.c
@@ -34,6 +34,8 @@
#include <X11/extensions/Xv.h>
#endif
+#include "xf86Crtc.h"
+
/*
* Driver data structures.
*/
@@ -175,6 +177,115 @@ dummySetup(pointer module, pointer opts, int *errmaj, int *errmin)
#endif /* XFree86LOADER */
static Bool
+size_valid(ScrnInfoPtr pScrn, int width, int height)
+{
+ /* Guard against invalid parameters */
+ if (width == 0 || height == 0 ||
+ width > DUMMY_MAX_WIDTH || height > DUMMY_MAX_HEIGHT)
+ return FALSE;
+
+ /* videoRam is in kb, divide first to avoid 32-bit int overflow */
+ if ((width*height+1023)/1024*pScrn->bitsPerPixel/8 > pScrn->videoRam)
+ return FALSE;
+
+ return TRUE;
+}
+
+static Bool
+dummy_xf86crtc_resize(ScrnInfoPtr pScrn, int width, int height)
+{
+ int old_width, old_height;
+
+ old_width = pScrn->virtualX;
+ old_height = pScrn->virtualY;
+
+ if (size_valid(pScrn, width, height)) {
+ PixmapPtr rootPixmap;
+ ScreenPtr pScreen = pScrn->pScreen;
+
+ pScrn->virtualX = width;
+ pScrn->virtualY = height;
+
+ rootPixmap = pScreen->GetScreenPixmap(pScreen);
+ if (!pScreen->ModifyPixmapHeader(rootPixmap, width, height,
+ -1, -1, -1, NULL)) {
+ pScrn->virtualX = old_width;
+ pScrn->virtualY = old_height;
+ return FALSE;
+ }
+
+ pScrn->displayWidth = rootPixmap->devKind /
+ (rootPixmap->drawable.bitsPerPixel / 8);
+
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+static const xf86CrtcConfigFuncsRec dummy_xf86crtc_config_funcs = {
+ dummy_xf86crtc_resize
+};
+
+static xf86OutputStatus
+dummy_output_detect(xf86OutputPtr output)
+{
+ return XF86OutputStatusConnected;
+}
+
+static int
+dummy_output_mode_valid(xf86OutputPtr output, DisplayModePtr pMode)
+{
+ if (size_valid(output->scrn, pMode->HDisplay, pMode->VDisplay)) {
+ return MODE_OK;
+ } else {
+ return MODE_MEM;
+ }
+}
+
+static DisplayModePtr
+dummy_output_get_modes(xf86OutputPtr output)
+{
+ return NULL;
+}
+
+static void
+dummy_output_dpms(xf86OutputPtr output, int dpms)
+{
+ return;
+}
+
+static const xf86OutputFuncsRec dummy_output_funcs = {
+ .detect = dummy_output_detect,
+ .mode_valid = dummy_output_mode_valid,
+ .get_modes = dummy_output_get_modes,
+ .dpms = dummy_output_dpms,
+};
+
+static Bool
+dummy_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
+ Rotation rotation, int x, int y)
+{
+ crtc->mode = *mode;
+ crtc->x = x;
+ crtc->y = y;
+ crtc->rotation = rotation;
+
+ return TRUE;
+}
+
+static void
+dummy_crtc_dpms(xf86CrtcPtr output, int dpms)
+{
+ return;
+}
+
+static const xf86CrtcFuncsRec dummy_crtc_funcs = {
+ .set_mode_major = dummy_crtc_set_mode_major,
+ .dpms = dummy_crtc_dpms,
+};
+
+static Bool
DUMMYGetRec(ScrnInfoPtr pScrn)
{
/*
@@ -280,6 +391,8 @@ DUMMYPreInit(ScrnInfoPtr pScrn, int flags)
DUMMYPtr dPtr;
int maxClock = 300000;
GDevPtr device = xf86GetEntityInfo(pScrn->entityList[0])->device;
+ xf86OutputPtr output;
+ xf86CrtcPtr crtc;
if (flags & PROBE_DETECT)
return TRUE;
@@ -343,13 +456,6 @@ DUMMYPreInit(ScrnInfoPtr pScrn, int flags)
if (!xf86SetDefaultVisual(pScrn, -1))
return FALSE;
- if (pScrn->depth > 1) {
- Gamma zeros = {0.0, 0.0, 0.0};
-
- if (!xf86SetGamma(pScrn, zeros))
- return FALSE;
- }
-
xf86CollectOptions(pScrn, device->options);
/* Process the options */
if (!(dPtr->Options = malloc(sizeof(DUMMYOptions))))
@@ -379,64 +485,45 @@ DUMMYPreInit(ScrnInfoPtr pScrn, int flags)
maxClock);
}
- pScrn->progClock = TRUE;
- /*
- * Setup the ClockRanges, which describe what clock ranges are available,
- * and what sort of modes they can be used for.
- */
- clockRanges = (ClockRangePtr)xnfcalloc(sizeof(ClockRange), 1);
- clockRanges->next = NULL;
- clockRanges->ClockMulFactor = 1;
- clockRanges->minClock = 11000; /* guessed §§§ */
- clockRanges->maxClock = maxClock;
- clockRanges->clockIndex = -1; /* programmable */
- clockRanges->interlaceAllowed = TRUE;
- clockRanges->doubleScanAllowed = TRUE;
-
- /* Subtract memory for HW cursor */
-
-
- {
- int apertureSize = (pScrn->videoRam * 1024);
- i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
- pScrn->display->modes, clockRanges,
- NULL, 256, DUMMY_MAX_WIDTH,
- (8 * pScrn->bitsPerPixel),
- 128, DUMMY_MAX_HEIGHT, pScrn->display->virtualX,
- pScrn->display->virtualY, apertureSize,
- LOOKUP_BEST_REFRESH);
-
- if (i == -1)
- RETURN;
- }
+ xf86CrtcConfigInit(pScrn, &dummy_xf86crtc_config_funcs);
+
+ xf86CrtcSetSizeRange(pScrn, 256, 256, DUMMY_MAX_WIDTH, DUMMY_MAX_HEIGHT);
+
+ crtc = xf86CrtcCreate(pScrn, &dummy_crtc_funcs);
+
+ output = xf86OutputCreate (pScrn, &dummy_output_funcs, "default");
- /* Prune the modes marked as invalid */
- xf86PruneDriverModes(pScrn);
+ output->possible_crtcs = 0x7f;
- if (i == 0 || pScrn->modes == NULL) {
+ xf86InitialConfiguration(pScrn, TRUE);
+
+ if (pScrn->depth > 1) {
+ Gamma zeros = {0.0, 0.0, 0.0};
+
+ if (!xf86SetGamma(pScrn, zeros))
+ return FALSE;
+ }
+
+ if (pScrn->modes == NULL) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
RETURN;
}
- /*
- * Set the CRTC parameters for all of the modes based on the type
- * of mode, and the chipset's interlace requirements.
- *
- * Calling this is required if the mode->Crtc* values are used by the
- * driver and if the driver doesn't provide code to set them. They
- * are not pre-initialised at all.
- */
- xf86SetCrtcForModes(pScrn, 0);
-
/* Set the current mode to the first in the list */
pScrn->currentMode = pScrn->modes;
- /* Print the list of modes being used */
- xf86PrintModes(pScrn);
+ /* Set default mode in CRTC */
+ crtc->funcs->set_mode_major(crtc, pScrn->currentMode, RR_Rotate_0, 0, 0);
/* If monitor resolution is set on the command line, use it */
xf86SetDpi(pScrn, 0, 0);
+ /* Set monitor size based on DPI */
+ output->mm_width = pScrn->xDpi > 0 ?
+ (pScrn->virtualX * 254 / (10*pScrn->xDpi)) : 0;
+ output->mm_height = pScrn->yDpi > 0 ?
+ (pScrn->virtualY * 254 / (10*pScrn->yDpi)) : 0;
+
if (xf86LoadSubModule(pScrn, "fb") == NULL) {
RETURN;
}
@@ -537,6 +624,8 @@ DUMMYScreenInit(SCREEN_INIT_ARGS_DECL)
if (!miSetPixmapDepths ()) return FALSE;
+ pScrn->displayWidth = pScrn->virtualX;
+
/*
* Call the framebuffer layer's ScreenInit function, and fill in other
* pScreen fields.
@@ -575,23 +664,6 @@ DUMMYScreenInit(SCREEN_INIT_ARGS_DECL)
if (dPtr->swCursor)
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using Software Cursor.\n");
- {
-
-
- BoxRec AvailFBArea;
- int lines = pScrn->videoRam * 1024 /
- (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
- AvailFBArea.x1 = 0;
- AvailFBArea.y1 = 0;
- AvailFBArea.x2 = pScrn->displayWidth;
- AvailFBArea.y2 = lines;
- xf86InitFBManager(pScreen, &AvailFBArea);
-
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Using %i scanlines of offscreen memory \n"
- , lines - pScrn->virtualY);
- }
-
xf86SetBackingStore(pScreen);
xf86SetSilkenMouse(pScreen);
@@ -618,6 +690,9 @@ DUMMYScreenInit(SCREEN_INIT_ARGS_DECL)
| CMAP_RELOAD_ON_MODE_SWITCH))
return FALSE;
+ if (!xf86CrtcScreenInit(pScreen))
+ return FALSE;
+
/* DUMMYInitVideo(pScreen); */
pScreen->SaveScreen = DUMMYSaveScreen;
EOF
# Fake version 0.3.9
package="xf86-video-dummy"
major='0'
minor='3'
patch='9'
version="$major.$minor.$patch"
sed -e '
s/#undef \(HAVE_.*\)$/#define \1 1/
s/#undef \(USE_.*\)$/#define \1 1/
s/#undef \(STDC_HEADERS\)$/#define \1 1/
s/#undef \(.*VERSION\)$/#define \1 "'$version'"/
s/#undef \(.*VERSION_MAJOR\)$/#define \1 '$major'/
s/#undef \(.*VERSION_MINOR\)$/#define \1 '$minor'/
s/#undef \(.*VERSION_PATCHLEVEL\)$/#define \1 '$patch'/
s/#undef \(.*PACKAGE_STRING\)$/#define \1 "'"$package $version"'"/
s/#undef \(.*PACKAGE_*\)$/#define \1 "'$package'"/
' config.h.in > config.h
echo "Compiling Xorg dummy driver..." 1>&2
cd src
# Convert Makefile.am to a shell script, and run it.
{
echo '
DGA=1
CFLAGS="-std=gnu99 -O2 -g -DHAVE_CONFIG_H -I.. -I."
XORG_CFLAGS="'"`pkg-config --cflags xorg-server`"'"
'
convert_automake
echo '
buildlib dummy_drv
'
} | sh -s -e $SETOPTIONS
echo "Installing Xorg dummy driver..." 1>&2
DRIVERDIR="/usr/lib/xorg/modules/drivers"
mkdir -p "$DRIVERDIR/"
/usr/bin/install -s dummy_drv.so "$DRIVERDIR/"
) # End compilation subshell
if [ "${DISTROAKA:-"$DISTRO"}" = 'debian' ]; then
# Hold xserver-xorg-video-dummy to make sure the driver does not get erased
apt-mark hold xserver-xorg-video-dummy$ltspackages
fi
TIPS="$TIPS"'
You can open your running chroot desktops by clicking on the extension icon.
Once in a crouton window, press fullscreen or the "switch window" key to switch
back to Chromium OS.
You can launch individual apps in crouton windows by using the "xiwi" command
in the chroot shell. Use startxiwi to launch directly from the host shell.
Use the startxiwi parameter -b to run in the background.
Example: sudo startxiwi -b xterm
'
### append x11-common