Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: client/deps/glbench/src/xlib_window.cc

Issue 1524009: Use gflags in teartest. (Closed)
Patch Set: nit Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/deps/glbench/src/teartest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 #include <gflags/gflags.h>
6
5 #include "base/logging.h" 7 #include "base/logging.h"
6 #include "main.h" 8 #include "main.h"
7 #include "xlib_window.h" 9 #include "xlib_window.h"
8 10
9 11
10 Display *g_xlib_display = NULL; 12 Display *g_xlib_display = NULL;
11 Window g_xlib_window = 0; 13 Window g_xlib_window = 0;
12 14
13 GLint g_width = WINDOW_WIDTH; 15 GLint g_width = WINDOW_WIDTH;
14 GLint g_height = WINDOW_HEIGHT; 16 GLint g_height = WINDOW_HEIGHT;
15 bool g_override_redirect = true; 17 DEFINE_bool(override_redirect, true, "Use an override redirect window");
16 18
17 19
18 bool XlibInit() { 20 bool XlibInit() {
19 g_xlib_display = XOpenDisplay(0); 21 g_xlib_display = XOpenDisplay(0);
20 if (!g_xlib_display) 22 if (!g_xlib_display)
21 return false; 23 return false;
22 24
23 int screen = DefaultScreen(g_xlib_display); 25 int screen = DefaultScreen(g_xlib_display);
24 Window root_window = RootWindow(g_xlib_display, screen); 26 Window root_window = RootWindow(g_xlib_display, screen);
25 27
26 XWindowAttributes attributes; 28 XWindowAttributes attributes;
27 XGetWindowAttributes(g_xlib_display, root_window, &attributes); 29 XGetWindowAttributes(g_xlib_display, root_window, &attributes);
28 30
29 g_width = g_width == -1 ? attributes.width : g_width; 31 g_width = g_width == -1 ? attributes.width : g_width;
30 g_height = g_height == -1 ? attributes.height : g_height; 32 g_height = g_height == -1 ? attributes.height : g_height;
31 XVisualInfo* xlib_visinfo = GetXVisual(); 33 XVisualInfo* xlib_visinfo = GetXVisual();
32 34
33 unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | 35 unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask |
34 CWOverrideRedirect; 36 CWOverrideRedirect;
35 XSetWindowAttributes attr; 37 XSetWindowAttributes attr;
36 attr.background_pixel = 0; 38 attr.background_pixel = 0;
37 attr.border_pixel = 0; 39 attr.border_pixel = 0;
38 attr.colormap = XCreateColormap(g_xlib_display, root_window, 40 attr.colormap = XCreateColormap(g_xlib_display, root_window,
39 xlib_visinfo->visual, AllocNone); 41 xlib_visinfo->visual, AllocNone);
40 attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; 42 attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
41 attr.override_redirect = g_override_redirect ? True : False; 43 attr.override_redirect = FLAGS_override_redirect ? True : False;
42 g_xlib_window = XCreateWindow(g_xlib_display, root_window, 44 g_xlib_window = XCreateWindow(g_xlib_display, root_window,
43 0, 0, g_width, g_height, 0, 45 0, 0, g_width, g_height, 0,
44 xlib_visinfo->depth, InputOutput, 46 xlib_visinfo->depth, InputOutput,
45 xlib_visinfo->visual, mask, &attr); 47 xlib_visinfo->visual, mask, &attr);
46 48
47 XMapWindow(g_xlib_display, g_xlib_window); 49 XMapWindow(g_xlib_display, g_xlib_window);
48 XSync(g_xlib_display, True); 50 XSync(g_xlib_display, True);
49 51
50 XGetWindowAttributes(g_xlib_display, g_xlib_window, &attributes); 52 XGetWindowAttributes(g_xlib_display, g_xlib_window, &attributes);
51 g_width = attributes.width; 53 g_width = attributes.width;
52 g_height = attributes.height; 54 g_height = attributes.height;
53 55
54 XFree(xlib_visinfo); 56 XFree(xlib_visinfo);
55 57
56 return true; 58 return true;
57 } 59 }
OLDNEW
« no previous file with comments | « client/deps/glbench/src/teartest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698