| Index: ui/views/widget/desktop_aura/x11_capture_window.cc
|
| diff --git a/ui/views/widget/desktop_aura/x11_capture_window.cc b/ui/views/widget/desktop_aura/x11_capture_window.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..918ca6dff2f03d90f45263fd71fc7fe9802897c5
|
| --- /dev/null
|
| +++ b/ui/views/widget/desktop_aura/x11_capture_window.cc
|
| @@ -0,0 +1,63 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/views/widget/desktop_aura/x11_capture_window.h"
|
| +
|
| +#include <X11/Xlib.h>
|
| +
|
| +#include "ui/events/platform/x11/x11_event_source.h"
|
| +
|
| +namespace views {
|
| +
|
| +X11CaptureWindow::X11CaptureWindow()
|
| + : captured_(false),
|
| + xwindow_(None) {
|
| + Display* display = gfx::GetXDisplay();
|
| + XSetWindowAttributes swa;
|
| + memset(&swa, 0, sizeof(swa));
|
| + swa.event_mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
|
| + LeaveWindowMask | FocusChangeMask | StructureNotifyMask;
|
| + swa.override_redirect = True;
|
| + xwindow_ = XCreateWindow(display,
|
| + DefaultRootWindow(display),
|
| + -100, -100, 10, 10,
|
| + 0,
|
| + CopyFromParent,
|
| + InputOnly,
|
| + CopyFromParent,
|
| + CWEventMask | CWOverrideRedirect,
|
| + &swa);
|
| + XMapRaised(display, xwindow_);
|
| + ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(xwindow_);
|
| +
|
| + unsigned int event_mask = PointerMotionMask | ButtonReleaseMask |
|
| + ButtonPressMask;
|
| + int status = XGrabPointer(display, xwindow_, True, event_mask, GrabModeAsync,
|
| + GrabModeAsync, None, None, CurrentTime);
|
| + captured_ = (status == GrabSuccess);
|
| +}
|
| +
|
| +X11CaptureWindow::~X11CaptureWindow() {
|
| + if (captured_)
|
| + XUngrabPointer(gfx::GetXDisplay(), CurrentTime);
|
| + XDestroyWindow(gfx::GetXDisplay(), xwindow_);
|
| +}
|
| +
|
| +bool X11CaptureWindow::CanDispatchEventToOwner(const ui::PlatformEvent& event) {
|
| + if (event->xany.window != xwindow_)
|
| + return false;
|
| + switch (event->type) {
|
| + case MotionNotify:
|
| + case ButtonPress:
|
| + case ButtonRelease:
|
| + case FocusOut:
|
| + case LeaveNotify:
|
| + return true;
|
| + default:
|
| + return false;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +} // namespace views
|
|
|