]> git.sesse.net Git - casparcg/blob - dependencies64/cef/linux/tests/cefclient/browser/temp_window_x11.cc
5e8af83d0d9527e37abd83d71235a51ba24669b6
[casparcg] / dependencies64 / cef / linux / tests / cefclient / browser / temp_window_x11.cc
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.
4
5 #include "tests/cefclient/browser/temp_window_x11.h"
6
7 #include <X11/Xlib.h>
8
9 #include "include/base/cef_logging.h"
10 #include "include/cef_app.h"
11
12 namespace client {
13
14 namespace {
15
16
17 // Create the temp window.
18 ::Window CreateTempWindow() {
19   ::Display* xdisplay = cef_get_xdisplay();
20   ::Window parent_xwindow = DefaultRootWindow(xdisplay);
21   
22   XSetWindowAttributes swa;
23   memset(&swa, 0, sizeof(swa));
24   swa.background_pixmap = None;
25   swa.override_redirect = false;
26   return XCreateWindow(
27       xdisplay, parent_xwindow,
28       0, 0, 1, 1,      // size (1x1px)
29       0,               // border width
30       CopyFromParent,  // depth
31       InputOutput,
32       CopyFromParent,  // visual
33       CWBackPixmap | CWOverrideRedirect,
34       &swa);
35 }
36
37 // Close the temp window.
38 void CloseTempWindow(::Window xwindow) {
39   ::Display* xdisplay = cef_get_xdisplay();
40   XDestroyWindow(xdisplay, xwindow);
41 }
42
43 TempWindowX11* g_temp_window = NULL;
44
45 }  // namespace
46
47 TempWindowX11::TempWindowX11()
48     : xwindow_(kNullWindowHandle) {
49   DCHECK(!g_temp_window);
50   g_temp_window = this;
51
52   xwindow_ = CreateTempWindow();
53   CHECK(xwindow_);
54 }
55
56 TempWindowX11::~TempWindowX11() {
57   g_temp_window = NULL;
58   DCHECK(xwindow_);
59   
60   CloseTempWindow(xwindow_);
61 }
62
63 // static
64 CefWindowHandle TempWindowX11::GetWindowHandle() {
65   DCHECK(g_temp_window);
66   return g_temp_window->xwindow_;
67 }
68
69 }  // namespace client