OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "gpu/vulkan/tests/native_window.h" |
| 6 |
| 7 #include <X11/Xlib.h> |
| 8 |
| 9 #include "ui/gfx/geometry/rect.h" |
| 10 #include "ui/gfx/x/x11_types.h" |
| 11 |
| 12 namespace gpu { |
| 13 |
| 14 gfx::AcceleratedWidget CreateNativeWindow(const gfx::Rect& bounds) { |
| 15 XDisplay* display = gfx::GetXDisplay(); |
| 16 XSetWindowAttributes swa; |
| 17 swa.event_mask = StructureNotifyMask | ExposureMask; |
| 18 swa.override_redirect = True; |
| 19 XID window = XCreateWindow( |
| 20 display, RootWindow(display, DefaultScreen(display)), // parent |
| 21 bounds.x(), bounds.y(), bounds.width(), bounds.height(), |
| 22 0, // border width |
| 23 CopyFromParent, // depth |
| 24 InputOutput, |
| 25 CopyFromParent, // visual |
| 26 CWEventMask | CWOverrideRedirect, &swa); |
| 27 XMapWindow(display, window); |
| 28 |
| 29 while (1) { |
| 30 XEvent event; |
| 31 XNextEvent(display, &event); |
| 32 if (event.type == MapNotify && event.xmap.window == window) |
| 33 break; |
| 34 } |
| 35 |
| 36 return window; |
| 37 } |
| 38 |
| 39 void DestroyNativeWindow(gfx::AcceleratedWidget window) { |
| 40 XDestroyWindow(gfx::GetXDisplay(), window); |
| 41 } |
| 42 |
| 43 } // namespace gpu |
OLD | NEW |