OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/widget/native_widget_wayland.h" | 5 #include "views/widget/native_widget_wayland.h" |
6 | 6 |
7 #include <cairo.h> | 7 #include <cairo.h> |
8 #include <cairo-gl.h> | 8 #include <cairo-gl.h> |
9 #include <EGL/egl.h> | 9 #include <EGL/egl.h> |
10 #include <GL/gl.h> | 10 #include <GL/gl.h> |
11 #include <wayland-egl.h> | 11 #include <wayland-egl.h> |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <list> | 14 #include <list> |
15 | 15 |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/wayland/wayland_event.h" |
18 #include "ui/base/view_prop.h" | 19 #include "ui/base/view_prop.h" |
19 #include "ui/gfx/canvas_skia_paint.h" | 20 #include "ui/gfx/canvas_skia_paint.h" |
20 #include "ui/gfx/compositor/compositor.h" | 21 #include "ui/gfx/compositor/compositor.h" |
21 #include "ui/gfx/gl/gl_surface.h" | 22 #include "ui/gfx/gl/gl_surface.h" |
22 #include "ui/gfx/gl/gl_surface_egl.h" | 23 #include "ui/gfx/gl/gl_surface_egl.h" |
23 #include "ui/wayland/events/wayland_event.h" | |
24 #include "ui/wayland/wayland_display.h" | 24 #include "ui/wayland/wayland_display.h" |
25 #include "ui/wayland/wayland_input_device.h" | 25 #include "ui/wayland/wayland_input_device.h" |
26 #include "ui/wayland/wayland_screen.h" | 26 #include "ui/wayland/wayland_screen.h" |
27 #include "ui/wayland/wayland_window.h" | 27 #include "ui/wayland/wayland_window.h" |
28 #include "views/ime/input_method_wayland.h" | 28 #include "views/ime/input_method_wayland.h" |
29 #include "views/views_delegate.h" | 29 #include "views/views_delegate.h" |
30 #include "views/widget/native_widget_views.h" | 30 #include "views/widget/native_widget_views.h" |
31 #include "views/widget/root_view.h" | 31 #include "views/widget/root_view.h" |
32 #include "views/widget/tooltip_manager_views.h" | 32 #include "views/widget/tooltip_manager_views.h" |
33 | 33 |
34 using ui::ViewProp; | 34 using ui::ViewProp; |
35 | 35 |
| 36 using base::wayland::WaylandEvent; |
| 37 |
36 namespace views { | 38 namespace views { |
37 | 39 |
38 namespace { | 40 namespace { |
39 | 41 |
40 // Links the WaylandWidget to its NativeWidget. | 42 // Links the WaylandWidget to its NativeWidget. |
41 const char* const kNativeWidgetKey = "__VIEWS_NATIVE_WIDGET__"; | 43 const char* const kNativeWidgetKey = "__VIEWS_NATIVE_WIDGET__"; |
42 | 44 |
43 } // namespace | 45 } // namespace |
44 | 46 |
45 NativeWidgetWayland::NativeWidgetWayland( | 47 NativeWidgetWayland::NativeWidgetWayland( |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 } | 544 } |
543 | 545 |
544 // Have cairo swap buffers, then let Wayland know of the damaged area. | 546 // Have cairo swap buffers, then let Wayland know of the damaged area. |
545 cairo_gl_surface_swapbuffers(cairo_surface_); | 547 cairo_gl_surface_swapbuffers(cairo_surface_); |
546 wl_surface_damage(wayland_window_->surface(), | 548 wl_surface_damage(wayland_window_->surface(), |
547 damage_area.x(), damage_area.y(), | 549 damage_area.x(), damage_area.y(), |
548 damage_area.width(), damage_area.height()); | 550 damage_area.width(), damage_area.height()); |
549 } | 551 } |
550 } | 552 } |
551 | 553 |
552 void NativeWidgetWayland::OnMotionNotify(ui::WaylandEvent event) { | 554 void NativeWidgetWayland::OnMotionNotify(WaylandEvent event) { |
553 MouseEvent mouse_event(&event); | 555 MouseEvent mouse_event(&event); |
554 delegate_->OnMouseEvent(mouse_event); | 556 delegate_->OnMouseEvent(mouse_event); |
555 } | 557 } |
556 | 558 |
557 void NativeWidgetWayland::OnButtonNotify(ui::WaylandEvent event) { | 559 void NativeWidgetWayland::OnButtonNotify(WaylandEvent event) { |
558 if (event.button.button == ui::SCROLL_UP || | 560 if (event.button.button == ui::SCROLL_UP || |
559 event.button.button == ui::SCROLL_DOWN) { | 561 event.button.button == ui::SCROLL_DOWN) { |
560 MouseWheelEvent mouse_event(&event); | 562 MouseWheelEvent mouse_event(&event); |
561 delegate_->OnMouseEvent(mouse_event); | 563 delegate_->OnMouseEvent(mouse_event); |
562 } else { | 564 } else { |
563 MouseEvent mouse_event(&event); | 565 MouseEvent mouse_event(&event); |
564 delegate_->OnMouseEvent(mouse_event); | 566 delegate_->OnMouseEvent(mouse_event); |
565 } | 567 } |
566 } | 568 } |
567 | 569 |
568 void NativeWidgetWayland::OnKeyNotify(ui::WaylandEvent event) { | 570 void NativeWidgetWayland::OnKeyNotify(WaylandEvent event) { |
569 KeyEvent key_event(&event); | 571 KeyEvent key_event(&event); |
570 InputMethod* input_method = GetWidget()->GetInputMethodDirect(); | 572 InputMethod* input_method = GetWidget()->GetInputMethodDirect(); |
571 if (input_method) | 573 if (input_method) |
572 input_method->DispatchKeyEvent(key_event); | 574 input_method->DispatchKeyEvent(key_event); |
573 else | 575 else |
574 DispatchKeyEventPostIME(key_event); | 576 DispatchKeyEventPostIME(key_event); |
575 } | 577 } |
576 | 578 |
577 void NativeWidgetWayland::OnPointerFocus(ui::WaylandEvent event) { | 579 void NativeWidgetWayland::OnPointerFocus(WaylandEvent event) { |
578 MouseEvent mouse_event(&event); | 580 MouseEvent mouse_event(&event); |
579 delegate_->OnMouseEvent(mouse_event); | 581 delegate_->OnMouseEvent(mouse_event); |
580 } | 582 } |
581 | 583 |
582 void NativeWidgetWayland::OnKeyboardFocus(ui::WaylandEvent event) { | 584 void NativeWidgetWayland::OnKeyboardFocus(WaylandEvent event) { |
583 InputMethod* input_method = GetWidget()->GetInputMethodDirect(); | 585 InputMethod* input_method = GetWidget()->GetInputMethodDirect(); |
584 if (input_method) { | 586 if (input_method) { |
585 if (event.keyboard_focus.state) | 587 if (event.keyboard_focus.state) |
586 input_method->OnFocus(); | 588 input_method->OnFocus(); |
587 else | 589 else |
588 input_method->OnBlur(); | 590 input_method->OnBlur(); |
589 } | 591 } |
590 } | 592 } |
591 | 593 |
592 void NativeWidgetWayland::OnGeometryChange(ui::WaylandEvent event) { | 594 void NativeWidgetWayland::OnGeometryChange(WaylandEvent event) { |
593 SetSize(gfx::Size(event.geometry_change.width, | 595 SetSize(gfx::Size(event.geometry_change.width, |
594 event.geometry_change.height)); | 596 event.geometry_change.height)); |
595 } | 597 } |
596 | 598 |
597 ///////////////////////////////////////////////////////////////////////////// | 599 ///////////////////////////////////////////////////////////////////////////// |
598 // Widget | 600 // Widget |
599 | 601 |
600 // static | 602 // static |
601 bool Widget::ConvertRect(const Widget* source, | 603 bool Widget::ConvertRect(const Widget* source, |
602 const Widget* target, | 604 const Widget* target, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 | 674 |
673 // static | 675 // static |
674 bool NativeWidgetPrivate::IsMouseButtonDown() { | 676 bool NativeWidgetPrivate::IsMouseButtonDown() { |
675 NOTIMPLEMENTED(); | 677 NOTIMPLEMENTED(); |
676 return false; | 678 return false; |
677 } | 679 } |
678 | 680 |
679 } // namespace internal | 681 } // namespace internal |
680 | 682 |
681 } // namespace views | 683 } // namespace views |
OLD | NEW |