1 // Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
5 #include "tests/cefclient/browser/temp_window_x11.h"
9 #include "include/base/cef_logging.h"
10 #include "include/cef_app.h"
17 // Create the temp window.
18 ::Window CreateTempWindow() {
19 ::Display* xdisplay = cef_get_xdisplay();
20 ::Window parent_xwindow = DefaultRootWindow(xdisplay);
22 XSetWindowAttributes swa;
23 memset(&swa, 0, sizeof(swa));
24 swa.background_pixmap = None;
25 swa.override_redirect = false;
27 xdisplay, parent_xwindow,
28 0, 0, 1, 1, // size (1x1px)
30 CopyFromParent, // depth
32 CopyFromParent, // visual
33 CWBackPixmap | CWOverrideRedirect,
37 // Close the temp window.
38 void CloseTempWindow(::Window xwindow) {
39 ::Display* xdisplay = cef_get_xdisplay();
40 XDestroyWindow(xdisplay, xwindow);
43 TempWindowX11* g_temp_window = NULL;
47 TempWindowX11::TempWindowX11()
48 : xwindow_(kNullWindowHandle) {
49 DCHECK(!g_temp_window);
52 xwindow_ = CreateTempWindow();
56 TempWindowX11::~TempWindowX11() {
60 CloseTempWindow(xwindow_);
64 CefWindowHandle TempWindowX11::GetWindowHandle() {
65 DCHECK(g_temp_window);
66 return g_temp_window->xwindow_;