Record MTU discovery packets in net-internals log.
[chromium-blink-merge.git] / ui / aura / window_tree_host_x11.cc
blob8059d90bff23d096a4275bfca2ff9036880f7f4e
1 // Copyright (c) 2012 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.
5 #include "ui/aura/window_tree_host_x11.h"
7 #include <strings.h>
8 #include <X11/cursorfont.h>
9 #include <X11/extensions/XInput2.h>
10 #include <X11/extensions/Xrandr.h>
11 #include <X11/Xatom.h>
12 #include <X11/Xcursor/Xcursor.h>
13 #include <X11/Xlib.h>
15 #include <algorithm>
16 #include <limits>
17 #include <string>
19 #include "base/basictypes.h"
20 #include "base/command_line.h"
21 #include "base/stl_util.h"
22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/string_split.h"
24 #include "base/strings/string_util.h"
25 #include "base/strings/stringprintf.h"
26 #include "base/sys_info.h"
27 #include "base/trace_event/trace_event.h"
28 #include "ui/aura/client/cursor_client.h"
29 #include "ui/aura/env.h"
30 #include "ui/aura/window.h"
31 #include "ui/aura/window_event_dispatcher.h"
32 #include "ui/base/cursor/cursor.h"
33 #include "ui/base/ui_base_switches.h"
34 #include "ui/base/view_prop.h"
35 #include "ui/base/x/x11_util.h"
36 #include "ui/compositor/compositor.h"
37 #include "ui/compositor/dip_util.h"
38 #include "ui/compositor/layer.h"
39 #include "ui/events/devices/x11/device_data_manager_x11.h"
40 #include "ui/events/devices/x11/device_list_cache_x11.h"
41 #include "ui/events/devices/x11/touch_factory_x11.h"
42 #include "ui/events/event.h"
43 #include "ui/events/event_switches.h"
44 #include "ui/events/event_utils.h"
45 #include "ui/events/keycodes/keyboard_codes.h"
46 #include "ui/events/platform/platform_event_observer.h"
47 #include "ui/events/platform/x11/x11_event_source.h"
48 #include "ui/gfx/screen.h"
50 using std::max;
51 using std::min;
53 namespace aura {
55 namespace {
57 const char* kAtomsToCache[] = {
58 "WM_DELETE_WINDOW",
59 "_NET_WM_PING",
60 "_NET_WM_PID",
61 NULL
64 ::Window FindEventTarget(const base::NativeEvent& xev) {
65 ::Window target = xev->xany.window;
66 if (xev->type == GenericEvent)
67 target = static_cast<XIDeviceEvent*>(xev->xcookie.data)->event;
68 return target;
71 void SelectXInput2EventsForRootWindow(XDisplay* display, ::Window root_window) {
72 CHECK(ui::IsXInput2Available());
73 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {};
74 memset(mask, 0, sizeof(mask));
76 XISetMask(mask, XI_HierarchyChanged);
78 XIEventMask evmask;
79 evmask.deviceid = XIAllDevices;
80 evmask.mask_len = sizeof(mask);
81 evmask.mask = mask;
82 XISelectEvents(display, root_window, &evmask, 1);
84 #if defined(OS_CHROMEOS)
85 if (base::SysInfo::IsRunningOnChromeOS()) {
86 // It is necessary to listen for touch events on the root window for proper
87 // touch event calibration on Chrome OS, but this is not currently necessary
88 // on the desktop. This seems to fail in some cases (e.g. when logging
89 // in incognito). So select for non-touch events first, and then select for
90 // touch-events (but keep the other events in the mask, i.e. do not memset
91 // |mask| back to 0).
92 // TODO(sad): Figure out why this happens. http://crbug.com/153976
93 XISetMask(mask, XI_TouchBegin);
94 XISetMask(mask, XI_TouchUpdate);
95 XISetMask(mask, XI_TouchEnd);
96 XISelectEvents(display, root_window, &evmask, 1);
98 #endif
101 bool default_override_redirect = false;
103 } // namespace
105 namespace internal {
107 // TODO(miletus) : Move this into DeviceDataManager.
108 // Accomplishes 2 tasks concerning touch event calibration:
109 // 1. Being a message-pump observer,
110 // routes all the touch events to the X root window,
111 // where they can be calibrated later.
112 // 2. Has the Calibrate method that does the actual bezel calibration,
113 // when invoked from X root window's event dispatcher.
114 class TouchEventCalibrate : public ui::PlatformEventObserver {
115 public:
116 TouchEventCalibrate() : left_(0), right_(0), top_(0), bottom_(0) {
117 if (ui::PlatformEventSource::GetInstance())
118 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
119 std::vector<std::string> parts = base::SplitString(
120 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
121 switches::kTouchCalibration),
122 ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
123 if (parts.size() >= 4) {
124 if (!base::StringToInt(parts[0], &left_))
125 DLOG(ERROR) << "Incorrect left border calibration value passed.";
126 if (!base::StringToInt(parts[1], &right_))
127 DLOG(ERROR) << "Incorrect right border calibration value passed.";
128 if (!base::StringToInt(parts[2], &top_))
129 DLOG(ERROR) << "Incorrect top border calibration value passed.";
130 if (!base::StringToInt(parts[3], &bottom_))
131 DLOG(ERROR) << "Incorrect bottom border calibration value passed.";
135 ~TouchEventCalibrate() override {
136 if (ui::PlatformEventSource::GetInstance())
137 ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this);
140 // Modify the location of the |event|,
141 // expanding it from |bounds| to (|bounds| + bezels).
142 // Required when touchscreen is bigger than screen (i.e. has bezels),
143 // because we receive events in touchscreen coordinates,
144 // which need to be expanded when converting to screen coordinates,
145 // so that location on bezels will be outside of screen area.
146 void Calibrate(ui::TouchEvent* event, const gfx::Rect& bounds) {
147 int x = event->x();
148 int y = event->y();
150 if (!left_ && !right_ && !top_ && !bottom_)
151 return;
153 const int resolution_x = bounds.width();
154 const int resolution_y = bounds.height();
155 if (left_ || right_) {
156 // Offset the x position to the real
157 x -= left_;
158 // Scale the screen area back to the full resolution of the screen.
159 x = (x * resolution_x) / (resolution_x - (right_ + left_));
161 if (top_ || bottom_) {
162 // When there is a top bezel we add our border,
163 y -= top_;
164 // Scale the screen area back to the full resolution of the screen.
165 y = (y * resolution_y) / (resolution_y - (bottom_ + top_));
168 // Set the modified coordinate back to the event.
169 if (event->root_location() == event->location()) {
170 // Usually those will be equal,
171 // if not, I am not sure what the correct value should be.
172 event->set_root_location(gfx::Point(x, y));
174 event->set_location(gfx::Point(x, y));
177 private:
178 // ui::PlatformEventObserver:
179 void WillProcessEvent(const ui::PlatformEvent& event) override {
180 if (event->type == GenericEvent &&
181 (event->xgeneric.evtype == XI_TouchBegin ||
182 event->xgeneric.evtype == XI_TouchUpdate ||
183 event->xgeneric.evtype == XI_TouchEnd)) {
184 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event->xcookie.data);
185 xievent->event = xievent->root;
186 xievent->event_x = xievent->root_x;
187 xievent->event_y = xievent->root_y;
191 void DidProcessEvent(const ui::PlatformEvent& event) override {}
193 // The difference in screen's native resolution pixels between
194 // the border of the touchscreen and the border of the screen,
195 // aka bezel sizes.
196 int left_;
197 int right_;
198 int top_;
199 int bottom_;
201 DISALLOW_COPY_AND_ASSIGN(TouchEventCalibrate);
204 } // namespace internal
206 ////////////////////////////////////////////////////////////////////////////////
207 // WindowTreeHostX11
209 WindowTreeHostX11::WindowTreeHostX11(const gfx::Rect& bounds)
210 : xdisplay_(gfx::GetXDisplay()),
211 xwindow_(0),
212 x_root_window_(DefaultRootWindow(xdisplay_)),
213 current_cursor_(ui::kCursorNull),
214 window_mapped_(false),
215 bounds_(bounds),
216 touch_calibrate_(new internal::TouchEventCalibrate),
217 atom_cache_(xdisplay_, kAtomsToCache) {
218 XSetWindowAttributes swa;
219 memset(&swa, 0, sizeof(swa));
220 swa.background_pixmap = None;
221 swa.override_redirect = default_override_redirect;
222 xwindow_ = XCreateWindow(
223 xdisplay_, x_root_window_,
224 bounds.x(), bounds.y(), bounds.width(), bounds.height(),
225 0, // border width
226 CopyFromParent, // depth
227 InputOutput,
228 CopyFromParent, // visual
229 CWBackPixmap | CWOverrideRedirect,
230 &swa);
231 if (ui::PlatformEventSource::GetInstance())
232 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
234 long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
235 KeyPressMask | KeyReleaseMask |
236 EnterWindowMask | LeaveWindowMask |
237 ExposureMask | VisibilityChangeMask |
238 StructureNotifyMask | PropertyChangeMask |
239 PointerMotionMask;
240 XSelectInput(xdisplay_, xwindow_, event_mask);
241 XFlush(xdisplay_);
243 if (ui::IsXInput2Available()) {
244 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_);
245 SelectXInput2EventsForRootWindow(xdisplay_, x_root_window_);
248 // TODO(erg): We currently only request window deletion events. We also
249 // should listen for activation events and anything else that GTK+ listens
250 // for, and do something useful.
251 ::Atom protocols[2];
252 protocols[0] = atom_cache_.GetAtom("WM_DELETE_WINDOW");
253 protocols[1] = atom_cache_.GetAtom("_NET_WM_PING");
254 XSetWMProtocols(xdisplay_, xwindow_, protocols, 2);
256 // We need a WM_CLIENT_MACHINE and WM_LOCALE_NAME value so we integrate with
257 // the desktop environment.
258 XSetWMProperties(xdisplay_, xwindow_, NULL, NULL, NULL, 0, NULL, NULL, NULL);
260 // Likewise, the X server needs to know this window's pid so it knows which
261 // program to kill if the window hangs.
262 // XChangeProperty() expects "pid" to be long.
263 static_assert(sizeof(long) >= sizeof(pid_t),
264 "pid_t should not be larger than long");
265 long pid = getpid();
266 XChangeProperty(xdisplay_,
267 xwindow_,
268 atom_cache_.GetAtom("_NET_WM_PID"),
269 XA_CARDINAL,
271 PropModeReplace,
272 reinterpret_cast<unsigned char*>(&pid), 1);
274 // Allow subclasses to create and cache additional atoms.
275 atom_cache_.allow_uncached_atoms();
277 XRRSelectInput(xdisplay_, x_root_window_,
278 RRScreenChangeNotifyMask | RROutputChangeNotifyMask);
279 CreateCompositor(GetAcceleratedWidget());
282 WindowTreeHostX11::~WindowTreeHostX11() {
283 if (ui::PlatformEventSource::GetInstance())
284 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
286 DestroyCompositor();
287 DestroyDispatcher();
288 XDestroyWindow(xdisplay_, xwindow_);
291 bool WindowTreeHostX11::CanDispatchEvent(const ui::PlatformEvent& event) {
292 ::Window target = FindEventTarget(event);
293 return target == xwindow_ || target == x_root_window_;
296 uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) {
297 XEvent* xev = event;
298 if (FindEventTarget(xev) == x_root_window_) {
299 if (xev->type == GenericEvent)
300 DispatchXI2Event(xev);
301 return ui::POST_DISPATCH_NONE;
304 if (xev->type == MotionNotify) {
305 // Discard all but the most recent motion event that targets the same
306 // window with unchanged state.
307 XEvent last_event;
308 while (XPending(xev->xany.display)) {
309 XEvent next_event;
310 XPeekEvent(xev->xany.display, &next_event);
311 if (next_event.type == MotionNotify &&
312 next_event.xmotion.window == xev->xmotion.window &&
313 next_event.xmotion.subwindow == xev->xmotion.subwindow &&
314 next_event.xmotion.state == xev->xmotion.state) {
315 XNextEvent(xev->xany.display, &last_event);
316 xev = &last_event;
317 } else {
318 break;
323 if ((xev->type == EnterNotify || xev->type == LeaveNotify) &&
324 xev->xcrossing.detail == NotifyInferior) {
325 // Ignore EventNotify and LeaveNotify events from children of |xwindow_|.
326 // NativeViewGLSurfaceGLX adds a child to |xwindow_|.
327 // TODO(pkotwicz|tdanderson): Figure out whether the suppression is
328 // necessary. crbug.com/385716
329 return ui::POST_DISPATCH_STOP_PROPAGATION;
332 if (xev->type == EnterNotify ||
333 xev->type == LeaveNotify ||
334 xev->type == KeyPress ||
335 xev->type == KeyRelease ||
336 xev->type == ButtonPress ||
337 xev->type == ButtonRelease ||
338 xev->type == MotionNotify) {
339 switch (ui::EventTypeFromNative(xev)) {
340 case ui::ET_KEY_PRESSED:
341 case ui::ET_KEY_RELEASED: {
342 ui::KeyEvent keydown_event(xev);
343 SendEventToProcessor(&keydown_event);
344 break;
346 case ui::ET_MOUSE_MOVED:
347 case ui::ET_MOUSE_DRAGGED:
348 case ui::ET_MOUSE_ENTERED:
349 case ui::ET_MOUSE_EXITED:
350 case ui::ET_MOUSE_PRESSED:
351 case ui::ET_MOUSE_RELEASED: {
352 ui::MouseEvent mouse_event(xev);
353 if (xev->type == EnterNotify) {
354 aura::Window* root_window = window();
355 client::CursorClient* cursor_client =
356 client::GetCursorClient(root_window);
357 if (cursor_client) {
358 const gfx::Display display = gfx::Screen::GetScreenFor(
359 root_window)->GetDisplayNearestWindow(root_window);
360 cursor_client->SetDisplay(display);
362 // EnterNotify creates ET_MOUSE_MOVE. Mark as synthesized as this is
363 // not a real mouse move event.
364 mouse_event.set_flags(mouse_event.flags() | ui::EF_IS_SYNTHESIZED);
367 TranslateAndDispatchLocatedEvent(&mouse_event);
368 break;
370 case ui::ET_MOUSEWHEEL: {
371 ui::MouseWheelEvent mouseev(xev);
372 TranslateAndDispatchLocatedEvent(&mouseev);
373 break;
375 case ui::ET_UNKNOWN:
376 // No event is created for X11-release events for mouse-wheel buttons.
377 break;
378 default:
379 NOTREACHED();
381 return ui::POST_DISPATCH_STOP_PROPAGATION;
384 switch (xev->type) {
385 case Expose: {
386 gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y,
387 xev->xexpose.width, xev->xexpose.height);
388 compositor()->ScheduleRedrawRect(damage_rect);
389 break;
391 case FocusOut:
392 if (xev->xfocus.mode != NotifyGrab)
393 OnHostLostWindowCapture();
394 break;
395 case ConfigureNotify: {
396 DCHECK_EQ(xwindow_, xev->xconfigure.event);
397 DCHECK_EQ(xwindow_, xev->xconfigure.window);
398 // It's possible that the X window may be resized by some other means
399 // than from within aura (e.g. the X window manager can change the
400 // size). Make sure the root window size is maintained properly.
401 gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y,
402 xev->xconfigure.width, xev->xconfigure.height);
403 bool size_changed = bounds_.size() != bounds.size();
404 bool origin_changed = bounds_.origin() != bounds.origin();
405 bounds_ = bounds;
406 OnConfigureNotify();
407 if (size_changed)
408 OnHostResized(bounds.size());
409 if (origin_changed)
410 OnHostMoved(bounds_.origin());
411 break;
413 case GenericEvent:
414 DispatchXI2Event(xev);
415 break;
416 case ClientMessage: {
417 Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]);
418 if (message_type == atom_cache_.GetAtom("WM_DELETE_WINDOW")) {
419 // We have received a close message from the window manager.
420 OnHostCloseRequested();
421 } else if (message_type == atom_cache_.GetAtom("_NET_WM_PING")) {
422 XEvent reply_event = *xev;
423 reply_event.xclient.window = x_root_window_;
425 XSendEvent(xdisplay_,
426 reply_event.xclient.window,
427 False,
428 SubstructureRedirectMask | SubstructureNotifyMask,
429 &reply_event);
430 XFlush(xdisplay_);
432 break;
434 case MappingNotify: {
435 switch (xev->xmapping.request) {
436 case MappingModifier:
437 case MappingKeyboard:
438 XRefreshKeyboardMapping(&xev->xmapping);
439 break;
440 case MappingPointer:
441 ui::DeviceDataManagerX11::GetInstance()->UpdateButtonMap();
442 break;
443 default:
444 NOTIMPLEMENTED() << " Unknown request: " << xev->xmapping.request;
445 break;
447 break;
450 return ui::POST_DISPATCH_STOP_PROPAGATION;
453 ui::EventSource* WindowTreeHostX11::GetEventSource() {
454 return this;
457 gfx::AcceleratedWidget WindowTreeHostX11::GetAcceleratedWidget() {
458 return xwindow_;
461 void WindowTreeHostX11::ShowImpl() {
462 if (!window_mapped_) {
463 // Before we map the window, set size hints. Otherwise, some window managers
464 // will ignore toplevel XMoveWindow commands.
465 XSizeHints size_hints;
466 size_hints.flags = PPosition | PWinGravity;
467 size_hints.x = bounds_.x();
468 size_hints.y = bounds_.y();
469 // Set StaticGravity so that the window position is not affected by the
470 // frame width when running with window manager.
471 size_hints.win_gravity = StaticGravity;
472 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints);
474 XMapWindow(xdisplay_, xwindow_);
476 // We now block until our window is mapped. Some X11 APIs will crash and
477 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is
478 // asynchronous.
479 if (ui::X11EventSource::GetInstance())
480 ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(xwindow_);
481 window_mapped_ = true;
485 void WindowTreeHostX11::HideImpl() {
486 if (window_mapped_) {
487 XWithdrawWindow(xdisplay_, xwindow_, 0);
488 window_mapped_ = false;
492 gfx::Rect WindowTreeHostX11::GetBounds() const {
493 return bounds_;
496 void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
497 // Even if the host window's size doesn't change, aura's root window
498 // size, which is in DIP, changes when the scale changes.
499 float current_scale = compositor()->device_scale_factor();
500 float new_scale = gfx::Screen::GetScreenFor(window())->
501 GetDisplayNearestWindow(window()).device_scale_factor();
502 bool origin_changed = bounds_.origin() != bounds.origin();
503 bool size_changed = bounds_.size() != bounds.size();
504 XWindowChanges changes = {0};
505 unsigned value_mask = 0;
507 if (size_changed) {
508 changes.width = bounds.width();
509 changes.height = bounds.height();
510 value_mask = CWHeight | CWWidth;
513 if (origin_changed) {
514 changes.x = bounds.x();
515 changes.y = bounds.y();
516 value_mask |= CWX | CWY;
518 if (value_mask)
519 XConfigureWindow(xdisplay_, xwindow_, value_mask, &changes);
521 // Assume that the resize will go through as requested, which should be the
522 // case if we're running without a window manager. If there's a window
523 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a
524 // (possibly synthetic) ConfigureNotify about the actual size and correct
525 // |bounds_| later.
526 bounds_ = bounds;
527 if (origin_changed)
528 OnHostMoved(bounds.origin());
529 if (size_changed || current_scale != new_scale) {
530 OnHostResized(bounds.size());
531 } else {
532 window()->SchedulePaintInRect(window()->bounds());
536 gfx::Point WindowTreeHostX11::GetLocationOnNativeScreen() const {
537 return bounds_.origin();
540 void WindowTreeHostX11::SetCapture() {
541 // Do not grab X11 input. Grabbing X11 input is asynchronous and this method
542 // is expected to be synchronous. Grabbing X11 input is unnecessary on
543 // ChromeOS because ChromeOS manages all of the X windows. When running
544 // ChromeOS on the desktop for the sake of debugging:
545 // - Implicit pointer grab as a result of pressing a mouse button
546 // - Releasing capture as a result of losing activation (FocusOut)
547 // is sufficient.
550 void WindowTreeHostX11::ReleaseCapture() {
553 void WindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) {
554 if (cursor == current_cursor_)
555 return;
556 current_cursor_ = cursor;
557 SetCursorInternal(cursor);
560 void WindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) {
561 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0,
562 bounds_.x() + location.x(),
563 bounds_.y() + location.y());
566 void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) {
569 void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
570 ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
571 XEvent* xev = event;
572 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data);
573 if (!factory->ShouldProcessXI2Event(xev))
574 return;
576 TRACE_EVENT1("input", "WindowTreeHostX11::DispatchXI2Event",
577 "event_latency_us",
578 (ui::EventTimeForNow() - ui::EventTimeFromNative(event)).
579 InMicroseconds());
581 int num_coalesced = 0;
582 XEvent last_event;
583 if (xev->xgeneric.evtype == XI_Motion) {
584 // If this is a motion event, we want to coalesce all pending motion
585 // events that are at the top of the queue. Note, we don't coalesce
586 // touch update events here.
587 num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event);
588 if (num_coalesced > 0)
589 xev = &last_event;
591 ui::EventType type = ui::EventTypeFromNative(xev);
593 switch (type) {
594 case ui::ET_TOUCH_MOVED:
595 case ui::ET_TOUCH_PRESSED:
596 case ui::ET_TOUCH_CANCELLED:
597 case ui::ET_TOUCH_RELEASED: {
598 ui::TouchEvent touchev(xev);
599 if (ui::DeviceDataManagerX11::GetInstance()->TouchEventNeedsCalibrate(
600 xiev->deviceid)) {
601 touch_calibrate_->Calibrate(&touchev, bounds_);
603 TranslateAndDispatchLocatedEvent(&touchev);
604 break;
606 case ui::ET_MOUSE_MOVED:
607 case ui::ET_MOUSE_DRAGGED:
608 case ui::ET_MOUSE_PRESSED:
609 case ui::ET_MOUSE_RELEASED:
610 case ui::ET_MOUSE_ENTERED:
611 case ui::ET_MOUSE_EXITED: {
612 ui::MouseEvent mouseev(xev);
613 TranslateAndDispatchLocatedEvent(&mouseev);
614 break;
616 case ui::ET_MOUSEWHEEL: {
617 ui::MouseWheelEvent mouseev(xev);
618 TranslateAndDispatchLocatedEvent(&mouseev);
619 break;
621 case ui::ET_SCROLL_FLING_START:
622 case ui::ET_SCROLL_FLING_CANCEL:
623 case ui::ET_SCROLL: {
624 ui::ScrollEvent scrollev(xev);
625 SendEventToProcessor(&scrollev);
626 break;
628 case ui::ET_KEY_PRESSED:
629 case ui::ET_KEY_RELEASED: {
630 ui::KeyEvent key_event(xev);
631 SendEventToProcessor(&key_event);
632 break;
634 case ui::ET_UMA_DATA:
635 break;
636 case ui::ET_UNKNOWN:
637 break;
638 default:
639 NOTREACHED();
642 // If we coalesced an event we need to free its cookie.
643 if (num_coalesced > 0)
644 XFreeEventData(xev->xgeneric.display, &last_event.xcookie);
647 void WindowTreeHostX11::SetCursorInternal(gfx::NativeCursor cursor) {
648 XDefineCursor(xdisplay_, xwindow_, cursor.platform());
651 void WindowTreeHostX11::OnConfigureNotify() {}
653 void WindowTreeHostX11::TranslateAndDispatchLocatedEvent(
654 ui::LocatedEvent* event) {
655 SendEventToProcessor(event);
658 // static
659 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
660 return new WindowTreeHostX11(bounds);
663 // static
664 gfx::Size WindowTreeHost::GetNativeScreenSize() {
665 ::XDisplay* xdisplay = gfx::GetXDisplay();
666 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
669 namespace test {
671 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) {
672 default_override_redirect = override_redirect;
675 } // namespace test
676 } // namespace aura