| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ozone/platform/caca/caca_window.h" | 5 #include "ui/ozone/platform/caca/caca_window.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 10 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 12 #include "ui/events/ozone/events_ozone.h" | 14 #include "ui/events/ozone/events_ozone.h" |
| 13 #include "ui/events/platform/platform_event_source.h" | 15 #include "ui/events/platform/platform_event_source.h" |
| 14 #include "ui/ozone/platform/caca/caca_event_source.h" | 16 #include "ui/ozone/platform/caca/caca_event_source.h" |
| 15 #include "ui/ozone/platform/caca/caca_window_manager.h" | 17 #include "ui/ozone/platform/caca/caca_window_manager.h" |
| 16 #include "ui/platform_window/platform_window_delegate.h" | 18 #include "ui/platform_window/platform_window_delegate.h" |
| 17 | 19 |
| 18 namespace ui { | 20 namespace ui { |
| 19 | 21 |
| 20 namespace { | 22 namespace { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 72 |
| 71 return true; | 73 return true; |
| 72 } | 74 } |
| 73 | 75 |
| 74 void CacaWindow::TryProcessingEvent() { | 76 void CacaWindow::TryProcessingEvent() { |
| 75 event_source_->TryProcessingEvent(this); | 77 event_source_->TryProcessingEvent(this); |
| 76 | 78 |
| 77 // Caca uses a poll based event retrieval. Since we don't want to block we'd | 79 // Caca uses a poll based event retrieval. Since we don't want to block we'd |
| 78 // either need to spin up a new thread or just poll. For simplicity just poll | 80 // either need to spin up a new thread or just poll. For simplicity just poll |
| 79 // for messages. | 81 // for messages. |
| 80 base::MessageLoop::current()->PostDelayedTask( | 82 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 81 FROM_HERE, | 83 FROM_HERE, base::Bind(&CacaWindow::TryProcessingEvent, |
| 82 base::Bind(&CacaWindow::TryProcessingEvent, | 84 weak_ptr_factory_.GetWeakPtr()), |
| 83 weak_ptr_factory_.GetWeakPtr()), | |
| 84 base::TimeDelta::FromMilliseconds(10)); | 85 base::TimeDelta::FromMilliseconds(10)); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void CacaWindow::UpdateDisplaySize() { | 88 void CacaWindow::UpdateDisplaySize() { |
| 88 physical_size_.SetSize(caca_get_canvas_width(canvas_.get()), | 89 physical_size_.SetSize(caca_get_canvas_width(canvas_.get()), |
| 89 caca_get_canvas_height(canvas_.get())); | 90 caca_get_canvas_height(canvas_.get())); |
| 90 | 91 |
| 91 bitmap_size_.SetSize(caca_get_display_width(display_.get()), | 92 bitmap_size_.SetSize(caca_get_display_width(display_.get()), |
| 92 caca_get_display_height(display_.get())); | 93 caca_get_display_height(display_.get())); |
| 93 } | 94 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 148 |
| 148 bool CacaWindow::CanDispatchEvent(const PlatformEvent& event) { return true; } | 149 bool CacaWindow::CanDispatchEvent(const PlatformEvent& event) { return true; } |
| 149 | 150 |
| 150 uint32_t CacaWindow::DispatchEvent(const PlatformEvent& ne) { | 151 uint32_t CacaWindow::DispatchEvent(const PlatformEvent& ne) { |
| 151 // We don't dispatch events via PlatformEventSource. | 152 // We don't dispatch events via PlatformEventSource. |
| 152 NOTREACHED(); | 153 NOTREACHED(); |
| 153 return ui::POST_DISPATCH_STOP_PROPAGATION; | 154 return ui::POST_DISPATCH_STOP_PROPAGATION; |
| 154 } | 155 } |
| 155 | 156 |
| 156 } // namespace ui | 157 } // namespace ui |
| OLD | NEW |