OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This is a small program that tries to connect to the X server. It | 5 // This is a small program that tries to connect to the X server. It |
6 // continually retries until it connects or 5 seconds pass. If it fails | 6 // continually retries until it connects or 5 seconds pass. If it fails |
7 // to connect to the X server after 5 seconds, it returns an error code | 7 // to connect to the X server after 5 seconds, it returns an error code |
8 // of -1. | 8 // of -1. |
9 // | 9 // |
10 // This is to help verify that the X server is available before we start | 10 // This is to help verify that the X server is available before we start |
11 // start running tests on the build bots. | 11 // start running tests on the build bots. |
12 | 12 |
13 #include <errno.h> | 13 #include <errno.h> |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 #include <time.h> | 15 #include <time.h> |
16 #include <X11/Xlib.h> | 16 #include <X11/Xlib.h> |
17 | 17 |
18 #if defined(TOUCH_UI) || defined(USE_AURA) | 18 #if defined(USE_AURA) |
19 #include <X11/extensions/XInput2.h> | 19 #include <X11/extensions/XInput2.h> |
20 #endif | 20 #endif |
21 | 21 |
22 void Sleep(int duration_ms) { | 22 void Sleep(int duration_ms) { |
23 struct timespec sleep_time, remaining; | 23 struct timespec sleep_time, remaining; |
24 | 24 |
25 // Contains the portion of duration_ms >= 1 sec. | 25 // Contains the portion of duration_ms >= 1 sec. |
26 sleep_time.tv_sec = duration_ms / 1000; | 26 sleep_time.tv_sec = duration_ms / 1000; |
27 duration_ms -= sleep_time.tv_sec * 1000; | 27 duration_ms -= sleep_time.tv_sec * 1000; |
28 | 28 |
(...skipping 12 matching lines...) Expand all Loading... |
41 if (display) | 41 if (display) |
42 break; | 42 break; |
43 Sleep(100); | 43 Sleep(100); |
44 } | 44 } |
45 | 45 |
46 if (!display) { | 46 if (!display) { |
47 fprintf(stderr, "Failed to connect to %s\n", XDisplayName(NULL)); | 47 fprintf(stderr, "Failed to connect to %s\n", XDisplayName(NULL)); |
48 return -1; | 48 return -1; |
49 } | 49 } |
50 | 50 |
51 #if defined(TOUCH_UI) || defined(USE_AURA) | 51 #if defined(USE_AURA) |
52 // Check for XInput2 | 52 // Check for XInput2 |
53 int opcode, event, err; | 53 int opcode, event, err; |
54 if (!XQueryExtension(display, "XInputExtension", &opcode, &event, &err)) { | 54 if (!XQueryExtension(display, "XInputExtension", &opcode, &event, &err)) { |
55 fprintf(stderr, | 55 fprintf(stderr, |
56 "Failed to get XInputExtension on %s.\n", XDisplayName(NULL)); | 56 "Failed to get XInputExtension on %s.\n", XDisplayName(NULL)); |
57 return -1; | 57 return -1; |
58 } | 58 } |
59 | 59 |
60 int major = 2, minor = 0; | 60 int major = 2, minor = 0; |
61 if (XIQueryVersion(display, &major, &minor) == BadRequest) { | 61 if (XIQueryVersion(display, &major, &minor) == BadRequest) { |
62 fprintf(stderr, | 62 fprintf(stderr, |
63 "Server does not have XInput2 on %s.\n", XDisplayName(NULL)); | 63 "Server does not have XInput2 on %s.\n", XDisplayName(NULL)); |
64 return -1; | 64 return -1; |
65 } | 65 } |
66 | 66 |
67 // Ask for the list of devices. This can cause some Xvfb to crash. | 67 // Ask for the list of devices. This can cause some Xvfb to crash. |
68 int count = 0; | 68 int count = 0; |
69 XIDeviceInfo* devices = XIQueryDevice(display, XIAllDevices, &count); | 69 XIDeviceInfo* devices = XIQueryDevice(display, XIAllDevices, &count); |
70 if (devices) | 70 if (devices) |
71 XIFreeDeviceInfo(devices); | 71 XIFreeDeviceInfo(devices); |
72 #endif | 72 #endif |
73 | 73 |
74 return 0; | 74 return 0; |
75 } | 75 } |
OLD | NEW |