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

Side by Side Diff: ui/platform_window/x11/x11_window_ozone.cc

Issue 1602173005: Add PlatformWindow/Event related code for Ozone X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for comments. Created 4 years, 10 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
OLDNEW
(Empty)
1 // Copyright 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 "ui/platform_window/x11/x11_window_ozone.h"
6
7 #include "ui/events/event.h"
8 #include "ui/events/ozone/events_ozone.h"
9 #include "ui/events/platform/x11/x11_event_source.h"
10 #include "ui/events/x/events_x_utils.h"
11 #include "ui/gfx/geometry/point.h"
12
13 namespace ui {
14
15 X11WindowOzone::X11WindowOzone(PlatformWindowDelegate* delegate)
16 : X11WindowBase(delegate) {}
17
18 X11WindowOzone::~X11WindowOzone() {
19 Destroy();
20 }
21
22 void X11WindowOzone::Create() {
23 X11EventSourceLibevent* event_source = X11EventSourceLibevent::GetInstance();
24 DCHECK(event_source);
25 event_source->AddPlatformEventDispatcher(this);
26 event_source->AddXEventDispatcher(this);
sadrul 2016/02/08 17:28:33 Is there a reason to not do this in the ctor?
kylechar 2016/02/08 19:08:10 Done.
27
28 X11WindowBase::Create();
29 }
30
31 void X11WindowOzone::Destroy() {
32 X11EventSourceLibevent* event_source = X11EventSourceLibevent::GetInstance();
33 event_source->RemovePlatformEventDispatcher(this);
34 event_source->RemoveXEventDispatcher(this);
35 }
36
37 void X11WindowOzone::Close() {
38 Destroy();
39 X11WindowBase::Destroy();
40 }
41
42 void X11WindowOzone::SetCursor(PlatformCursor cursor) {}
43
44 bool X11WindowOzone::DispatchXEvent(XEvent* xev) {
45 if (XWindowFromXEvent(*xev) != xwindow())
46 return false;
47
48 ProcessXWindowEvent(xev);
49 return true;
50 }
51
52 bool X11WindowOzone::CanDispatchEvent(const PlatformEvent& event) {
53 // TODO(kylechar): This is broken, there is no way to include XID of XWindow
54 // in ui::Event. Fix or use similar hack to DrmWindowHost.
55 return true;
56 }
57
58 uint32_t X11WindowOzone::DispatchEvent(const PlatformEvent& platform_event) {
59 Event* event = static_cast<Event*>(platform_event);
60 delegate()->DispatchEvent(event);
61 return POST_DISPATCH_STOP_PROPAGATION;
62 }
63
64 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698