OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/aura/window_tree_host_x11.h" | 5 #include "ui/aura/window_tree_host_x11.h" |
6 | 6 |
7 #include <strings.h> | 7 #include <strings.h> |
8 #include <X11/cursorfont.h> | 8 #include <X11/cursorfont.h> |
9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
10 #include <X11/extensions/Xrandr.h> | 10 #include <X11/extensions/Xrandr.h> |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 bool WindowTreeHostX11::CanDispatchEvent(const ui::PlatformEvent& event) { | 318 bool WindowTreeHostX11::CanDispatchEvent(const ui::PlatformEvent& event) { |
319 ::Window target = FindEventTarget(event); | 319 ::Window target = FindEventTarget(event); |
320 return target == xwindow_ || target == x_root_window_; | 320 return target == xwindow_ || target == x_root_window_; |
321 } | 321 } |
322 | 322 |
323 uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) { | 323 uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) { |
324 XEvent* xev = event; | 324 XEvent* xev = event; |
325 if (FindEventTarget(xev) == x_root_window_) { | 325 if (FindEventTarget(xev) == x_root_window_) { |
326 if (xev->type == GenericEvent) | 326 if (xev->type == GenericEvent) |
327 DispatchXI2Event(xev); | 327 DispatchXI2Event(xev); |
328 return ui::POST_DISPATCH_NONE; | 328 return ui::kPostDispatchNone; |
329 } | 329 } |
330 | 330 |
331 if (xev->type == MotionNotify) { | 331 if (xev->type == MotionNotify) { |
332 // Discard all but the most recent motion event that targets the same | 332 // Discard all but the most recent motion event that targets the same |
333 // window with unchanged state. | 333 // window with unchanged state. |
334 XEvent last_event; | 334 XEvent last_event; |
335 while (XPending(xev->xany.display)) { | 335 while (XPending(xev->xany.display)) { |
336 XEvent next_event; | 336 XEvent next_event; |
337 XPeekEvent(xev->xany.display, &next_event); | 337 XPeekEvent(xev->xany.display, &next_event); |
338 if (next_event.type == MotionNotify && | 338 if (next_event.type == MotionNotify && |
339 next_event.xmotion.window == xev->xmotion.window && | 339 next_event.xmotion.window == xev->xmotion.window && |
340 next_event.xmotion.subwindow == xev->xmotion.subwindow && | 340 next_event.xmotion.subwindow == xev->xmotion.subwindow && |
341 next_event.xmotion.state == xev->xmotion.state) { | 341 next_event.xmotion.state == xev->xmotion.state) { |
342 XNextEvent(xev->xany.display, &last_event); | 342 XNextEvent(xev->xany.display, &last_event); |
343 xev = &last_event; | 343 xev = &last_event; |
344 } else { | 344 } else { |
345 break; | 345 break; |
346 } | 346 } |
347 } | 347 } |
348 } | 348 } |
349 | 349 |
350 if ((xev->type == EnterNotify || xev->type == LeaveNotify) && | 350 if ((xev->type == EnterNotify || xev->type == LeaveNotify) && |
351 xev->xcrossing.detail == NotifyInferior) { | 351 xev->xcrossing.detail == NotifyInferior) { |
352 // Ignore EventNotify and LeaveNotify events from children of |xwindow_|. | 352 // Ignore EventNotify and LeaveNotify events from children of |xwindow_|. |
353 // NativeViewGLSurfaceGLX adds a child to |xwindow_|. | 353 // NativeViewGLSurfaceGLX adds a child to |xwindow_|. |
354 // TODO(pkotwicz|tdanderson): Figure out whether the suppression is | 354 // TODO(pkotwicz|tdanderson): Figure out whether the suppression is |
355 // necessary. crbug.com/385716 | 355 // necessary. crbug.com/385716 |
356 return ui::POST_DISPATCH_STOP_PROPAGATION; | 356 return ui::kPostDispatchStopPropagation; |
357 } | 357 } |
358 | 358 |
359 if (xev->type == EnterNotify || | 359 if (xev->type == EnterNotify || |
360 xev->type == LeaveNotify || | 360 xev->type == LeaveNotify || |
361 xev->type == KeyPress || | 361 xev->type == KeyPress || |
362 xev->type == KeyRelease || | 362 xev->type == KeyRelease || |
363 xev->type == ButtonPress || | 363 xev->type == ButtonPress || |
364 xev->type == ButtonRelease || | 364 xev->type == ButtonRelease || |
365 xev->type == MotionNotify) { | 365 xev->type == MotionNotify) { |
366 switch (ui::EventTypeFromNative(xev)) { | 366 switch (ui::EventTypeFromNative(xev)) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 ui::MouseWheelEvent mouseev(xev); | 398 ui::MouseWheelEvent mouseev(xev); |
399 TranslateAndDispatchLocatedEvent(&mouseev); | 399 TranslateAndDispatchLocatedEvent(&mouseev); |
400 break; | 400 break; |
401 } | 401 } |
402 case ui::ET_UNKNOWN: | 402 case ui::ET_UNKNOWN: |
403 // No event is created for X11-release events for mouse-wheel buttons. | 403 // No event is created for X11-release events for mouse-wheel buttons. |
404 break; | 404 break; |
405 default: | 405 default: |
406 NOTREACHED(); | 406 NOTREACHED(); |
407 } | 407 } |
408 return ui::POST_DISPATCH_STOP_PROPAGATION; | 408 return ui::kPostDispatchStopPropagation; |
409 } | 409 } |
410 | 410 |
411 switch (xev->type) { | 411 switch (xev->type) { |
412 case Expose: { | 412 case Expose: { |
413 gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y, | 413 gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y, |
414 xev->xexpose.width, xev->xexpose.height); | 414 xev->xexpose.width, xev->xexpose.height); |
415 compositor()->ScheduleRedrawRect(damage_rect); | 415 compositor()->ScheduleRedrawRect(damage_rect); |
416 break; | 416 break; |
417 } | 417 } |
418 case FocusOut: | 418 case FocusOut: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 case MappingPointer: | 467 case MappingPointer: |
468 ui::DeviceDataManagerX11::GetInstance()->UpdateButtonMap(); | 468 ui::DeviceDataManagerX11::GetInstance()->UpdateButtonMap(); |
469 break; | 469 break; |
470 default: | 470 default: |
471 NOTIMPLEMENTED() << " Unknown request: " << xev->xmapping.request; | 471 NOTIMPLEMENTED() << " Unknown request: " << xev->xmapping.request; |
472 break; | 472 break; |
473 } | 473 } |
474 break; | 474 break; |
475 } | 475 } |
476 } | 476 } |
477 return ui::POST_DISPATCH_STOP_PROPAGATION; | 477 return ui::kPostDispatchStopPropagation; |
478 } | 478 } |
479 | 479 |
480 ui::EventSource* WindowTreeHostX11::GetEventSource() { | 480 ui::EventSource* WindowTreeHostX11::GetEventSource() { |
481 return this; | 481 return this; |
482 } | 482 } |
483 | 483 |
484 gfx::AcceleratedWidget WindowTreeHostX11::GetAcceleratedWidget() { | 484 gfx::AcceleratedWidget WindowTreeHostX11::GetAcceleratedWidget() { |
485 return xwindow_; | 485 return xwindow_; |
486 } | 486 } |
487 | 487 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 } | 727 } |
728 | 728 |
729 namespace test { | 729 namespace test { |
730 | 730 |
731 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { | 731 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { |
732 default_override_redirect = override_redirect; | 732 default_override_redirect = override_redirect; |
733 } | 733 } |
734 | 734 |
735 } // namespace test | 735 } // namespace test |
736 } // namespace aura | 736 } // namespace aura |
OLD | NEW |